Text to vertical video in 100+ styles: AI codes each scene (HTML/SVG/WebGL), renders a 9:16 MP4 with music and English/Vietnamese voice. MCP, CLI and REST for AI agents.
Edit video thành Studio kiểu CapCut: màn tạo mới 3 bước + trình edit toàn màn hình
Lumtek6fb6437841e7
diff --git a/edit-styles/thumbs/ban-tin-nhanh.webp b/edit-styles/thumbs/ban-tin-nhanh.webpnew file mode 100644index 0000000..a6162aeBinary files /dev/null and b/edit-styles/thumbs/ban-tin-nhanh.webp differdiff --git a/edit-styles/thumbs/chot-don-livestream.webp b/edit-styles/thumbs/chot-don-livestream.webpnew file mode 100644index 0000000..6e6e99eBinary files /dev/null and b/edit-styles/thumbs/chot-don-livestream.webp differdiff --git a/edit-styles/thumbs/huong-dan-buoc.webp b/edit-styles/thumbs/huong-dan-buoc.webpnew file mode 100644index 0000000..15241a2Binary files /dev/null and b/edit-styles/thumbs/huong-dan-buoc.webp differdiff --git a/edit-styles/thumbs/review-san-pham.webp b/edit-styles/thumbs/review-san-pham.webpnew file mode 100644index 0000000..e3a1079Binary files /dev/null and b/edit-styles/thumbs/review-san-pham.webp differdiff --git a/edit-styles/thumbs/vlog-nhe.webp b/edit-styles/thumbs/vlog-nhe.webpnew file mode 100644index 0000000..b2a7465Binary files /dev/null and b/edit-styles/thumbs/vlog-nhe.webp differdiff --git a/server/public/edit-panel.css b/server/public/edit-panel.cssdeleted file mode 100644index 5e6d424..0000000--- a/server/public/edit-panel.css+++ /dev/null@@ -1,279 +0,0 @@-/* Tab "Edit video của bạn" — dùng chung token của style.css */-.tabs { display: flex; gap: 8px; padding: 4px 24px 0; flex-wrap: wrap; }-.tab { min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); font: 700 18px/1 var(--cond); text-transform: uppercase; letter-spacing: .04em; cursor: pointer; transition: background .15s, color .15s; }-.tab:hover { color: var(--ink); }-.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }-.tab .new { font: 600 11px/1 var(--mono); color: var(--accent); margin-left: 6px; vertical-align: 2px; }-.tab[aria-selected="true"] .new { color: var(--accent); }--.edit-wrap { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 24px; padding: 16px 24px 48px; }-.edit-wrap[hidden], .layout[hidden] { display: none; }-.ed-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }-.ed-setup { grid-column: 1 / -1; border-left: 3px solid var(--warn); }-.ed-setup h3 { margin: 0 0 6px; font: 700 20px/1.2 var(--cond); text-transform: uppercase; letter-spacing: .03em; }-.ed-setup p { margin: 0; color: var(--ink-2); font-size: 15px; }-.ed-setup-act { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 14px; }-.ed-install { min-height: 44px; padding: 0 22px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font: 800 18px/1 var(--cond); text-transform: uppercase; letter-spacing: .04em; cursor: pointer; }-.ed-install:hover:not(:disabled) { filter: brightness(1.08); }-.ed-install:disabled { opacity: .5; cursor: not-allowed; }-.ed-install-note { color: var(--ink-3); font-size: 14px; }-.ed-install-prog { margin-top: 14px; }-.ed-install-step { font-weight: 600; font-size: 15px; }-.ed-install-step.ok { color: var(--ok); } .ed-install-step.bad { color: var(--bad); }-.ed-install-bar { height: 4px; margin: 8px 0 10px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }-.ed-install-bar span { display: block; width: 30%; height: 100%; background: var(--accent); animation: edbar 1.4s ease-in-out infinite; }-.ed-install-prog.stop .ed-install-bar { display: none; }-@keyframes edbar { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }-@media (prefers-reduced-motion: reduce) { .ed-install-bar span { animation: none; width: 100%; opacity: .5; } }-.ed-install-hint { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; font: 400 13px/1.5 var(--mono); white-space: pre-wrap; color: var(--warn); background: rgba(242,201,76,.08); border: 1px solid rgba(242,201,76,.3); }-.ed-install-prog summary, .ed-setup-manual summary { cursor: pointer; color: var(--ink-3); font-size: 14px; }-.ed-install-prog pre { max-height: 220px; overflow: auto; margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--bg); font: 400 12px/1.45 var(--mono); color: var(--ink-2); white-space: pre-wrap; word-break: break-all; }-.ed-setup-manual { margin-top: 12px; }--.drop { display: grid; place-items: center; text-align: center; gap: 6px; min-height: 150px; padding: 18px; border: 2px dashed var(--line); border-radius: 14px; background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s; }-.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg)); }-.drop svg { width: 34px; height: 34px; fill: none; stroke: var(--accent); stroke-width: 1.8; }-.drop .big { font-weight: 700; font-size: 16px; }-.drop .small { font-size: 13px; color: var(--ink-3); }-.drop.has { border-style: solid; border-color: var(--ok); }-.drop.has .big { color: var(--ok); word-break: break-all; }--/* lưới thẻ kiểu edit: ảnh dọc 9:16 + tên; 14 kiểu → khung cuộn riêng (cao ~2,5 hàng) để form không dài vô tận */-.sty-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }-.sty-count { font-size: 13px; color: var(--ink-3); }-.styles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-height: 452px; overflow-y: auto; overscroll-behavior: contain;- padding: 4px; margin: 0 -4px; scroll-snap-type: y proximity; scrollbar-width: thin; }-.sty { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 4px 4px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2);- cursor: pointer; transition: border-color .15s, transform .12s; scroll-snap-align: start; min-width: 0; color: var(--ink); }-.sty:hover { border-color: var(--ink-3); }-.sty:active { transform: scale(.97); }-.sty .pic { display: block; aspect-ratio: 9 / 16; border-radius: 9px; overflow: hidden; background: #000; }-.sty .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }-.sty .ph { display: grid; place-items: center; height: 100%; padding: 8px; text-align: center; font: 700 15px/1.15 var(--cond); text-transform: uppercase;- color: var(--sty-acc); background: radial-gradient(120% 80% at 50% 100%, color-mix(in srgb, var(--sty-acc) 28%, #000), #0b0b0d 70%); }-.sty .n { font-weight: 700; font-size: 13px; line-height: 1.25; padding: 0 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }-.sty[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,107,44,.22); }-.sty[aria-checked="true"] .n { color: var(--accent); }-.sty-desc { margin: 8px 0 0; min-height: 2.8em; font-size: 14px; line-height: 1.4; color: var(--ink-2); }-@media (prefers-reduced-motion: reduce) { .sty { transition: none; } .sty:active { transform: none; } }-.ed-in { width: 100%; min-height: 44px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }-.ed-row { display: flex; gap: 8px; align-items: center; }-.ed-row select { flex: 1; }-.ed-file { font-size: 13px; color: var(--ink-2); margin-top: 6px; word-break: break-all; }-.ed-check { display: flex; gap: 8px; align-items: center; min-height: 44px; color: var(--ink-2); font-size: 15px; cursor: pointer; }-.ed-check input { width: 18px; height: 18px; accent-color: var(--accent); }-.edit-wrap textarea { min-height: 84px; }--.ed-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; min-width: 0; }-.ed-empty { color: var(--ink-3); text-align: center; padding: 48px 24px; border: 1px dashed var(--line); border-radius: 18px; background: var(--panel); }-.ed-list { display: grid; gap: 8px; }-.ed-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; text-align: left; min-height: 52px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }-.ed-item.sel { border-color: var(--accent); }-.ed-item .t { font-weight: 600; font-size: 14px; word-break: break-all; }-.ed-item .s { font: 500 12px var(--mono); color: var(--ink-3); }-.sty:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }-.bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; margin: 6px 0 2px; }-.bar > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .3s ease-out; }--/* ===== màn kết quả: kiểu trình edit (CapCut / Descript) =====- 1 dòng đầu · trái player dọc + thanh thời gian (dính khi cuộn) · phải bảng chỉnh có tab · thanh Áp dụng dính đáy */-.ed-res { padding: 14px 16px 16px; }-.ed-res [hidden] { display: none !important; }--/* dòng đầu: tên · thời lượng | Cần xem lại · Tải MP4 · ⋯ */-.ed-rhead { position: relative; display: flex; align-items: center; gap: 8px 12px; min-height: 44px; }-.ed-rtitle { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; }-.ed-rtitle .tt { min-width: 0; font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }-.ed-dur { flex: none; font: 500 13px var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }-.ed-rtitle .st { flex: none; }-.ed-ract { flex: none; display: flex; align-items: center; gap: 8px; }-.ed-review, .ed-dl, .ed-moreb { min-height: 40px; display: inline-flex; white-space: nowrap; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; cursor: pointer; transition: filter .15s, border-color .15s, background .15s, transform .1s; }-.ed-review { padding: 0 12px; border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); background: color-mix(in srgb, var(--warn) 7%, var(--panel)); color: var(--warn); font: 600 14px/1 var(--sans); }-.ed-review[aria-expanded="true"], .ed-review:hover { background: color-mix(in srgb, var(--warn) 15%, var(--panel)); }-.ed-dl { padding: 0 16px; border: 0; background: var(--accent); color: var(--accent-ink); font: 700 15px/1 var(--sans); text-decoration: none; }-.ed-dl:hover { filter: brightness(1.08); }-.ed-moreb { width: 44px; padding: 0; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2); }-.ed-moreb:hover, .ed-moreb[aria-expanded="true"] { color: var(--ink); border-color: var(--ink-3); }-.ed-review svg, .ed-dl svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }-.ed-moreb svg { width: 20px; height: 20px; fill: currentColor; }-.ed-review:active, .ed-dl:active, .ed-moreb:active { transform: scale(.97); }--/* menu bật lên */-.ed-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; width: min(380px, 100%); max-height: min(60vh, 480px); overflow-y: auto; overscroll-behavior: contain;- padding: 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); box-shadow: 0 18px 40px -16px rgba(0,0,0,.75); animation: edpop .16s ease-out; }-@keyframes edpop { from { opacity: 0; transform: translateY(-4px); } }-.ed-pop h4 { margin: 10px 8px 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }-.ed-popmeta { padding: 4px 8px; font: 500 12px var(--mono); color: var(--ink-3); word-break: break-all; }-.ed-poplinks { display: grid; gap: 2px; margin-top: 4px; }-.ed-poplinks a, .ed-delb { width: 100%; min-height: 40px; display: flex; align-items: center; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--ink); text-decoration: none; font-size: 14px; text-align: left; cursor: pointer; }-.ed-poplinks a:hover, .ed-delb:hover:not(:disabled) { background: var(--panel); }-.ed-checks { padding: 0 8px; font-size: 13px; color: var(--ink-2); line-height: 1.5; }-.ed-checks .ok { color: var(--ok); } .ed-checks .bad { color: var(--bad); }-.ed-pop .log { margin: 8px 8px 0; }-.ed-pop .log summary { min-height: 36px; display: flex; align-items: center; font-size: 14px; color: var(--ink-2); cursor: pointer; }-.ed-pop .log pre { max-height: 200px; overflow: auto; margin: 4px 0 0; font-size: 12px; white-space: pre-wrap; word-break: break-all; }-.ed-delb { margin-top: 6px; color: var(--bad); }-.ed-delb:disabled { opacity: .45; cursor: not-allowed; }--/* danh sách "Cần xem lại" */-.ed-rlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }-.ed-rlist .h { padding: 8px 8px 2px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }-.ed-rlist .h:first-child { padding-top: 2px; }-.ed-ritem { width: 100%; min-height: 40px; display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; align-items: center; padding: 4px 8px; border: 0; border-radius: 8px; background: none; color: var(--ink); text-align: left; font-size: 14px; line-height: 1.35; cursor: pointer; }-.ed-ritem:hover:not(:disabled), .ed-ritem.on { background: var(--panel); }-.ed-ritem.on { box-shadow: inset 2px 0 0 var(--accent); }-.ed-ritem:disabled { cursor: default; }-.ed-ritem .tm { font: 600 12px var(--mono); color: var(--accent); font-variant-numeric: tabular-nums; }-.ed-ritem:disabled .tm { color: var(--ink-3); }-.ed-ritem s { color: var(--ink-3); }-.ed-ritem b { color: var(--warn); font-weight: 600; }--/* đang dựng: 1 thanh + tên bước */-.ed-prog { display: flex; align-items: center; gap: 12px; margin-top: 8px; }-.ed-prog .bar { flex: 1; margin: 0; }-.ed-progt { flex: 0 1 auto; max-width: 60%; font: 500 13px var(--mono); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }-.ed-res > .errmsg:empty { display: none; }--/* thân: player | bảng chỉnh */-.ed-body { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 12px; }-.ed-res.solo .ed-body { grid-template-columns: minmax(220px, 300px); justify-content: center; }-.ed-stage { position: sticky; top: 12px; width: min(100%, calc((100vh - 120px) * 9 / 16)); justify-self: center; display: grid; gap: 6px; }-.ed-media { aspect-ratio: 9 / 16; background: #000; border-radius: 12px; overflow: hidden; display: grid; place-items: center; color: var(--ink-3); font-size: 14px; text-align: center; }-.ed-media video, .ed-media img { width: 100%; height: 100%; object-fit: contain; display: block; }--/* thanh thời gian mảnh dưới player */-.ed-tl { display: grid; gap: 2px; }-.ed-tltrack { position: relative; height: 22px; cursor: pointer; }-.ed-tltrack::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; background: var(--line); }-.ed-tltrack i { position: absolute; top: 50%; pointer-events: none; }-.ed-tltrack i.g { height: 8px; margin-top: -4px; border-radius: 3px; background: color-mix(in srgb, var(--warn) 55%, transparent); }-.ed-tltrack i.z { width: 3px; height: 14px; margin: -7px 0 0 -1.5px; border-radius: 2px; background: var(--accent); }-.ed-tltrack i.gone { opacity: .2; }-.ed-tltrack .ed-tlh { width: 2px; height: 20px; margin: -10px 0 0 -1px; border-radius: 1px; background: var(--ink); }-.ed-tlleg { display: flex; gap: 14px; font-size: 12px; color: var(--ink-3); }-.ed-tlleg span::before { content: ''; display: inline-block; vertical-align: 1px; margin-right: 6px; border-radius: 2px; }-.ed-tlleg .z::before { width: 3px; height: 10px; background: var(--accent); }-.ed-tlleg .g::before { width: 12px; height: 6px; background: color-mix(in srgb, var(--warn) 55%, transparent); }--/* bảng chỉnh có tab */-.ed-side { min-width: 0; }-.ed-mtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }-.ed-mtabs::-webkit-scrollbar { display: none; }-.ed-mtabs [role="tab"] { flex: none; min-height: 44px; padding: 0 14px; border: 0; background: none; color: var(--ink-3); font: 600 14px/1.2 var(--sans); white-space: nowrap; cursor: pointer; box-shadow: inset 0 -2px 0 transparent; transition: color .15s, box-shadow .15s; }-.ed-mtabs [role="tab"]:hover:not(:disabled) { color: var(--ink); }-.ed-mtabs [role="tab"][aria-selected="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }-.ed-mtabs [role="tab"]:disabled { opacity: .4; cursor: not-allowed; }-.ed-mtabs [role="tab"]:focus-visible { outline-offset: -2px; }-.ed-mpanel { padding: 10px 0 4px; }-.ed-side h5 { margin: 6px 0 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }-.ed-side h5 ~ h5 { margin-top: 14px; }-.ed-mini { flex: none; font-size: 13px; color: var(--ink-3); }-.ed-sm { min-height: 36px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); font-size: 14px; }-.ed-minichk { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: 14px; color: var(--ink-2); cursor: pointer; }-.ed-minichk input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }-.ed-file { font-size: 13px; color: var(--ink-2); word-break: break-all; }-.ed-file:empty { display: none; }--/* phụ đề kiểu transcript */-.ed-captop { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding-bottom: 6px; }-.ed-captop select { min-width: 0; max-width: 220px; }-.ed-captop .ed-minichk { margin-left: auto; }-.ed-lines { position: relative; list-style: none; margin: 0; padding: 0 4px 0 0; max-height: max(280px, calc(100vh - 290px)); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }-.ed-lines > li.none { color: var(--ink-3); font-size: 14px; padding: 8px 0; }-.ed-ln { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; align-items: center; column-gap: 4px; padding: 1px 4px 1px 0; border-radius: 8px; transition: background .15s; }-.ed-ln:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }-.ed-ln.now { background: color-mix(in srgb, var(--accent) 11%, transparent); }-.ed-ln.sel { background: var(--panel-2); }-.ed-ln.bad { box-shadow: inset 2px 0 0 var(--bad); }-.ed-tm { min-height: 36px; padding: 0 6px; border: 0; border-radius: 6px; background: none; color: var(--ink-3); font: 500 12px var(--mono); font-variant-numeric: tabular-nums; text-align: left; cursor: pointer; }-.ed-tm:hover, .ed-ln.now .ed-tm { color: var(--accent); }-.ed-ltext { width: 100%; min-width: 0; min-height: 36px; padding: 0 6px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 15px; }-.ed-ln.now .ed-ltext { font-weight: 600; }-.ed-ltext:focus { outline: none; background: var(--bg); box-shadow: inset 0 0 0 1px var(--accent); }-.ed-ltext:disabled { color: var(--ink-2); }-.ed-lx { display: contents; }-.ed-lact { grid-column: 3; grid-row: 1; display: flex; gap: 2px; visibility: hidden; }-.ed-ln:hover .ed-lact, .ed-ln.sel .ed-lact, .ed-ln:focus-within .ed-lact { visibility: visible; }-.ed-lact button { min-height: 32px; min-width: 36px; padding: 0 8px; border: 0; border-radius: 6px; background: none; color: var(--ink-2); font-size: 13px; cursor: pointer; }-.ed-lact button:hover:not(:disabled) { color: var(--ink); background: var(--panel); }-.ed-lact button:disabled { opacity: .35; cursor: not-allowed; }-.ed-lact .del { color: var(--bad); font-size: 18px; line-height: 1; }-.ed-ltime { grid-column: 2 / -1; grid-row: 2; display: none; align-items: center; gap: 6px; padding: 2px 6px 6px; color: var(--ink-3); font-size: 13px; }-.ed-ln.sel .ed-ltime { display: flex; }-.ed-num { width: 84px; padding: 0 6px; font: 500 13px var(--mono); font-variant-numeric: tabular-nums; }-.ed-lerr { grid-column: 2 / -1; padding: 0 6px 4px; font-size: 13px; color: var(--bad); }--/* nhạc & tiếng */-.ed-arow { display: grid; grid-template-columns: 96px minmax(0, 1fr) 64px; align-items: center; gap: 10px; min-height: 40px; }-.ed-arow select { grid-column: 2 / -1; min-width: 0; }-.ed-arow .ed-num { grid-column: 2; justify-self: start; }-.ed-arow output { font: 600 13px var(--mono); font-variant-numeric: tabular-nums; text-align: right; color: var(--ink); }-.ed-arow input[type="range"] { width: 100%; min-height: 32px; margin: 0; accent-color: var(--accent); }-.ed-agrp { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }--/* zoom & đồ hoạ */-.ed-fxlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }-.ed-fxlist li { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 2px 4px 2px 0; border-radius: 8px; font-size: 14px; }-.ed-fxlist li:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }-.ed-fxlist li.none { display: block; padding: 6px 0; color: var(--ink-3); }-.ed-fxlist li.gone span { text-decoration: line-through; color: var(--ink-3); }-.ed-mx { min-height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: none; color: var(--ink-2); font-size: 13px; cursor: pointer; }-.ed-mx:hover { color: var(--ink); border-color: var(--ink-3); }-.ed-mx[aria-pressed="true"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }--/* sửa bằng lời */-.ed-revf { display: flex; gap: 8px; }-.ed-revf .ed-in { flex: 1; min-width: 0; }-.ed-revf button { min-height: 44px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; white-space: nowrap; cursor: pointer; }-.ed-revf button:disabled { background: var(--panel-2); color: var(--ink-3); cursor: not-allowed; }-.ed-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }-.ed-presets button { min-height: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--ink-3); font-size: 13px; cursor: pointer; }-.ed-presets button:hover { color: var(--ink); border-color: var(--ink-3); }-.ed-hist { margin-top: 16px; }-.ed-hist ol { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 14px; }-.ed-hist a { color: var(--accent); }-.ed-hist li.man .tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); color: var(--accent); }-.ed-hist li.orig { color: var(--ink-3); }--/* Áp dụng / Bỏ thay đổi: chỉ hiện khi có thay đổi, dính đáy bảng phải */-.ed-mbar { position: sticky; bottom: 12px; z-index: 4; display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 8px 8px 14px; border-radius: 12px;- border: 1px solid var(--line); background: var(--panel-2); box-shadow: 0 -12px 28px -14px rgba(0,0,0,.75); animation: edup .18s ease-out; }-@keyframes edup { from { opacity: 0; transform: translateY(8px); } }-.ed-mdirty { flex: 1 1 auto; min-width: 0; font-size: 14px; color: var(--ink-2); }-.ed-mdirty.bad { color: var(--bad); }-.ed-mreset { min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: none; color: var(--ink-2); cursor: pointer; }-.ed-mreset:hover:not(:disabled) { color: var(--ink); }-.ed-mapply { min-height: 40px; padding: 0 20px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }-.ed-mreset:disabled, .ed-mapply:disabled { opacity: .45; cursor: not-allowed; }-.ed-side > .errmsg:empty { display: none; }--/* màn cảm ứng: không có hover → công cụ dòng hiện khi chọn dòng, nằm hàng dưới; vùng bấm 44px */-@media (hover: none), (max-width: 767px) {- .ed-lx { display: none; grid-column: 2 / -1; flex-wrap: wrap; align-items: center; gap: 6px; padding: 2px 6px 6px; }- .ed-ln.sel .ed-lx { display: flex; }- .ed-lact, .ed-ltime, .ed-ln.sel .ed-ltime { display: flex; visibility: visible; padding: 0; }- .ed-lact { margin-left: auto; }- .ed-tm, .ed-ltext, .ed-lact button, .ed-mx, .ed-sm, .ed-presets button { min-height: 44px; }-}-/* màn hẹp: nút Dựng của form cố định ở đáy → thanh Áp dụng dính ngay trên nó */-@media (max-width: 900px) {- .tabs { padding: 4px 16px 0; }- .edit-wrap { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 120px; }- .ed-mbar { bottom: calc(12px + env(safe-area-inset-bottom)); }-}-@media (max-width: 767px) {- .ed-res { padding: 12px; }- .ed-rhead { flex-wrap: wrap; }- .ed-rtitle { flex-basis: 100%; }- .ed-ract { flex: 1 1 auto; justify-content: flex-end; }- .ed-ract .ed-review { margin-right: auto; }- .ed-ract { min-width: 0; gap: 6px; }- .ed-ract > * { min-width: 0; padding-inline: 10px; font-size: 14px; }- .ed-body, .ed-res.solo .ed-body { grid-template-columns: minmax(0, 1fr); gap: 14px; }- .ed-stage { position: static; width: min(100%, calc(56vh * 9 / 16)); }- .ed-pop { width: 100%; }- .ed-lines { max-height: 60vh; }- .ed-arow { grid-template-columns: 80px minmax(0, 1fr) 56px; }- .ed-captop select { max-width: none; flex: 1; }-}-@media (prefers-reduced-motion: reduce) { .ed-ln, .ed-pop, .ed-mbar { transition: none; animation: none; } }diff --git a/server/public/edit-panel.js b/server/public/edit-panel.jsdeleted file mode 100644index 2f795cf..0000000--- a/server/public/edit-panel.js+++ /dev/null@@ -1,837 +0,0 @@-// Tab "Edit video của bạn": tải video tự quay lên, chọn kiểu edit, dựng, xem tiến độ, sửa bằng lời.-// API: GET /api/edit-options, GET/POST /api/edits, GET /api/edits/:id, POST /api/edits/:id/revise (edit/http.mjs)-(() => {- const $ = (s, r = document) => r.querySelector(s);- const fmtMB = (b) => (b >= 1e9 ? (b / 1e9).toFixed(2) + ' GB' : Math.max(1, Math.round(b / 1e6)) + ' MB');- const I = window.I18N;- const t = (k, v) => I.t(k, v);- const stLabel = (s) => (['queued', 'running', 'done', 'error'].includes(s) ? t('ed.st.' + s) : s);-- const state = { opts: null, style: null, video: null, music: null, current: null, timer: null, uploading: false, view: null, list: null, noServer: false };-- // ---- tab ------------------------------------------------------------------------------------------------------- const tabs = document.querySelectorAll('.tab');- function show(which) {- tabs.forEach((t) => t.setAttribute('aria-selected', String(t.dataset.tab === which)));- $('main.layout').hidden = which !== 'tpl';- $('#editTab').hidden = which !== 'edit';- try { localStorage.setItem('lumreels.tab', which); } catch { /* bỏ qua */ }- if (which === 'edit' && !state.opts) init();- }- tabs.forEach((t) => t.addEventListener('click', () => show(t.dataset.tab)));- document.addEventListener('keydown', (e) => {- if (!e.target.closest?.('.tabs') || !['ArrowLeft', 'ArrowRight'].includes(e.key)) return;- const list = [...tabs]; const i = list.indexOf(document.activeElement);- const n = list[(i + (e.key === 'ArrowRight' ? 1 : list.length - 1)) % list.length]; n.focus(); n.click();- });-- // ---- form ------------------------------------------------------------------------------------------------------- async function init() {- try {- state.opts = await fetch('/api/edit-options').then((r) => r.json());- } catch { state.noServer = true; $('#edSetup').hidden = false; $('#edSetupText').textContent = t('ed.noServer'); return; }- const o = state.opts;- if (!o.ready) {- $('#edSetup').hidden = false;- $('#edSetupText').textContent = t('ed.setupText');- $('#edSetupCmd').textContent = o.setup;- // đang cài dở (vd. tải lại trang giữa chừng) → hiện lại tiến độ- fetch('/api/edit-setup').then((r) => r.json()).then((st) => { if (st.running) watchInstall(); }).catch(() => {});- } else $('#edSetup').hidden = true;- state.style = o.styles[0]?.id || null;- renderStyles();- renderMusic();- refreshGo();- loadList();- }- // ---- lưới thẻ kiểu edit: ảnh minh hoạ dọc + tên (theo ngôn ngữ); tóm tắt kiểu đang chọn hiện dưới lưới ------------- const styleName = (s) => (I.lang === 'en' && s.nameEn ? s.nameEn : s.name);- const styleSummary = (s) => (I.lang === 'en' && s.summaryEn ? s.summaryEn : s.summary);- const styleById = (id) => (state.opts?.styles || []).find((s) => s.id === id);- // Thẻ cách dựng dựng bằng DOM: tên/tóm tắt của cách dựng trong gói là chữ người lạ (L9) → chỉ textContent.- const SRC = ['builtin', 'local', 'pack'];- const srcOf = (s) => (SRC.includes(s?.source) ? s.source : 'builtin');- const HEX = /^#[0-9A-Fa-f]{6}$/;- function el(tag, cls, text) { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; }- function styleCard(s) {- const on = s.id === state.style;- const b = el('button', 'sty');- b.type = 'button';- b.setAttribute('role', 'radio'); b.setAttribute('aria-checked', String(on)); b.tabIndex = on ? 0 : -1;- b.dataset.id = s.id;- b.setAttribute('aria-label', t('ed.styleAria', { name: styleName(s), summary: styleSummary(s) }) + ' · ' + t('src.' + srcOf(s)));- const pic = el('span', 'pic');- if (s.thumb) {- const img = el('img'); img.src = s.thumb; img.alt = ''; img.loading = 'lazy'; img.decoding = 'async'; img.width = 360; img.height = 640;- pic.append(img);- } else {- const ph = el('span', 'ph', styleName(s));- ph.style.setProperty('--sty-acc', HEX.test(String(s.accent || '')) ? s.accent : '#FCE802');- pic.append(ph);- }- const src = el('span', 'src src-' + srcOf(s), t('src.' + srcOf(s)));- b.append(pic, el('span', 'n', styleName(s)), src);- return b;- }- function renderStyles() {- const list = state.opts?.styles || [];- $('#edStyles').replaceChildren(...list.map(styleCard));- $('#edStyleCount').textContent = list.length > 6 ? t('ed.styleHint', { n: list.length }) : '';- renderStyleDesc();- }- function renderStyleDesc() { const s = styleById(state.style); $('#edStyleDesc').textContent = s ? styleSummary(s) : ''; }-- window.addEventListener('lumreels:packs', async () => {- if (!state.opts) return; // chưa mở tab Edit: lần mở đầu sẽ tải- try {- const o = await fetch('/api/edit-options').then((r) => r.json());- state.opts = { ...state.opts, styles: o.styles };- if (!styleById(state.style)) state.style = o.styles[0]?.id || null;- renderStyles(); refreshGo();- } catch { /* bỏ qua */ }- });-- // ---- nút "Cài ngay": server chạy edit/setup.mjs, trang hỏi tiến độ mỗi 1,5 giây ------------------------------ const INSTALL_FAIL = new Set(['NEED_PYTHON', 'NEED_FFMPEG', 'NEED_NETWORK', 'NEED_NPM']);- let installTimer = null;- let lastInstall = null;- function paintInstall(st) {- lastInstall = st;- const prog = $('#edInstallProg'); const step = $('#edInstallStep'); const btn = $('#edInstall');- prog.hidden = false;- const mm = (s) => `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;- step.className = 'ed-install-step';- if (st.running) {- step.textContent = t('ed.installStep', { step: st.step ? I.srv(st.step) : t('ed.installStepDefault'), t: mm(st.elapsedS || 0) });- btn.disabled = true; btn.textContent = t('ed.installing');- } else if (st.ok) {- step.classList.add('ok'); step.textContent = t('ed.installDone', { t: mm(st.elapsedS || 0) });- } else {- step.classList.add('bad'); step.textContent = INSTALL_FAIL.has(st.word) ? t('ed.fail.' + st.word) : t('ed.installFail');- btn.disabled = false; btn.textContent = t('ed.installRetry');- }- prog.classList.toggle('stop', !st.running);- $('#edInstallHint').hidden = !st.hint; $('#edInstallHint').textContent = st.hint || '';- const log = $('#edInstallLog'); const atEnd = log.scrollTop + log.clientHeight >= log.scrollHeight - 8;- log.textContent = (st.log || []).join(String.fromCharCode(10));- if (atEnd) log.scrollTop = log.scrollHeight;- }- function watchInstall() {- clearTimeout(installTimer);- const tick = async () => {- let st;- try { st = await fetch('/api/edit-setup').then((r) => r.json()); } catch { installTimer = setTimeout(tick, 3000); return; }- paintInstall(st);- if (st.running) { installTimer = setTimeout(tick, 1500); return; }- if (st.ok && st.ready) setTimeout(() => { state.opts = null; $('#edSetup').hidden = true; init(); }, 1200);- };- tick();- }- $('#edInstall').addEventListener('click', async () => {- $('#edInstall').disabled = true;- try {- const r = await fetch('/api/edit-setup', { method: 'POST' });- if (!r.ok && r.status !== 409) throw new Error((await r.json().catch(() => ({}))).error || 'HTTP ' + r.status);- watchInstall();- } catch (e) {- $('#edInstall').disabled = false;- $('#edInstallProg').hidden = false; $('#edInstallStep').className = 'ed-install-step bad';- $('#edInstallStep').textContent = t('ed.installCantStart', { e: e.message });- }- });-- // danh sách nhạc (vẽ lại khi đổi ngôn ngữ, giữ lựa chọn)- function renderMusic() {- const sel = $('#edMusic'), keep = sel.value;- sel.replaceChildren(new Option(t('ed.noMusic'), 'none'),- ...(state.opts?.music || []).map((m) => new Option(t('ed.musicSynth', { id: m.id, desc: I.srv(m.desc) }), m.id)),- new Option(t('ed.musicFile'), 'file'));- if (keep && [...sel.options].some((o) => o.value === keep)) sel.value = keep;- }- // radiogroup: bấm hoặc mũi tên chọn kiểu; chỉ nút đang chọn nằm trong thứ tự Tab (roving tabindex)- function pickStyle(b, focus) {- state.style = b.dataset.id;- document.querySelectorAll('#edStyles .sty').forEach((x) => { x.setAttribute('aria-checked', String(x === b)); x.tabIndex = x === b ? 0 : -1; });- renderStyleDesc();- if (focus) { b.focus(); b.scrollIntoView({ block: 'nearest' }); }- }- $('#edStyles').addEventListener('click', (e) => { const b = e.target.closest('.sty'); if (b) pickStyle(b); });- $('#edStyles').addEventListener('keydown', (e) => {- const list = [...document.querySelectorAll('#edStyles .sty')];- const i = list.indexOf(document.activeElement);- if (i < 0) return;- const cols = Math.max(1, getComputedStyle($('#edStyles')).gridTemplateColumns.split(' ').length);- const step = { ArrowDown: cols, ArrowRight: 1, ArrowUp: -cols, ArrowLeft: -1 }[e.key];- if (step) { e.preventDefault(); pickStyle(list[(i + step + list.length) % list.length], true); }- else if (e.key === 'Home' || e.key === 'End') { e.preventDefault(); pickStyle(e.key === 'Home' ? list[0] : list[list.length - 1], true); }- });- // nhạc: chọn "Tải file…" mà huỷ hộp chọn file → trả select về lựa chọn trước- let musicPrev = 'none';- $('#edMusic').addEventListener('focus', () => { musicPrev = $('#edMusic').value; });- $('#edMusic').addEventListener('change', () => {- const v = $('#edMusic').value;- if (v === 'file') {- const inp = $('#edMusicFile');- const onFocusBack = () => setTimeout(() => { if (!inp.files.length && !state.music) $('#edMusic').value = musicPrev; }, 400);- window.addEventListener('focus', onFocusBack, { once: true });- inp.addEventListener('cancel', () => { if (!state.music) $('#edMusic').value = musicPrev; }, { once: true });- inp.click();- } else { state.music = null; $('#edMusicName').textContent = ''; musicPrev = v; }- });- $('#edMusicFile').addEventListener('change', (e) => {- state.music = e.target.files[0] || null;- if (!state.music) $('#edMusic').value = musicPrev;- $('#edMusicName').textContent = state.music ? `${state.music.name} · ${fmtMB(state.music.size)}` : '';- });-- const drop = $('#edDrop');- const pickVideo = (f) => {- if (!f) return;- if (!/^video\//.test(f.type) && !/\.(mp4|mov|m4v|mkv|webm|avi|3gp)$/i.test(f.name)) { setErr(t('ed.notVideo')); return; }- if (state.opts && f.size > state.opts.maxUploadBytes) { setErr(t('ed.tooBig', { size: fmtMB(f.size) })); return; }- state.video = f; setErr('');- renderDrop();- refreshGo();- };- // ô thả video: chưa chọn → chữ hướng dẫn; đã chọn → tên file (giữ nguyên) + cỡ- function renderDrop() {- const f = state.video;- drop.classList.toggle('has', !!f);- $('.big', drop).textContent = f ? f.name : t('ed.dropBig');- $('.small', drop).textContent = f ? t('ed.changeFile', { size: fmtMB(f.size) }) : t('ed.dropSmall');- }- drop.addEventListener('click', () => $('#edVideo').click());- drop.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); $('#edVideo').click(); } });- $('#edVideo').addEventListener('change', (e) => pickVideo(e.target.files[0]));- ['dragenter', 'dragover'].forEach((ev) => drop.addEventListener(ev, (e) => { e.preventDefault(); drop.classList.add('over'); }));- ['dragleave', 'drop'].forEach((ev) => drop.addEventListener(ev, (e) => { e.preventDefault(); drop.classList.remove('over'); }));- drop.addEventListener('drop', (e) => pickVideo(e.dataTransfer.files[0]));-- const setErr = (t) => { $('#edErr').textContent = t; };- function refreshGo() { $('#edGo').disabled = !(state.opts?.ready && state.video && state.style) || state.uploading; }-- $('#edGo').addEventListener('click', () => {- if ($('#edMusic').value === 'file' && !state.music) { setErr(t('ed.needMusic')); return; }- const fd = new FormData();- fd.append('style', state.style);- fd.append('content', $('#edNotes').value.trim());- fd.append('names', $('#edNames').value.trim());- fd.append('draft', $('#edDraft').checked ? '1' : '0');- const mv = $('#edMusic').value;- if (mv !== 'file') fd.append('musicStyle', mv);- if (mv === 'file' && state.music) fd.append('music', state.music, state.music.name);- fd.append('video', state.video, state.video.name); // file sau cùng: trường chữ tới server trước- state.uploading = true; refreshGo(); setErr('');- const goLabel = $('#edGo span');- const xhr = new XMLHttpRequest();- xhr.open('POST', '/api/edits');- xhr.upload.onprogress = (e) => { if (e.lengthComputable) goLabel.textContent = t('ed.uploading', { p: Math.round((e.loaded / e.total) * 100) }); };- xhr.onload = () => {- state.uploading = false; goLabel.textContent = t('ed.go'); refreshGo();- let j = {}; try { j = JSON.parse(xhr.responseText); } catch { /* bỏ qua */ }- if (xhr.status !== 202) { setErr(j.error || t('err.status', { s: xhr.status })); return; }- select(j.id, j); loadList();- };- xhr.onerror = () => { state.uploading = false; goLabel.textContent = t('ed.go'); refreshGo(); setErr(t('ed.uploadCut')); };- xhr.send(fd);- });-- // ---- bản đang xem ------------------------------------------------------------------------------------------------- // Màn kết quả kiểu trình edit: 1 dòng đầu (tên · thời lượng · Cần xem lại · Tải MP4 · ⋯), trái là player + thanh- // thời gian, phải là bảng chỉnh có tab. Chữ từ server chỉ vào DOM qua textContent / new Option (luật P2).- async function loadList() {- let list = [];- try { list = await fetch('/api/edits').then((r) => r.json()); } catch { return; }- state.list = list;- renderList();- if (!state.current && list[0]) select(list[0].id, list[0]);- }- const viewStyleName = (v) => { const s = styleById(v.style); return s ? styleName(s) : v.styleName || v.style; };- function renderList() {- const list = state.list || [];- // tên cách dựng có thể là chữ của gói (L9): dựng bằng DOM- $('#edList').replaceChildren(...(list.length ? list.map((v) => {- const b = el('button', 'ed-item' + (v.id === state.current ? ' sel' : ''));- b.type = 'button'; b.dataset.id = v.id;- const info = el('span');- info.append(el('span', 't', v.sourceName || v.id), el('br'), el('span', 's', `${viewStyleName(v)} · ${v.id}`));- b.append(info, el('span', 'st ' + (v.status === 'done' ? 'done' : v.status === 'error' ? 'error' : 'run'), stLabel(v.status)));- return b;- }) : [el('div', 'hint', t('ed.listEmpty'))]));- }- $('#edList').addEventListener('click', (e) => { const b = e.target.closest('.ed-item'); if (b) select(b.dataset.id); });-- function select(id, view) {- state.current = id;- document.querySelectorAll('.ed-item').forEach((b) => b.classList.toggle('sel', b.dataset.id === id));- closePops();- if (view) render(view);- poll();- }- async function poll() {- clearTimeout(state.timer);- const id = state.current; if (!id) return;- let v;- try { v = await fetch(`/api/edits/${encodeURIComponent(id)}`).then((r) => r.json()); } catch { state.timer = setTimeout(poll, 3000); return; }- if (id !== state.current) return;- render(v);- if (['queued', 'running'].includes(v.status)) state.timer = setTimeout(poll, 1500);- else loadList();- }-- const fmtDur = (s) => { const x = Math.max(0, Math.round(s)); return `${Math.floor(x / 60)}:${String(x % 60).padStart(2, '0')}`; };- const fmtT = (s) => { const x = Math.max(0, Math.round(s * 10) / 10); const m = Math.floor(x / 60); return `${m}:${(x - m * 60).toFixed(1).padStart(4, '0')}`; };- // chỉ nhận đường dẫn cùng gốc ("/edits/…"), không nhận javascript:, //host…- const safeUrl = (u) => (typeof u === 'string' && /^\/(?!\/)/.test(u) ? u : null);- const video = () => $('#edMedia video');- function seek(at, play) {- const v = video(); if (!v || !Number.isFinite(at)) return;- v.currentTime = Math.max(0, at + 0.02);- if (play) v.play().catch(() => {});- }- const narrow = () => window.matchMedia('(max-width: 767px)').matches;-- // ---- menu bật lên: "Cần xem lại" và "⋯" ----- const POPS = ['#edReviewBtn', '#edMoreBtn'];- function setPop(btnSel, open) {- const b = $(btnSel); const p = $('#' + b.getAttribute('aria-controls'));- p.hidden = !open; b.setAttribute('aria-expanded', String(open));- }- function closePops(except) { POPS.forEach((b) => { if (b !== except) setPop(b, false); }); }- POPS.forEach((sel) => $(sel).addEventListener('click', () => {- const p = $('#' + $(sel).getAttribute('aria-controls')); const open = p.hidden;- closePops(sel); setPop(sel, open);- if (open) p.querySelector('a[href], button:not(:disabled), summary')?.focus();- }));- document.addEventListener('click', (e) => { if (!e.target.closest?.('.ed-pop, #edReviewBtn, #edMoreBtn')) closePops(); });- document.addEventListener('keydown', (e) => {- if (e.key !== 'Escape') return;- const open = POPS.find((s) => !$('#' + $(s).getAttribute('aria-controls')).hidden);- if (open) { closePops(); $(open).focus(); }- });-- // ---- "Cần xem lại": chữ AI sửa + số nghe không chắc; giờ nguồn → giờ bản ra theo đoạn giữ của EDL ----- const EDL = { key: null, keep: null, words: null };- async function loadEdl(v) {- const url = safeUrl(v.links?.edl); const key = `${v.id}|${v.links?.out || ''}`;- if (!url || EDL.key === key) return;- EDL.key = key; EDL.keep = null; EDL.words = null;- try {- const e = await fetch(url, { cache: 'no-store' }).then((r) => r.json());- if (EDL.key !== key) return;- EDL.keep = Array.isArray(e.keep) ? e.keep.filter((k) => Number.isFinite(k.start) && Number.isFinite(k.end)) : null;- EDL.words = new Map((e.captions?.words || []).filter((w) => Number.isFinite(w.start)).map((w) => [w.i, w.start]));- if (state.view?.id === v.id) renderReview(state.view);- } catch { /* không có EDL: mục vẫn hiện, chỉ không nhảy được */ }- }- function toOut(src) {- if (!EDL.keep || !Number.isFinite(src)) return null;- let acc = 0;- for (const k of EDL.keep) {- if (src < k.start) return acc;- if (src <= k.end) return acc + (src - k.start);- acc += k.end - k.start;- }- return null;- }- function reviewItems(v) {- const fixes = (v.fixes || []).map((f) => ({ kind: 'fix', f, at: toOut(EDL.words?.get(f.word)) }));- const figs = (v.checks?.figures || []).map((f) => ({ kind: 'fig', f, at: toOut(f.at) }));- return { fixes, figs, n: fixes.length + figs.length };- }- function reviewRow(it) {- const li = el('li');- const b = el('button', 'ed-ritem'); b.type = 'button';- const at = it.at;- if (at != null) b.dataset.t = String(at); else b.disabled = true;- const tx = el('span', 'rx');- if (it.kind === 'fix') tx.append(el('s', null, it.f.heard), ' → ', el('b', null, it.f.text || t('ed.hidden')));- else {- tx.append(el('b', null, it.f.text), ' · ', el('s', null, it.f.said));- if (it.f.why) b.title = String(it.f.why);- }- if (at != null) b.setAttribute('aria-label', `${fmtT(at)} · ${tx.textContent}`);- b.append(el('span', 'tm', at != null ? fmtT(at) : '–'), tx);- li.append(b);- return li;- }- function renderReview(v) {- const r = reviewItems(v);- $('#edReviewBtn').hidden = !r.n;- $('#edReviewL').textContent = t('ed.review', { n: r.n });- if (!r.n) { setPop('#edReviewBtn', false); $('#edReviewList').replaceChildren(); return; }- const out = [];- if (r.fixes.length) out.push(el('li', 'h', t('ed.revFixes')), ...r.fixes.map(reviewRow));- if (r.figs.length) out.push(el('li', 'h', t('ed.revFigs')), ...r.figs.map(reviewRow));- $('#edReviewList').replaceChildren(...out);- }- $('#edReviewList').addEventListener('click', (e) => {- const b = e.target.closest('.ed-ritem'); if (!b || b.disabled) return;- document.querySelectorAll('.ed-ritem.on').forEach((x) => x.classList.remove('on'));- b.classList.add('on');- seek(Number(b.dataset.t), true);- if (narrow()) { closePops(); video()?.scrollIntoView({ block: 'nearest' }); }- });-- let lastOut = null;- function render(v) {- state.view = v;- $('#edEmpty').hidden = true; $('#edView').hidden = false;- const busy = ['queued', 'running'].includes(v.status);- const name = v.sourceName || v.id;- $('#edTitle').textContent = name; $('#edTitle').title = name;- const dur = v.checks?.edl?.outSeconds;- $('#edDur').textContent = Number.isFinite(dur) && !busy ? fmtDur(dur) : '';- $('#edId').textContent = `${viewStyleName(v)} · ${v.id}`;- const st = $('#edStatus');- st.hidden = v.status === 'done';- st.className = 'st ' + (v.status === 'done' ? 'done' : v.status === 'error' ? 'error' : 'run');- st.textContent = busy ? t(v.status === 'queued' ? 'ed.waitTurn' : v.action === 'revise' ? 'ed.revising' : v.action === 'manual' ? 'man.running' : 'ed.st.running') : stLabel(v.status);- // tiến độ: 1 thanh + tên bước đang chạy (không còn list các bước)- const steps = v.steps || [];- $('#edProg').hidden = !busy;- if (busy) {- const i = Math.max(0, Math.min(steps.length - 1, v.stepIndex ?? 0));- const done = i + (v.pct || 0) / 100;- $('#edBar').style.width = `${Math.min(100, (done / Math.max(1, steps.length)) * 100)}%`;- $('#edProgText').textContent = v.status === 'queued' || !steps.length ? t('ed.waitTurn')- : t('ed.stepOf', { i: i + 1, n: steps.length, step: I.srv(steps[i]), p: v.pct || 0 });- $('#edProgText').title = v.note || '';- }- $('#edViewErr').textContent = v.status === 'error' ? (v.error || t('ed.err')) : v.reviseError ? t('ed.reviseErr', { e: v.reviseError }) : '';- // video- const media = $('#edMedia');- const out = safeUrl(v.links?.out);- if (out && out !== lastOut) {- lastOut = out;- const vid = document.createElement('video');- vid.controls = true; vid.playsInline = true; vid.preload = 'metadata'; vid.src = out;- media.replaceChildren(vid);- } else if (!out) {- lastOut = null;- const pv = safeUrl(v.links?.preview);- if (pv) { const img = document.createElement('img'); img.src = pv; img.alt = t('ed.previewAlt'); media.replaceChildren(img); }- else media.replaceChildren(el('span', null, t('ed.mediaEmpty')));- }- const dl = $('#edDl'); dl.hidden = !out; if (out) dl.href = out; else dl.removeAttribute('href');- // menu ⋯: lưới khung, EDL, thông số- const link = (u, label) => { const a = el('a', null, label); a.href = u; a.target = '_blank'; a.rel = 'noopener'; return a; };- const pf = safeUrl(v.links?.previewFinal); const edl = safeUrl(v.links?.edl);- $('#edLinks').replaceChildren(...[pf && link(pf, t('ed.gridOut')), edl && link(edl, 'EDL')].filter(Boolean));- const c = v.checks || {};- const bits = [];- if (c.edl) bits.push(el('span', null, t('ed.checksEdl', { out: c.edl.outSeconds ?? '', rm: c.edl.removedSeconds, z: c.edl.zooms })));- if (c.overcut) bits.push(c.overcut.lost?.length || c.overcut.chopped?.length ? el('span', 'bad', t('ed.overcut', { v: c.overcut.verdict })) : el('span', 'ok', t('ed.noOvercut')));- if (c.cutRepairs?.length) bits.push(el('span', null, t('ed.cutRepairs', { n: c.cutRepairs.length })));- if (c.loudness) bits.push(el('span', null, `${c.loudness.lufs} LUFS`));- if (c.qc?.fails?.length) bits.push(el('span', null, `qc: ${c.qc.fails.join('; ')}`));- $('#edChecks').replaceChildren(...bits.flatMap((b, k) => (k ? [' · ', b] : [b])));- $('#edLog').textContent = (v.log || []).join('\n');- $('#edDelete').disabled = busy;- // cần xem lại- renderReview(v);- if (out && !busy) loadEdl(v);- // sửa bằng lời + các lần sửa- $('#edReviseBtn').disabled = busy || v.status !== 'done';- const revs = v.revisions || [];- $('#edHist').hidden = !revs.length;- const watch = (u) => { const s = safeUrl(u); if (!s) return []; const a = el('a', null, t('man.watch')); a.href = s; a.target = '_blank'; a.rel = 'noopener'; return [' ', a]; };- const hist = [];- if (v.originalUrl && revs.length) { const li = el('li', 'orig', t('man.original')); li.append(...watch(v.originalUrl)); hist.push(li); }- for (const r of revs) {- const li = el('li', r.manual ? 'man' : null);- if (r.manual) li.append(el('span', 'tag', t('man.tag')), ' ', r.instruction || '');- else li.append(`"${r.instruction || ''}"`);- if (r.notes) li.append(` — ${r.notes}`);- if (r.manual && r.seconds) li.append(` · ${t('man.took', { s: Math.round(r.seconds) })}`);- li.append(...watch(r.url));- hist.push(li);- }- $('#edHistList').replaceChildren(...hist);- Man.onView(v, busy);- }-- async function revise(text) {- if (!state.current || !text) return;- $('#edReviseBtn').disabled = true;- try {- const r = await fetch(`/api/edits/${encodeURIComponent(state.current)}/revise`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ instruction: text }) });- const j = await r.json();- if (!r.ok) { $('#edViewErr').textContent = j.error || t('err.status', { s: r.status }); $('#edReviseBtn').disabled = false; return; }- $('#edReviseText').value = '';- render(j); poll();- } catch { $('#edViewErr').textContent = t('ed.sendFail'); $('#edReviseBtn').disabled = false; }- }- $('#edDelete').addEventListener('click', async () => {- const id = state.current; if (!id) return;- if (!confirm(t('ed.confirmDel'))) return;- closePops();- const r = await fetch(`/api/edits/${encodeURIComponent(id)}`, { method: 'DELETE' });- const j = await r.json().catch(() => ({}));- if (!r.ok) { $('#edViewErr').textContent = j.error || t('err.status', { s: r.status }); return; }- clearTimeout(state.timer);- state.current = null; lastOut = null; state.view = null;- $('#edView').hidden = true; $('#edEmpty').hidden = false;- loadList();- });- $('#edReviseForm').addEventListener('submit', (e) => { e.preventDefault(); revise($('#edReviseText').value.trim()); });- $('#edPresets').addEventListener('click', (e) => { const b = e.target.closest('button'); if (b) $('#edReviseText').value = b.textContent; $('#edReviseText').focus(); });-- // ---- chỉnh tay (GET/POST /api/edits/:id/manual, POST /api/edits/:id/music) ------------------------------------- // Phụ đề dạng transcript (giây bản ra), nhạc, giọng, sfx, zoom, đồ hoạ. Sửa trong trang (bản nháp cục bộ), bấm Áp dụng- // thì gửi một bản vá chỉ gồm phần đã đổi; server dựng lại lớp cần thiết ra out-r<n>.mp4.- const Man = (() => {- const M = { id: null, outKey: null, orig: null, cur: null, loading: false, sel: -1, now: -1 };- const clone = (x) => JSON.parse(JSON.stringify(x));- const sec = (x) => (Math.round(x * 100) / 100).toFixed(2);- const db = (x) => `${x > 0 ? '+' : ''}${x} dB`;- const isBusy = () => !!state.view && ['queued', 'running'].includes(state.view.status);-- async function load(id) {- M.loading = true;- try {- const r = await fetch(`/api/edits/${encodeURIComponent(id)}/manual`);- const j = await r.json().catch(() => ({}));- if (!r.ok) throw new Error(j.error || 'HTTP ' + r.status);- if (id !== M.id) return;- M.orig = j; M.cur = clone(j); M.sel = -1; M.now = -1; $('#edManErr').textContent = '';- paint();- } catch (e) { if (id === M.id) $('#edManErr').textContent = t('man.loadErr', { e: I.srv(e.message) }); } finally { M.loading = false; paintTabs(); paintDirty(); }- }- // gọi mỗi lần vẽ bản edit: tải lại khi đổi bản hoặc có video ra mới- function onView(v, busy) {- const ready = v.status === 'done' && !!v.links?.out;- if (v.id !== M.id) { M.id = v.id; M.orig = M.cur = null; M.outKey = null; $('#edManErr').textContent = ''; $('#edLines').replaceChildren(); }- $('#edMan').hidden = !M.orig && !ready && !v.links?.out;- $('#edView').classList.toggle('solo', $('#edMan').hidden);- const key = ready ? `${v.id}|${v.links.out}` : null;- if (key && !busy && key !== M.outKey) { M.outKey = key; load(v.id); } // load() đặt M.loading ngay (trước await)- paintTabs();- paintDirty();- paintTl();- }-- // ---- tab: chưa tải được phần chỉnh tay thì chỉ còn "Sửa bằng lời" ----- const tabsEl = [...document.querySelectorAll('.ed-mtabs [role="tab"]')];- function pickTab(b, focus) {- tabsEl.forEach((x) => { const on = x === b; x.setAttribute('aria-selected', String(on)); x.tabIndex = on ? 0 : -1; $('#' + x.getAttribute('aria-controls')).hidden = !on; });- if (focus) b.focus();- if (b.id === 'edMtCap') scrollToNow(true);- }- function paintTabs() {- const has = !!M.cur;- tabsEl.forEach((x) => { if (x.id !== 'edMtRev') x.disabled = !has; });- const sel = tabsEl.find((x) => x.getAttribute('aria-selected') === 'true');- if (!has && sel && sel.id !== 'edMtRev' && !M.loading) { pickTab($('#edMtRev')); M.autoRev = true; }- else if (has && M.autoRev) { M.autoRev = false; if (sel?.id === 'edMtRev') pickTab($('#edMtCap')); }- }- tabsEl.forEach((b) => b.addEventListener('click', () => pickTab(b)));- $('.ed-mtabs').addEventListener('keydown', (e) => {- const on = tabsEl.filter((x) => !x.disabled);- const i = on.indexOf(document.activeElement); if (i < 0) return;- const step = { ArrowRight: 1, ArrowLeft: -1 }[e.key];- if (step) { e.preventDefault(); pickTab(on[(i + step + on.length) % on.length], true); }- });-- // ---- vẽ ----- const musicLabel = (name) => (!name ? '' : name.startsWith('synth:') ? t('man.synth', { id: name.slice(6) }) : name);- function paint() {- const c = M.cur; if (!c) return;- $('#edMan').hidden = false; $('#edView').classList.remove('solo');- $('#edManLook').replaceChildren(...c.captions.looks.map((l) => new Option(I.lang === 'en' ? l.nameEn : l.name, l.id)));- $('#edManLook').value = c.captions.look;- $('#edManHi').checked = c.captions.highlights;- $('#edManDraft').hidden = !c.draft;- $('#edManLook').disabled = !!c.draft; $('#edManHi').disabled = !!c.draft;- paintLines();- const mu = c.music;- const opts = [];- if (M.orig.music.on) opts.push(new Option(t('man.musicKeep', { name: musicLabel(M.orig.music.name) }), 'keep'));- opts.push(new Option(t('ed.noMusic'), 'none'));- for (const s of mu.synth) opts.push(new Option(t('man.synth', { id: s }), `synth:${s}`));- for (const u of mu.uploads) opts.push(new Option(t('man.uploaded', { name: u.name }), `upload:${u.file}`));- opts.push(new Option(t('ed.musicFile'), 'file'));- $('#edManMusic').replaceChildren(...opts);- $('#edManMusic').value = mu.source || (M.orig.music.on ? 'keep' : 'none');- $('#edManGain').value = mu.gainDb; $('#edManDuck').checked = mu.duck; $('#edManFade').value = mu.fadeOut; $('#edManStart').value = mu.start;- $('#edManVoice').value = c.voice.gainDb;- $('#edManSfx').checked = c.sfx.on; $('#edManSfx').disabled = !c.sfx.count;- $('#edManSfxL').textContent = t('man.sfx', { n: c.sfx.count });- paintAudioOut();- $('#edManZooms').replaceChildren(...(c.zooms.length ? c.zooms.map((z) => fxRow(z.at, t('man.zoomKind', { kind: z.kind, scale: z.scale.toFixed(2) }), !!z.gone, `zoom ${sec(z.at)} s`, { n: String(z.n) })) : [el('li', 'none', t('man.noZoom'))]));- $('#edManGfx').replaceChildren(...(c.graphics.length ? c.graphics.map((g) => fxRow(g.at, `${g.type}${g.title ? ` · ${String(g.title).slice(0, 40)}` : ''}`, !!g.gone, `${g.type} ${sec(g.at)} s`, { id: String(g.id) })) : [el('li', 'none', t('man.noGfx'))]));- paintTl();- paintDirty();- }- function tmBtn(at) {- const b = el('button', 'ed-tm', fmtT(at)); b.type = 'button'; b.dataset.t = String(at);- b.setAttribute('aria-label', t('man.jump', { s: sec(at) }));- return b;- }- function fxRow(at, label, gone, what, data) {- const li = el('li', gone ? 'gone' : null);- Object.assign(li.dataset, data);- const x = el('button', 'ed-mx', gone ? t('man.undo') : t('man.remove')); x.type = 'button';- x.setAttribute('aria-pressed', String(gone));- x.setAttribute('aria-label', gone ? t('man.undoN', { what }) : t('man.removeN', { what }));- li.append(tmBtn(at), el('span', null, label), x);- return li;- }- function paintAudioOut() {- $('#edManGainV').textContent = db(Number($('#edManGain').value));- $('#edManFadeV').textContent = `${Number($('#edManFade').value)} s`;- $('#edManVoiceV').textContent = db(Number($('#edManVoice').value));- $('#edManMusicBox').hidden = $('#edManMusic').value === 'none';- if (M.cur) M.cur.music.source = $('#edManMusic').value;- }- function lineErrors(lines) {- const bad = new Map();- lines.forEach((l, k) => {- if (!(l.end - l.start >= 0.1)) bad.set(k, t('man.errShort'));- else if (l.start >= M.cur.duration) bad.set(k, t('man.errAfter', { d: sec(M.cur.duration) }));- else if (k && l.start < lines[k - 1].end - 1e-6) bad.set(k, t('man.errOverlap'));- else if (!l.text.replace(/\*/g, '').trim()) bad.set(k, t('man.errEmpty'));- });- return bad;- }- // một dòng transcript: mốc giờ nhỏ + chữ sửa tại chỗ; giờ bắt đầu/kết thúc và Tách/Gộp/Xoá chỉ hiện khi rê chuột- // hoặc khi dòng đang chọn- function lineRow(l, k, n, bad, draft) {- const li = el('li', 'ed-ln'); li.dataset.k = String(k);- if (bad.has(k)) li.classList.add('bad');- if (k === M.sel) li.classList.add('sel');- if (k === M.now) li.classList.add('now');- const tx = el('input', 'ed-ltext'); tx.value = l.text; tx.maxLength = 200; tx.disabled = draft; tx.spellcheck = false;- tx.setAttribute('aria-label', t('man.lineText', { n: k + 1 }));- const num = (f, v) => {- const i = el('input', 'ed-sm ed-num'); i.type = 'number'; i.step = '0.05'; i.min = '0'; i.inputMode = 'decimal';- i.dataset.f = f; i.value = sec(v); i.disabled = draft;- i.setAttribute('aria-label', t(f === 'start' ? 'man.lineStart' : 'man.lineEnd', { n: k + 1 }));- return i;- };- const times = el('span', 'ed-ltime'); times.append(num('start', l.start), el('span', null, '→'), num('end', l.end));- times.lastChild.previousSibling.setAttribute('aria-hidden', 'true');- const act = el('span', 'ed-lact');- const btn = (a, label, aria, dis, cls) => { const b = el('button', cls || null, label); b.type = 'button'; b.dataset.a = a; b.setAttribute('aria-label', aria); b.disabled = dis; return b; };- act.append(btn('split', t('man.split'), t('man.splitN', { n: k + 1 }), draft),- btn('merge', t('man.merge'), t('man.mergeN', { n: k + 1 }), draft || k + 1 >= n),- btn('del', '×', t('man.delN', { n: k + 1 }), draft, 'del'));- const x = el('div', 'ed-lx'); x.append(times, act);- li.append(tmBtn(l.start), tx, x);- if (bad.has(k)) li.append(el('span', 'ed-lerr', bad.get(k)));- return li;- }- function paintLines() {- const c = M.cur; const lines = c.captions.lines;- const bad = lineErrors(lines);- $('#edLines').replaceChildren(...(lines.length ? lines.map((l, k) => lineRow(l, k, lines.length, bad, !!c.draft)) : [el('li', 'none', t('man.noLines'))]));- }- // thanh thời gian dưới player: vạch zoom, khoảng đồ hoạ, đầu phát- function paintTl() {- const c = M.cur; const tl = $('#edTl');- tl.hidden = !c || !video() || !(c.duration > 0);- if (tl.hidden) return;- const pc = (x) => `${Math.max(0, Math.min(100, (x / c.duration) * 100))}%`;- const marks = [];- for (const g of c.graphics) { const m = el('i', 'g' + (g.gone ? ' gone' : '')); m.style.left = pc(g.at); m.style.width = `calc(${pc(Math.max(0.2, (g.until ?? g.at + 1) - g.at))})`; marks.push(m); }- for (const z of c.zooms) { const m = el('i', 'z' + (z.gone ? ' gone' : '')); m.style.left = pc(z.at); marks.push(m); }- $('#edTlTrack').replaceChildren(...marks, $('#edTlHead'));- paintHead();- }- function paintHead() {- const v = video(); const c = M.cur; if (!v || !c?.duration) return;- $('#edTlHead').style.left = `${Math.min(100, (v.currentTime / c.duration) * 100)}%`;- }- $('#edTlTrack').addEventListener('click', (e) => {- const c = M.cur; if (!c) return;- const r = e.currentTarget.getBoundingClientRect();- seek(((e.clientX - r.left) / r.width) * c.duration, false);- });-- // ---- bản vá = phần khác bản đang có ----- function patch() {- const o = M.orig; const c = M.cur; if (!o || !c) return {};- const p = {}; const cap = {};- const ls = (x) => JSON.stringify(x.map((l) => [Math.round(l.start * 100), Math.round(l.end * 100), l.text.trim()]));- if (ls(o.captions.lines) !== ls(c.captions.lines)) cap.lines = c.captions.lines.map((l) => ({ start: +sec(l.start), end: +sec(l.end), text: l.text.trim() }));- if (o.captions.highlights !== c.captions.highlights) cap.highlights = c.captions.highlights;- if (o.captions.look !== c.captions.look) cap.look = c.captions.look;- if (Object.keys(cap).length) p.captions = cap;- const mu = {}; const src0 = o.music.on ? 'keep' : 'none'; const src = c.music.source || src0;- if (src !== src0) mu.source = src;- if (src !== 'none') {- for (const k of ['gainDb', 'duck', 'fadeOut', 'start']) if (c.music[k] !== o.music[k] || mu.source) mu[k] = c.music[k];- }- if (Object.keys(mu).length) p.music = mu;- if (c.voice.gainDb !== o.voice.gainDb) p.voice = { gainDb: c.voice.gainDb };- if (c.sfx.on !== o.sfx.on) p.sfx = { on: c.sfx.on };- const zr = c.zooms.filter((z) => z.gone).map((z) => z.n); if (zr.length) p.zooms = { remove: zr };- const gr = c.graphics.filter((g) => g.gone).map((g) => g.id); if (gr.length) p.graphics = { remove: gr };- return p;- }- // thanh Áp dụng / Bỏ thay đổi: chỉ hiện khi có thay đổi (hoặc dòng lỗi, hoặc đang dựng bản chỉnh tay)- function paintDirty() {- const p = patch(); const n = Object.values(p).reduce((s, v) => s + Object.keys(v).length, 0);- const bad = M.cur ? lineErrors(M.cur.captions.lines).size : 0;- const applying = isBusy() && state.view?.action === 'manual' && !!M.orig; // trang mở giữa chừng: tiến độ đã ở dòng đầu- const what = [...new Set([(p.captions || p.graphics) && t('man.wCap'), (p.music || p.voice || p.sfx) && t('man.wAud'), (p.zooms || p.graphics) && t('man.wBase')].filter(Boolean))];- $('#edManBar').hidden = !(n || bad || applying);- const d = $('#edManDirty');- d.textContent = bad ? t('man.fixFirst', { n: bad }) : applying ? t('man.running') : t('man.dirtyS', { n });- d.title = n ? t('man.dirty', { n, what: what.join(' + ') }) : '';- d.classList.toggle('bad', !!bad);- $('#edManApply').disabled = !n || !!bad || isBusy() || M.loading;- $('#edManApply').textContent = applying ? t('man.applying') : t('man.apply');- $('#edManReset').disabled = !n || isBusy();- }-- // ---- sự kiện ----- // bấm mốc giờ → video nhảy tới đúng giây (dòng phụ đề, zoom, đồ hoạ)- $('#edMan').addEventListener('click', (e) => {- const tm = e.target.closest('.ed-tm'); if (tm) seek(Number(tm.dataset.t), true);- });- function setSel(k) {- M.sel = k;- document.querySelectorAll('#edLines li.sel').forEach((x) => { if (Number(x.dataset.k) !== k) x.classList.remove('sel'); });- $(`#edLines li[data-k="${k}"]`)?.classList.add('sel');- }- // chọn 1 dòng (bấm vào chữ) → dòng mở công cụ, video đứng ở đầu dòng- $('#edLines').addEventListener('focusin', (e) => {- const li = e.target.closest('li[data-k]'); if (!li || !M.cur) return;- const k = Number(li.dataset.k);- if (k !== M.sel) {- setSel(k);- const v = video(); const l = M.cur.captions.lines[k];- if (v && l && v.paused && e.target.classList.contains('ed-ltext')) seek(l.start, false);- }- });- $('#edLines').addEventListener('keydown', (e) => {- if (!e.target.classList.contains('ed-ltext') || !['Enter', 'ArrowDown', 'ArrowUp'].includes(e.key)) return;- const k = Number(e.target.closest('li').dataset.k) + (e.key === 'ArrowUp' ? -1 : 1);- const nx = $(`#edLines li[data-k="${k}"] .ed-ltext`);- if (nx) { e.preventDefault(); nx.focus(); }- });- $('#edLines').addEventListener('input', (e) => {- const li = e.target.closest('li[data-k]'); if (!li || !M.cur) return;- const l = M.cur.captions.lines[Number(li.dataset.k)];- if (e.target.classList.contains('ed-ltext')) l.text = e.target.value;- else if (e.target.dataset.f) { const x = Number(e.target.value); if (Number.isFinite(x)) l[e.target.dataset.f] = x; }- const bad = lineErrors(M.cur.captions.lines);- document.querySelectorAll('#edLines li[data-k]').forEach((x) => {- const k = Number(x.dataset.k); x.classList.toggle('bad', bad.has(k));- let er = x.querySelector('.ed-lerr');- if (bad.has(k)) { if (!er) { er = el('span', 'ed-lerr'); x.append(er); } er.textContent = bad.get(k); } else er?.remove();- const tb = x.querySelector('.ed-tm'); const ln = M.cur.captions.lines[k];- if (tb && ln) { tb.dataset.t = String(ln.start); tb.textContent = fmtT(ln.start); }- });- paintDirty();- });- $('#edLines').addEventListener('click', (e) => {- const b = e.target.closest('button[data-a]'); if (!b || !M.cur) return;- const lines = M.cur.captions.lines; const k = Number(b.closest('li').dataset.k); const l = lines[k];- if (b.dataset.a === 'del') lines.splice(k, 1);- else if (b.dataset.a === 'merge' && lines[k + 1]) { const n = lines[k + 1]; lines.splice(k, 2, { start: l.start, end: n.end, text: `${l.text} ${n.text}`.trim() }); }- else if (b.dataset.a === 'split') {- const ws = l.text.trim().split(/\s+/);- if (ws.length < 2) { $('#edManErr').textContent = t('man.cantSplit'); return; }- const cut = Math.ceil(ws.length / 2); const a = ws.slice(0, cut).join(' '); const z = ws.slice(cut).join(' ');- const mid = Math.round((l.start + (l.end - l.start) * (a.length / (a.length + z.length))) * 100) / 100;- lines.splice(k, 1, { start: l.start, end: mid, text: a }, { start: mid, end: l.end, text: z });- }- $('#edManErr').textContent = '';- M.sel = Math.min(k, lines.length - 1);- paintLines(); paintDirty();- $(`#edLines li[data-k="${M.sel}"] .ed-ltext`)?.focus();- });- // dòng đang phát tô sáng và tự cuộn tới (trong khung danh sách, không kéo cả trang; đang gõ thì không cuộn)- function scrollToNow(force) {- const list = $('#edLines'); const li = $(`#edLines li[data-k="${M.now}"]`); // .ed-lines position: relative → li.offsetTop tính từ khung list- if (!li || list.hidden || !list.offsetParent) return;- if (!force && list.contains(document.activeElement)) return;- const top = li.offsetTop; const bot = top + li.offsetHeight;- if (top < list.scrollTop + 8 || bot > list.scrollTop + list.clientHeight - 8) {- const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;- list.scrollTo({ top: Math.max(0, top - list.clientHeight / 3), behavior: reduce || force ? 'auto' : 'smooth' });- }- }- $('#edMedia').addEventListener('timeupdate', (e) => {- if (!M.cur || e.target.tagName !== 'VIDEO') return;- paintHead();- const tt = e.target.currentTime; const lines = M.cur.captions.lines;- const k = lines.findIndex((l) => tt >= l.start && tt < l.end);- if (k === M.now) return;- $(`#edLines li[data-k="${M.now}"]`)?.classList.remove('now');- M.now = k;- $(`#edLines li[data-k="${k}"]`)?.classList.add('now');- scrollToNow(false);- }, true);- $('#edMedia').addEventListener('loadedmetadata', () => paintTl(), true);- $('#edManLook').addEventListener('change', (e) => { M.cur.captions.look = e.target.value; paintDirty(); });- $('#edManHi').addEventListener('change', (e) => { M.cur.captions.highlights = e.target.checked; paintDirty(); });- const num = (id, f) => $(id).addEventListener('input', (e) => { const x = Number(e.target.value); if (Number.isFinite(x) && M.cur) f(x); paintAudioOut(); paintDirty(); });- num('#edManGain', (x) => { M.cur.music.gainDb = x; });- num('#edManFade', (x) => { M.cur.music.fadeOut = x; });- num('#edManStart', (x) => { M.cur.music.start = Math.min(600, Math.max(0, x)); });- num('#edManVoice', (x) => { M.cur.voice.gainDb = x; });- $('#edManDuck').addEventListener('change', (e) => { M.cur.music.duck = e.target.checked; paintDirty(); });- $('#edManSfx').addEventListener('change', (e) => { M.cur.sfx.on = e.target.checked; paintDirty(); });- let musicPrev = null;- $('#edManMusic').addEventListener('focus', (e) => { musicPrev = e.target.value; });- $('#edManMusic').addEventListener('change', (e) => {- if (e.target.value === 'file') { e.target.value = musicPrev || M.cur.music.source || 'keep'; $('#edManMusicFile').click(); return; }- musicPrev = e.target.value;- paintAudioOut(); paintDirty();- });- $('#edManMusicFile').addEventListener('change', async (e) => {- const f = e.target.files[0]; e.target.value = '';- if (!f || !M.id) return;- const msg = $('#edManMusicMsg'); msg.textContent = t('man.uploading', { name: f.name, size: fmtMB(f.size) });- const fd = new FormData(); fd.append('music', f, f.name);- try {- const r = await fetch(`/api/edits/${encodeURIComponent(M.id)}/music`, { method: 'POST', body: fd });- const j = await r.json().catch(() => ({}));- if (!r.ok) throw new Error(j.error || 'HTTP ' + r.status);- for (const x of [M.cur, M.orig]) x.music.uploads.push({ file: j.file, name: j.name });- M.cur.music.source = `upload:${j.file}`;- msg.textContent = t('man.uploadOk', { name: j.name });- paint();- } catch (err) { msg.textContent = t('man.uploadErr', { e: I.srv(err.message) }); }- });- const toggleGone = (list, find) => { const x = list.find(find); if (x) x.gone = !x.gone; paint(); };- $('#edManZooms').addEventListener('click', (e) => { const b = e.target.closest('.ed-mx'); if (b) toggleGone(M.cur.zooms, (x) => x.n === Number(b.closest('li').dataset.n)); });- $('#edManGfx').addEventListener('click', (e) => { const b = e.target.closest('.ed-mx'); if (b) toggleGone(M.cur.graphics, (x) => String(x.id) === b.closest('li').dataset.id); });- $('#edManReset').addEventListener('click', () => { if (M.orig) { M.cur = clone(M.orig); M.sel = -1; $('#edManErr').textContent = ''; $('#edManMusicMsg').textContent = ''; paint(); } });- $('#edManApply').addEventListener('click', async () => {- const p = patch(); if (!M.id || !Object.keys(p).length) return;- $('#edManApply').disabled = true; $('#edManErr').textContent = '';- try {- const r = await fetch(`/api/edits/${encodeURIComponent(M.id)}/manual`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(p) });- const j = await r.json().catch(() => ({}));- if (!r.ok) { $('#edManErr').textContent = I.srv(j.error || t('err.status', { s: r.status })); paintDirty(); return; }- render(j); poll();- } catch { $('#edManErr').textContent = t('man.sendFail'); paintDirty(); }- });- return { onView, repaint: () => { if (M.cur) paint(); } };- })();-- // Đổi VI/EN: vẽ lại phần JS sinh (chữ tĩnh do i18n.js đổi). Lỗi/ghi chú server giữ nguyên.- window.addEventListener('lumreels:lang', () => {- if (state.noServer) $('#edSetupText').textContent = t('ed.noServer');- else if (state.opts && !state.opts.ready) $('#edSetupText').textContent = t('ed.setupText');- if (lastInstall) paintInstall(lastInstall);- if (state.opts) { renderMusic(); const had = document.activeElement?.closest?.('#edStyles'); renderStyles(); if (had) $('#edStyles .sty[aria-checked="true"]')?.focus(); }- renderDrop();- if (!state.uploading) $('#edGo span').textContent = t('ed.go');- if (state.list) renderList();- document.querySelectorAll('.ed-item').forEach((b) => b.classList.toggle('sel', b.dataset.id === state.current));- if (state.view) render(state.view);- Man.repaint();- });- renderDrop();-- // mở lại tab đã chọn lần trước- let saved = 'tpl';- try { saved = localStorage.getItem('lumreels.tab') || 'tpl'; } catch { /* bỏ qua */ }- if (location.hash === '#edit') saved = 'edit';- show(saved);-})();diff --git a/server/public/i18n.js b/server/public/i18n.jsindex 12454b7..f884666 100644--- a/server/public/i18n.js+++ b/server/public/i18n.js@@ -1,1348 +1,1572 @@-// Ngôn ngữ giao diện VI / EN. Chỉ dịch chữ giao diện; tên mẫu, nội dung người dùng, lỗi server giữ nguyên.-// HTML: data-i18n (textContent), data-i18n-placeholder, data-i18n-aria (aria-label).-// JS: window.I18N.t(key, vars) · I18N.lang · I18N.set('vi'|'en') · I18N.srv(chuỗi server) · sự kiện window 'lumreels:lang'.-// Giá trị trong bảng là chuỗi (thay {tên}) hoặc hàm (vars) => chuỗi (dùng cho số nhiều).-(() => {- const S = (n) => (n === 1 ? '' : 's');- const vi = {- 'meta.title': 'LumReels — dựng video dọc từ mẫu',- 'top.tag': 'Chọn mẫu, dán nội dung, AI dựng cảnh, ra MP4 dọc 1080×1920.',- 'lang.group': 'Ngôn ngữ giao diện',- 'lang.vi': 'Tiếng Việt (VI)',- 'lang.en': 'Tiếng Anh (EN)',-- 'update.hide': 'Ẩn thông báo',- 'update.text': (v) => `Có ${v.n} cập nhật mới cho LumReels${v.first ? ` (${v.first}${v.n > 1 ? ', …' : ''})` : ''}. Tắt app rồi chạy lại `,- 'update.after': ' để cập nhật.',-- 'tabs.aria': 'Chế độ',- 'tabs.tpl': 'Dựng từ mẫu',- 'tabs.edit': 'Edit video của bạn',- 'tabs.new': 'MỚI',-- 'pick.h': 'Chọn mẫu',- 'pick.searchLabel': 'Tìm mẫu theo tên',- 'pick.searchPh': 'Tìm theo tên, thể loại…',- 'pick.chipsAria': 'Lọc theo nhóm',- 'cat.all': 'Tất cả',- 'cat.faceless': 'Faceless',- 'cat.ads': 'Quảng cáo',- 'cat.multi-style': 'Đa phong cách',- 'cat.viet-nam': 'Việt Nam hoá',- 'pick.readyOnly': 'Chỉ mẫu dùng được',- 'pick.multi': 'Chọn nhiều mẫu',- 'pick.multiHint': 'Bật lên thì bấm mẫu để chọn hoặc bỏ, tối đa 12 mẫu, mỗi mẫu ra 1 video cùng nội dung.',- 'pick.count': '{ready}/{total} mẫu dùng được',- 'pick.max': 'Tối đa {max} mẫu mỗi lần dựng. Bỏ bớt 1 mẫu rồi chọn tiếp.',- 'grid.loading': 'Đang tải mẫu…',- 'grid.loadErr': 'Không tải được danh sách mẫu. Kiểm tra server rồi tải lại trang.',- 'grid.empty': 'Không có mẫu khớp. Thử bỏ lọc hoặc đổi từ khoá.',- 'tpl.aria': (v) => `Mẫu ${v.id}: ${v.name}${v.ready ? '' : ' (chưa có guidance, chưa dùng được)'}${v.order ? `, đã chọn thứ ${v.order}` : ''}`,- 'tpl.noThumb': 'chưa có ảnh',- 'tpl.ready': 'Sẵn sàng',- 'tpl.noGuide': 'Chưa có guidance',- 'tpl.playDemo': 'Xem video demo mẫu {id}',- 'tpl.playRef': 'Xem video tham chiếu mẫu {id}',- // ---- gói mẫu (.lumpack) ----- 'src.builtin': 'Gốc',- 'src.local': 'Của tôi',- 'src.pack': 'Cộng đồng',- 'grid.emptySrc.local': 'Chưa có mẫu "Của tôi". Mẫu tự tạo hoặc nhập từ gói của bạn sẽ hiện ở đây.',- 'grid.emptySrc.pack': 'Chưa cài gói cộng đồng nào.',- 'pack.importBtn': 'Nhập gói',- 'pack.mineBtn': 'Gói của tôi',- 'pack.lockedNote': 'Mẫu ngoài chạy ở chế độ khoá: AI chỉ đọc/ghi trong thư mục của video này.',- 'kind.template': 'Mẫu dựng',- 'kind.edit-style': 'Cách dựng Edit',- 'prov.original': 'Tự sáng tác',- 'prov.own-video': 'Học từ video của chính tác giả',- 'prov.style-study': 'Học phong cách từ video khác',- 'pk.title': 'Nhập gói mẫu',- 'pk.close': 'Đóng',- 'pk.dropBig': 'Chọn file .lumpack',- 'pk.dropSmall': 'hoặc kéo thả vào đây · tối đa 12 MB · xem trước rồi mới cài',- 'pk.reading': 'Đang đọc và kiểm gói…',- 'pk.restricted': 'Mẫu cộng đồng chạy ở chế độ khoá: AI chỉ đọc/ghi trong thư mục của video này.',- 'pk.noName': '(không tên)',- 'pk.author': 'Tác giả',- 'pk.contact': 'Liên hệ',- 'pk.license': 'Giấy phép',- 'pk.provenance': 'Nguồn gốc',- 'pk.id': 'Mã gói',- 'pk.engine': 'Cần LumReels',- 'pk.items': 'Số mục',- 'pk.sha': 'Mã kiểm (sha256)',- 'pk.warnHead': (v) => `${v.n} mục có chữ cần đọc kỹ (tô vàng bên dưới). Chữ này không bị chặn, nhưng nên đọc trước khi cài.`,- 'pk.warnItem': 'cần đọc kỹ',- 'pk.showText': 'Xem nguyên văn',- 'pk.err.not-pack': 'File này không phải gói LumReels (.lumpack).',- 'pk.err.tooBig': 'File lớn hơn 12 MB.',- 'pk.err.engine': 'Gói này cần bản LumReels mới hơn. Cập nhật app rồi nhập lại.',- 'pk.err.rejected': 'Gói bị từ chối: nội dung không an toàn hoặc sai định dạng.',- 'pk.err.first': 'Lý do đầu tiên: {e}',- 'pk.err.more': 'Xem tất cả lỗi ({n})',- 'pk.err.expired': 'Bản xem trước đã hết hạn (10 phút). Chọn lại file.',- 'pk.err.net': 'Không gửi được tới app. Kiểm tra app còn chạy rồi thử lại.',- 'pk.st.installed': 'Gói này (bản {v}) đã cài rồi.',- 'pk.st.conflict': 'Đã cài {id} bản {v}, nhưng nội dung khác bản này: không cài đè được.',- 'pk.st.older': 'Máy đang có bản mới hơn ({v}).',- 'pk.st.upgrade': 'Máy đang có bản {v}.',- 'pk.replace': 'Thay bằng bản {v}',- 'pk.cancel': 'Huỷ',- 'pk.other': 'Chọn file khác',- 'pk.install': 'Cài',- 'pk.installing': 'Đang cài…',- 'pk.done': (v) => `Đã cài "${v.name}": ${v.n} mục. Mẫu hiện trong lưới với nhãn Cộng đồng.`,- 'pk.showGrid': 'Xem trong lưới',- 'mp.title': 'Gói của tôi',- 'mp.loading': 'Đang tải…',- 'mp.loadErr': 'Không tải được danh sách gói.',- 'mp.retry': 'Thử lại',- 'mp.empty': 'Chưa cài gói nào. Bấm Nhập gói để thêm mẫu từ file .lumpack.',- 'mp.items': '{n} mục',- 'mp.view': 'Xem',- 'mp.hide': 'Ẩn',- 'mp.verified': 'Đã duyệt',- 'mp.remove': 'Gỡ',- 'mp.removeQ': 'Gỡ gói "{name}"? Video đã dựng bằng gói này vẫn giữ nguyên.',- 'mp.removeYes': 'Gỡ gói',- 'mp.removed': 'Đã gỡ "{name}".',- 'mp.deleted': 'Đã xoá "{name}".',- 'mp.delItem': 'Xoá',- 'mp.delItemQ': 'Xoá "{name}" khỏi mẫu của tôi? Không lấy lại được.',- 'mp.export': 'Xuất gói',- 'ex.title': 'Xuất mẫu "Của tôi" ra file .lumpack',- 'ex.none': 'Chưa có mẫu "Của tôi" để xuất. Mẫu tự tạo (nút Tạo mẫu, sắp có) sẽ hiện ở đây.',- 'ex.pick': 'Chọn mục',- 'ex.name': 'Tên gói',- 'ex.id': 'Mã gói',- 'ex.idHint': 'Dạng tac-gia.ten-goi: chữ thường không dấu, số, gạch nối. Tự điền theo tác giả + tên.',- 'ex.author': 'Tác giả',- 'ex.contact': 'Liên hệ (không bắt buộc)',- 'ex.license': 'Giấy phép',- 'ex.version': 'Phiên bản',- 'ex.go': 'Tải file .lumpack',- 'ex.busy': 'Đang xuất…',- 'ex.ok': 'Đã xuất {file} ({kb}).',- 'ex.err.items': 'Chọn ít nhất 1 mục để xuất.',- 'ex.err.name': 'Điền tên gói.',- 'ex.err.author': 'Điền tên tác giả.',- 'ex.err.id': 'Mã gói phải dạng tac-gia.ten-goi, mỗi nửa 2–24 ký tự.',- 'ex.err.ver': 'Phiên bản phải dạng 1.0.0.',- 'ex.err.reserved': 'Tên tác giả này dành riêng cho LumReels. Đổi phần trước dấu chấm của mã gói.',-- 'picked.none': 'Chưa chọn mẫu. Bấm 1 mẫu sáng màu bên trái.',- 'picked.noneMulti': 'Đang chọn nhiều: bấm các mẫu sáng màu bên trái (tối đa {max}), mỗi mẫu ra 1 video.',- 'picked.count': 'Đã chọn {n} mẫu',- 'picked.clear': 'Bỏ chọn hết',- 'picked.strip': 'Các mẫu đã chọn',- 'picked.remove': 'Bỏ mẫu {id}: {name}',-- 'viewer.aria': 'Video minh hoạ của mẫu',- 'viewer.close': 'Đóng',- 'viewer.demo': 'Video demo dựng bằng LumReels. ',- 'viewer.ref': 'Video tham chiếu trên máy mày (không có trong repo). ',-- 'compose.h': 'Nội dung',- 'compose.label': 'Nội dung video',- 'compose.ph': 'Ví dụ: Mỗi tháng bỏ 3 triệu vào quỹ chỉ số, lãi giả định 10%/năm, sau 20 năm có bao nhiêu? Kênh: Lumfin. CTA: Theo dõi để biết thêm mẹo tiền',- 'compose.charsTail': '/4000 ký tự · ghi luôn tên kênh và CTA nếu có',- 'rw.btn': 'Viết lại kịch bản',- 'rw.btnBusy': 'Đang viết lại',- 'rw.hint': 'Viết lại kịch bản: AI xếp nội dung vào đúng ô của mẫu đang chọn và thời lượng bên dưới, giữ nguyên số liệu, tên kênh, CTA.',- 'rw.hintMany': 'Viết lại kịch bản tắt vì đang chọn {n} mẫu: mỗi mẫu có ô nội dung khác nhau. Muốn AI viết lại thì chọn 1 mẫu; còn không, cả {n} video dùng chung nội dung đang gõ.',- 'rw.busy': 'Đang viết lại…',- 'rw.needOne': 'Chọn 1 mẫu trước',- 'rw.onlyOne': 'Chỉ viết lại được khi chọn 1 mẫu',- 'rw.needText': 'Gõ nội dung trước (tối thiểu 10 ký tự)',- 'rw.loading': 'Đang viết lại cho mẫu {id} · {d}… (thường 20–60 giây)',- 'rw.title': 'Bản viết lại · mẫu {id} · {d}',- 'rw.fallback': 'Đã chuyển sang Claude Code vì {why}.',- 'rw.use': 'Dùng bản này',- 'rw.drop': 'Bỏ',- 'rw.timeout': 'Quá 100 giây chưa xong, đã dừng chờ. Bấm lại thử.',- 'rw.replaced': 'Đã thay nội dung bằng bản viết lại.',- 'rw.undo': 'Hoàn tác',- 'rw.close': 'Đóng',- 'err.status': 'Lỗi {s}',-- 'dur.label': 'Thời lượng',- 'dur.range': '(3 giây – 10 phút)',- 'dur.presets': 'Chọn nhanh thời lượng',- 'dur.hint': 'Gõ số giây (90) hoặc phút:giây (1:30).',- 'dur.errEmpty': 'Nhập thời lượng, vd 8 hoặc 1:30',- 'dur.errFmt': 'Gõ số giây (90) hoặc phút:giây (1:30)',- 'dur.errMin': 'Ngắn nhất 3 giây',- 'dur.errMax': 'Dài nhất 10 phút (10:00)',- 'dur.eqLong': '= {s} giây ({f}).',- 'dur.eq': '= {s} giây. Gõ số giây (90) hoặc phút:giây (1:30).',- 'dur.warn': 'Video dài {f}: render ước tính {range} (đo thực tế: video 8 giây mất 20–60 giây render), chưa tính lúc AI viết cảnh. AI phải viết khoảng {scenes} cảnh nối nhau nên tốn token và chi phí hơn hẳn video 8 giây.',- 'unit.sec': 'giây',- 'unit.min': 'phút',- 'unit.hour': 'giờ',- 'num.dec': ',',-- 'audio.aria': 'Âm thanh',- 'mode.label': 'Ai dựng cảnh',- 'mode.auto': 'Tự động',- 'mode.manual': 'Agent ngoài',- 'modeLabel.auto': 'tự động',- 'modeLabel.manual': 'agent ngoài',- 'mode.hintAuto': 'Tự động: đang dùng {m}.',- 'mode.hintApi': 'Gọi Claude API bằng khoá trong .env (tốn tiền theo token, ghi chi phí vào job).',- 'mode.hintClaude': 'Chạy Claude Code trên máy này (dùng gói Claude của mày).',- 'mode.hintManual': 'Chỉ tạo đề bài; agent bên ngoài (MCP/CLI) viết cảnh rồi gọi render.',- 'mode.hintExport': ' Xong sẽ chép MP4 ra thư mục xuất.',- 'model.label': 'Model viết cảnh',- 'model.auto': 'Tự chọn theo mẫu',- 'model.autoRec': 'Tự chọn theo mẫu ({m})',- 'model.autoMany': 'Tự chọn theo từng mẫu',- 'model.opus': 'Opus (đẹp nhất, tốn nhất)',- 'model.sonnet': 'Sonnet (cân bằng)',- 'model.haiku': 'Haiku (rẻ nhất)',- 'model.rec': (v) => `Mẫu này ${v.heavy ? 'dựng 3D/shader' : 'là 2D'} → đề xuất ${v.m}.`,- 'model.pickFirst': 'Chọn mẫu để xem đề xuất.',- 'model.haikuWarn': ' Haiku hay làm phẳng cảnh 3D, nên dùng Opus.',- 'model.override': ' (đang chọn {m} thay vì đề xuất)',- 'model.agentNote': ' Agent ngoài thì model do agent đó quyết.',- 'model.manyLight': '{n} mẫu 2D → {m}',- 'model.manyHeavy': '{n} mẫu 3D/shader → {m}',- 'model.manyAuto': 'Mỗi video tự chọn theo mẫu: {parts}.',- 'model.manyFixed': 'Cả {n} video dùng {m} (đề xuất: {parts}).',- 'model.haikuWarnMany': ' Haiku hay làm phẳng cảnh 3D, nên dùng Opus cho mẫu 3D.',- 'runAt.label': 'Hẹn giờ dựng',- 'runAt.opt': '(bỏ trống = dựng ngay)',- 'runAt.clear': 'Bỏ hẹn',- 'runAt.clearAria': 'Bỏ hẹn giờ',- 'go.build': (v) => (v.n > 1 ? `Dựng ${v.n} video` : 'Dựng video'),- 'go.schedule': (v) => (v.n > 1 ? `Hẹn dựng ${v.n} video` : 'Hẹn dựng video'),- 'go.sending': 'Đang gửi',- 'go.needTpl': 'Chọn mẫu trước',- 'go.needText': 'Nội dung tối thiểu 10 ký tự',- 'go.badDur': 'Thời lượng chưa đúng',- 'form.jobErr': 'Tạo job lỗi',- 'form.retry': '. Sửa rồi bấm lại.',-- 'jobs.h': 'Video đã dựng',- 'jobs.empty': 'Chưa có video nào. Chọn mẫu, dán nội dung rồi bấm <b>Dựng video</b>.',- 'jobs.less': 'Thu gọn',- 'jobs.more': 'Xem thêm ({n} video cũ hơn)',- 'st.scheduled': 'Đã hẹn',- 'st.queued': 'Đang chờ',- 'st.generating': 'AI đang viết cảnh',- 'st.waiting_agent': 'Chờ agent viết cảnh',- 'st.previewing': 'Đang dựng preview',- 'st.rendering': 'Đang render',- 'st.done': 'Xong',- 'st.error': 'Lỗi',- 'job.previewAlt': 'Preview 16 khung',- 'job.building': 'Đang dựng…',- 'job.waitScene': 'Chờ cảnh',- 'job.noImage': 'Chưa có hình',- 'job.tpl': 'Mẫu {id} · {name}',- 'job.at': 'Hẹn dựng lúc {t}',- 'job.api': 'API: {i}k vào · {o}k ra · ≈ ${c}',- 'job.exported': 'Đã chép ra: {p}',- 'job.errUnknown': 'Lỗi không rõ',- 'job.errTail': '. Xem log, sửa cảnh rồi bấm Render lại.',- 'job.agent': 'Agent đọc: {prompt}\nViết: {scene}\nRồi chạy: node cli.mjs render {id}',- 'job.mp4': 'Tải MP4',- 'job.preview': 'Preview 16 khung',- 'job.rerender': 'Render lại',- 'job.render': 'Render',- 'job.log': 'Log ({n} dòng)',-- 'ap.title': 'Âm thanh',- 'ap.loadingOpts': 'Đang tải lựa chọn…',- 'ap.stop': 'Dừng nghe thử',- 'ap.making': 'Đang tạo bản nghe thử',- 'ap.voiceLoading': 'Đang tạo giọng mẫu… (lần đầu nạp mô hình có thể mất vài phút)',- 'ap.prevFail': 'không tạo được bản nghe thử',- 'ap.prevErr': 'Nghe thử lỗi: ',- 'ap.keep': 'Giữ như hiện tại',- 'ap.music': 'Nhạc nền',- 'ap.musicPrev': 'Nghe thử nhạc nền',- 'ap.voice': 'Giọng đọc',- 'ap.voicePrev': 'Nghe thử giọng đọc',- 'ap.sfx': 'Tiếng động gắn theo chuyển động',- 'ap.pickMusic': 'Chọn 1 kiểu nhạc cụ thể để nghe thử.',- 'ap.pickVoice': 'Chọn 1 giọng cụ thể để nghe thử.',- 'ap.vAuto': 'giọng theo mẫu',- 'ap.vNone': 'không lời',- 'ap.versions': 'Các bản ({n})',- 'ap.ver': 'Bản {n}',- 'ap.latest': ' · mới nhất',- 'ap.noSfx': ' · không sfx',- 'ap.view': 'Xem',- 'ap.dl': 'Tải',- 'ap.mix': 'Trộn tiếng mới',- 'ap.mixNote': 'Không dựng lại hình. Bản cũ được giữ lại; chọn giọng mà video chưa có lời thì AI viết lời ngắn.',- 'ap.lastErr': 'Lần trộn trước lỗi: ',- 'ap.mixing': 'Đang trộn tiếng…',- 'ap.mixingNote': 'Đang trộn (giọng VieNeu có thể mất vài phút)…',- 'ap.err': 'Lỗi: ',- 'ap.unknown': 'không rõ',- 'ap.done': 'Xong — đang phát bản mới nhất.',- 'ap.summary': 'Âm thanh · đổi nhạc, giọng đọc',- 'ap.loading': 'Đang tải…',- 'ap.mixFail': 'Không trộn được: ',- 'ap.errShort': 'lỗi',- 'vc.title': 'Giọng của tôi',- 'vc.optTag': 'giọng nhân bản',- 'vc.add': '+ Thêm giọng',- 'vc.loading': 'Đang tải giọng của bạn…',- 'vc.loadErr': 'Không tải được danh sách giọng.',- 'vc.retry': 'Thử lại',- 'vc.empty': 'Chưa có giọng nào. Tải lên hoặc thu 10 giây – 3 phút giọng nói, app học giọng rồi đọc lời video bằng chính giọng đó.',- 'vc.needVieneu': 'Cần VieNeu-TTS trên máy để nhân bản giọng: pip install vieneu',- 'vc.ready': 'Sẵn sàng',- 'vc.error': 'Lỗi',- 'vc.step.queued': 'Đang chờ…',- 'vc.step.transcribe': 'Đang chép lời đoạn mẫu…',- 'vc.step.encode': 'Đang học giọng + đọc thử…',- 'vc.play': 'Nghe thử giọng {name}',- 'vc.stop': 'Dừng nghe',- 'vc.rename': 'Đổi tên giọng {name}',- 'vc.delete': 'Xoá giọng {name}',- 'vc.newName': 'Tên mới',- 'vc.save': 'Lưu',- 'vc.cancel': 'Huỷ',- 'vc.refSum': 'Đoạn mẫu app đã chọn',- 'vc.refText': 'Lời của đoạn mẫu',- 'vc.byWhisper': '(máy tự chép, sửa nếu sai)',- 'vc.refTextPh': 'Gõ đúng những gì bạn nói trong đoạn mẫu',- 'vc.refTextHint': 'Không bắt buộc với VieNeu v3 Turbo; giúp nhận ra đoạn mẫu nói gì.',- 'vc.saveText': 'Lưu lời',- 'vc.noWhisper': 'Máy chưa có whisper nên chưa chép được lời đoạn mẫu. Mở "Đoạn mẫu" để nghe và gõ lời (không bắt buộc).',- 'vc.srcAria': 'Lấy giọng từ',- 'vc.srcFile': 'Chọn file',- 'vc.srcRec': 'Thu âm',- 'vc.fileLabel': 'File âm thanh giọng nói',- 'vc.fileHint': 'wav, mp3, m4a, ogg hoặc webm · 10 giây – 3 phút · tối đa {max} MB · chỉ 1 người nói, ít tạp âm.',- 'vc.readTip': 'Gợi ý: đọc to đoạn này, tự nhiên như đang nói chuyện',- 'vc.readText': 'Hôm nay mình muốn kể cho bạn nghe một chuyện nhỏ. Sáng nào mình cũng dậy sớm, pha một ly cà phê, mở cửa sổ và nghe phố xá bắt đầu nhộn nhịp. Có hôm trời mưa, có hôm nắng gắt, nhưng mình vẫn giữ thói quen đó. Một, hai, ba, bốn, năm: thói quen nhỏ, kết quả lớn.',- 'vc.recStart': 'Bắt đầu thu',- 'vc.recAgain': 'Thu lại',- 'vc.recStop': 'Dừng',- 'vc.recHint': 'Thu ở chỗ yên tĩnh, cách micro một gang tay, ít nhất 20 giây. Tự dừng sau 3 phút.',- 'vc.recFile': 'thu-am',- 'vc.nameLabel': 'Tên giọng',- 'vc.namePh': 'Ví dụ: Giọng Nam',- 'vc.consent': 'Đây là giọng của tôi, hoặc tôi được người đó cho phép dùng',- 'vc.langNote': 'Giọng nhân bản đọc tiếng Việt. Chọn giọng này cho nội dung tiếng Anh thì lời đọc được viết bằng tiếng Việt.',- 'vc.create': 'Tạo giọng',- 'vc.sending': 'Đang gửi… {pct}%',- 'vc.processing': 'Đã nhận giọng {name}. Đang học giọng, khoảng 1 phút.',- 'vc.readyNote': 'Giọng {name} đã sẵn sàng và được chọn làm giọng đọc. Bấm nút phát để nghe thử.',- 'vc.errNoFile': 'Chọn 1 file âm thanh.',- 'vc.errNoRec': 'Thu âm trước đã.',- 'vc.errExt': 'Định dạng chưa hỗ trợ. Dùng wav, mp3, m4a, ogg hoặc webm.',- 'vc.errBig': 'File quá lớn (tối đa {max} MB).',- 'vc.errShort': 'Ngắn quá ({s} giây). Cần ít nhất 10 giây.',- 'vc.errLong': 'Dài quá 3 phút. Cắt bớt rồi thử lại.',- 'vc.errName': 'Đặt tên cho giọng.',- 'vc.errNameLong': 'Tên tối đa {max} ký tự.',- 'vc.errConsent': 'Tick xác nhận để tiếp tục.',- 'vc.errNoMic': 'Trình duyệt này không thu âm được. Chọn file thay thế.',- 'vc.errMicDenied': 'Chưa được dùng micro. Cho phép micro trong trình duyệt rồi thử lại.',- 'vc.errUpload': 'Gửi không được. Kiểm tra app còn chạy rồi thử lại.',- 'vc.errDel': 'Không xoá được giọng.',- 'vc.errSave': 'Không lưu được.',- 'vc.confirmDel': 'Xoá giọng "{name}"? File giọng trên máy bị xoá hẳn, không khôi phục được.',- 'vc.deleted': 'Đã xoá giọng {name}.',- 'vc.renamed': 'Đã đổi tên thành {name}.',- 'vc.textSaved': 'Đã lưu lời đoạn mẫu.',-- 'ed.aria': 'Edit video của bạn',- 'ed.setupH': 'Chưa cài phần Edit video',- 'ed.noServer': 'Không gọi được server.',- 'ed.h': 'Video của bạn',- 'ed.dropAria': 'Chọn hoặc kéo thả video',- 'ed.dropBig': 'Kéo thả video vào đây',- 'ed.dropSmall': 'hoặc bấm để chọn · mp4, mov, mkv… tối đa 2 GB · nói trước máy, tiếng Việt',- 'ed.fileLabel': 'File video',- 'ed.style': 'Kiểu edit',- 'ed.music': 'Nhạc nền',- 'ed.musicOpt': '(tự hạ khi bạn nói)',- 'ed.noMusic': 'Không nhạc',- 'ed.musicSynth': 'Nhạc tổng hợp: {id} — {desc}',- 'ed.musicFile': 'Tải file nhạc của tôi…',- 'ed.musicFileLabel': 'File nhạc',- 'ed.names': 'Tên riêng, thuật ngữ',- 'ed.namesOpt': '(để AI viết phụ đề đúng)',- 'ed.namesPh': 'Ví dụ: Lumfin, Hà Nội, ETF',- 'ed.notes': 'Dặn thêm',- 'ed.notesOpt': '(không bắt buộc)',- 'ed.notesPh': 'Ví dụ: bỏ câu chào đầu, giữ đoạn cuối kêu gọi theo dõi',- 'ed.draft': 'Bản nháp nhanh (phụ đề đơn giản, nhanh hơn ~1 phút)',- 'ed.go': 'Dựng',- 'ed.empty': 'Chọn video bên trái rồi bấm Dựng.',- 'ed.steps': 'Các bước',- 'ed.fixesH': 'Chữ AI đã sửa trong phụ đề, xem lại giúp',- 'ed.reviseH': 'Sửa bằng lời',- 'ed.reviseLabel': 'Lời sửa',- 'ed.revisePh': 'Ví dụ: "bỏ 3 giây đầu", "zoom ít lại"',- 'ed.reviseBtn': 'Render lại',- 'ed.p1': 'bỏ 3 giây đầu',- 'ed.p2': 'zoom ít lại',- 'ed.p3': 'nhạc nhỏ lại',- 'ed.p4': 'phụ đề 2 chữ một lần',- 'ed.histH': 'Các lần sửa',- 'ed.log': 'Nhật ký',- 'ed.delete': 'Xoá bản dựng này',- 'ed.listH': 'Các bản đã dựng',- 'ed.st.queued': 'Đang chờ',- 'ed.st.running': 'Đang dựng',- 'ed.st.done': 'Xong',- 'ed.st.error': 'Lỗi',- 'ed.waitTurn': 'Đang chờ lượt',- 'ed.revising': 'Đang sửa',- 'ed.notVideo': 'File này không phải video (mp4, mov, mkv, webm…).',- 'ed.tooBig': 'Video {size} quá lớn (tối đa 2 GB).',- 'ed.changeFile': '{size} · bấm để đổi file',- 'ed.needMusic': 'Chọn file nhạc, hoặc đổi sang "Không nhạc".',- 'ed.uploading': 'Đang tải lên {p}%',- 'ed.uploadCut': 'Tải lên bị ngắt. Kiểm tra server rồi thử lại.',- 'ed.listEmpty': 'Chưa có bản nào.',- 'ed.err': 'Lỗi',- 'ed.reviseErr': 'Sửa chưa được: {e}',- 'ed.previewAlt': 'Lưới khung xem trước',- 'ed.mediaEmpty': 'Video sẽ hiện ở đây khi dựng xong',- 'ed.mp4': 'Tải MP4',- 'ed.gridOut': 'Lưới khung bản ra',- 'ed.hidden': '(ẩn khỏi phụ đề)',- 'ed.checksEdl': '{out} s · bỏ {rm} s · {z} zoom',- 'ed.overcut': 'lẹm chữ: {v}',- 'ed.noOvercut': 'không lẹm chữ',- 'ed.sendFail': 'Không gửi được lời sửa.',- 'ed.confirmDel': 'Xoá hẳn bản dựng này (video ra, EDL, file đã tải lên)? Không lấy lại được.',- 'man.h': 'Chỉnh tay',- 'man.tabCap': 'Phụ đề',- 'man.tabAud': 'Nhạc & tiếng',- 'man.tabFx': 'Zoom & đồ hoạ',- 'man.look': 'Kiểu chữ',- 'man.hi': 'Chữ nhấn (chữ trong *sao* đổi màu)',- 'man.capHint': 'Bấm mốc giờ để video nhảy tới dòng đó. Bọc *chữ* để nhấn.',- 'man.draftNote': 'Bản nháp vẽ phụ đề thẳng vào nền nên chưa sửa tay được. Bỏ "nháp" rồi dựng lại.',- 'man.music': 'Nhạc',- 'man.musicKeep': 'Giữ nhạc đang dùng ({name})',- 'man.synth': 'Nhạc tổng hợp: {id}',- 'man.uploaded': 'Đã tải: {name}',- 'man.uploading': 'Đang tải {name} ({size})…',- 'man.uploadOk': 'Đã tải lên {name}. Bấm Áp dụng để trộn lại tiếng.',- 'man.uploadErr': 'Tải nhạc chưa được: {e}',- 'man.musicGain': 'Âm lượng nhạc',- 'man.duck': 'Ducking: nhạc nhỏ lại khi có tiếng nói',- 'man.fade': 'Fade out cuối',- 'man.start': 'Nhạc bắt đầu từ giây',- 'man.voice': 'Âm lượng giọng (so với nhạc)',- 'man.loudHint': 'Cả bản luôn chuẩn về −14 LUFS: tăng giọng tức là nhạc và tiếng động nhỏ đi tương đối.',- 'man.sfx': (v) => `Tiếng động${v.n ? ` · ${v.n}` : ' · không có'}`,- 'man.zooms': 'Zoom',- 'man.gfx': 'Đồ hoạ',- 'man.zoomKind': (v) => `${v.kind === 'punch' ? 'Zoom giật' : 'Zoom đẩy'} ×${v.scale}`,- 'man.noZoom': 'Bản này không có zoom.',- 'man.noGfx': 'Bản này không có đồ hoạ.',- 'man.noLines': 'Bản này không có phụ đề.',- 'man.remove': 'Xoá',- 'man.undo': 'Giữ lại',- 'man.removeN': 'Xoá {what}',- 'man.undoN': 'Giữ lại {what}',- 'man.jump': 'Nhảy tới giây {s}',- 'man.lineText': 'Chữ dòng {n}',- 'man.lineStart': 'Giây bắt đầu dòng {n}',- 'man.lineEnd': 'Giây kết thúc dòng {n}',- 'man.split': 'Tách',- 'man.merge': 'Gộp ↓',- 'man.splitN': 'Tách dòng {n} làm đôi',- 'man.mergeN': 'Gộp dòng {n} với dòng sau',- 'man.delN': 'Xoá dòng {n}',- 'man.cantSplit': 'Dòng chỉ có 1 chữ, không tách được.',- 'man.errShort': 'Dòng phải dài ít nhất 0,1 giây (kết thúc sau bắt đầu).',- 'man.errAfter': 'Bắt đầu sau cuối video ({d} s).',- 'man.errOverlap': 'Đè lên dòng trước: dời giờ bắt đầu ra sau.',- 'man.errEmpty': 'Dòng trống: gõ chữ hoặc xoá dòng.',- 'man.fixFirst': (v) => `Sửa ${v.n} dòng báo đỏ trước khi áp dụng.`,- 'man.dirty': (v) => `${v.n} thay đổi · dựng lại: ${v.what}`,- 'man.clean': 'Chưa có thay đổi.',- 'man.wCap': 'lớp chữ',- 'man.wAud': 'tiếng',- 'man.wBase': 'nền',- 'man.reset': 'Bỏ thay đổi',- 'man.apply': 'Áp dụng',- 'man.applying': 'Đang dựng…',- 'man.running': 'Đang dựng bản chỉnh tay',- 'man.loadErr': 'Không tải được phần chỉnh tay: {e}',- 'man.sendFail': 'Không gửi được phần chỉnh tay.',- 'man.tag': 'Chỉnh tay',- 'man.took': 'dựng {s} giây',- 'man.watch': 'Xem',- 'man.original': 'Bản đầu tiên',- 'ed.styleHint': '{n} kiểu · cuộn để xem hết',- 'ed.styleAria': (v) => `${v.name}: ${v.summary}`,- 'ed.setupText': 'Phần Edit video cần thêm Python, model chép lời và model nhận mặt. Bấm Cài ngay, LumReels tự cài hết (chỉ làm một lần).',- 'ed.install': 'Cài ngay',- 'ed.installing': 'Đang cài…',- 'ed.installStep': '{step}… ({t})',- 'ed.installStepDefault': 'Đang cài',- 'ed.installDone': 'Cài xong sau {t}. Edit video đã sẵn sàng.',- 'ed.installRetry': 'Cài lại',- 'ed.installFail': 'Cài chưa xong. Xem chi tiết bên dưới rồi bấm Cài lại.',- 'ed.installCantStart': 'Không bắt đầu cài được: {e}',- 'ed.installNote': 'Tải khoảng 6 GB, mất 5–20 phút tuỳ mạng. Cứ để trang mở.',- 'ed.installDetails': 'Xem chi tiết',- 'ed.installManual': 'Hoặc tự cài bằng lệnh',- 'ed.fail.NEED_PYTHON': 'Máy chưa có Python 3.10–3.12. Cài theo hướng dẫn dưới rồi bấm Cài lại.',- 'ed.fail.NEED_FFMPEG': 'Máy chưa có ffmpeg. Cài theo hướng dẫn dưới rồi bấm Cài lại.',- 'ed.fail.NEED_NETWORK': 'Tải bị lỗi, kiểm tra mạng rồi bấm Cài lại (phần đã tải xong không phải tải lại).',- 'ed.fail.NEED_NPM': 'Thiếu font của LumReels: chạy npm install ở thư mục LumReels rồi bấm Cài lại.',- 'ed.figuresH': 'Số máy nghe không chắc, chưa đưa lên đồ hoạ, nghe lại giúp',- 'ed.figAt': '{s} s nguồn',- 'ed.figHeard': 'nghe lại: “{h}”',- 'ed.more': 'Thêm',- 'ed.review': (v) => `Cần xem lại (${v.n})`,- 'ed.revFixes': 'Chữ AI sửa',- 'ed.revFigs': 'Số chưa chắc',- 'ed.specs': 'Thông số',- 'ed.stepOf': '{i}/{n} · {step} · {p}%',- 'ed.revisePhS': 'bỏ 3 giây đầu…',- 'man.hiShort': 'Chữ nhấn',- 'man.hiTip': 'Bọc *chữ* để đổi màu',- 'man.gainS': 'Âm lượng',- 'man.fadeS': 'Fade cuối',- 'man.startS': 'Bắt đầu (s)',- 'man.duckS': 'Tự hạ khi nói',- 'man.voiceS': 'Giọng',- 'man.dirtyS': (v) => `${v.n} thay đổi`,- 'ed.cutRepairs': (v) => `đã sửa ${v.n} vết cắt lẹm chữ`,-- // ---- Tạo mẫu từ video (learn-panel.js) ----- 'cat.mine': 'Của tôi',- 'lp.open': 'Tạo mẫu từ video',- 'lp.title': 'Tạo mẫu từ video',- 'lp.lead': 'Đưa 1 video trên máy, AI học phong cách dựng (màu, bố cục, nhịp, chuyển động), dựng thử 1 bản với nội dung khác, rồi bạn xem và lưu thành mẫu của mình.',- 'lp.back': 'Quay lại',- 'lp.close': 'Đóng',- 'lp.loadErr': 'Không tải được nháp. Thử lại sau.',- 'lp.noDrafts': 'Chưa có nháp nào.',- 'lp.new': 'Tạo từ video mới',- 'lp.drop': 'Kéo thả video vào đây',- 'lp.dropHint': 'hoặc bấm để chọn · mp4, mov, webm · 4 giây – 3 phút · tối đa 200 MB',- 'lp.change': 'Đổi video',- 'lp.refVideo': 'Video tham khảo',- 'lp.from': 'Học đoạn 8 giây nào',- 'lp.seg': '{a}–{b} s',- 'lp.fromHint': 'Chọn đoạn có phong cách rõ nhất. Video đang phát lặp đúng đoạn này.',- 'lp.name': 'Tên mẫu',- 'lp.optional': '(không bắt buộc)',- 'lp.namePh': 'Ví dụ: Thẻ bài giấy cũ',- 'lp.cat': 'Nhóm',- 'lp.catAuto': 'Để AI chọn',- 'lp.note': 'Đây là video gì',- 'lp.notePh': 'Ví dụ: video giới thiệu món ăn, chữ to, cắt nhanh',- 'lp.rulesH': 'Học phong cách, không chép',- 'lp.rule1': 'Chỉ học màu, bố cục, nhịp, kiểu chuyển động, kiểu chữ gần nhất trong font mở.',- 'lp.rule2': 'Chữ, tên kênh, logo, nhân vật nhìn thấy trong video được gỡ khỏi mẫu bằng máy.',- 'lp.rule3': 'Video tham khảo chỉ nằm trên máy này, bị xoá khi bạn Lưu hoặc Bỏ. Ảnh đại diện lấy từ bản dựng thử.',- 'lp.consent': 'Video này của tôi, hoặc tôi chỉ dùng nó để học phong cách dựng. Tôi không sao chép nhân vật, logo, nhạc hay hình ảnh của người khác.',- 'lp.needConsent': 'Tick ô xác nhận để bắt đầu',- 'lp.skipTest': 'Bỏ dựng thử (nhanh và rẻ hơn, nhưng chưa biết mẫu có ra hình đúng không)',- 'lp.est': 'Khoảng 7–13 phút, chi phí AI khoảng 1–2,5 USD theo giá API (có dựng thử 1 video 8 giây).',- 'lp.estNoTest': 'Khoảng 2–3 phút, chi phí AI khoảng 0,2–0,4 USD theo giá API. Nháp sẽ ghi "chưa dựng thử".',- 'lp.go': 'Bắt đầu',- 'lp.uploading': 'Đang tải video lên',- 'lp.uploadingPct': 'Đang tải lên {p}%',- 'lp.started': 'Đã nhận video, đang đo.',- 'lp.err.ext': 'Định dạng này chưa hỗ trợ. Dùng mp4, mov hoặc webm.',- 'lp.err.big': 'Video quá nặng (tối đa 200 MB).',- 'lp.err.short': 'Video quá ngắn, cần ít nhất {min} giây.',- 'lp.err.long': 'Video quá dài, tối đa 3 phút. Cắt bớt rồi thử lại.',- 'lp.err.upload': 'Không gửi được video. Kiểm tra server rồi thử lại.',- 'lp.err.run': 'Tạo mẫu bị lỗi.',- 'lp.st.uploaded': 'Đã nhận',- 'lp.st.measuring': 'Đang đo',- 'lp.st.writing': 'AI đang viết',- 'lp.st.testing': 'Đang dựng thử',- 'lp.st.comparing': 'Đang so',- 'lp.st.revising': 'AI đang sửa',- 'lp.st.ready': 'Sẵn sàng',- 'lp.st.readyNoTest': 'Sẵn sàng (chưa dựng thử)',- 'lp.st.error': 'Lỗi',- 'lp.st.saved': 'Đã lưu',- 'lp.st.discarded': 'Đã bỏ',- 'lp.step.measuring': 'Đo video (màu, nhịp, chuyển động)',- 'lp.step.writing': 'AI viết mẫu theo khuôn',- 'lp.step.testing': 'Dựng thử 1 video 8 giây',- 'lp.step.comparing': 'So bản dựng thử với video gốc',- 'lp.step.revising': 'AI sửa mẫu 1 vòng',- 'lp.stepNow': '{e} / ~{est}',- 'lp.stepEst': '~{est}',- 'lp.progress': 'Tiến độ tạo mẫu',- 'lp.canClose': 'Có thể đóng hộp này, việc vẫn chạy. Mở lại bằng nút Tạo mẫu từ video.',- 'lp.draftH': 'Nháp mẫu',- 'lp.totals': 'Thời gian {t} · chi phí AI {c}',- 'lp.fromFile': '{f} · đoạn {a}–{b} s',- 'lp.noRef': 'Video tham khảo đã xoá',- 'lp.testVideo': 'Bản dựng thử',- 'lp.notTested': 'Chưa dựng thử',- 'lp.sheets': 'Xem 16 khung cạnh nhau',- 'lp.refSheet': 'Gốc',- 'lp.refSheetAlt': 'Lưới 16 khung của video tham khảo',- 'lp.testSheet': 'Bản dựng thử',- 'lp.testSheetAlt': 'Lưới 16 khung của bản dựng thử',- 'lp.cmpH': (v) => `So số đo: ${v.n}/${v.total} chỉ số lệch quá 25%`,- 'lp.cmpMetric': 'Chỉ số',- 'lp.cmpRef': 'Gốc',- 'lp.cmpTest': 'Dựng thử',- 'lp.cmpDev': 'Lệch',- 'lp.off': 'lệch',- 'lp.near': 'gần',- 'lp.m.palette': 'Bảng màu chính',- 'lp.m.brightness': 'Độ sáng',- 'lp.m.saturation': 'Độ đậm màu',- 'lp.m.events': 'Phần tử mới mỗi giây',- 'lp.m.motion': 'Mức chuyển động',- 'lp.m.cuts': 'Số lần cắt cảnh',- 'lp.m.still': 'Tỉ lệ đứng im',- 'lp.diffsH': 'Điểm còn lệch (AI nhìn 2 lưới)',- 'lp.diffsFixed': 'Điểm lệch AI thấy và đã sửa vào mẫu',- 'lp.selfH': 'Tự kiểm: {ok}/{n} câu đạt',- 'lp.yes': 'có',- 'lp.no': 'không',- 'lp.guideH': 'Mẫu (guidance)',- 'lp.guideHint': 'AI dựng cảnh đọc chữ này. Sửa tay được.',- 'lp.saveText': 'Lưu chỗ sửa',- 'lp.unsaved': 'Có chỗ sửa chưa lưu',- 'lp.seenHit': 'còn chữ của video gốc: "{s}"',- 'lp.textOk': 'Đã lưu chỗ sửa, qua bộ kiểm.',- 'lp.textBad': 'Đã lưu chỗ sửa, còn lỗi cần sửa trước khi lưu mẫu.',- 'lp.saveH': 'Lưu thành mẫu "Của tôi"',- 'lp.saveName': 'Tên mẫu',- 'lp.slug': 'Mã mẫu',- 'lp.slugHint': 'Chữ thường không dấu, số, gạch nối. Dùng trong lệnh: make --template local.mine/<mã>',- 'lp.save': 'Lưu thành mẫu',- 'lp.retest': 'Dựng thử lại',- 'lp.discard': 'Bỏ nháp',- 'lp.discardAsk': 'Bỏ nháp này? Video tham khảo và bản nháp sẽ bị xoá.',- 'lp.discarded': 'Đã bỏ nháp.',- 'lp.saveNote': 'Lưu xong, video tham khảo và khung hình bị xoá khỏi máy. Mẫu chạy ở chế độ khoá: AI chỉ đọc/ghi trong thư mục của video đang dựng.',- 'lp.errNoSave': 'Nháp lỗi ở bước dựng thử: sửa mẫu rồi bấm Dựng thử lại trước khi lưu.',- 'lp.savedH': 'Đã lưu vào Của tôi',- 'lp.savedP': 'Mẫu {ref} nằm trong lưới mẫu, lọc "Của tôi". Dựng với nội dung bất kỳ như mẫu gốc.',- 'lp.useNow': 'Dùng mẫu này',- };-- const en = {- 'meta.title': 'LumReels — vertical videos from templates',- 'top.tag': 'Pick a template, paste your text, AI builds the scenes. Out comes a 1080×1920 vertical MP4.',- 'lang.group': 'Interface language',- 'lang.vi': 'Vietnamese (VI)',- 'lang.en': 'English (EN)',-- 'update.hide': 'Dismiss',- 'update.text': (v) => `${v.n} new update${S(v.n)} for LumReels${v.first ? ` (${v.first}${v.n > 1 ? ', …' : ''})` : ''}. Quit the app and run `,- 'update.after': ' to update.',-- 'tabs.aria': 'Mode',- 'tabs.tpl': 'From a template',- 'tabs.edit': 'Edit your video',- 'tabs.new': 'NEW',-- 'pick.h': 'Pick a template',- 'pick.searchLabel': 'Search templates by name',- 'pick.searchPh': 'Search by name or genre…',- 'pick.chipsAria': 'Filter by group',- 'cat.all': 'All',- 'cat.faceless': 'Faceless',- 'cat.ads': 'Ads',- 'cat.multi-style': 'Multi-style',- 'cat.viet-nam': 'Vietnam edition',- 'pick.readyOnly': 'Ready only',- 'pick.multi': 'Pick several',- 'pick.multiHint': 'When on, tap templates to add or remove them, up to 12. Each one makes a video from the same text.',- 'pick.count': '{ready}/{total} templates ready',- 'pick.max': 'Up to {max} templates per run. Remove one to pick another.',- 'grid.loading': 'Loading templates…',- 'grid.loadErr': "Couldn't load templates. Check the server, then reload the page.",- 'grid.empty': 'No matching templates. Clear the filters or try another word.',- 'tpl.aria': (v) => `Template ${v.id}: ${v.name}${v.ready ? '' : ' (no guidance yet, not usable)'}${v.order ? `, picked #${v.order}` : ''}`,- 'tpl.noThumb': 'no image',- 'tpl.ready': 'Ready',- 'tpl.noGuide': 'No guidance',- 'tpl.playDemo': 'Play demo video for template {id}',- 'tpl.playRef': 'Play reference video for template {id}',- // ---- template packs (.lumpack) ----- 'src.builtin': 'Built-in',- 'src.local': 'Mine',- 'src.pack': 'Community',- 'grid.emptySrc.local': 'No templates of your own yet. Ones you create or import from your own pack show up here.',- 'grid.emptySrc.pack': 'No community packs installed yet.',- 'pack.importBtn': 'Import pack',- 'pack.mineBtn': 'My packs',- 'pack.lockedNote': 'Outside templates run locked: the AI can only read/write inside this video’s folder.',- 'kind.template': 'Template',- 'kind.edit-style': 'Edit style',- 'prov.original': 'Original work',- 'prov.own-video': 'Learned from the author’s own video',- 'prov.style-study': 'Style study of another video',- 'pk.title': 'Import a template pack',- 'pk.close': 'Close',- 'pk.dropBig': 'Choose a .lumpack file',- 'pk.dropSmall': 'or drop it here · up to 12 MB · you preview it before installing',- 'pk.reading': 'Reading and checking the pack…',- 'pk.restricted': 'Community templates run locked: the AI can only read/write inside this video’s folder.',- 'pk.noName': '(no name)',- 'pk.author': 'Author',- 'pk.contact': 'Contact',- 'pk.license': 'License',- 'pk.provenance': 'Origin',- 'pk.id': 'Pack ID',- 'pk.engine': 'Needs LumReels',- 'pk.items': 'Items',- 'pk.sha': 'Checksum (sha256)',- 'pk.warnHead': (v) => `${v.n} item${S(v.n)} contain${v.n === 1 ? 's' : ''} words worth reading closely (highlighted below). They aren’t blocked, but read them before installing.`,- 'pk.warnItem': 'read closely',- 'pk.showText': 'Show full text',- 'pk.err.not-pack': 'This file isn’t a LumReels pack (.lumpack).',- 'pk.err.tooBig': 'The file is larger than 12 MB.',- 'pk.err.engine': 'This pack needs a newer LumReels. Update the app, then import again.',- 'pk.err.rejected': 'Pack rejected: unsafe content or wrong format.',- 'pk.err.first': 'First reason: {e}',- 'pk.err.more': 'Show all errors ({n})',- 'pk.err.expired': 'The preview expired (10 minutes). Choose the file again.',- 'pk.err.net': 'Couldn’t reach the app. Check it’s still running, then try again.',- 'pk.st.installed': 'This pack (version {v}) is already installed.',- 'pk.st.conflict': '{id} version {v} is installed with different content: can’t overwrite it.',- 'pk.st.older': 'A newer version ({v}) is already installed.',- 'pk.st.upgrade': 'Version {v} is installed.',- 'pk.replace': 'Replace it with version {v}',- 'pk.cancel': 'Cancel',- 'pk.other': 'Choose another file',- 'pk.install': 'Install',- 'pk.installing': 'Installing…',- 'pk.done': (v) => `Installed "${v.name}": ${v.n} item${S(v.n)}. They show in the grid with the Community label.`,- 'pk.showGrid': 'Show in grid',- 'mp.title': 'My packs',- 'mp.loading': 'Loading…',- 'mp.loadErr': 'Couldn’t load the pack list.',- 'mp.retry': 'Try again',- 'mp.empty': 'No packs installed. Click Import pack to add templates from a .lumpack file.',- 'mp.items': (v) => `${v.n} item${S(v.n)}`,- 'mp.view': 'View',- 'mp.hide': 'Hide',- 'mp.verified': 'Reviewed',- 'mp.remove': 'Remove',- 'mp.removeQ': 'Remove pack "{name}"? Videos already made with it stay as they are.',- 'mp.removeYes': 'Remove pack',- 'mp.removed': 'Removed "{name}".',- 'mp.deleted': 'Deleted "{name}".',- 'mp.delItem': 'Delete',- 'mp.delItemQ': 'Delete "{name}" from your templates? This can’t be undone.',- 'mp.export': 'Export pack',- 'ex.title': 'Export your own templates to a .lumpack file',- 'ex.none': 'Nothing of your own to export yet. Templates you create (Create template button, coming soon) show up here.',- 'ex.pick': 'Choose items',- 'ex.name': 'Pack name',- 'ex.id': 'Pack ID',- 'ex.idHint': 'Format author.pack-name: lowercase without accents, digits, hyphens. Filled in from author + name.',- 'ex.author': 'Author',- 'ex.contact': 'Contact (optional)',- 'ex.license': 'License',- 'ex.version': 'Version',- 'ex.go': 'Download .lumpack',- 'ex.busy': 'Exporting…',- 'ex.ok': 'Exported {file} ({kb}).',- 'ex.err.items': 'Pick at least 1 item to export.',- 'ex.err.name': 'Enter a pack name.',- 'ex.err.author': 'Enter the author name.',- 'ex.err.id': 'Pack ID must look like author.pack-name, each half 2–24 characters.',- 'ex.err.ver': 'Version must look like 1.0.0.',- 'ex.err.reserved': 'That author name is reserved for LumReels. Change the part before the dot.',-- 'picked.none': 'No template yet. Tap a bright one on the left.',- 'picked.noneMulti': 'Multi-pick on: tap bright templates on the left (up to {max}). Each makes one video.',- 'picked.count': (v) => `${v.n} template${S(v.n)} picked`,- 'picked.clear': 'Clear all',- 'picked.strip': 'Picked templates',- 'picked.remove': 'Remove template {id}: {name}',-- 'viewer.aria': 'Template preview video',- 'viewer.close': 'Close',- 'viewer.demo': 'Demo video made with LumReels. ',- 'viewer.ref': 'Reference video on your machine (not in the repo). ',-- 'compose.h': 'Your text',- 'compose.label': 'Video text',- 'compose.ph': 'Example: Put $100 a month into an index fund at an assumed 10% a year. How much after 20 years? Channel: Lumfin. CTA: Follow for more money tips',- 'compose.charsTail': '/4000 characters · include your channel name and CTA if you have them',- 'rw.btn': 'Rewrite script',- 'rw.btnBusy': 'Rewriting',- 'rw.hint': 'Rewrite script: AI fits your text into the slots of the picked template and the length below, keeping numbers, channel name and CTA.',- 'rw.hintMany': 'Rewrite is off because {n} templates are picked and each has different slots. Pick 1 template to use it; otherwise all {n} videos share the text you typed.',- 'rw.busy': 'Rewriting…',- 'rw.needOne': 'Pick 1 template first',- 'rw.onlyOne': 'Rewrite works with 1 template only',- 'rw.needText': 'Type your text first (at least 10 characters)',- 'rw.loading': 'Rewriting for template {id} · {d}… (usually 20–60 seconds)',- 'rw.title': 'Rewrite · template {id} · {d}',- 'rw.fallback': 'Switched to Claude Code because: {why}.',- 'rw.use': 'Use this',- 'rw.drop': 'Discard',- 'rw.timeout': 'Still not done after 100 seconds, so we stopped waiting. Try again.',- 'rw.replaced': 'Your text was replaced with the rewrite.',- 'rw.undo': 'Undo',- 'rw.close': 'Close',- 'err.status': 'Error {s}',-- 'dur.label': 'Length',- 'dur.range': '(3 s – 10 min)',- 'dur.presets': 'Quick lengths',- 'dur.hint': 'Type seconds (90) or min:sec (1:30).',- 'dur.errEmpty': 'Enter a length, e.g. 8 or 1:30',- 'dur.errFmt': 'Type seconds (90) or min:sec (1:30)',- 'dur.errMin': 'Minimum 3 seconds',- 'dur.errMax': 'Maximum 10 minutes (10:00)',- 'dur.eqLong': '= {s} seconds ({f}).',- 'dur.eq': '= {s} seconds. Type seconds (90) or min:sec (1:30).',- 'dur.warn': 'A {f} video takes about {range} to render (measured: an 8-second video takes 20–60 seconds), not counting the time AI spends writing scenes. AI has to write about {scenes} connected scenes, so it costs far more tokens than an 8-second video.',- 'unit.sec': 'seconds',- 'unit.min': 'min',- 'unit.hour': 'hours',- 'num.dec': '.',-- 'audio.aria': 'Audio',- 'mode.label': 'Scene builder',- 'mode.auto': 'Auto',- 'mode.manual': 'External agent',- 'modeLabel.auto': 'auto',- 'modeLabel.manual': 'external agent',- 'mode.hintAuto': 'Auto: using {m}.',- 'mode.hintApi': 'Calls the Claude API with the key in .env (billed per token; cost is saved on the job).',- 'mode.hintClaude': 'Runs Claude Code on this machine (uses your Claude plan).',- 'mode.hintManual': 'Only writes the brief; an external agent (MCP/CLI) writes the scenes and calls render.',- 'mode.hintExport': ' When done, the MP4 is copied to your export folder.',- 'model.label': 'Scene model',- 'model.auto': 'Auto (by template)',- 'model.autoRec': 'Auto by template ({m})',- 'model.autoMany': 'Auto per template',- 'model.opus': 'Opus (best, priciest)',- 'model.sonnet': 'Sonnet (balanced)',- 'model.haiku': 'Haiku (cheapest)',- 'model.rec': (v) => `This template ${v.heavy ? 'uses 3D/shaders' : 'is 2D'} → ${v.m} recommended.`,- 'model.pickFirst': 'Pick a template to see a recommendation.',- 'model.haikuWarn': ' Haiku tends to flatten 3D scenes; use Opus.',- 'model.override': ' (using {m} instead of the recommendation)',- 'model.agentNote': ' With an external agent, that agent picks the model.',- 'model.manyLight': '{n} 2D → {m}',- 'model.manyHeavy': '{n} 3D/shader → {m}',- 'model.manyAuto': 'Each video picks by its template: {parts}.',- 'model.manyFixed': 'All {n} videos use {m} (recommended: {parts}).',- 'model.haikuWarnMany': ' Haiku tends to flatten 3D scenes; use Opus for 3D templates.',- 'runAt.label': 'Schedule',- 'runAt.opt': '(leave blank to build now)',- 'runAt.clear': 'Clear',- 'runAt.clearAria': 'Clear schedule',- 'go.build': (v) => (v.n > 1 ? `Build ${v.n} videos` : 'Build video'),- 'go.schedule': (v) => (v.n > 1 ? `Schedule ${v.n} videos` : 'Schedule video'),- 'go.sending': 'Sending',- 'go.needTpl': 'Pick a template first',- 'go.needText': 'Text needs at least 10 characters',- 'go.badDur': 'Length is not valid',- 'form.jobErr': "Couldn't create the job",- 'form.retry': '. Fix it and try again.',-- 'jobs.h': 'Your videos',- 'jobs.empty': 'No videos yet. Pick a template, paste your text, then hit <b>Build video</b>.',- 'jobs.less': 'Show less',- 'jobs.more': (v) => `Show more (${v.n} older video${S(v.n)})`,- 'st.scheduled': 'Scheduled',- 'st.queued': 'Queued',- 'st.generating': 'AI writing scenes',- 'st.waiting_agent': 'Waiting for agent',- 'st.previewing': 'Building preview',- 'st.rendering': 'Rendering',- 'st.done': 'Done',- 'st.error': 'Error',- 'job.previewAlt': '16-frame preview',- 'job.building': 'Building…',- 'job.waitScene': 'Waiting for scenes',- 'job.noImage': 'No image yet',- 'job.tpl': 'Template {id} · {name}',- 'job.at': 'Scheduled for {t}',- 'job.api': 'API: {i}k in · {o}k out · ≈ ${c}',- 'job.exported': 'Copied to: {p}',- 'job.errUnknown': 'Unknown error',- 'job.errTail': '. Check the log, fix the scenes, then hit Re-render.',- 'job.agent': 'Agent reads: {prompt}\nWrites: {scene}\nThen run: node cli.mjs render {id}',- 'job.mp4': 'Download MP4',- 'job.preview': '16-frame preview',- 'job.rerender': 'Re-render',- 'job.render': 'Render',- 'job.log': (v) => `Log (${v.n} line${S(v.n)})`,-- 'ap.title': 'Audio',- 'ap.loadingOpts': 'Loading options…',- 'ap.stop': 'Stop preview',- 'ap.making': 'Making preview',- 'ap.voiceLoading': 'Generating a voice sample… (the first model load can take a few minutes)',- 'ap.prevFail': "couldn't make a preview",- 'ap.prevErr': 'Preview failed: ',- 'ap.keep': 'Keep current',- 'ap.music': 'Background music',- 'ap.musicPrev': 'Preview music',- 'ap.voice': 'Voiceover',- 'ap.voicePrev': 'Preview voice',- 'ap.sfx': 'Sound effects synced to motion',- 'ap.pickMusic': 'Pick a specific music style to preview.',- 'ap.pickVoice': 'Pick a specific voice to preview.',- 'ap.vAuto': 'template voice',- 'ap.vNone': 'no voice',- 'ap.versions': 'Versions ({n})',- 'ap.ver': 'Version {n}',- 'ap.latest': ' · latest',- 'ap.noSfx': ' · no SFX',- 'ap.view': 'Play',- 'ap.dl': 'Download',- 'ap.mix': 'Remix audio',- 'ap.mixNote': "Visuals aren't rebuilt and old versions are kept. If you pick a voice for a video with no script, AI writes a short one.",- 'ap.lastErr': 'Last mix failed: ',- 'ap.mixing': 'Mixing audio…',- 'ap.mixingNote': 'Mixing (VieNeu voices can take a few minutes)…',- 'ap.err': 'Error: ',- 'ap.unknown': 'unknown',- 'ap.done': 'Done — playing the latest version.',- 'ap.summary': 'Audio · change music, voice',- 'ap.loading': 'Loading…',- 'ap.mixFail': "Couldn't mix: ",- 'ap.errShort': 'error',- 'vc.title': 'My voices',- 'vc.optTag': 'cloned voice',- 'vc.add': '+ Add voice',- 'vc.loading': 'Loading your voices…',- 'vc.loadErr': "Couldn't load your voices.",- 'vc.retry': 'Retry',- 'vc.empty': 'No voices yet. Upload or record 10 seconds to 3 minutes of speech and the app learns it, then reads your video script in that voice.',- 'vc.needVieneu': 'Voice cloning needs VieNeu-TTS on this machine: pip install vieneu',- 'vc.ready': 'Ready',- 'vc.error': 'Error',- 'vc.step.queued': 'Waiting…',- 'vc.step.transcribe': 'Transcribing the sample…',- 'vc.step.encode': 'Learning the voice + test read…',- 'vc.play': 'Play sample of {name}',- 'vc.stop': 'Stop',- 'vc.rename': 'Rename voice {name}',- 'vc.delete': 'Delete voice {name}',- 'vc.newName': 'New name',- 'vc.save': 'Save',- 'vc.cancel': 'Cancel',- 'vc.refSum': 'Sample the app picked',- 'vc.refText': 'Words spoken in the sample',- 'vc.byWhisper': '(auto-transcribed, fix if wrong)',- 'vc.refTextPh': 'Type exactly what you say in the sample',- 'vc.refTextHint': 'Optional for VieNeu v3 Turbo; helps you see what the sample says.',- 'vc.saveText': 'Save text',- 'vc.noWhisper': "Whisper isn't installed, so the sample wasn't transcribed. Open the sample to listen and type it (optional).",- 'vc.srcAria': 'Voice source',- 'vc.srcFile': 'Choose file',- 'vc.srcRec': 'Record',- 'vc.fileLabel': 'Voice audio file',- 'vc.fileHint': 'wav, mp3, m4a, ogg or webm · 10 seconds to 3 minutes · up to {max} MB · one speaker, little background noise.',- 'vc.readTip': 'Tip: read this aloud naturally (Vietnamese text, since cloned voices speak Vietnamese)',- 'vc.readText': 'Hôm nay mình muốn kể cho bạn nghe một chuyện nhỏ. Sáng nào mình cũng dậy sớm, pha một ly cà phê, mở cửa sổ và nghe phố xá bắt đầu nhộn nhịp. Có hôm trời mưa, có hôm nắng gắt, nhưng mình vẫn giữ thói quen đó. Một, hai, ba, bốn, năm: thói quen nhỏ, kết quả lớn.',- 'vc.recStart': 'Start recording',- 'vc.recAgain': 'Record again',- 'vc.recStop': 'Stop',- 'vc.recHint': 'Record somewhere quiet, a hand-width from the mic, at least 20 seconds. Stops by itself at 3 minutes.',- 'vc.recFile': 'recording',- 'vc.nameLabel': 'Voice name',- 'vc.namePh': 'e.g. My voice',- 'vc.consent': "This is my voice, or I have that person's permission to use it",- 'vc.langNote': 'Cloned voices speak Vietnamese. Pick one for English content and the voiceover is written in Vietnamese.',- 'vc.create': 'Create voice',- 'vc.sending': 'Uploading… {pct}%',- 'vc.processing': 'Got voice {name}. Learning it now, about a minute.',- 'vc.readyNote': 'Voice {name} is ready and selected as the voiceover. Press play to hear it.',- 'vc.errNoFile': 'Choose an audio file.',- 'vc.errNoRec': 'Record something first.',- 'vc.errExt': 'Unsupported format. Use wav, mp3, m4a, ogg or webm.',- 'vc.errBig': 'File too large (max {max} MB).',- 'vc.errShort': 'Too short ({s} seconds). It needs at least 10 seconds.',- 'vc.errLong': 'Longer than 3 minutes. Trim it and try again.',- 'vc.errName': 'Give the voice a name.',- 'vc.errNameLong': 'Name can be up to {max} characters.',- 'vc.errConsent': 'Tick the confirmation to continue.',- 'vc.errNoMic': "This browser can't record. Choose a file instead.",- 'vc.errMicDenied': 'Microphone access was blocked. Allow it in the browser and try again.',- 'vc.errUpload': 'Upload failed. Check the app is still running and try again.',- 'vc.errDel': "Couldn't delete the voice.",- 'vc.errSave': "Couldn't save.",- 'vc.confirmDel': 'Delete voice "{name}"? Its files on this machine are removed for good.',- 'vc.deleted': 'Deleted voice {name}.',- 'vc.renamed': 'Renamed to {name}.',- 'vc.textSaved': 'Sample text saved.',-- 'ed.aria': 'Edit your video',- 'ed.setupH': "Video editing isn't installed",- 'ed.noServer': "Can't reach the server.",- 'ed.h': 'Your video',- 'ed.dropAria': 'Choose or drop a video',- 'ed.dropBig': 'Drop your video here',- 'ed.dropSmall': 'or click to choose · mp4, mov, mkv… up to 2 GB · talking to camera, in Vietnamese',- 'ed.fileLabel': 'Video file',- 'ed.style': 'Edit style',- 'ed.music': 'Background music',- 'ed.musicOpt': '(ducks while you talk)',- 'ed.noMusic': 'No music',- 'ed.musicSynth': 'Generated: {id} — {desc}',- 'ed.musicFile': 'Upload my own music…',- 'ed.musicFileLabel': 'Music file',- 'ed.names': 'Names and terms',- 'ed.namesOpt': '(so AI spells captions right)',- 'ed.namesPh': 'e.g. Lumfin, Hanoi, ETF',- 'ed.notes': 'Extra notes',- 'ed.notesOpt': '(optional)',- 'ed.notesPh': 'e.g. cut the opening greeting, keep the follow call at the end',- 'ed.draft': 'Quick draft (simple captions, ~1 min faster)',- 'ed.go': 'Build',- 'ed.empty': 'Pick a video on the left, then hit Build.',- 'ed.steps': 'Steps',- 'ed.fixesH': 'Words AI fixed in the captions — please check',- 'ed.reviseH': 'Request changes',- 'ed.reviseLabel': 'Change request',- 'ed.revisePh': 'e.g. "cut the first 3 seconds", "less zoom"',- 'ed.reviseBtn': 'Re-render',- 'ed.p1': 'cut the first 3 seconds',- 'ed.p2': 'less zoom',- 'ed.p3': 'lower the music',- 'ed.p4': 'captions 2 words at a time',- 'ed.histH': 'Revisions',- 'ed.log': 'Log',- 'ed.delete': 'Delete this edit',- 'ed.listH': 'Your edits',- 'ed.st.queued': 'Queued',- 'ed.st.running': 'Editing',- 'ed.st.done': 'Done',- 'ed.st.error': 'Error',- 'ed.waitTurn': 'Waiting in line',- 'ed.revising': 'Revising',- 'ed.notVideo': "This file isn't a video (mp4, mov, mkv, webm…).",- 'ed.tooBig': 'Video is {size}, too large (max 2 GB).',- 'ed.changeFile': '{size} · click to change',- 'ed.needMusic': 'Choose a music file, or switch to "No music".',- 'ed.uploading': 'Uploading {p}%',- 'ed.uploadCut': 'Upload interrupted. Check the server and try again.',- 'ed.listEmpty': 'Nothing here yet.',- 'ed.err': 'Error',- 'ed.reviseErr': 'Change failed: {e}',- 'ed.previewAlt': 'Preview frame grid',- 'ed.mediaEmpty': 'Your video shows up here when it is done',- 'ed.mp4': 'Download MP4',- 'ed.gridOut': 'Output frame grid',- 'ed.hidden': '(hidden from captions)',- 'ed.checksEdl': '{out} s · cut {rm} s · {z} zooms',- 'ed.overcut': 'clipped words: {v}',- 'ed.noOvercut': 'no clipped words',- 'ed.sendFail': "Couldn't send your change.",- 'ed.confirmDel': 'Delete this edit for good (output video, EDL, uploaded files)? This cannot be undone.',- 'man.h': 'Manual edit',- 'man.tabCap': 'Captions',- 'man.tabAud': 'Music & sound',- 'man.tabFx': 'Zoom & graphics',- 'man.look': 'Caption look',- 'man.hi': 'Highlights (words in *stars* get the accent colour)',- 'man.capHint': 'Tap a time to jump the video there. Wrap a *word* to highlight it.',- 'man.draftNote': "A draft burns captions into the picture, so they can't be edited by hand. Turn off \"draft\" and edit again.",- 'man.music': 'Music',- 'man.musicKeep': 'Keep current music ({name})',- 'man.synth': 'Built-in music: {id}',- 'man.uploaded': 'Uploaded: {name}',- 'man.uploading': 'Uploading {name} ({size})…',- 'man.uploadOk': 'Uploaded {name}. Press Apply to remix the sound.',- 'man.uploadErr': "Couldn't upload the music: {e}",- 'man.musicGain': 'Music volume',- 'man.duck': 'Ducking: music dips while someone speaks',- 'man.fade': 'Fade out at the end',- 'man.start': 'Music starts at second',- 'man.voice': 'Voice volume (vs. music)',- 'man.loudHint': 'The whole mix is always normalised to −14 LUFS: a louder voice means relatively quieter music and effects.',- 'man.sfx': (v) => `Sound effects${v.n ? ` · ${v.n}` : ' · none'}`,- 'man.zooms': 'Zooms',- 'man.gfx': 'Graphics',- 'man.zoomKind': (v) => `${v.kind === 'punch' ? 'Punch zoom' : 'Push zoom'} ×${v.scale}`,- 'man.noZoom': 'This edit has no zooms.',- 'man.noGfx': 'This edit has no graphics.',- 'man.noLines': 'This edit has no captions.',- 'man.remove': 'Remove',- 'man.undo': 'Keep',- 'man.removeN': 'Remove {what}',- 'man.undoN': 'Keep {what}',- 'man.jump': 'Jump to {s} s',- 'man.lineText': 'Text of line {n}',- 'man.lineStart': 'Start of line {n} (seconds)',- 'man.lineEnd': 'End of line {n} (seconds)',- 'man.split': 'Split',- 'man.merge': 'Merge ↓',- 'man.splitN': 'Split line {n} in two',- 'man.mergeN': 'Merge line {n} with the next',- 'man.delN': 'Delete line {n}',- 'man.cantSplit': 'This line has one word; nothing to split.',- 'man.errShort': 'A line must last at least 0.1 s (end after start).',- 'man.errAfter': 'Starts after the end of the video ({d} s).',- 'man.errOverlap': 'Overlaps the line before: move its start later.',- 'man.errEmpty': 'Empty line: type something or delete it.',- 'man.fixFirst': (v) => `Fix ${v.n} line${S(v.n)} marked red before applying.`,- 'man.dirty': (v) => `${v.n} change${S(v.n)} · redo: ${v.what}`,- 'man.clean': 'No changes yet.',- 'man.wCap': 'caption layer',- 'man.wAud': 'sound',- 'man.wBase': 'picture',- 'man.reset': 'Discard changes',- 'man.apply': 'Apply',- 'man.applying': 'Rendering…',- 'man.running': 'Rendering manual edit',- 'man.loadErr': "Couldn't load manual editing: {e}",- 'man.sendFail': "Couldn't send the manual edit.",- 'man.tag': 'Manual',- 'man.took': 'took {s} s',- 'man.watch': 'Watch',- 'man.original': 'First version',- 'ed.styleHint': '{n} styles · scroll to see them all',- 'ed.styleAria': (v) => `${v.name}: ${v.summary}`,- 'ed.setupText': 'Video editing needs Python, a speech-to-text model and a face model. Click Install now and LumReels sets everything up (one time only).',- 'ed.install': 'Install now',- 'ed.installing': 'Installing…',- 'ed.installStep': '{step}… ({t})',- 'ed.installStepDefault': 'Installing',- 'ed.installDone': 'Installed in {t}. Video editing is ready.',- 'ed.installRetry': 'Try again',- 'ed.installFail': "Install didn't finish. See the details below, then click Try again.",- 'ed.installCantStart': "Couldn't start the install: {e}",- 'ed.installNote': 'About a 6 GB download, 5–20 minutes depending on your connection. Keep this page open.',- 'ed.installDetails': 'Show details',- 'ed.installManual': 'Or install it yourself with a command',- 'ed.fail.NEED_PYTHON': "Python 3.10–3.12 isn't installed. Install it as described below, then click Try again.",- 'ed.fail.NEED_FFMPEG': "ffmpeg isn't installed. Install it as described below, then click Try again.",- 'ed.fail.NEED_NETWORK': "The download failed. Check your connection, then click Try again (finished parts won't download again).",- 'ed.fail.NEED_NPM': 'LumReels fonts are missing: run npm install in the LumReels folder, then click Try again.',- 'ed.figuresH': "Numbers the machine wasn't sure it heard, left off the graphics: please listen again",- 'ed.figAt': '{s} s in source',- 'ed.figHeard': 'heard again as: “{h}”',- 'ed.more': 'More',- 'ed.review': (v) => `Review (${v.n})`,- 'ed.revFixes': 'AI-fixed words',- 'ed.revFigs': 'Unsure numbers',- 'ed.specs': 'Specs',- 'ed.stepOf': '{i}/{n} · {step} · {p}%',- 'ed.revisePhS': 'cut the first 3 seconds…',- 'man.hiShort': 'Highlights',- 'man.hiTip': 'Wrap *words* to highlight',- 'man.gainS': 'Volume',- 'man.fadeS': 'Fade out',- 'man.startS': 'Start (s)',- 'man.duckS': 'Duck under voice',- 'man.voiceS': 'Voice',- 'man.dirtyS': (v) => `${v.n} change${S(v.n)}`,- 'ed.cutRepairs': (v) => `fixed ${v.n} cut${S(v.n)} that clipped words`,-- // ---- Create a template from a video (learn-panel.js) ----- 'cat.mine': 'Mine',- 'lp.open': 'Template from a video',- 'lp.title': 'Create a template from a video',- 'lp.lead': 'Give it one video from this computer. The AI learns its editing style (colours, layout, pacing, motion), builds one test video with different content, then you review it and save it as your own template.',- 'lp.back': 'Back',- 'lp.close': 'Close',- 'lp.loadErr': "Couldn't load the draft. Try again later.",- 'lp.noDrafts': 'No drafts yet.',- 'lp.new': 'Start from a new video',- 'lp.drop': 'Drop a video here',- 'lp.dropHint': 'or click to choose · mp4, mov, webm · 4 seconds – 3 minutes · up to 200 MB',- 'lp.change': 'Change video',- 'lp.refVideo': 'Reference video',- 'lp.from': 'Which 8 seconds to learn',- 'lp.seg': '{a}–{b} s',- 'lp.fromHint': 'Pick the part where the style shows best. The video loops over exactly this part.',- 'lp.name': 'Template name',- 'lp.optional': '(optional)',- 'lp.namePh': 'For example: Old paper cards',- 'lp.cat': 'Group',- 'lp.catAuto': 'Let the AI choose',- 'lp.note': 'What is this video',- 'lp.notePh': 'For example: food promo, big text, fast cuts',- 'lp.rulesH': 'Learn the style, never copy',- 'lp.rule1': 'Only colours, layout, pacing, motion and the closest open font are learned.',- 'lp.rule2': 'Text, channel names, logos and characters seen in the video are removed from the template by code.',- 'lp.rule3': 'The reference video stays on this computer and is deleted when you Save or Discard. The thumbnail comes from the test video.',- 'lp.consent': "This video is mine, or I only use it to learn the editing style. I won't copy other people's characters, logos, music or images.",- 'lp.needConsent': 'Tick the confirmation box to start',- 'lp.skipTest': "Skip the test build (faster and cheaper, but you won't know if the template renders right)",- 'lp.est': 'About 7–13 minutes, about 1–2.5 USD of AI at API prices (includes one 8-second test video).',- 'lp.estNoTest': 'About 2–3 minutes, about 0.2–0.4 USD of AI at API prices. The draft will say "not test-built".',- 'lp.go': 'Start',- 'lp.uploading': 'Uploading the video',- 'lp.uploadingPct': 'Uploading {p}%',- 'lp.started': 'Video received, measuring.',- 'lp.err.ext': "This format isn't supported. Use mp4, mov or webm.",- 'lp.err.big': 'The video is too large (200 MB max).',- 'lp.err.short': 'The video is too short, it needs at least {min} seconds.',- 'lp.err.long': 'The video is too long, 3 minutes max. Trim it and try again.',- 'lp.err.upload': "Couldn't send the video. Check the server and try again.",- 'lp.err.run': 'Creating the template failed.',- 'lp.st.uploaded': 'Received',- 'lp.st.measuring': 'Measuring',- 'lp.st.writing': 'AI writing',- 'lp.st.testing': 'Test building',- 'lp.st.comparing': 'Comparing',- 'lp.st.revising': 'AI revising',- 'lp.st.ready': 'Ready',- 'lp.st.readyNoTest': 'Ready (not test-built)',- 'lp.st.error': 'Error',- 'lp.st.saved': 'Saved',- 'lp.st.discarded': 'Discarded',- 'lp.step.measuring': 'Measure the video (colour, pacing, motion)',- 'lp.step.writing': 'AI writes the template from the spec',- 'lp.step.testing': 'Build one 8-second test video',- 'lp.step.comparing': 'Compare the test with the original',- 'lp.step.revising': 'AI revises the template once',- 'lp.stepNow': '{e} / ~{est}',- 'lp.stepEst': '~{est}',- 'lp.progress': 'Template progress',- 'lp.canClose': 'You can close this box, the work keeps running. Reopen it with the Template from a video button.',- 'lp.draftH': 'Template draft',- 'lp.totals': 'Time {t} · AI cost {c}',- 'lp.fromFile': '{f} · seconds {a}–{b}',- 'lp.noRef': 'Reference video deleted',- 'lp.testVideo': 'Test video',- 'lp.notTested': 'Not test-built',- 'lp.sheets': 'See the 16 frames side by side',- 'lp.refSheet': 'Original',- 'lp.refSheetAlt': '16-frame grid of the reference video',- 'lp.testSheet': 'Test video',- 'lp.testSheetAlt': '16-frame grid of the test video',- 'lp.cmpH': (v) => `Measurements: ${v.n}/${v.total} off by more than 25%`,- 'lp.cmpMetric': 'Measure',- 'lp.cmpRef': 'Original',- 'lp.cmpTest': 'Test',- 'lp.cmpDev': 'Off by',- 'lp.off': 'off',- 'lp.near': 'close',- 'lp.m.palette': 'Main colours',- 'lp.m.brightness': 'Brightness',- 'lp.m.saturation': 'Colour strength',- 'lp.m.events': 'New elements per second',- 'lp.m.motion': 'Amount of motion',- 'lp.m.cuts': 'Scene cuts',- 'lp.m.still': 'Share of still time',- 'lp.diffsH': 'Remaining differences (AI compared both grids)',- 'lp.diffsFixed': 'Differences the AI found and fixed in the template',- 'lp.selfH': 'Self-check: {ok}/{n} passed',- 'lp.yes': 'yes',- 'lp.no': 'no',- 'lp.guideH': 'Template (guidance)',- 'lp.guideHint': 'The scene-building AI reads this text. You can edit it.',- 'lp.saveText': 'Save edits',- 'lp.unsaved': 'You have unsaved edits',- 'lp.seenHit': 'still has text from the original video: "{s}"',- 'lp.textOk': 'Edits saved and passed the checks.',- 'lp.textBad': 'Edits saved, but there are errors to fix before saving the template.',- 'lp.saveH': 'Save as a "Mine" template',- 'lp.saveName': 'Template name',- 'lp.slug': 'Template code',- 'lp.slugHint': 'Lowercase letters without accents, digits, hyphens. Used in: make --template local.mine/<code>',- 'lp.save': 'Save template',- 'lp.retest': 'Test-build again',- 'lp.discard': 'Discard draft',- 'lp.discardAsk': 'Discard this draft? The reference video and the draft will be deleted.',- 'lp.discarded': 'Draft discarded.',- 'lp.saveNote': 'After saving, the reference video and its frames are deleted from this computer. The template runs locked: the AI only reads and writes inside the folder of the video being built.',- 'lp.errNoSave': 'The draft failed at the test build: fix the template, then click Test-build again before saving.',- 'lp.savedH': 'Saved to Mine',- 'lp.savedP': 'Template {ref} is in the template grid under "Mine". Build with any content, like the built-in templates.',- 'lp.useNow': 'Use this template',- };-- // Chuỗi tiếng Việt cố định do server trả cho giao diện (nhãn tuỳ chọn, bước dựng). Không gồm lỗi, tên mẫu, kiểu edit.- const SRV_EN = {- 'Tự chọn theo mẫu': 'Auto (by template)', 'Không nhạc': 'No music',- 'Theo mẫu (chỉ đọc khi mẫu có lời)': 'Template default (only if it has a script)', 'Không lời đọc': 'No voiceover',- 'Tiếng Việt': 'Vietnamese',- nam: 'male', 'nữ': 'female', 'Bắc': 'North', Trung: 'Central', Nam: 'South',- 'tự nhiên (mặc định)': 'natural (default)', 'kể chuyện, trầm': 'storytelling, deep', 'tự nhiên': 'natural', 'lầy': 'goofy',- 'tin tức': 'news', 'kể chuyện': 'storytelling', 'đọc truyện': 'audiobook', 'cần mạng': 'needs internet',- 'ấm, tự nhiên (mặc định)': 'warm, natural (default)', 'sáng, nhiều cảm xúc': 'bright, expressive', 'trầm, điềm đạm': 'deep, calm',- 'khoẻ, dứt khoát': 'strong, crisp', 'nhẹ nhàng, rõ chữ': 'soft, clear', 'trầm, kể chuyện': 'deep, storytelling',- 'lofi ấm, chậm, có tiếng đĩa than (78 BPM)': 'warm lo-fi, slow, vinyl crackle (78 BPM)',- 'pop sáng, 4 phách đều, vui tươi (118 BPM)': 'bright pop, steady four-beat, cheerful (118 BPM)',- 'drone căng, nhịp tim, tích tắc (70 BPM)': 'tense drone, heartbeat, ticking (70 BPM)',- 'tung tăng, marimba + pizzicato (112 BPM)': 'bouncy marimba + pizzicato (112 BPM)',- 'điện ảnh: dàn dây + trống trận (90 BPM)': 'cinematic: strings + war drums (90 BPM)',- 'game 8-bit: xung vuông + trống nhiễu (132 BPM)': '8-bit game: square waves + noise drums (132 BPM)',- 'Bắt đầu': 'Starting', 'Kiểm tra ffmpeg': 'Checking ffmpeg', 'Tạo môi trường Python': 'Creating the Python environment',- 'Cài gói Python (vài trăm MB)': 'Installing Python packages (a few hundred MB)', 'Cài phần chạy bằng GPU (~2 GB)': 'Installing GPU support (~2 GB)',- 'Tải model nhận mặt, người': 'Downloading face and person models', 'Chuẩn bị font phụ đề': 'Preparing caption fonts',- 'Tải model chép lời (~3 GB, lâu nhất)': 'Downloading the speech-to-text model (~3 GB, the longest step)', 'Kiểm tra lần cuối': 'Final check',- 'piano chậm, cảm hứng, không trống (70 BPM)': 'slow inspiring piano, no drums (70 BPM)',- 'nền bản tin: nhịp đều, pad + tiếng tích (120 BPM)': 'newsroom bed: steady pulse, pad + ticks (120 BPM)',- 'nạp': 'load', 'phân tích': 'analyze', 'LLM lập EDL': 'LLM plans EDL', 'xem trước': 'preview', 'render nền': 'base render',- 'phụ đề': 'captions', 'tiếng': 'audio', 'ghép': 'mux', 'kiểm': 'check',- // ghi chú bước của "Tạo mẫu từ video"- 'đã sửa guidance': 'guidance revised', 'giữ nguyên guidance': 'guidance kept as is', 'lỗi': 'error',- };- // Mảnh câu trong gợi ý cài đặt / tên giọng ("Heart (US, nữ)").- const SRV_EN_PARTS = [- ['Cài giọng đọc: ', 'Install voices: '], ['Cài giọng Anh: ', 'Install English voices: '],- [' (đang dùng edge-tts, cần mạng)', ' (using edge-tts for now, needs internet)'], [' (hoặc pip install edge-tts)', ' (or pip install edge-tts)'],- [/, nữ(?=[,)])/g, ', female'], [/, nam(?=[,)])/g, ', male'],- [/^(\d+) chỉ số lệch$/, '$1 measures off'],- ];-- const TABLE = { vi, en };- const KEY = 'lumreels.lang';- let lang = 'vi';- try { lang = localStorage.getItem(KEY) || ''; } catch { lang = ''; }- if (lang !== 'vi' && lang !== 'en') lang = /^vi\b/i.test(navigator.language || '') ? 'vi' : 'en';-- function t(key, vars = {}) {- let v = TABLE[lang][key];- if (v === undefined) v = vi[key];- if (v === undefined) return key;- if (typeof v === 'function') return v(vars);- return v.replace(/\{(\w+)\}/g, (m, k) => (k in vars ? String(vars[k]) : m));- }- function srv(s) {- if (lang === 'vi' || s == null) return s;- const str = String(s);- if (Object.prototype.hasOwnProperty.call(SRV_EN, str)) return SRV_EN[str];- return SRV_EN_PARTS.reduce((acc, [a, b]) => (typeof a === 'string' ? acc.split(a).join(b) : acc.replace(a, b)), str);- }- function apply(root = document) {- root.querySelectorAll('[data-i18n]').forEach((el) => { el.textContent = t(el.dataset.i18n); });- root.querySelectorAll('[data-i18n-placeholder]').forEach((el) => { el.placeholder = t(el.dataset.i18nPlaceholder); });- root.querySelectorAll('[data-i18n-aria]').forEach((el) => { el.setAttribute('aria-label', t(el.dataset.i18nAria)); });- root.querySelectorAll('[data-i18n-title]').forEach((el) => { el.title = t(el.dataset.i18nTitle); });- }- function syncSwitch() {- document.querySelectorAll('[data-lang]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.lang === lang)));- }- function set(next) {- if (next !== 'vi' && next !== 'en') return;- const changed = next !== lang;- lang = next;- try { localStorage.setItem(KEY, lang); } catch { /* bỏ qua */ }- document.documentElement.lang = lang;- apply();- syncSwitch();- if (changed) window.dispatchEvent(new CustomEvent('lumreels:lang', { detail: { lang } }));- }-- window.I18N = {- t, srv, set, apply,- get lang() { return lang; },- /** Locale cho toLocaleString. */- get locale() { return lang === 'vi' ? 'vi-VN' : 'en-GB'; },- };-- document.addEventListener('click', (e) => { const b = e.target.closest?.('[data-lang]'); if (b) set(b.dataset.lang); });- document.documentElement.lang = lang;- apply();- syncSwitch();-})();+// Ngôn ngữ giao diện VI / EN. Chỉ dịch chữ giao diện; tên mẫu, nội dung người dùng, lỗi server giữ nguyên.+// HTML: data-i18n (textContent), data-i18n-placeholder, data-i18n-aria (aria-label).+// JS: window.I18N.t(key, vars) · I18N.lang · I18N.set('vi'|'en') · I18N.srv(chuỗi server) · sự kiện window 'lumreels:lang'.+// Giá trị trong bảng là chuỗi (thay {tên}) hoặc hàm (vars) => chuỗi (dùng cho số nhiều).+(() => {+ const S = (n) => (n === 1 ? '' : 's');+ const vi = {+ 'meta.title': 'LumReels — dựng video dọc từ mẫu',+ 'top.tag': 'Chọn mẫu, dán nội dung, AI dựng cảnh, ra MP4 dọc 1080×1920.',+ 'lang.group': 'Ngôn ngữ giao diện',+ 'lang.vi': 'Tiếng Việt (VI)',+ 'lang.en': 'Tiếng Anh (EN)',++ 'update.hide': 'Ẩn thông báo',+ 'update.text': (v) => `Có ${v.n} cập nhật mới cho LumReels${v.first ? ` (${v.first}${v.n > 1 ? ', …' : ''})` : ''}. Tắt app rồi chạy lại `,+ 'update.after': ' để cập nhật.',++ 'tabs.aria': 'Chế độ',+ 'tabs.tpl': 'Dựng từ mẫu',+ 'tabs.edit': 'Edit video của bạn',+ 'tabs.new': 'MỚI',++ 'pick.h': 'Chọn mẫu',+ 'pick.searchLabel': 'Tìm mẫu theo tên',+ 'pick.searchPh': 'Tìm theo tên, thể loại…',+ 'pick.chipsAria': 'Lọc theo nhóm',+ 'cat.all': 'Tất cả',+ 'cat.faceless': 'Faceless',+ 'cat.ads': 'Quảng cáo',+ 'cat.multi-style': 'Đa phong cách',+ 'cat.viet-nam': 'Việt Nam hoá',+ 'pick.readyOnly': 'Chỉ mẫu dùng được',+ 'pick.multi': 'Chọn nhiều mẫu',+ 'pick.multiHint': 'Bật lên thì bấm mẫu để chọn hoặc bỏ, tối đa 12 mẫu, mỗi mẫu ra 1 video cùng nội dung.',+ 'pick.count': '{ready}/{total} mẫu dùng được',+ 'pick.max': 'Tối đa {max} mẫu mỗi lần dựng. Bỏ bớt 1 mẫu rồi chọn tiếp.',+ 'grid.loading': 'Đang tải mẫu…',+ 'grid.loadErr': 'Không tải được danh sách mẫu. Kiểm tra server rồi tải lại trang.',+ 'grid.empty': 'Không có mẫu khớp. Thử bỏ lọc hoặc đổi từ khoá.',+ 'tpl.aria': (v) => `Mẫu ${v.id}: ${v.name}${v.ready ? '' : ' (chưa có guidance, chưa dùng được)'}${v.order ? `, đã chọn thứ ${v.order}` : ''}`,+ 'tpl.noThumb': 'chưa có ảnh',+ 'tpl.ready': 'Sẵn sàng',+ 'tpl.noGuide': 'Chưa có guidance',+ 'tpl.playDemo': 'Xem video demo mẫu {id}',+ 'tpl.playRef': 'Xem video tham chiếu mẫu {id}',+ // ---- gói mẫu (.lumpack) ----+ 'src.builtin': 'Gốc',+ 'src.local': 'Của tôi',+ 'src.pack': 'Cộng đồng',+ 'grid.emptySrc.local': 'Chưa có mẫu "Của tôi". Mẫu tự tạo hoặc nhập từ gói của bạn sẽ hiện ở đây.',+ 'grid.emptySrc.pack': 'Chưa cài gói cộng đồng nào.',+ 'pack.importBtn': 'Nhập gói',+ 'pack.mineBtn': 'Gói của tôi',+ 'pack.lockedNote': 'Mẫu ngoài chạy ở chế độ khoá: AI chỉ đọc/ghi trong thư mục của video này.',+ 'kind.template': 'Mẫu dựng',+ 'kind.edit-style': 'Cách dựng Edit',+ 'prov.original': 'Tự sáng tác',+ 'prov.own-video': 'Học từ video của chính tác giả',+ 'prov.style-study': 'Học phong cách từ video khác',+ 'pk.title': 'Nhập gói mẫu',+ 'pk.close': 'Đóng',+ 'pk.dropBig': 'Chọn file .lumpack',+ 'pk.dropSmall': 'hoặc kéo thả vào đây · tối đa 12 MB · xem trước rồi mới cài',+ 'pk.reading': 'Đang đọc và kiểm gói…',+ 'pk.restricted': 'Mẫu cộng đồng chạy ở chế độ khoá: AI chỉ đọc/ghi trong thư mục của video này.',+ 'pk.noName': '(không tên)',+ 'pk.author': 'Tác giả',+ 'pk.contact': 'Liên hệ',+ 'pk.license': 'Giấy phép',+ 'pk.provenance': 'Nguồn gốc',+ 'pk.id': 'Mã gói',+ 'pk.engine': 'Cần LumReels',+ 'pk.items': 'Số mục',+ 'pk.sha': 'Mã kiểm (sha256)',+ 'pk.warnHead': (v) => `${v.n} mục có chữ cần đọc kỹ (tô vàng bên dưới). Chữ này không bị chặn, nhưng nên đọc trước khi cài.`,+ 'pk.warnItem': 'cần đọc kỹ',+ 'pk.showText': 'Xem nguyên văn',+ 'pk.err.not-pack': 'File này không phải gói LumReels (.lumpack).',+ 'pk.err.tooBig': 'File lớn hơn 12 MB.',+ 'pk.err.engine': 'Gói này cần bản LumReels mới hơn. Cập nhật app rồi nhập lại.',+ 'pk.err.rejected': 'Gói bị từ chối: nội dung không an toàn hoặc sai định dạng.',+ 'pk.err.first': 'Lý do đầu tiên: {e}',+ 'pk.err.more': 'Xem tất cả lỗi ({n})',+ 'pk.err.expired': 'Bản xem trước đã hết hạn (10 phút). Chọn lại file.',+ 'pk.err.net': 'Không gửi được tới app. Kiểm tra app còn chạy rồi thử lại.',+ 'pk.st.installed': 'Gói này (bản {v}) đã cài rồi.',+ 'pk.st.conflict': 'Đã cài {id} bản {v}, nhưng nội dung khác bản này: không cài đè được.',+ 'pk.st.older': 'Máy đang có bản mới hơn ({v}).',+ 'pk.st.upgrade': 'Máy đang có bản {v}.',+ 'pk.replace': 'Thay bằng bản {v}',+ 'pk.cancel': 'Huỷ',+ 'pk.other': 'Chọn file khác',+ 'pk.install': 'Cài',+ 'pk.installing': 'Đang cài…',+ 'pk.done': (v) => `Đã cài "${v.name}": ${v.n} mục. Mẫu hiện trong lưới với nhãn Cộng đồng.`,+ 'pk.showGrid': 'Xem trong lưới',+ 'mp.title': 'Gói của tôi',+ 'mp.loading': 'Đang tải…',+ 'mp.loadErr': 'Không tải được danh sách gói.',+ 'mp.retry': 'Thử lại',+ 'mp.empty': 'Chưa cài gói nào. Bấm Nhập gói để thêm mẫu từ file .lumpack.',+ 'mp.items': '{n} mục',+ 'mp.view': 'Xem',+ 'mp.hide': 'Ẩn',+ 'mp.verified': 'Đã duyệt',+ 'mp.remove': 'Gỡ',+ 'mp.removeQ': 'Gỡ gói "{name}"? Video đã dựng bằng gói này vẫn giữ nguyên.',+ 'mp.removeYes': 'Gỡ gói',+ 'mp.removed': 'Đã gỡ "{name}".',+ 'mp.deleted': 'Đã xoá "{name}".',+ 'mp.delItem': 'Xoá',+ 'mp.delItemQ': 'Xoá "{name}" khỏi mẫu của tôi? Không lấy lại được.',+ 'mp.export': 'Xuất gói',+ 'ex.title': 'Xuất mẫu "Của tôi" ra file .lumpack',+ 'ex.none': 'Chưa có mẫu "Của tôi" để xuất. Mẫu tự tạo (nút Tạo mẫu, sắp có) sẽ hiện ở đây.',+ 'ex.pick': 'Chọn mục',+ 'ex.name': 'Tên gói',+ 'ex.id': 'Mã gói',+ 'ex.idHint': 'Dạng tac-gia.ten-goi: chữ thường không dấu, số, gạch nối. Tự điền theo tác giả + tên.',+ 'ex.author': 'Tác giả',+ 'ex.contact': 'Liên hệ (không bắt buộc)',+ 'ex.license': 'Giấy phép',+ 'ex.version': 'Phiên bản',+ 'ex.go': 'Tải file .lumpack',+ 'ex.busy': 'Đang xuất…',+ 'ex.ok': 'Đã xuất {file} ({kb}).',+ 'ex.err.items': 'Chọn ít nhất 1 mục để xuất.',+ 'ex.err.name': 'Điền tên gói.',+ 'ex.err.author': 'Điền tên tác giả.',+ 'ex.err.id': 'Mã gói phải dạng tac-gia.ten-goi, mỗi nửa 2–24 ký tự.',+ 'ex.err.ver': 'Phiên bản phải dạng 1.0.0.',+ 'ex.err.reserved': 'Tên tác giả này dành riêng cho LumReels. Đổi phần trước dấu chấm của mã gói.',++ 'picked.none': 'Chưa chọn mẫu. Bấm 1 mẫu sáng màu bên trái.',+ 'picked.noneMulti': 'Đang chọn nhiều: bấm các mẫu sáng màu bên trái (tối đa {max}), mỗi mẫu ra 1 video.',+ 'picked.count': 'Đã chọn {n} mẫu',+ 'picked.clear': 'Bỏ chọn hết',+ 'picked.strip': 'Các mẫu đã chọn',+ 'picked.remove': 'Bỏ mẫu {id}: {name}',++ 'viewer.aria': 'Video minh hoạ của mẫu',+ 'viewer.close': 'Đóng',+ 'viewer.demo': 'Video demo dựng bằng LumReels. ',+ 'viewer.ref': 'Video tham chiếu trên máy mày (không có trong repo). ',++ 'compose.h': 'Nội dung',+ 'compose.label': 'Nội dung video',+ 'compose.ph': 'Ví dụ: Mỗi tháng bỏ 3 triệu vào quỹ chỉ số, lãi giả định 10%/năm, sau 20 năm có bao nhiêu? Kênh: Lumfin. CTA: Theo dõi để biết thêm mẹo tiền',+ 'compose.charsTail': '/4000 ký tự · ghi luôn tên kênh và CTA nếu có',+ 'rw.btn': 'Viết lại kịch bản',+ 'rw.btnBusy': 'Đang viết lại',+ 'rw.hint': 'Viết lại kịch bản: AI xếp nội dung vào đúng ô của mẫu đang chọn và thời lượng bên dưới, giữ nguyên số liệu, tên kênh, CTA.',+ 'rw.hintMany': 'Viết lại kịch bản tắt vì đang chọn {n} mẫu: mỗi mẫu có ô nội dung khác nhau. Muốn AI viết lại thì chọn 1 mẫu; còn không, cả {n} video dùng chung nội dung đang gõ.',+ 'rw.busy': 'Đang viết lại…',+ 'rw.needOne': 'Chọn 1 mẫu trước',+ 'rw.onlyOne': 'Chỉ viết lại được khi chọn 1 mẫu',+ 'rw.needText': 'Gõ nội dung trước (tối thiểu 10 ký tự)',+ 'rw.loading': 'Đang viết lại cho mẫu {id} · {d}… (thường 20–60 giây)',+ 'rw.title': 'Bản viết lại · mẫu {id} · {d}',+ 'rw.fallback': 'Đã chuyển sang Claude Code vì {why}.',+ 'rw.use': 'Dùng bản này',+ 'rw.drop': 'Bỏ',+ 'rw.timeout': 'Quá 100 giây chưa xong, đã dừng chờ. Bấm lại thử.',+ 'rw.replaced': 'Đã thay nội dung bằng bản viết lại.',+ 'rw.undo': 'Hoàn tác',+ 'rw.close': 'Đóng',+ 'err.status': 'Lỗi {s}',++ 'dur.label': 'Thời lượng',+ 'dur.range': '(3 giây – 10 phút)',+ 'dur.presets': 'Chọn nhanh thời lượng',+ 'dur.hint': 'Gõ số giây (90) hoặc phút:giây (1:30).',+ 'dur.errEmpty': 'Nhập thời lượng, vd 8 hoặc 1:30',+ 'dur.errFmt': 'Gõ số giây (90) hoặc phút:giây (1:30)',+ 'dur.errMin': 'Ngắn nhất 3 giây',+ 'dur.errMax': 'Dài nhất 10 phút (10:00)',+ 'dur.eqLong': '= {s} giây ({f}).',+ 'dur.eq': '= {s} giây. Gõ số giây (90) hoặc phút:giây (1:30).',+ 'dur.warn': 'Video dài {f}: render ước tính {range} (đo thực tế: video 8 giây mất 20–60 giây render), chưa tính lúc AI viết cảnh. AI phải viết khoảng {scenes} cảnh nối nhau nên tốn token và chi phí hơn hẳn video 8 giây.',+ 'unit.sec': 'giây',+ 'unit.min': 'phút',+ 'unit.hour': 'giờ',+ 'num.dec': ',',++ 'audio.aria': 'Âm thanh',+ 'mode.label': 'Ai dựng cảnh',+ 'mode.auto': 'Tự động',+ 'mode.manual': 'Agent ngoài',+ 'modeLabel.auto': 'tự động',+ 'modeLabel.manual': 'agent ngoài',+ 'mode.hintAuto': 'Tự động: đang dùng {m}.',+ 'mode.hintApi': 'Gọi Claude API bằng khoá trong .env (tốn tiền theo token, ghi chi phí vào job).',+ 'mode.hintClaude': 'Chạy Claude Code trên máy này (dùng gói Claude của mày).',+ 'mode.hintManual': 'Chỉ tạo đề bài; agent bên ngoài (MCP/CLI) viết cảnh rồi gọi render.',+ 'mode.hintExport': ' Xong sẽ chép MP4 ra thư mục xuất.',+ 'model.label': 'Model viết cảnh',+ 'model.auto': 'Tự chọn theo mẫu',+ 'model.autoRec': 'Tự chọn theo mẫu ({m})',+ 'model.autoMany': 'Tự chọn theo từng mẫu',+ 'model.opus': 'Opus (đẹp nhất, tốn nhất)',+ 'model.sonnet': 'Sonnet (cân bằng)',+ 'model.haiku': 'Haiku (rẻ nhất)',+ 'model.rec': (v) => `Mẫu này ${v.heavy ? 'dựng 3D/shader' : 'là 2D'} → đề xuất ${v.m}.`,+ 'model.pickFirst': 'Chọn mẫu để xem đề xuất.',+ 'model.haikuWarn': ' Haiku hay làm phẳng cảnh 3D, nên dùng Opus.',+ 'model.override': ' (đang chọn {m} thay vì đề xuất)',+ 'model.agentNote': ' Agent ngoài thì model do agent đó quyết.',+ 'model.manyLight': '{n} mẫu 2D → {m}',+ 'model.manyHeavy': '{n} mẫu 3D/shader → {m}',+ 'model.manyAuto': 'Mỗi video tự chọn theo mẫu: {parts}.',+ 'model.manyFixed': 'Cả {n} video dùng {m} (đề xuất: {parts}).',+ 'model.haikuWarnMany': ' Haiku hay làm phẳng cảnh 3D, nên dùng Opus cho mẫu 3D.',+ 'runAt.label': 'Hẹn giờ dựng',+ 'runAt.opt': '(bỏ trống = dựng ngay)',+ 'runAt.clear': 'Bỏ hẹn',+ 'runAt.clearAria': 'Bỏ hẹn giờ',+ 'go.build': (v) => (v.n > 1 ? `Dựng ${v.n} video` : 'Dựng video'),+ 'go.schedule': (v) => (v.n > 1 ? `Hẹn dựng ${v.n} video` : 'Hẹn dựng video'),+ 'go.sending': 'Đang gửi',+ 'go.needTpl': 'Chọn mẫu trước',+ 'go.needText': 'Nội dung tối thiểu 10 ký tự',+ 'go.badDur': 'Thời lượng chưa đúng',+ 'form.jobErr': 'Tạo job lỗi',+ 'form.retry': '. Sửa rồi bấm lại.',++ 'jobs.h': 'Video đã dựng',+ 'jobs.empty': 'Chưa có video nào. Chọn mẫu, dán nội dung rồi bấm <b>Dựng video</b>.',+ 'jobs.less': 'Thu gọn',+ 'jobs.more': 'Xem thêm ({n} video cũ hơn)',+ 'st.scheduled': 'Đã hẹn',+ 'st.queued': 'Đang chờ',+ 'st.generating': 'AI đang viết cảnh',+ 'st.waiting_agent': 'Chờ agent viết cảnh',+ 'st.previewing': 'Đang dựng preview',+ 'st.rendering': 'Đang render',+ 'st.done': 'Xong',+ 'st.error': 'Lỗi',+ 'job.previewAlt': 'Preview 16 khung',+ 'job.building': 'Đang dựng…',+ 'job.waitScene': 'Chờ cảnh',+ 'job.noImage': 'Chưa có hình',+ 'job.tpl': 'Mẫu {id} · {name}',+ 'job.at': 'Hẹn dựng lúc {t}',+ 'job.api': 'API: {i}k vào · {o}k ra · ≈ ${c}',+ 'job.exported': 'Đã chép ra: {p}',+ 'job.errUnknown': 'Lỗi không rõ',+ 'job.errTail': '. Xem log, sửa cảnh rồi bấm Render lại.',+ 'job.agent': 'Agent đọc: {prompt}\nViết: {scene}\nRồi chạy: node cli.mjs render {id}',+ 'job.mp4': 'Tải MP4',+ 'job.preview': 'Preview 16 khung',+ 'job.rerender': 'Render lại',+ 'job.render': 'Render',+ 'job.log': 'Log ({n} dòng)',++ 'ap.title': 'Âm thanh',+ 'ap.loadingOpts': 'Đang tải lựa chọn…',+ 'ap.stop': 'Dừng nghe thử',+ 'ap.making': 'Đang tạo bản nghe thử',+ 'ap.voiceLoading': 'Đang tạo giọng mẫu… (lần đầu nạp mô hình có thể mất vài phút)',+ 'ap.prevFail': 'không tạo được bản nghe thử',+ 'ap.prevErr': 'Nghe thử lỗi: ',+ 'ap.keep': 'Giữ như hiện tại',+ 'ap.music': 'Nhạc nền',+ 'ap.musicPrev': 'Nghe thử nhạc nền',+ 'ap.voice': 'Giọng đọc',+ 'ap.voicePrev': 'Nghe thử giọng đọc',+ 'ap.sfx': 'Tiếng động gắn theo chuyển động',+ 'ap.pickMusic': 'Chọn 1 kiểu nhạc cụ thể để nghe thử.',+ 'ap.pickVoice': 'Chọn 1 giọng cụ thể để nghe thử.',+ 'ap.vAuto': 'giọng theo mẫu',+ 'ap.vNone': 'không lời',+ 'ap.versions': 'Các bản ({n})',+ 'ap.ver': 'Bản {n}',+ 'ap.latest': ' · mới nhất',+ 'ap.noSfx': ' · không sfx',+ 'ap.view': 'Xem',+ 'ap.dl': 'Tải',+ 'ap.mix': 'Trộn tiếng mới',+ 'ap.mixNote': 'Không dựng lại hình. Bản cũ được giữ lại; chọn giọng mà video chưa có lời thì AI viết lời ngắn.',+ 'ap.lastErr': 'Lần trộn trước lỗi: ',+ 'ap.mixing': 'Đang trộn tiếng…',+ 'ap.mixingNote': 'Đang trộn (giọng VieNeu có thể mất vài phút)…',+ 'ap.err': 'Lỗi: ',+ 'ap.unknown': 'không rõ',+ 'ap.done': 'Xong — đang phát bản mới nhất.',+ 'ap.summary': 'Âm thanh · đổi nhạc, giọng đọc',+ 'ap.loading': 'Đang tải…',+ 'ap.mixFail': 'Không trộn được: ',+ 'ap.errShort': 'lỗi',+ 'vc.title': 'Giọng của tôi',+ 'vc.optTag': 'giọng nhân bản',+ 'vc.add': '+ Thêm giọng',+ 'vc.loading': 'Đang tải giọng của bạn…',+ 'vc.loadErr': 'Không tải được danh sách giọng.',+ 'vc.retry': 'Thử lại',+ 'vc.empty': 'Chưa có giọng nào. Tải lên hoặc thu 10 giây – 3 phút giọng nói, app học giọng rồi đọc lời video bằng chính giọng đó.',+ 'vc.needVieneu': 'Cần VieNeu-TTS trên máy để nhân bản giọng: pip install vieneu',+ 'vc.ready': 'Sẵn sàng',+ 'vc.error': 'Lỗi',+ 'vc.step.queued': 'Đang chờ…',+ 'vc.step.transcribe': 'Đang chép lời đoạn mẫu…',+ 'vc.step.encode': 'Đang học giọng + đọc thử…',+ 'vc.play': 'Nghe thử giọng {name}',+ 'vc.stop': 'Dừng nghe',+ 'vc.rename': 'Đổi tên giọng {name}',+ 'vc.delete': 'Xoá giọng {name}',+ 'vc.newName': 'Tên mới',+ 'vc.save': 'Lưu',+ 'vc.cancel': 'Huỷ',+ 'vc.refSum': 'Đoạn mẫu app đã chọn',+ 'vc.refText': 'Lời của đoạn mẫu',+ 'vc.byWhisper': '(máy tự chép, sửa nếu sai)',+ 'vc.refTextPh': 'Gõ đúng những gì bạn nói trong đoạn mẫu',+ 'vc.refTextHint': 'Không bắt buộc với VieNeu v3 Turbo; giúp nhận ra đoạn mẫu nói gì.',+ 'vc.saveText': 'Lưu lời',+ 'vc.noWhisper': 'Máy chưa có whisper nên chưa chép được lời đoạn mẫu. Mở "Đoạn mẫu" để nghe và gõ lời (không bắt buộc).',+ 'vc.srcAria': 'Lấy giọng từ',+ 'vc.srcFile': 'Chọn file',+ 'vc.srcRec': 'Thu âm',+ 'vc.fileLabel': 'File âm thanh giọng nói',+ 'vc.fileHint': 'wav, mp3, m4a, ogg hoặc webm · 10 giây – 3 phút · tối đa {max} MB · chỉ 1 người nói, ít tạp âm.',+ 'vc.readTip': 'Gợi ý: đọc to đoạn này, tự nhiên như đang nói chuyện',+ 'vc.readText': 'Hôm nay mình muốn kể cho bạn nghe một chuyện nhỏ. Sáng nào mình cũng dậy sớm, pha một ly cà phê, mở cửa sổ và nghe phố xá bắt đầu nhộn nhịp. Có hôm trời mưa, có hôm nắng gắt, nhưng mình vẫn giữ thói quen đó. Một, hai, ba, bốn, năm: thói quen nhỏ, kết quả lớn.',+ 'vc.recStart': 'Bắt đầu thu',+ 'vc.recAgain': 'Thu lại',+ 'vc.recStop': 'Dừng',+ 'vc.recHint': 'Thu ở chỗ yên tĩnh, cách micro một gang tay, ít nhất 20 giây. Tự dừng sau 3 phút.',+ 'vc.recFile': 'thu-am',+ 'vc.nameLabel': 'Tên giọng',+ 'vc.namePh': 'Ví dụ: Giọng Nam',+ 'vc.consent': 'Đây là giọng của tôi, hoặc tôi được người đó cho phép dùng',+ 'vc.langNote': 'Giọng nhân bản đọc tiếng Việt. Chọn giọng này cho nội dung tiếng Anh thì lời đọc được viết bằng tiếng Việt.',+ 'vc.create': 'Tạo giọng',+ 'vc.sending': 'Đang gửi… {pct}%',+ 'vc.processing': 'Đã nhận giọng {name}. Đang học giọng, khoảng 1 phút.',+ 'vc.readyNote': 'Giọng {name} đã sẵn sàng và được chọn làm giọng đọc. Bấm nút phát để nghe thử.',+ 'vc.errNoFile': 'Chọn 1 file âm thanh.',+ 'vc.errNoRec': 'Thu âm trước đã.',+ 'vc.errExt': 'Định dạng chưa hỗ trợ. Dùng wav, mp3, m4a, ogg hoặc webm.',+ 'vc.errBig': 'File quá lớn (tối đa {max} MB).',+ 'vc.errShort': 'Ngắn quá ({s} giây). Cần ít nhất 10 giây.',+ 'vc.errLong': 'Dài quá 3 phút. Cắt bớt rồi thử lại.',+ 'vc.errName': 'Đặt tên cho giọng.',+ 'vc.errNameLong': 'Tên tối đa {max} ký tự.',+ 'vc.errConsent': 'Tick xác nhận để tiếp tục.',+ 'vc.errNoMic': 'Trình duyệt này không thu âm được. Chọn file thay thế.',+ 'vc.errMicDenied': 'Chưa được dùng micro. Cho phép micro trong trình duyệt rồi thử lại.',+ 'vc.errUpload': 'Gửi không được. Kiểm tra app còn chạy rồi thử lại.',+ 'vc.errDel': 'Không xoá được giọng.',+ 'vc.errSave': 'Không lưu được.',+ 'vc.confirmDel': 'Xoá giọng "{name}"? File giọng trên máy bị xoá hẳn, không khôi phục được.',+ 'vc.deleted': 'Đã xoá giọng {name}.',+ 'vc.renamed': 'Đã đổi tên thành {name}.',+ 'vc.textSaved': 'Đã lưu lời đoạn mẫu.',++ 'ed.aria': 'Edit video của bạn',+ 'ed.setupH': 'Chưa cài phần Edit video',+ 'ed.noServer': 'Không gọi được server.',+ 'ed.h': 'Video của bạn',+ 'ed.dropAria': 'Chọn hoặc kéo thả video',+ 'ed.dropBig': 'Kéo thả video vào đây',+ 'ed.dropSmall': 'hoặc bấm để chọn · mp4, mov, mkv… tối đa 2 GB · nói trước máy, tiếng Việt',+ 'ed.fileLabel': 'File video',+ 'ed.style': 'Kiểu edit',+ 'ed.music': 'Nhạc nền',+ 'ed.musicOpt': '(tự hạ khi bạn nói)',+ 'ed.noMusic': 'Không nhạc',+ 'ed.musicSynth': 'Nhạc tổng hợp: {id} — {desc}',+ 'ed.musicFile': 'Tải file nhạc của tôi…',+ 'ed.musicFileLabel': 'File nhạc',+ 'ed.names': 'Tên riêng, thuật ngữ',+ 'ed.namesOpt': '(để AI viết phụ đề đúng)',+ 'ed.namesPh': 'Ví dụ: Lumfin, Hà Nội, ETF',+ 'ed.notes': 'Dặn thêm',+ 'ed.notesOpt': '(không bắt buộc)',+ 'ed.notesPh': 'Ví dụ: bỏ câu chào đầu, giữ đoạn cuối kêu gọi theo dõi',+ 'ed.draft': 'Bản nháp nhanh (phụ đề đơn giản, nhanh hơn ~1 phút)',+ 'ed.go': 'Dựng',+ 'ed.empty': 'Chọn video bên trái rồi bấm Dựng.',+ 'ed.steps': 'Các bước',+ 'ed.fixesH': 'Chữ AI đã sửa trong phụ đề, xem lại giúp',+ 'ed.reviseH': 'Sửa bằng lời',+ 'ed.reviseLabel': 'Lời sửa',+ 'ed.revisePh': 'Ví dụ: "bỏ 3 giây đầu", "zoom ít lại"',+ 'ed.reviseBtn': 'Render lại',+ 'ed.p1': 'bỏ 3 giây đầu',+ 'ed.p2': 'zoom ít lại',+ 'ed.p3': 'nhạc nhỏ lại',+ 'ed.p4': 'phụ đề 2 chữ một lần',+ 'ed.histH': 'Các lần sửa',+ 'ed.log': 'Nhật ký',+ 'ed.delete': 'Xoá bản dựng này',+ 'ed.listH': 'Các bản đã dựng',+ 'ed.st.queued': 'Đang chờ',+ 'ed.st.running': 'Đang dựng',+ 'ed.st.done': 'Xong',+ 'ed.st.error': 'Lỗi',+ 'ed.waitTurn': 'Đang chờ lượt',+ 'ed.revising': 'Đang sửa',+ 'ed.notVideo': 'File này không phải video (mp4, mov, mkv, webm…).',+ 'ed.tooBig': 'Video {size} quá lớn (tối đa 2 GB).',+ 'ed.changeFile': '{size} · bấm để đổi file',+ 'ed.needMusic': 'Chọn file nhạc, hoặc đổi sang "Không nhạc".',+ 'ed.uploading': 'Đang tải lên {p}%',+ 'ed.uploadCut': 'Tải lên bị ngắt. Kiểm tra server rồi thử lại.',+ 'ed.listEmpty': 'Chưa có bản nào.',+ 'ed.err': 'Lỗi',+ 'ed.reviseErr': 'Sửa chưa được: {e}',+ 'ed.previewAlt': 'Lưới khung xem trước',+ 'ed.mediaEmpty': 'Video sẽ hiện ở đây khi dựng xong',+ 'ed.mp4': 'Tải MP4',+ 'ed.gridOut': 'Lưới khung bản ra',+ 'ed.hidden': '(ẩn khỏi phụ đề)',+ 'ed.checksEdl': '{out} s · bỏ {rm} s · {z} zoom',+ 'ed.overcut': 'lẹm chữ: {v}',+ 'ed.noOvercut': 'không lẹm chữ',+ 'ed.sendFail': 'Không gửi được lời sửa.',+ 'ed.confirmDel': 'Xoá hẳn bản dựng này (video ra, EDL, file đã tải lên)? Không lấy lại được.',+ 'man.h': 'Chỉnh tay',+ 'man.tabCap': 'Phụ đề',+ 'man.tabAud': 'Nhạc & tiếng',+ 'man.tabFx': 'Zoom & đồ hoạ',+ 'man.look': 'Kiểu chữ',+ 'man.hi': 'Chữ nhấn (chữ trong *sao* đổi màu)',+ 'man.capHint': 'Bấm mốc giờ để video nhảy tới dòng đó. Bọc *chữ* để nhấn.',+ 'man.draftNote': 'Bản nháp vẽ phụ đề thẳng vào nền nên chưa sửa tay được. Bỏ "nháp" rồi dựng lại.',+ 'man.music': 'Nhạc',+ 'man.musicKeep': 'Giữ nhạc đang dùng ({name})',+ 'man.synth': 'Nhạc tổng hợp: {id}',+ 'man.uploaded': 'Đã tải: {name}',+ 'man.uploading': 'Đang tải {name} ({size})…',+ 'man.uploadOk': 'Đã tải lên {name}. Bấm Áp dụng để trộn lại tiếng.',+ 'man.uploadErr': 'Tải nhạc chưa được: {e}',+ 'man.musicGain': 'Âm lượng nhạc',+ 'man.duck': 'Ducking: nhạc nhỏ lại khi có tiếng nói',+ 'man.fade': 'Fade out cuối',+ 'man.start': 'Nhạc bắt đầu từ giây',+ 'man.voice': 'Âm lượng giọng (so với nhạc)',+ 'man.loudHint': 'Cả bản luôn chuẩn về −14 LUFS: tăng giọng tức là nhạc và tiếng động nhỏ đi tương đối.',+ 'man.sfx': (v) => `Tiếng động${v.n ? ` · ${v.n}` : ' · không có'}`,+ 'man.zooms': 'Zoom',+ 'man.gfx': 'Đồ hoạ',+ 'man.zoomKind': (v) => `${v.kind === 'punch' ? 'Zoom giật' : 'Zoom đẩy'} ×${v.scale}`,+ 'man.noZoom': 'Bản này không có zoom.',+ 'man.noGfx': 'Bản này không có đồ hoạ.',+ 'man.noLines': 'Bản này không có phụ đề.',+ 'man.remove': 'Xoá',+ 'man.undo': 'Giữ lại',+ 'man.removeN': 'Xoá {what}',+ 'man.undoN': 'Giữ lại {what}',+ 'man.jump': 'Nhảy tới giây {s}',+ 'man.lineText': 'Chữ dòng {n}',+ 'man.lineStart': 'Giây bắt đầu dòng {n}',+ 'man.lineEnd': 'Giây kết thúc dòng {n}',+ 'man.split': 'Tách',+ 'man.merge': 'Gộp ↓',+ 'man.splitN': 'Tách dòng {n} làm đôi',+ 'man.mergeN': 'Gộp dòng {n} với dòng sau',+ 'man.delN': 'Xoá dòng {n}',+ 'man.cantSplit': 'Dòng chỉ có 1 chữ, không tách được.',+ 'man.errShort': 'Dòng phải dài ít nhất 0,1 giây (kết thúc sau bắt đầu).',+ 'man.errAfter': 'Bắt đầu sau cuối video ({d} s).',+ 'man.errOverlap': 'Đè lên dòng trước: dời giờ bắt đầu ra sau.',+ 'man.errEmpty': 'Dòng trống: gõ chữ hoặc xoá dòng.',+ 'man.fixFirst': (v) => `Sửa ${v.n} dòng báo đỏ trước khi áp dụng.`,+ 'man.dirty': (v) => `${v.n} thay đổi · dựng lại: ${v.what}`,+ 'man.clean': 'Chưa có thay đổi.',+ 'man.wCap': 'lớp chữ',+ 'man.wAud': 'tiếng',+ 'man.wBase': 'nền',+ 'man.reset': 'Bỏ thay đổi',+ 'man.apply': 'Áp dụng',+ 'man.applying': 'Đang dựng…',+ 'man.running': 'Đang dựng bản chỉnh tay',+ 'man.loadErr': 'Không tải được phần chỉnh tay: {e}',+ 'man.sendFail': 'Không gửi được phần chỉnh tay.',+ 'man.tag': 'Chỉnh tay',+ 'man.took': 'dựng {s} giây',+ 'man.watch': 'Xem',+ 'man.original': 'Bản đầu tiên',+ 'ed.styleHint': '{n} kiểu · cuộn để xem hết',+ 'ed.styleAria': (v) => `${v.name}: ${v.summary}`,+ 'ed.setupText': 'Phần Edit video cần thêm Python, model chép lời và model nhận mặt. Bấm Cài ngay, LumReels tự cài hết (chỉ làm một lần).',+ 'ed.install': 'Cài ngay',+ 'ed.installing': 'Đang cài…',+ 'ed.installStep': '{step}… ({t})',+ 'ed.installStepDefault': 'Đang cài',+ 'ed.installDone': 'Cài xong sau {t}. Edit video đã sẵn sàng.',+ 'ed.installRetry': 'Cài lại',+ 'ed.installFail': 'Cài chưa xong. Xem chi tiết bên dưới rồi bấm Cài lại.',+ 'ed.installCantStart': 'Không bắt đầu cài được: {e}',+ 'ed.installNote': 'Tải khoảng 6 GB, mất 5–20 phút tuỳ mạng. Cứ để trang mở.',+ 'ed.installDetails': 'Xem chi tiết',+ 'ed.installManual': 'Hoặc tự cài bằng lệnh',+ 'ed.fail.NEED_PYTHON': 'Máy chưa có Python 3.10–3.12. Cài theo hướng dẫn dưới rồi bấm Cài lại.',+ 'ed.fail.NEED_FFMPEG': 'Máy chưa có ffmpeg. Cài theo hướng dẫn dưới rồi bấm Cài lại.',+ 'ed.fail.NEED_NETWORK': 'Tải bị lỗi, kiểm tra mạng rồi bấm Cài lại (phần đã tải xong không phải tải lại).',+ 'ed.fail.NEED_NPM': 'Thiếu font của LumReels: chạy npm install ở thư mục LumReels rồi bấm Cài lại.',+ 'ed.figuresH': 'Số máy nghe không chắc, chưa đưa lên đồ hoạ, nghe lại giúp',+ 'ed.figAt': '{s} s nguồn',+ 'ed.figHeard': 'nghe lại: “{h}”',+ 'ed.more': 'Thêm',+ 'ed.review': (v) => `Cần xem lại (${v.n})`,+ 'ed.revFixes': 'Chữ AI sửa',+ 'ed.revFigs': 'Số chưa chắc',+ 'ed.specs': 'Thông số',+ 'ed.stepOf': '{i}/{n} · {step} · {p}%',+ 'ed.revisePhS': 'bỏ 3 giây đầu…',+ 'man.hiShort': 'Chữ nhấn',+ 'man.hiTip': 'Bọc *chữ* để đổi màu',+ 'man.gainS': 'Âm lượng',+ 'man.fadeS': 'Fade cuối',+ 'man.startS': 'Bắt đầu (s)',+ 'man.duckS': 'Tự hạ khi nói',+ 'man.voiceS': 'Giọng',+ 'man.dirtyS': (v) => `${v.n} thay đổi`,+ 'ed.cutRepairs': (v) => `đã sửa ${v.n} vết cắt lẹm chữ`,++ // ---- Tạo mẫu từ video (learn-panel.js) ----+ 'cat.mine': 'Của tôi',+ 'lp.open': 'Tạo mẫu từ video',+ 'lp.title': 'Tạo mẫu từ video',+ 'lp.lead': 'Đưa 1 video trên máy, AI học phong cách dựng (màu, bố cục, nhịp, chuyển động), dựng thử 1 bản với nội dung khác, rồi bạn xem và lưu thành mẫu của mình.',+ 'lp.back': 'Quay lại',+ 'lp.close': 'Đóng',+ 'lp.loadErr': 'Không tải được nháp. Thử lại sau.',+ 'lp.noDrafts': 'Chưa có nháp nào.',+ 'lp.new': 'Tạo từ video mới',+ 'lp.drop': 'Kéo thả video vào đây',+ 'lp.dropHint': 'hoặc bấm để chọn · mp4, mov, webm · 4 giây – 3 phút · tối đa 200 MB',+ 'lp.change': 'Đổi video',+ 'lp.refVideo': 'Video tham khảo',+ 'lp.from': 'Học đoạn 8 giây nào',+ 'lp.seg': '{a}–{b} s',+ 'lp.fromHint': 'Chọn đoạn có phong cách rõ nhất. Video đang phát lặp đúng đoạn này.',+ 'lp.name': 'Tên mẫu',+ 'lp.optional': '(không bắt buộc)',+ 'lp.namePh': 'Ví dụ: Thẻ bài giấy cũ',+ 'lp.cat': 'Nhóm',+ 'lp.catAuto': 'Để AI chọn',+ 'lp.note': 'Đây là video gì',+ 'lp.notePh': 'Ví dụ: video giới thiệu món ăn, chữ to, cắt nhanh',+ 'lp.rulesH': 'Học phong cách, không chép',+ 'lp.rule1': 'Chỉ học màu, bố cục, nhịp, kiểu chuyển động, kiểu chữ gần nhất trong font mở.',+ 'lp.rule2': 'Chữ, tên kênh, logo, nhân vật nhìn thấy trong video được gỡ khỏi mẫu bằng máy.',+ 'lp.rule3': 'Video tham khảo chỉ nằm trên máy này, bị xoá khi bạn Lưu hoặc Bỏ. Ảnh đại diện lấy từ bản dựng thử.',+ 'lp.consent': 'Video này của tôi, hoặc tôi chỉ dùng nó để học phong cách dựng. Tôi không sao chép nhân vật, logo, nhạc hay hình ảnh của người khác.',+ 'lp.needConsent': 'Tick ô xác nhận để bắt đầu',+ 'lp.skipTest': 'Bỏ dựng thử (nhanh và rẻ hơn, nhưng chưa biết mẫu có ra hình đúng không)',+ 'lp.est': 'Khoảng 7–13 phút, chi phí AI khoảng 1–2,5 USD theo giá API (có dựng thử 1 video 8 giây).',+ 'lp.estNoTest': 'Khoảng 2–3 phút, chi phí AI khoảng 0,2–0,4 USD theo giá API. Nháp sẽ ghi "chưa dựng thử".',+ 'lp.go': 'Bắt đầu',+ 'lp.uploading': 'Đang tải video lên',+ 'lp.uploadingPct': 'Đang tải lên {p}%',+ 'lp.started': 'Đã nhận video, đang đo.',+ 'lp.err.ext': 'Định dạng này chưa hỗ trợ. Dùng mp4, mov hoặc webm.',+ 'lp.err.big': 'Video quá nặng (tối đa 200 MB).',+ 'lp.err.short': 'Video quá ngắn, cần ít nhất {min} giây.',+ 'lp.err.long': 'Video quá dài, tối đa 3 phút. Cắt bớt rồi thử lại.',+ 'lp.err.upload': 'Không gửi được video. Kiểm tra server rồi thử lại.',+ 'lp.err.run': 'Tạo mẫu bị lỗi.',+ 'lp.st.uploaded': 'Đã nhận',+ 'lp.st.measuring': 'Đang đo',+ 'lp.st.writing': 'AI đang viết',+ 'lp.st.testing': 'Đang dựng thử',+ 'lp.st.comparing': 'Đang so',+ 'lp.st.revising': 'AI đang sửa',+ 'lp.st.ready': 'Sẵn sàng',+ 'lp.st.readyNoTest': 'Sẵn sàng (chưa dựng thử)',+ 'lp.st.error': 'Lỗi',+ 'lp.st.saved': 'Đã lưu',+ 'lp.st.discarded': 'Đã bỏ',+ 'lp.step.measuring': 'Đo video (màu, nhịp, chuyển động)',+ 'lp.step.writing': 'AI viết mẫu theo khuôn',+ 'lp.step.testing': 'Dựng thử 1 video 8 giây',+ 'lp.step.comparing': 'So bản dựng thử với video gốc',+ 'lp.step.revising': 'AI sửa mẫu 1 vòng',+ 'lp.stepNow': '{e} / ~{est}',+ 'lp.stepEst': '~{est}',+ 'lp.progress': 'Tiến độ tạo mẫu',+ 'lp.canClose': 'Có thể đóng hộp này, việc vẫn chạy. Mở lại bằng nút Tạo mẫu từ video.',+ 'lp.draftH': 'Nháp mẫu',+ 'lp.totals': 'Thời gian {t} · chi phí AI {c}',+ 'lp.fromFile': '{f} · đoạn {a}–{b} s',+ 'lp.noRef': 'Video tham khảo đã xoá',+ 'lp.testVideo': 'Bản dựng thử',+ 'lp.notTested': 'Chưa dựng thử',+ 'lp.sheets': 'Xem 16 khung cạnh nhau',+ 'lp.refSheet': 'Gốc',+ 'lp.refSheetAlt': 'Lưới 16 khung của video tham khảo',+ 'lp.testSheet': 'Bản dựng thử',+ 'lp.testSheetAlt': 'Lưới 16 khung của bản dựng thử',+ 'lp.cmpH': (v) => `So số đo: ${v.n}/${v.total} chỉ số lệch quá 25%`,+ 'lp.cmpMetric': 'Chỉ số',+ 'lp.cmpRef': 'Gốc',+ 'lp.cmpTest': 'Dựng thử',+ 'lp.cmpDev': 'Lệch',+ 'lp.off': 'lệch',+ 'lp.near': 'gần',+ 'lp.m.palette': 'Bảng màu chính',+ 'lp.m.brightness': 'Độ sáng',+ 'lp.m.saturation': 'Độ đậm màu',+ 'lp.m.events': 'Phần tử mới mỗi giây',+ 'lp.m.motion': 'Mức chuyển động',+ 'lp.m.cuts': 'Số lần cắt cảnh',+ 'lp.m.still': 'Tỉ lệ đứng im',+ 'lp.diffsH': 'Điểm còn lệch (AI nhìn 2 lưới)',+ 'lp.diffsFixed': 'Điểm lệch AI thấy và đã sửa vào mẫu',+ 'lp.selfH': 'Tự kiểm: {ok}/{n} câu đạt',+ 'lp.yes': 'có',+ 'lp.no': 'không',+ 'lp.guideH': 'Mẫu (guidance)',+ 'lp.guideHint': 'AI dựng cảnh đọc chữ này. Sửa tay được.',+ 'lp.saveText': 'Lưu chỗ sửa',+ 'lp.unsaved': 'Có chỗ sửa chưa lưu',+ 'lp.seenHit': 'còn chữ của video gốc: "{s}"',+ 'lp.textOk': 'Đã lưu chỗ sửa, qua bộ kiểm.',+ 'lp.textBad': 'Đã lưu chỗ sửa, còn lỗi cần sửa trước khi lưu mẫu.',+ 'lp.saveH': 'Lưu thành mẫu "Của tôi"',+ 'lp.saveName': 'Tên mẫu',+ 'lp.slug': 'Mã mẫu',+ 'lp.slugHint': 'Chữ thường không dấu, số, gạch nối. Dùng trong lệnh: make --template local.mine/<mã>',+ 'lp.save': 'Lưu thành mẫu',+ 'lp.retest': 'Dựng thử lại',+ 'lp.discard': 'Bỏ nháp',+ 'lp.discardAsk': 'Bỏ nháp này? Video tham khảo và bản nháp sẽ bị xoá.',+ 'lp.discarded': 'Đã bỏ nháp.',+ 'lp.saveNote': 'Lưu xong, video tham khảo và khung hình bị xoá khỏi máy. Mẫu chạy ở chế độ khoá: AI chỉ đọc/ghi trong thư mục của video đang dựng.',+ 'lp.errNoSave': 'Nháp lỗi ở bước dựng thử: sửa mẫu rồi bấm Dựng thử lại trước khi lưu.',+ 'lp.savedH': 'Đã lưu vào Của tôi',+ 'lp.savedP': 'Mẫu {ref} nằm trong lưới mẫu, lọc "Của tôi". Dựng với nội dung bất kỳ như mẫu gốc.',+ 'lp.useNow': 'Dùng mẫu này',+ // ---- màn tạo mới (studio/create.js) ----+ 'cr.title': 'Dự án mới',+ 'cr.backStep': 'Về bước trước',+ 'cr.stepsAria': 'Các bước',+ 'cr.s1': 'Clip', 'cr.s2': 'Cách dựng', 'cr.s3': 'Dựng',+ 'cr.sideAria': 'Thiết lập bản dựng',+ 'cr.yourClip': 'Clip của bạn',+ 'cr.changeClip': 'Đổi clip',+ 'cr.noClip': 'Chưa chọn clip. Kéo thả video vào ô bên phải.',+ 'cr.musicStyle': 'Theo cách dựng',+ 'cr.musicUpload': 'Tải nhạc',+ 'cr.len': 'Độ dài bản ra',+ 'cr.lenAuto': 'Tự động',+ 'cr.lenAutoOn': 'Đặt độ dài',+ 'cr.lenAutoV': 'Tự động',+ 'cr.lenV': '~{s} giây',+ 'cr.names': 'Tên riêng',+ 'cr.namesWhy': 'để phụ đề viết đúng',+ 'cr.namePh': 'Ví dụ: Lumfin (Enter để thêm)',+ 'cr.addName': 'Thêm',+ 'cr.removeName': 'Bỏ tên riêng {n}',+ 'cr.h1': 'Chọn clip',+ 'cr.sub1': 'Video nói trước máy, tiếng Việt. AI cắt khoảng lặng, làm phụ đề, zoom và đồ hoạ.',+ 'cr.h2': 'Chọn cách dựng',+ 'cr.sub2': 'Mỗi cách là một kiểu cắt, phụ đề và đồ hoạ. Đổi lại được sau khi dựng.',+ 'cr.h3': 'Đang dựng',+ 'cr.open': 'Mở Studio',+ 'cr.another': 'Dựng clip khác',+ 'cr.next': 'Tiếp: chọn cách dựng',+ 'cr.eta': 'Mất khoảng {m} phút',+ 'cr.delete': 'Xoá bản dựng {name}',+ // ---- Studio (studio/*.js) ----+ 'st.back': 'Quay lại danh sách',+ 'st.versions': 'Phiên bản',+ 'st.r0': 'gốc',+ 'st.r0Tip': 'Bản dựng đầu tiên',+ 'st.undo': 'Hoàn tác (Ctrl+Z)',+ 'st.redo': 'Làm lại (Ctrl+Shift+Z)',+ 'st.needReview': 'Cần xem lại',+ 'st.publish': (v) => `Xuất bản mới (${v.n} thay đổi)`,+ 'st.publishing': 'Đang xuất bản',+ 'st.published': 'Đã xuất bản r{n}. Đang xem bản mới.',+ 'st.resetAsk': 'Bỏ hết thay đổi chưa xuất bản?',+ 'st.tools': 'Công cụ',+ 'st.railAi': 'Sửa lời',+ 'st.trVideo': 'Video', 'st.trCap': 'Phụ đề', 'st.trZoom': 'Zoom', 'st.trGfx': 'Đồ hoạ', 'st.trMusic': 'Nhạc',+ 'st.timeline': 'Dòng thời gian',+ 'st.splitS': 'Tách phụ đề tại đầu phát (S)',+ 'st.mergeNext': 'Gộp với dòng sau',+ 'st.delSel': 'Xoá khối đang chọn (Delete)',+ 'st.addZoom': 'Thêm zoom tại đầu phát',+ 'st.zoomIn': 'Phóng to timeline',+ 'st.zoomOut': 'Thu nhỏ timeline',+ 'st.tlZoom': 'Độ phóng timeline (Ctrl + lăn chuột)',+ 'st.noMusic': 'Không nhạc',+ 'st.lineText': 'Sửa chữ dòng phụ đề',+ 'st.play': 'Phát', 'st.pause': 'Dừng',+ 'st.prevFrame': 'Lùi 1 khung (←, Shift: 1 giây)',+ 'st.nextFrame': 'Tới 1 khung (→, Shift: 1 giây)',+ 'st.viewOut': 'Bản xuất',+ 'st.viewingOut': 'Đang xem MP4 đã xuất',+ 'st.closeSheet': 'Đóng bảng',+ 'st.readOnly': 'Đang xem bản cũ: chỉ xem. Chọn bản mới nhất để chỉnh.',+ 'st.capLines': 'Dòng chữ',+ 'st.capLook': 'Kiểu chữ',+ 'st.capReview': (v) => `Xem lại · ${v.n}`,+ 'st.flagged': 'Có chỗ cần xem lại',+ 'st.markHi': 'Nhấn chữ: bọc chữ đang chọn để đổi màu',+ 'st.del': 'Xoá',+ 'st.aiFixed': 'AI sửa “{heard}” thành “{text}”',+ 'st.figCheck': 'Số “{text}” — nghe được: “{said}”',+ 'st.lineErr.short': 'Dòng ngắn hơn 0,1 giây.',+ 'st.lineErr.after': 'Dòng bắt đầu sau cuối video.',+ 'st.lineErr.overlap': 'Dòng đè lên dòng trước.',+ 'st.lineErr.empty': 'Dòng không có chữ.',+ 'st.reviewH': 'Cần xem lại',+ 'st.reviewNone': 'Không có gì cần xem lại.',+ 'st.prevItem': 'Mục trước', 'st.nextItem': 'Mục sau',+ 'st.rFix': 'AI sửa', 'st.rFig': 'Số',+ 'st.rKeep': 'Giữ', 'st.rEdit': 'Sửa', 'st.rRevert': 'Trả lại',+ 'st.rNoRevert': 'Không trả lại được: dòng không còn chữ AI đã sửa',+ 'st.rStatus.keep': 'Đã giữ', 'st.rStatus.edit': 'Đã mở sửa', 'st.rStatus.revert': 'Đã trả lại chữ gốc',+ 'st.uploadMusic': 'Tải bài lên',+ 'st.gain': 'Âm lượng nhạc',+ 'st.zoomKind': 'Kiểu zoom',+ 'st.push': 'Đẩy chậm', 'st.punch': 'Giật nhanh', 'st.pushS': 'Đẩy', 'st.punchS': 'Giật',+ 'st.pushHint': 'Phóng chậm suốt khối, lùi về ở cuối.',+ 'st.punchHint': 'Phóng tức thì, giữ, rồi trả về.',+ 'st.zStrength': 'Độ mạnh',+ 'st.zLength': 'Độ dài',+ 'st.zoomPick': 'Chọn 1 khối zoom trên timeline, hoặc thêm zoom tại đầu phát.',+ 'st.zoomHere': 'Đầu phát đang ở trong 1 zoom: đã chọn zoom đó.',+ 'st.zoomNoRoom': 'Không đủ chỗ cho zoom mới ở đây.',+ 'st.gfxPick': 'Chọn 1 đồ hoạ trên timeline để sửa chữ, số và giờ hiện.',+ 'st.gStart': 'Giờ bắt đầu đồ hoạ', 'st.gEnd': 'Giờ kết thúc đồ hoạ',+ 'st.estimate': 'ước tính',+ 'st.delGfx': 'Xoá đồ hoạ',+ 'st.aiH': 'Sửa bằng lời (AI)',+ 'st.aiHint': 'Nói điều muốn đổi, AI dựng lại từ bản mới nhất (vài phút).',+ 'st.aiGo': 'Sửa bằng AI',+ 'st.aiPending': (v) => `Còn ${v.n} thay đổi chưa xuất bản: xuất bản hoặc bỏ thay đổi trước khi sửa bằng lời.`,+ 'st.noLineHere': 'Đầu phát không nằm trên dòng phụ đề nào.',+ 'st.noMerge': 'Chọn 1 dòng còn dòng sau để gộp.',+ 'st.selFirst': 'Chọn 1 khối trên timeline trước.',+ 'st.fixFirst': (v) => `Còn ${v.n} dòng phụ đề lỗi (đỏ): sửa xong mới xuất bản được.`,+ 'st.notFound': 'Không mở được bản này: {e}',+ 'st.buildErr': 'Bản này dựng lỗi: {e}',+ 'gf.kicker': 'Dòng nhỏ trên', 'gf.title': 'Tiêu đề', 'gf.unit': 'Đơn vị', 'gf.label': 'Nhãn', 'gf.prefix': 'Trước số',+ 'gf.value': 'Số', 'gf.suffix': 'Sau số', 'gf.old': 'Giá cũ', 'gf.text': 'Chữ', 'gf.a': 'Cột A', 'gf.b': 'Cột B',+ 'gf.row': 'Dòng {n}', 'gf.ok': 'Đánh dấu ✓',+ 'gfx.counter': 'Số đếm', 'gfx.bar_chart': 'Biểu đồ cột', 'gfx.compare': 'So sánh', 'gfx.spec_table': 'Bảng',+ 'gfx.checklist': 'Checklist', 'gfx.price_tag': 'Tem giá', 'gfx.sticker': 'Sticker', 'gfx.line_chart': 'Biểu đồ đường', 'gfx.title_card': 'Thẻ tiêu đề',+ };++ const en = {+ 'meta.title': 'LumReels — vertical videos from templates',+ 'top.tag': 'Pick a template, paste your text, AI builds the scenes. Out comes a 1080×1920 vertical MP4.',+ 'lang.group': 'Interface language',+ 'lang.vi': 'Vietnamese (VI)',+ 'lang.en': 'English (EN)',++ 'update.hide': 'Dismiss',+ 'update.text': (v) => `${v.n} new update${S(v.n)} for LumReels${v.first ? ` (${v.first}${v.n > 1 ? ', …' : ''})` : ''}. Quit the app and run `,+ 'update.after': ' to update.',++ 'tabs.aria': 'Mode',+ 'tabs.tpl': 'From a template',+ 'tabs.edit': 'Edit your video',+ 'tabs.new': 'NEW',++ 'pick.h': 'Pick a template',+ 'pick.searchLabel': 'Search templates by name',+ 'pick.searchPh': 'Search by name or genre…',+ 'pick.chipsAria': 'Filter by group',+ 'cat.all': 'All',+ 'cat.faceless': 'Faceless',+ 'cat.ads': 'Ads',+ 'cat.multi-style': 'Multi-style',+ 'cat.viet-nam': 'Vietnam edition',+ 'pick.readyOnly': 'Ready only',+ 'pick.multi': 'Pick several',+ 'pick.multiHint': 'When on, tap templates to add or remove them, up to 12. Each one makes a video from the same text.',+ 'pick.count': '{ready}/{total} templates ready',+ 'pick.max': 'Up to {max} templates per run. Remove one to pick another.',+ 'grid.loading': 'Loading templates…',+ 'grid.loadErr': "Couldn't load templates. Check the server, then reload the page.",+ 'grid.empty': 'No matching templates. Clear the filters or try another word.',+ 'tpl.aria': (v) => `Template ${v.id}: ${v.name}${v.ready ? '' : ' (no guidance yet, not usable)'}${v.order ? `, picked #${v.order}` : ''}`,+ 'tpl.noThumb': 'no image',+ 'tpl.ready': 'Ready',+ 'tpl.noGuide': 'No guidance',+ 'tpl.playDemo': 'Play demo video for template {id}',+ 'tpl.playRef': 'Play reference video for template {id}',+ // ---- template packs (.lumpack) ----+ 'src.builtin': 'Built-in',+ 'src.local': 'Mine',+ 'src.pack': 'Community',+ 'grid.emptySrc.local': 'No templates of your own yet. Ones you create or import from your own pack show up here.',+ 'grid.emptySrc.pack': 'No community packs installed yet.',+ 'pack.importBtn': 'Import pack',+ 'pack.mineBtn': 'My packs',+ 'pack.lockedNote': 'Outside templates run locked: the AI can only read/write inside this video’s folder.',+ 'kind.template': 'Template',+ 'kind.edit-style': 'Edit style',+ 'prov.original': 'Original work',+ 'prov.own-video': 'Learned from the author’s own video',+ 'prov.style-study': 'Style study of another video',+ 'pk.title': 'Import a template pack',+ 'pk.close': 'Close',+ 'pk.dropBig': 'Choose a .lumpack file',+ 'pk.dropSmall': 'or drop it here · up to 12 MB · you preview it before installing',+ 'pk.reading': 'Reading and checking the pack…',+ 'pk.restricted': 'Community templates run locked: the AI can only read/write inside this video’s folder.',+ 'pk.noName': '(no name)',+ 'pk.author': 'Author',+ 'pk.contact': 'Contact',+ 'pk.license': 'License',+ 'pk.provenance': 'Origin',+ 'pk.id': 'Pack ID',+ 'pk.engine': 'Needs LumReels',+ 'pk.items': 'Items',+ 'pk.sha': 'Checksum (sha256)',+ 'pk.warnHead': (v) => `${v.n} item${S(v.n)} contain${v.n === 1 ? 's' : ''} words worth reading closely (highlighted below). They aren’t blocked, but read them before installing.`,+ 'pk.warnItem': 'read closely',+ 'pk.showText': 'Show full text',+ 'pk.err.not-pack': 'This file isn’t a LumReels pack (.lumpack).',+ 'pk.err.tooBig': 'The file is larger than 12 MB.',+ 'pk.err.engine': 'This pack needs a newer LumReels. Update the app, then import again.',+ 'pk.err.rejected': 'Pack rejected: unsafe content or wrong format.',+ 'pk.err.first': 'First reason: {e}',+ 'pk.err.more': 'Show all errors ({n})',+ 'pk.err.expired': 'The preview expired (10 minutes). Choose the file again.',+ 'pk.err.net': 'Couldn’t reach the app. Check it’s still running, then try again.',+ 'pk.st.installed': 'This pack (version {v}) is already installed.',+ 'pk.st.conflict': '{id} version {v} is installed with different content: can’t overwrite it.',+ 'pk.st.older': 'A newer version ({v}) is already installed.',+ 'pk.st.upgrade': 'Version {v} is installed.',+ 'pk.replace': 'Replace it with version {v}',+ 'pk.cancel': 'Cancel',+ 'pk.other': 'Choose another file',+ 'pk.install': 'Install',+ 'pk.installing': 'Installing…',+ 'pk.done': (v) => `Installed "${v.name}": ${v.n} item${S(v.n)}. They show in the grid with the Community label.`,+ 'pk.showGrid': 'Show in grid',+ 'mp.title': 'My packs',+ 'mp.loading': 'Loading…',+ 'mp.loadErr': 'Couldn’t load the pack list.',+ 'mp.retry': 'Try again',+ 'mp.empty': 'No packs installed. Click Import pack to add templates from a .lumpack file.',+ 'mp.items': (v) => `${v.n} item${S(v.n)}`,+ 'mp.view': 'View',+ 'mp.hide': 'Hide',+ 'mp.verified': 'Reviewed',+ 'mp.remove': 'Remove',+ 'mp.removeQ': 'Remove pack "{name}"? Videos already made with it stay as they are.',+ 'mp.removeYes': 'Remove pack',+ 'mp.removed': 'Removed "{name}".',+ 'mp.deleted': 'Deleted "{name}".',+ 'mp.delItem': 'Delete',+ 'mp.delItemQ': 'Delete "{name}" from your templates? This can’t be undone.',+ 'mp.export': 'Export pack',+ 'ex.title': 'Export your own templates to a .lumpack file',+ 'ex.none': 'Nothing of your own to export yet. Templates you create (Create template button, coming soon) show up here.',+ 'ex.pick': 'Choose items',+ 'ex.name': 'Pack name',+ 'ex.id': 'Pack ID',+ 'ex.idHint': 'Format author.pack-name: lowercase without accents, digits, hyphens. Filled in from author + name.',+ 'ex.author': 'Author',+ 'ex.contact': 'Contact (optional)',+ 'ex.license': 'License',+ 'ex.version': 'Version',+ 'ex.go': 'Download .lumpack',+ 'ex.busy': 'Exporting…',+ 'ex.ok': 'Exported {file} ({kb}).',+ 'ex.err.items': 'Pick at least 1 item to export.',+ 'ex.err.name': 'Enter a pack name.',+ 'ex.err.author': 'Enter the author name.',+ 'ex.err.id': 'Pack ID must look like author.pack-name, each half 2–24 characters.',+ 'ex.err.ver': 'Version must look like 1.0.0.',+ 'ex.err.reserved': 'That author name is reserved for LumReels. Change the part before the dot.',++ 'picked.none': 'No template yet. Tap a bright one on the left.',+ 'picked.noneMulti': 'Multi-pick on: tap bright templates on the left (up to {max}). Each makes one video.',+ 'picked.count': (v) => `${v.n} template${S(v.n)} picked`,+ 'picked.clear': 'Clear all',+ 'picked.strip': 'Picked templates',+ 'picked.remove': 'Remove template {id}: {name}',++ 'viewer.aria': 'Template preview video',+ 'viewer.close': 'Close',+ 'viewer.demo': 'Demo video made with LumReels. ',+ 'viewer.ref': 'Reference video on your machine (not in the repo). ',++ 'compose.h': 'Your text',+ 'compose.label': 'Video text',+ 'compose.ph': 'Example: Put $100 a month into an index fund at an assumed 10% a year. How much after 20 years? Channel: Lumfin. CTA: Follow for more money tips',+ 'compose.charsTail': '/4000 characters · include your channel name and CTA if you have them',+ 'rw.btn': 'Rewrite script',+ 'rw.btnBusy': 'Rewriting',+ 'rw.hint': 'Rewrite script: AI fits your text into the slots of the picked template and the length below, keeping numbers, channel name and CTA.',+ 'rw.hintMany': 'Rewrite is off because {n} templates are picked and each has different slots. Pick 1 template to use it; otherwise all {n} videos share the text you typed.',+ 'rw.busy': 'Rewriting…',+ 'rw.needOne': 'Pick 1 template first',+ 'rw.onlyOne': 'Rewrite works with 1 template only',+ 'rw.needText': 'Type your text first (at least 10 characters)',+ 'rw.loading': 'Rewriting for template {id} · {d}… (usually 20–60 seconds)',+ 'rw.title': 'Rewrite · template {id} · {d}',+ 'rw.fallback': 'Switched to Claude Code because: {why}.',+ 'rw.use': 'Use this',+ 'rw.drop': 'Discard',+ 'rw.timeout': 'Still not done after 100 seconds, so we stopped waiting. Try again.',+ 'rw.replaced': 'Your text was replaced with the rewrite.',+ 'rw.undo': 'Undo',+ 'rw.close': 'Close',+ 'err.status': 'Error {s}',++ 'dur.label': 'Length',+ 'dur.range': '(3 s – 10 min)',+ 'dur.presets': 'Quick lengths',+ 'dur.hint': 'Type seconds (90) or min:sec (1:30).',+ 'dur.errEmpty': 'Enter a length, e.g. 8 or 1:30',+ 'dur.errFmt': 'Type seconds (90) or min:sec (1:30)',+ 'dur.errMin': 'Minimum 3 seconds',+ 'dur.errMax': 'Maximum 10 minutes (10:00)',+ 'dur.eqLong': '= {s} seconds ({f}).',+ 'dur.eq': '= {s} seconds. Type seconds (90) or min:sec (1:30).',+ 'dur.warn': 'A {f} video takes about {range} to render (measured: an 8-second video takes 20–60 seconds), not counting the time AI spends writing scenes. AI has to write about {scenes} connected scenes, so it costs far more tokens than an 8-second video.',+ 'unit.sec': 'seconds',+ 'unit.min': 'min',+ 'unit.hour': 'hours',+ 'num.dec': '.',++ 'audio.aria': 'Audio',+ 'mode.label': 'Scene builder',+ 'mode.auto': 'Auto',+ 'mode.manual': 'External agent',+ 'modeLabel.auto': 'auto',+ 'modeLabel.manual': 'external agent',+ 'mode.hintAuto': 'Auto: using {m}.',+ 'mode.hintApi': 'Calls the Claude API with the key in .env (billed per token; cost is saved on the job).',+ 'mode.hintClaude': 'Runs Claude Code on this machine (uses your Claude plan).',+ 'mode.hintManual': 'Only writes the brief; an external agent (MCP/CLI) writes the scenes and calls render.',+ 'mode.hintExport': ' When done, the MP4 is copied to your export folder.',+ 'model.label': 'Scene model',+ 'model.auto': 'Auto (by template)',+ 'model.autoRec': 'Auto by template ({m})',+ 'model.autoMany': 'Auto per template',+ 'model.opus': 'Opus (best, priciest)',+ 'model.sonnet': 'Sonnet (balanced)',+ 'model.haiku': 'Haiku (cheapest)',+ 'model.rec': (v) => `This template ${v.heavy ? 'uses 3D/shaders' : 'is 2D'} → ${v.m} recommended.`,+ 'model.pickFirst': 'Pick a template to see a recommendation.',+ 'model.haikuWarn': ' Haiku tends to flatten 3D scenes; use Opus.',+ 'model.override': ' (using {m} instead of the recommendation)',+ 'model.agentNote': ' With an external agent, that agent picks the model.',+ 'model.manyLight': '{n} 2D → {m}',+ 'model.manyHeavy': '{n} 3D/shader → {m}',+ 'model.manyAuto': 'Each video picks by its template: {parts}.',+ 'model.manyFixed': 'All {n} videos use {m} (recommended: {parts}).',+ 'model.haikuWarnMany': ' Haiku tends to flatten 3D scenes; use Opus for 3D templates.',+ 'runAt.label': 'Schedule',+ 'runAt.opt': '(leave blank to build now)',+ 'runAt.clear': 'Clear',+ 'runAt.clearAria': 'Clear schedule',+ 'go.build': (v) => (v.n > 1 ? `Build ${v.n} videos` : 'Build video'),+ 'go.schedule': (v) => (v.n > 1 ? `Schedule ${v.n} videos` : 'Schedule video'),+ 'go.sending': 'Sending',+ 'go.needTpl': 'Pick a template first',+ 'go.needText': 'Text needs at least 10 characters',+ 'go.badDur': 'Length is not valid',+ 'form.jobErr': "Couldn't create the job",+ 'form.retry': '. Fix it and try again.',++ 'jobs.h': 'Your videos',+ 'jobs.empty': 'No videos yet. Pick a template, paste your text, then hit <b>Build video</b>.',+ 'jobs.less': 'Show less',+ 'jobs.more': (v) => `Show more (${v.n} older video${S(v.n)})`,+ 'st.scheduled': 'Scheduled',+ 'st.queued': 'Queued',+ 'st.generating': 'AI writing scenes',+ 'st.waiting_agent': 'Waiting for agent',+ 'st.previewing': 'Building preview',+ 'st.rendering': 'Rendering',+ 'st.done': 'Done',+ 'st.error': 'Error',+ 'job.previewAlt': '16-frame preview',+ 'job.building': 'Building…',+ 'job.waitScene': 'Waiting for scenes',+ 'job.noImage': 'No image yet',+ 'job.tpl': 'Template {id} · {name}',+ 'job.at': 'Scheduled for {t}',+ 'job.api': 'API: {i}k in · {o}k out · ≈ ${c}',+ 'job.exported': 'Copied to: {p}',+ 'job.errUnknown': 'Unknown error',+ 'job.errTail': '. Check the log, fix the scenes, then hit Re-render.',+ 'job.agent': 'Agent reads: {prompt}\nWrites: {scene}\nThen run: node cli.mjs render {id}',+ 'job.mp4': 'Download MP4',+ 'job.preview': '16-frame preview',+ 'job.rerender': 'Re-render',+ 'job.render': 'Render',+ 'job.log': (v) => `Log (${v.n} line${S(v.n)})`,++ 'ap.title': 'Audio',+ 'ap.loadingOpts': 'Loading options…',+ 'ap.stop': 'Stop preview',+ 'ap.making': 'Making preview',+ 'ap.voiceLoading': 'Generating a voice sample… (the first model load can take a few minutes)',+ 'ap.prevFail': "couldn't make a preview",+ 'ap.prevErr': 'Preview failed: ',+ 'ap.keep': 'Keep current',+ 'ap.music': 'Background music',+ 'ap.musicPrev': 'Preview music',+ 'ap.voice': 'Voiceover',+ 'ap.voicePrev': 'Preview voice',+ 'ap.sfx': 'Sound effects synced to motion',+ 'ap.pickMusic': 'Pick a specific music style to preview.',+ 'ap.pickVoice': 'Pick a specific voice to preview.',+ 'ap.vAuto': 'template voice',+ 'ap.vNone': 'no voice',+ 'ap.versions': 'Versions ({n})',+ 'ap.ver': 'Version {n}',+ 'ap.latest': ' · latest',+ 'ap.noSfx': ' · no SFX',+ 'ap.view': 'Play',+ 'ap.dl': 'Download',+ 'ap.mix': 'Remix audio',+ 'ap.mixNote': "Visuals aren't rebuilt and old versions are kept. If you pick a voice for a video with no script, AI writes a short one.",+ 'ap.lastErr': 'Last mix failed: ',+ 'ap.mixing': 'Mixing audio…',+ 'ap.mixingNote': 'Mixing (VieNeu voices can take a few minutes)…',+ 'ap.err': 'Error: ',+ 'ap.unknown': 'unknown',+ 'ap.done': 'Done — playing the latest version.',+ 'ap.summary': 'Audio · change music, voice',+ 'ap.loading': 'Loading…',+ 'ap.mixFail': "Couldn't mix: ",+ 'ap.errShort': 'error',+ 'vc.title': 'My voices',+ 'vc.optTag': 'cloned voice',+ 'vc.add': '+ Add voice',+ 'vc.loading': 'Loading your voices…',+ 'vc.loadErr': "Couldn't load your voices.",+ 'vc.retry': 'Retry',+ 'vc.empty': 'No voices yet. Upload or record 10 seconds to 3 minutes of speech and the app learns it, then reads your video script in that voice.',+ 'vc.needVieneu': 'Voice cloning needs VieNeu-TTS on this machine: pip install vieneu',+ 'vc.ready': 'Ready',+ 'vc.error': 'Error',+ 'vc.step.queued': 'Waiting…',+ 'vc.step.transcribe': 'Transcribing the sample…',+ 'vc.step.encode': 'Learning the voice + test read…',+ 'vc.play': 'Play sample of {name}',+ 'vc.stop': 'Stop',+ 'vc.rename': 'Rename voice {name}',+ 'vc.delete': 'Delete voice {name}',+ 'vc.newName': 'New name',+ 'vc.save': 'Save',+ 'vc.cancel': 'Cancel',+ 'vc.refSum': 'Sample the app picked',+ 'vc.refText': 'Words spoken in the sample',+ 'vc.byWhisper': '(auto-transcribed, fix if wrong)',+ 'vc.refTextPh': 'Type exactly what you say in the sample',+ 'vc.refTextHint': 'Optional for VieNeu v3 Turbo; helps you see what the sample says.',+ 'vc.saveText': 'Save text',+ 'vc.noWhisper': "Whisper isn't installed, so the sample wasn't transcribed. Open the sample to listen and type it (optional).",+ 'vc.srcAria': 'Voice source',+ 'vc.srcFile': 'Choose file',+ 'vc.srcRec': 'Record',+ 'vc.fileLabel': 'Voice audio file',+ 'vc.fileHint': 'wav, mp3, m4a, ogg or webm · 10 seconds to 3 minutes · up to {max} MB · one speaker, little background noise.',+ 'vc.readTip': 'Tip: read this aloud naturally (Vietnamese text, since cloned voices speak Vietnamese)',+ 'vc.readText': 'Hôm nay mình muốn kể cho bạn nghe một chuyện nhỏ. Sáng nào mình cũng dậy sớm, pha một ly cà phê, mở cửa sổ và nghe phố xá bắt đầu nhộn nhịp. Có hôm trời mưa, có hôm nắng gắt, nhưng mình vẫn giữ thói quen đó. Một, hai, ba, bốn, năm: thói quen nhỏ, kết quả lớn.',+ 'vc.recStart': 'Start recording',+ 'vc.recAgain': 'Record again',+ 'vc.recStop': 'Stop',+ 'vc.recHint': 'Record somewhere quiet, a hand-width from the mic, at least 20 seconds. Stops by itself at 3 minutes.',+ 'vc.recFile': 'recording',+ 'vc.nameLabel': 'Voice name',+ 'vc.namePh': 'e.g. My voice',+ 'vc.consent': "This is my voice, or I have that person's permission to use it",+ 'vc.langNote': 'Cloned voices speak Vietnamese. Pick one for English content and the voiceover is written in Vietnamese.',+ 'vc.create': 'Create voice',+ 'vc.sending': 'Uploading… {pct}%',+ 'vc.processing': 'Got voice {name}. Learning it now, about a minute.',+ 'vc.readyNote': 'Voice {name} is ready and selected as the voiceover. Press play to hear it.',+ 'vc.errNoFile': 'Choose an audio file.',+ 'vc.errNoRec': 'Record something first.',+ 'vc.errExt': 'Unsupported format. Use wav, mp3, m4a, ogg or webm.',+ 'vc.errBig': 'File too large (max {max} MB).',+ 'vc.errShort': 'Too short ({s} seconds). It needs at least 10 seconds.',+ 'vc.errLong': 'Longer than 3 minutes. Trim it and try again.',+ 'vc.errName': 'Give the voice a name.',+ 'vc.errNameLong': 'Name can be up to {max} characters.',+ 'vc.errConsent': 'Tick the confirmation to continue.',+ 'vc.errNoMic': "This browser can't record. Choose a file instead.",+ 'vc.errMicDenied': 'Microphone access was blocked. Allow it in the browser and try again.',+ 'vc.errUpload': 'Upload failed. Check the app is still running and try again.',+ 'vc.errDel': "Couldn't delete the voice.",+ 'vc.errSave': "Couldn't save.",+ 'vc.confirmDel': 'Delete voice "{name}"? Its files on this machine are removed for good.',+ 'vc.deleted': 'Deleted voice {name}.',+ 'vc.renamed': 'Renamed to {name}.',+ 'vc.textSaved': 'Sample text saved.',++ 'ed.aria': 'Edit your video',+ 'ed.setupH': "Video editing isn't installed",+ 'ed.noServer': "Can't reach the server.",+ 'ed.h': 'Your video',+ 'ed.dropAria': 'Choose or drop a video',+ 'ed.dropBig': 'Drop your video here',+ 'ed.dropSmall': 'or click to choose · mp4, mov, mkv… up to 2 GB · talking to camera, in Vietnamese',+ 'ed.fileLabel': 'Video file',+ 'ed.style': 'Edit style',+ 'ed.music': 'Background music',+ 'ed.musicOpt': '(ducks while you talk)',+ 'ed.noMusic': 'No music',+ 'ed.musicSynth': 'Generated: {id} — {desc}',+ 'ed.musicFile': 'Upload my own music…',+ 'ed.musicFileLabel': 'Music file',+ 'ed.names': 'Names and terms',+ 'ed.namesOpt': '(so AI spells captions right)',+ 'ed.namesPh': 'e.g. Lumfin, Hanoi, ETF',+ 'ed.notes': 'Extra notes',+ 'ed.notesOpt': '(optional)',+ 'ed.notesPh': 'e.g. cut the opening greeting, keep the follow call at the end',+ 'ed.draft': 'Quick draft (simple captions, ~1 min faster)',+ 'ed.go': 'Build',+ 'ed.empty': 'Pick a video on the left, then hit Build.',+ 'ed.steps': 'Steps',+ 'ed.fixesH': 'Words AI fixed in the captions — please check',+ 'ed.reviseH': 'Request changes',+ 'ed.reviseLabel': 'Change request',+ 'ed.revisePh': 'e.g. "cut the first 3 seconds", "less zoom"',+ 'ed.reviseBtn': 'Re-render',+ 'ed.p1': 'cut the first 3 seconds',+ 'ed.p2': 'less zoom',+ 'ed.p3': 'lower the music',+ 'ed.p4': 'captions 2 words at a time',+ 'ed.histH': 'Revisions',+ 'ed.log': 'Log',+ 'ed.delete': 'Delete this edit',+ 'ed.listH': 'Your edits',+ 'ed.st.queued': 'Queued',+ 'ed.st.running': 'Editing',+ 'ed.st.done': 'Done',+ 'ed.st.error': 'Error',+ 'ed.waitTurn': 'Waiting in line',+ 'ed.revising': 'Revising',+ 'ed.notVideo': "This file isn't a video (mp4, mov, mkv, webm…).",+ 'ed.tooBig': 'Video is {size}, too large (max 2 GB).',+ 'ed.changeFile': '{size} · click to change',+ 'ed.needMusic': 'Choose a music file, or switch to "No music".',+ 'ed.uploading': 'Uploading {p}%',+ 'ed.uploadCut': 'Upload interrupted. Check the server and try again.',+ 'ed.listEmpty': 'Nothing here yet.',+ 'ed.err': 'Error',+ 'ed.reviseErr': 'Change failed: {e}',+ 'ed.previewAlt': 'Preview frame grid',+ 'ed.mediaEmpty': 'Your video shows up here when it is done',+ 'ed.mp4': 'Download MP4',+ 'ed.gridOut': 'Output frame grid',+ 'ed.hidden': '(hidden from captions)',+ 'ed.checksEdl': '{out} s · cut {rm} s · {z} zooms',+ 'ed.overcut': 'clipped words: {v}',+ 'ed.noOvercut': 'no clipped words',+ 'ed.sendFail': "Couldn't send your change.",+ 'ed.confirmDel': 'Delete this edit for good (output video, EDL, uploaded files)? This cannot be undone.',+ 'man.h': 'Manual edit',+ 'man.tabCap': 'Captions',+ 'man.tabAud': 'Music & sound',+ 'man.tabFx': 'Zoom & graphics',+ 'man.look': 'Caption look',+ 'man.hi': 'Highlights (words in *stars* get the accent colour)',+ 'man.capHint': 'Tap a time to jump the video there. Wrap a *word* to highlight it.',+ 'man.draftNote': "A draft burns captions into the picture, so they can't be edited by hand. Turn off \"draft\" and edit again.",+ 'man.music': 'Music',+ 'man.musicKeep': 'Keep current music ({name})',+ 'man.synth': 'Built-in music: {id}',+ 'man.uploaded': 'Uploaded: {name}',+ 'man.uploading': 'Uploading {name} ({size})…',+ 'man.uploadOk': 'Uploaded {name}. Press Apply to remix the sound.',+ 'man.uploadErr': "Couldn't upload the music: {e}",+ 'man.musicGain': 'Music volume',+ 'man.duck': 'Ducking: music dips while someone speaks',+ 'man.fade': 'Fade out at the end',+ 'man.start': 'Music starts at second',+ 'man.voice': 'Voice volume (vs. music)',+ 'man.loudHint': 'The whole mix is always normalised to −14 LUFS: a louder voice means relatively quieter music and effects.',+ 'man.sfx': (v) => `Sound effects${v.n ? ` · ${v.n}` : ' · none'}`,+ 'man.zooms': 'Zooms',+ 'man.gfx': 'Graphics',+ 'man.zoomKind': (v) => `${v.kind === 'punch' ? 'Punch zoom' : 'Push zoom'} ×${v.scale}`,+ 'man.noZoom': 'This edit has no zooms.',+ 'man.noGfx': 'This edit has no graphics.',+ 'man.noLines': 'This edit has no captions.',+ 'man.remove': 'Remove',+ 'man.undo': 'Keep',+ 'man.removeN': 'Remove {what}',+ 'man.undoN': 'Keep {what}',+ 'man.jump': 'Jump to {s} s',+ 'man.lineText': 'Text of line {n}',+ 'man.lineStart': 'Start of line {n} (seconds)',+ 'man.lineEnd': 'End of line {n} (seconds)',+ 'man.split': 'Split',+ 'man.merge': 'Merge ↓',+ 'man.splitN': 'Split line {n} in two',+ 'man.mergeN': 'Merge line {n} with the next',+ 'man.delN': 'Delete line {n}',+ 'man.cantSplit': 'This line has one word; nothing to split.',+ 'man.errShort': 'A line must last at least 0.1 s (end after start).',+ 'man.errAfter': 'Starts after the end of the video ({d} s).',+ 'man.errOverlap': 'Overlaps the line before: move its start later.',+ 'man.errEmpty': 'Empty line: type something or delete it.',+ 'man.fixFirst': (v) => `Fix ${v.n} line${S(v.n)} marked red before applying.`,+ 'man.dirty': (v) => `${v.n} change${S(v.n)} · redo: ${v.what}`,+ 'man.clean': 'No changes yet.',+ 'man.wCap': 'caption layer',+ 'man.wAud': 'sound',+ 'man.wBase': 'picture',+ 'man.reset': 'Discard changes',+ 'man.apply': 'Apply',+ 'man.applying': 'Rendering…',+ 'man.running': 'Rendering manual edit',+ 'man.loadErr': "Couldn't load manual editing: {e}",+ 'man.sendFail': "Couldn't send the manual edit.",+ 'man.tag': 'Manual',+ 'man.took': 'took {s} s',+ 'man.watch': 'Watch',+ 'man.original': 'First version',+ 'ed.styleHint': '{n} styles · scroll to see them all',+ 'ed.styleAria': (v) => `${v.name}: ${v.summary}`,+ 'ed.setupText': 'Video editing needs Python, a speech-to-text model and a face model. Click Install now and LumReels sets everything up (one time only).',+ 'ed.install': 'Install now',+ 'ed.installing': 'Installing…',+ 'ed.installStep': '{step}… ({t})',+ 'ed.installStepDefault': 'Installing',+ 'ed.installDone': 'Installed in {t}. Video editing is ready.',+ 'ed.installRetry': 'Try again',+ 'ed.installFail': "Install didn't finish. See the details below, then click Try again.",+ 'ed.installCantStart': "Couldn't start the install: {e}",+ 'ed.installNote': 'About a 6 GB download, 5–20 minutes depending on your connection. Keep this page open.',+ 'ed.installDetails': 'Show details',+ 'ed.installManual': 'Or install it yourself with a command',+ 'ed.fail.NEED_PYTHON': "Python 3.10–3.12 isn't installed. Install it as described below, then click Try again.",+ 'ed.fail.NEED_FFMPEG': "ffmpeg isn't installed. Install it as described below, then click Try again.",+ 'ed.fail.NEED_NETWORK': "The download failed. Check your connection, then click Try again (finished parts won't download again).",+ 'ed.fail.NEED_NPM': 'LumReels fonts are missing: run npm install in the LumReels folder, then click Try again.',+ 'ed.figuresH': "Numbers the machine wasn't sure it heard, left off the graphics: please listen again",+ 'ed.figAt': '{s} s in source',+ 'ed.figHeard': 'heard again as: “{h}”',+ 'ed.more': 'More',+ 'ed.review': (v) => `Review (${v.n})`,+ 'ed.revFixes': 'AI-fixed words',+ 'ed.revFigs': 'Unsure numbers',+ 'ed.specs': 'Specs',+ 'ed.stepOf': '{i}/{n} · {step} · {p}%',+ 'ed.revisePhS': 'cut the first 3 seconds…',+ 'man.hiShort': 'Highlights',+ 'man.hiTip': 'Wrap *words* to highlight',+ 'man.gainS': 'Volume',+ 'man.fadeS': 'Fade out',+ 'man.startS': 'Start (s)',+ 'man.duckS': 'Duck under voice',+ 'man.voiceS': 'Voice',+ 'man.dirtyS': (v) => `${v.n} change${S(v.n)}`,+ 'ed.cutRepairs': (v) => `fixed ${v.n} cut${S(v.n)} that clipped words`,++ // ---- Create a template from a video (learn-panel.js) ----+ 'cat.mine': 'Mine',+ 'lp.open': 'Template from a video',+ 'lp.title': 'Create a template from a video',+ 'lp.lead': 'Give it one video from this computer. The AI learns its editing style (colours, layout, pacing, motion), builds one test video with different content, then you review it and save it as your own template.',+ 'lp.back': 'Back',+ 'lp.close': 'Close',+ 'lp.loadErr': "Couldn't load the draft. Try again later.",+ 'lp.noDrafts': 'No drafts yet.',+ 'lp.new': 'Start from a new video',+ 'lp.drop': 'Drop a video here',+ 'lp.dropHint': 'or click to choose · mp4, mov, webm · 4 seconds – 3 minutes · up to 200 MB',+ 'lp.change': 'Change video',+ 'lp.refVideo': 'Reference video',+ 'lp.from': 'Which 8 seconds to learn',+ 'lp.seg': '{a}–{b} s',+ 'lp.fromHint': 'Pick the part where the style shows best. The video loops over exactly this part.',+ 'lp.name': 'Template name',+ 'lp.optional': '(optional)',+ 'lp.namePh': 'For example: Old paper cards',+ 'lp.cat': 'Group',+ 'lp.catAuto': 'Let the AI choose',+ 'lp.note': 'What is this video',+ 'lp.notePh': 'For example: food promo, big text, fast cuts',+ 'lp.rulesH': 'Learn the style, never copy',+ 'lp.rule1': 'Only colours, layout, pacing, motion and the closest open font are learned.',+ 'lp.rule2': 'Text, channel names, logos and characters seen in the video are removed from the template by code.',+ 'lp.rule3': 'The reference video stays on this computer and is deleted when you Save or Discard. The thumbnail comes from the test video.',+ 'lp.consent': "This video is mine, or I only use it to learn the editing style. I won't copy other people's characters, logos, music or images.",+ 'lp.needConsent': 'Tick the confirmation box to start',+ 'lp.skipTest': "Skip the test build (faster and cheaper, but you won't know if the template renders right)",+ 'lp.est': 'About 7–13 minutes, about 1–2.5 USD of AI at API prices (includes one 8-second test video).',+ 'lp.estNoTest': 'About 2–3 minutes, about 0.2–0.4 USD of AI at API prices. The draft will say "not test-built".',+ 'lp.go': 'Start',+ 'lp.uploading': 'Uploading the video',+ 'lp.uploadingPct': 'Uploading {p}%',+ 'lp.started': 'Video received, measuring.',+ 'lp.err.ext': "This format isn't supported. Use mp4, mov or webm.",+ 'lp.err.big': 'The video is too large (200 MB max).',+ 'lp.err.short': 'The video is too short, it needs at least {min} seconds.',+ 'lp.err.long': 'The video is too long, 3 minutes max. Trim it and try again.',+ 'lp.err.upload': "Couldn't send the video. Check the server and try again.",+ 'lp.err.run': 'Creating the template failed.',+ 'lp.st.uploaded': 'Received',+ 'lp.st.measuring': 'Measuring',+ 'lp.st.writing': 'AI writing',+ 'lp.st.testing': 'Test building',+ 'lp.st.comparing': 'Comparing',+ 'lp.st.revising': 'AI revising',+ 'lp.st.ready': 'Ready',+ 'lp.st.readyNoTest': 'Ready (not test-built)',+ 'lp.st.error': 'Error',+ 'lp.st.saved': 'Saved',+ 'lp.st.discarded': 'Discarded',+ 'lp.step.measuring': 'Measure the video (colour, pacing, motion)',+ 'lp.step.writing': 'AI writes the template from the spec',+ 'lp.step.testing': 'Build one 8-second test video',+ 'lp.step.comparing': 'Compare the test with the original',+ 'lp.step.revising': 'AI revises the template once',+ 'lp.stepNow': '{e} / ~{est}',+ 'lp.stepEst': '~{est}',+ 'lp.progress': 'Template progress',+ 'lp.canClose': 'You can close this box, the work keeps running. Reopen it with the Template from a video button.',+ 'lp.draftH': 'Template draft',+ 'lp.totals': 'Time {t} · AI cost {c}',+ 'lp.fromFile': '{f} · seconds {a}–{b}',+ 'lp.noRef': 'Reference video deleted',+ 'lp.testVideo': 'Test video',+ 'lp.notTested': 'Not test-built',+ 'lp.sheets': 'See the 16 frames side by side',+ 'lp.refSheet': 'Original',+ 'lp.refSheetAlt': '16-frame grid of the reference video',+ 'lp.testSheet': 'Test video',+ 'lp.testSheetAlt': '16-frame grid of the test video',+ 'lp.cmpH': (v) => `Measurements: ${v.n}/${v.total} off by more than 25%`,+ 'lp.cmpMetric': 'Measure',+ 'lp.cmpRef': 'Original',+ 'lp.cmpTest': 'Test',+ 'lp.cmpDev': 'Off by',+ 'lp.off': 'off',+ 'lp.near': 'close',+ 'lp.m.palette': 'Main colours',+ 'lp.m.brightness': 'Brightness',+ 'lp.m.saturation': 'Colour strength',+ 'lp.m.events': 'New elements per second',+ 'lp.m.motion': 'Amount of motion',+ 'lp.m.cuts': 'Scene cuts',+ 'lp.m.still': 'Share of still time',+ 'lp.diffsH': 'Remaining differences (AI compared both grids)',+ 'lp.diffsFixed': 'Differences the AI found and fixed in the template',+ 'lp.selfH': 'Self-check: {ok}/{n} passed',+ 'lp.yes': 'yes',+ 'lp.no': 'no',+ 'lp.guideH': 'Template (guidance)',+ 'lp.guideHint': 'The scene-building AI reads this text. You can edit it.',+ 'lp.saveText': 'Save edits',+ 'lp.unsaved': 'You have unsaved edits',+ 'lp.seenHit': 'still has text from the original video: "{s}"',+ 'lp.textOk': 'Edits saved and passed the checks.',+ 'lp.textBad': 'Edits saved, but there are errors to fix before saving the template.',+ 'lp.saveH': 'Save as a "Mine" template',+ 'lp.saveName': 'Template name',+ 'lp.slug': 'Template code',+ 'lp.slugHint': 'Lowercase letters without accents, digits, hyphens. Used in: make --template local.mine/<code>',+ 'lp.save': 'Save template',+ 'lp.retest': 'Test-build again',+ 'lp.discard': 'Discard draft',+ 'lp.discardAsk': 'Discard this draft? The reference video and the draft will be deleted.',+ 'lp.discarded': 'Draft discarded.',+ 'lp.saveNote': 'After saving, the reference video and its frames are deleted from this computer. The template runs locked: the AI only reads and writes inside the folder of the video being built.',+ 'lp.errNoSave': 'The draft failed at the test build: fix the template, then click Test-build again before saving.',+ 'lp.savedH': 'Saved to Mine',+ 'lp.savedP': 'Template {ref} is in the template grid under "Mine". Build with any content, like the built-in templates.',+ 'lp.useNow': 'Use this template',+ // ---- create screen (studio/create.js) ----+ 'cr.title': 'New project',+ 'cr.backStep': 'Previous step',+ 'cr.stepsAria': 'Steps',+ 'cr.s1': 'Clip', 'cr.s2': 'Edit style', 'cr.s3': 'Build',+ 'cr.sideAria': 'Build settings',+ 'cr.yourClip': 'Your clip',+ 'cr.changeClip': 'Change clip',+ 'cr.noClip': 'No clip yet. Drop a video into the box on the right.',+ 'cr.musicStyle': 'Style default',+ 'cr.musicUpload': 'Upload music',+ 'cr.len': 'Output length',+ 'cr.lenAuto': 'Auto',+ 'cr.lenAutoOn': 'Set a length',+ 'cr.lenAutoV': 'Auto',+ 'cr.lenV': '~{s} s',+ 'cr.names': 'Names & terms',+ 'cr.namesWhy': 'so captions spell them right',+ 'cr.namePh': 'e.g. Lumfin (Enter to add)',+ 'cr.addName': 'Add',+ 'cr.removeName': 'Remove {n}',+ 'cr.h1': 'Pick a clip',+ 'cr.sub1': 'Talking-to-camera video in Vietnamese. AI cuts pauses, writes captions, adds zooms and graphics.',+ 'cr.h2': 'Pick an edit style',+ 'cr.sub2': 'Each style is a way of cutting, captioning and adding graphics. You can change it after the build.',+ 'cr.h3': 'Building',+ 'cr.open': 'Open Studio',+ 'cr.another': 'Build another clip',+ 'cr.next': 'Next: edit style',+ 'cr.eta': 'Takes about {m} min',+ 'cr.delete': 'Delete edit {name}',+ // ---- Studio (studio/*.js) ----+ 'st.back': 'Back to the list',+ 'st.versions': 'Versions',+ 'st.r0': 'orig',+ 'st.r0Tip': 'First build',+ 'st.undo': 'Undo (Ctrl+Z)',+ 'st.redo': 'Redo (Ctrl+Shift+Z)',+ 'st.needReview': 'Review',+ 'st.publish': (v) => `Publish new (${v.n} change${v.n === 1 ? '' : 's'})`,+ 'st.publishing': 'Publishing',+ 'st.published': 'Published r{n}. Now showing the new version.',+ 'st.resetAsk': 'Discard all unpublished changes?',+ 'st.tools': 'Tools',+ 'st.railAi': 'AI edit',+ 'st.trVideo': 'Video', 'st.trCap': 'Captions', 'st.trZoom': 'Zoom', 'st.trGfx': 'Graphics', 'st.trMusic': 'Music',+ 'st.timeline': 'Timeline',+ 'st.splitS': 'Split caption at playhead (S)',+ 'st.mergeNext': 'Merge with next line',+ 'st.delSel': 'Delete selected block (Delete)',+ 'st.addZoom': 'Add zoom at playhead',+ 'st.zoomIn': 'Zoom timeline in',+ 'st.zoomOut': 'Zoom timeline out',+ 'st.tlZoom': 'Timeline zoom (Ctrl + wheel)',+ 'st.noMusic': 'No music',+ 'st.lineText': 'Edit caption text',+ 'st.play': 'Play', 'st.pause': 'Pause',+ 'st.prevFrame': 'Back 1 frame (←, Shift: 1 s)',+ 'st.nextFrame': 'Forward 1 frame (→, Shift: 1 s)',+ 'st.viewOut': 'Export',+ 'st.viewingOut': 'Watching the exported MP4',+ 'st.closeSheet': 'Close panel',+ 'st.readOnly': 'Viewing an older version: read only. Pick the latest version to edit.',+ 'st.capLines': 'Lines',+ 'st.capLook': 'Look',+ 'st.capReview': (v) => `Review · ${v.n}`,+ 'st.flagged': 'Has something to review',+ 'st.markHi': 'Highlight: wrap the selected words to color them',+ 'st.del': 'Delete',+ 'st.aiFixed': 'AI changed “{heard}” to “{text}”',+ 'st.figCheck': 'Number “{text}” — heard: “{said}”',+ 'st.lineErr.short': 'Line is shorter than 0.1 s.',+ 'st.lineErr.after': 'Line starts after the end of the video.',+ 'st.lineErr.overlap': 'Line overlaps the previous one.',+ 'st.lineErr.empty': 'Line has no text.',+ 'st.reviewH': 'Review',+ 'st.reviewNone': 'Nothing to review.',+ 'st.prevItem': 'Previous item', 'st.nextItem': 'Next item',+ 'st.rFix': 'AI fix', 'st.rFig': 'Number',+ 'st.rKeep': 'Keep', 'st.rEdit': 'Edit', 'st.rRevert': 'Revert',+ 'st.rNoRevert': 'Can’t revert: the line no longer has the AI-fixed words',+ 'st.rStatus.keep': 'Kept', 'st.rStatus.edit': 'Opened for editing', 'st.rStatus.revert': 'Reverted to what was heard',+ 'st.uploadMusic': 'Upload a track',+ 'st.gain': 'Music volume',+ 'st.zoomKind': 'Zoom type',+ 'st.push': 'Slow push', 'st.punch': 'Punch', 'st.pushS': 'Push', 'st.punchS': 'Punch',+ 'st.pushHint': 'Slowly zooms over the whole block, eases back at the end.',+ 'st.punchHint': 'Snaps in, holds, then snaps back.',+ 'st.zStrength': 'Strength',+ 'st.zLength': 'Length',+ 'st.zoomPick': 'Pick a zoom block on the timeline, or add one at the playhead.',+ 'st.zoomHere': 'The playhead is inside a zoom: selected it.',+ 'st.zoomNoRoom': 'Not enough room for a new zoom here.',+ 'st.gfxPick': 'Pick a graphic on the timeline to edit its text, numbers and timing.',+ 'st.gStart': 'Graphic start time', 'st.gEnd': 'Graphic end time',+ 'st.estimate': 'estimate',+ 'st.delGfx': 'Delete graphic',+ 'st.aiH': 'AI edit',+ 'st.aiHint': 'Say what to change; AI rebuilds from the latest version (a few minutes).',+ 'st.aiGo': 'Edit with AI',+ 'st.aiPending': (v) => `${v.n} unpublished change${v.n === 1 ? '' : 's'}: publish or discard them before an AI edit.`,+ 'st.noLineHere': 'The playhead is not on a caption line.',+ 'st.noMerge': 'Pick a line that has a next line to merge.',+ 'st.selFirst': 'Select a block on the timeline first.',+ 'st.fixFirst': (v) => `${v.n} caption line${v.n === 1 ? ' has' : 's have'} errors (red): fix before publishing.`,+ 'st.notFound': 'Could not open this edit: {e}',+ 'st.buildErr': 'This edit failed: {e}',+ 'gf.kicker': 'Kicker', 'gf.title': 'Title', 'gf.unit': 'Unit', 'gf.label': 'Label', 'gf.prefix': 'Prefix',+ 'gf.value': 'Number', 'gf.suffix': 'Suffix', 'gf.old': 'Old price', 'gf.text': 'Text', 'gf.a': 'Column A', 'gf.b': 'Column B',+ 'gf.row': 'Row {n}', 'gf.ok': 'Tick ✓',+ 'gfx.counter': 'Counter', 'gfx.bar_chart': 'Bar chart', 'gfx.compare': 'Compare', 'gfx.spec_table': 'Table',+ 'gfx.checklist': 'Checklist', 'gfx.price_tag': 'Price tag', 'gfx.sticker': 'Sticker', 'gfx.line_chart': 'Line chart', 'gfx.title_card': 'Title card',+ };++ // Chuỗi tiếng Việt cố định do server trả cho giao diện (nhãn tuỳ chọn, bước dựng). Không gồm lỗi, tên mẫu, kiểu edit.+ const SRV_EN = {+ 'Tự chọn theo mẫu': 'Auto (by template)', 'Không nhạc': 'No music',+ 'Theo mẫu (chỉ đọc khi mẫu có lời)': 'Template default (only if it has a script)', 'Không lời đọc': 'No voiceover',+ 'Tiếng Việt': 'Vietnamese',+ nam: 'male', 'nữ': 'female', 'Bắc': 'North', Trung: 'Central', Nam: 'South',+ 'tự nhiên (mặc định)': 'natural (default)', 'kể chuyện, trầm': 'storytelling, deep', 'tự nhiên': 'natural', 'lầy': 'goofy',+ 'tin tức': 'news', 'kể chuyện': 'storytelling', 'đọc truyện': 'audiobook', 'cần mạng': 'needs internet',+ 'ấm, tự nhiên (mặc định)': 'warm, natural (default)', 'sáng, nhiều cảm xúc': 'bright, expressive', 'trầm, điềm đạm': 'deep, calm',+ 'khoẻ, dứt khoát': 'strong, crisp', 'nhẹ nhàng, rõ chữ': 'soft, clear', 'trầm, kể chuyện': 'deep, storytelling',+ 'lofi ấm, chậm, có tiếng đĩa than (78 BPM)': 'warm lo-fi, slow, vinyl crackle (78 BPM)',+ 'pop sáng, 4 phách đều, vui tươi (118 BPM)': 'bright pop, steady four-beat, cheerful (118 BPM)',+ 'drone căng, nhịp tim, tích tắc (70 BPM)': 'tense drone, heartbeat, ticking (70 BPM)',+ 'tung tăng, marimba + pizzicato (112 BPM)': 'bouncy marimba + pizzicato (112 BPM)',+ 'điện ảnh: dàn dây + trống trận (90 BPM)': 'cinematic: strings + war drums (90 BPM)',+ 'game 8-bit: xung vuông + trống nhiễu (132 BPM)': '8-bit game: square waves + noise drums (132 BPM)',+ 'Bắt đầu': 'Starting', 'Kiểm tra ffmpeg': 'Checking ffmpeg', 'Tạo môi trường Python': 'Creating the Python environment',+ 'Cài gói Python (vài trăm MB)': 'Installing Python packages (a few hundred MB)', 'Cài phần chạy bằng GPU (~2 GB)': 'Installing GPU support (~2 GB)',+ 'Tải model nhận mặt, người': 'Downloading face and person models', 'Chuẩn bị font phụ đề': 'Preparing caption fonts',+ 'Tải model chép lời (~3 GB, lâu nhất)': 'Downloading the speech-to-text model (~3 GB, the longest step)', 'Kiểm tra lần cuối': 'Final check',+ 'piano chậm, cảm hứng, không trống (70 BPM)': 'slow inspiring piano, no drums (70 BPM)',+ 'nền bản tin: nhịp đều, pad + tiếng tích (120 BPM)': 'newsroom bed: steady pulse, pad + ticks (120 BPM)',+ 'nạp': 'load', 'phân tích': 'analyze', 'LLM lập EDL': 'LLM plans EDL', 'xem trước': 'preview', 'render nền': 'base render',+ 'phụ đề': 'captions', 'tiếng': 'audio', 'ghép': 'mux', 'kiểm': 'check',+ // ghi chú bước của "Tạo mẫu từ video"+ 'đã sửa guidance': 'guidance revised', 'giữ nguyên guidance': 'guidance kept as is', 'lỗi': 'error',+ };+ // Mảnh câu trong gợi ý cài đặt / tên giọng ("Heart (US, nữ)").+ const SRV_EN_PARTS = [+ ['Cài giọng đọc: ', 'Install voices: '], ['Cài giọng Anh: ', 'Install English voices: '],+ [' (đang dùng edge-tts, cần mạng)', ' (using edge-tts for now, needs internet)'], [' (hoặc pip install edge-tts)', ' (or pip install edge-tts)'],+ [/, nữ(?=[,)])/g, ', female'], [/, nam(?=[,)])/g, ', male'],+ [/^(\d+) chỉ số lệch$/, '$1 measures off'],+ ];++ const TABLE = { vi, en };+ const KEY = 'lumreels.lang';+ let lang = 'vi';+ try { lang = localStorage.getItem(KEY) || ''; } catch { lang = ''; }+ if (lang !== 'vi' && lang !== 'en') lang = /^vi\b/i.test(navigator.language || '') ? 'vi' : 'en';++ function t(key, vars = {}) {+ let v = TABLE[lang][key];+ if (v === undefined) v = vi[key];+ if (v === undefined) return key;+ if (typeof v === 'function') return v(vars);+ return v.replace(/\{(\w+)\}/g, (m, k) => (k in vars ? String(vars[k]) : m));+ }+ function srv(s) {+ if (lang === 'vi' || s == null) return s;+ const str = String(s);+ if (Object.prototype.hasOwnProperty.call(SRV_EN, str)) return SRV_EN[str];+ return SRV_EN_PARTS.reduce((acc, [a, b]) => (typeof a === 'string' ? acc.split(a).join(b) : acc.replace(a, b)), str);+ }+ function apply(root = document) {+ root.querySelectorAll('[data-i18n]').forEach((el) => { el.textContent = t(el.dataset.i18n); });+ root.querySelectorAll('[data-i18n-placeholder]').forEach((el) => { el.placeholder = t(el.dataset.i18nPlaceholder); });+ root.querySelectorAll('[data-i18n-aria]').forEach((el) => { el.setAttribute('aria-label', t(el.dataset.i18nAria)); });+ root.querySelectorAll('[data-i18n-title]').forEach((el) => { el.title = t(el.dataset.i18nTitle); });+ }+ function syncSwitch() {+ document.querySelectorAll('[data-lang]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.lang === lang)));+ }+ function set(next) {+ if (next !== 'vi' && next !== 'en') return;+ const changed = next !== lang;+ lang = next;+ try { localStorage.setItem(KEY, lang); } catch { /* bỏ qua */ }+ document.documentElement.lang = lang;+ apply();+ syncSwitch();+ if (changed) window.dispatchEvent(new CustomEvent('lumreels:lang', { detail: { lang } }));+ }++ window.I18N = {+ t, srv, set, apply,+ get lang() { return lang; },+ /** Locale cho toLocaleString. */+ get locale() { return lang === 'vi' ? 'vi-VN' : 'en-GB'; },+ };++ document.addEventListener('click', (e) => { const b = e.target.closest?.('[data-lang]'); if (b) set(b.dataset.lang); });+ document.documentElement.lang = lang;+ apply();+ syncSwitch();+})();diff --git a/server/public/index.html b/server/public/index.htmlindex 5cfdec7..4fe038e 100644--- a/server/public/index.html+++ b/server/public/index.html@@ -1,291 +1,269 @@-<!doctype html>-<html lang="vi">-<head>-<meta charset="UTF-8" />-<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />-<title data-i18n="meta.title">LumReels — dựng video dọc từ mẫu</title>-<link rel="stylesheet" href="/fonts/fonts.css" />-<link rel="stylesheet" href="/style.css" />-<link rel="stylesheet" href="/edit-panel.css" />-<link rel="stylesheet" href="/packs-panel.css" />-</head>-<body>-<header class="top">- <div class="brand"><span class="mark" aria-hidden="true"></span>LumReels</div>- <p class="tag" data-i18n="top.tag">Chọn mẫu, dán nội dung, AI dựng cảnh, ra MP4 dọc 1080×1920.</p>- <button type="button" class="ghost packs-open" id="packsOpen" data-packs-open><span data-i18n="pack.mineBtn">Gói của tôi</span></button>- <div class="lang-sw" role="group" aria-label="Ngôn ngữ giao diện" data-i18n-aria="lang.group">- <button type="button" data-lang="vi" aria-pressed="true" aria-label="Tiếng Việt" data-i18n-aria="lang.vi">VI</button>- <button type="button" data-lang="en" aria-pressed="false" aria-label="Tiếng Anh" data-i18n-aria="lang.en">EN</button>- </div>-</header>-<div id="update-banner" class="update-banner" role="status" hidden>- <span class="ub-text"></span>- <button type="button" class="ub-close" aria-label="Ẩn thông báo" data-i18n-aria="update.hide">×</button>-</div>--<nav class="tabs" role="tablist" aria-label="Chế độ" data-i18n-aria="tabs.aria">- <button type="button" class="tab" role="tab" data-tab="tpl" aria-selected="true" aria-controls="tplTab"><span data-i18n="tabs.tpl">Dựng từ mẫu</span></button>- <button type="button" class="tab" role="tab" data-tab="edit" aria-selected="false" aria-controls="editTab"><span data-i18n="tabs.edit">Edit video của bạn</span><span class="new" data-i18n="tabs.new">MỚI</span></button>-</nav>--<main class="layout" id="tplTab" role="tabpanel">- <section class="pick" aria-labelledby="h-pick">- <div class="sec-head">- <h2 id="h-pick"><span class="step">1</span><span data-i18n="pick.h">Chọn mẫu</span></h2>- <span class="count" id="tplCount"></span>- </div>- <div class="filters">- <label class="search">- <span class="sr" data-i18n="pick.searchLabel">Tìm mẫu theo tên</span>- <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>- <input id="q" type="search" placeholder="Tìm theo tên, thể loại…" data-i18n-placeholder="pick.searchPh" autocomplete="off" />- </label>- <div class="pack-act">- <button type="button" class="ghost" id="packImport" data-pack-import aria-haspopup="dialog">- <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4v12m0 0-4-4m4 4 4-4"/><path d="M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3"/></svg>- <span data-i18n="pack.importBtn">Nhập gói</span>- </button>- </div>- <div class="chips" role="radiogroup" aria-label="Lọc theo nhóm" data-i18n-aria="pick.chipsAria">- <button class="chip on" data-cat="" role="radio" aria-checked="true" data-i18n="cat.all">Tất cả</button>- <button class="chip" data-cat="faceless" role="radio" aria-checked="false" data-i18n="cat.faceless">Faceless</button>- <button class="chip" data-cat="ads" role="radio" aria-checked="false" data-i18n="cat.ads">Quảng cáo</button>- <button class="chip" data-cat="multi-style" role="radio" aria-checked="false" data-i18n="cat.multi-style">Đa phong cách</button>- <button class="chip" data-cat="viet-nam" role="radio" aria-checked="false" data-i18n="cat.viet-nam">Việt Nam hoá</button>- <button class="chip" data-src="local" role="radio" aria-checked="false" data-i18n="src.local">Của tôi</button>- <button class="chip" data-src="pack" role="radio" aria-checked="false" data-i18n="src.pack">Cộng đồng</button>- </div>- <label class="toggle"><input type="checkbox" id="readyOnly" /> <span data-i18n="pick.readyOnly">Chỉ mẫu dùng được</span></label>- <label class="toggle switch"><input type="checkbox" id="multiPick" role="switch" aria-describedby="multiHint" /> <span data-i18n="pick.multi">Chọn nhiều mẫu</span></label>- <span class="sr" id="multiHint" data-i18n="pick.multiHint">Bật lên thì bấm mẫu để chọn hoặc bỏ, tối đa 12 mẫu, mỗi mẫu ra 1 video cùng nội dung.</span>- </div>- <p class="pick-note" id="pickNote" role="status" aria-live="polite"></p>- <div id="grid" class="grid" aria-live="polite"></div>- </section>-- <aside class="compose" aria-labelledby="h-compose">- <div class="sticky">- <h2 id="h-compose"><span class="step">2</span><span data-i18n="compose.h">Nội dung</span></h2>- <div id="picked" class="picked empty">Chưa chọn mẫu. Bấm 1 mẫu sáng màu bên trái.</div>- <div class="field-head">- <label class="field" for="content" data-i18n="compose.label">Nội dung video</label>- <button type="button" id="rewrite" class="ghost" disabled aria-describedby="rwHint">- <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 20h4L19 9l-4-4L4 16z"/><path d="m13.5 6.5 4 4"/></svg>- <span data-i18n="rw.btn">Viết lại kịch bản</span>- </button>- </div>- <textarea id="content" rows="7" maxlength="4000" data-i18n-placeholder="compose.ph" placeholder="Ví dụ: Mỗi tháng bỏ 3 triệu vào quỹ chỉ số, lãi giả định 10%/năm, sau 20 năm có bao nhiêu? Kênh: Lumfin. CTA: Theo dõi để biết thêm mẹo tiền"></textarea>- <div class="hint"><span id="chars">0</span><span data-i18n="compose.charsTail">/4000 ký tự · ghi luôn tên kênh và CTA nếu có</span></div>- <div class="hint" id="rwHint">Viết lại kịch bản: AI xếp nội dung vào đúng ô của mẫu đang chọn và thời lượng bên dưới, giữ nguyên số liệu, tên kênh, CTA.</div>- <div id="rwBox" class="rw" hidden aria-live="polite"></div>-- <label class="field" for="duration"><span data-i18n="dur.label">Thời lượng</span> <span class="opt" data-i18n="dur.range">(3 giây – 10 phút)</span></label>- <div class="dur">- <input id="duration" type="text" inputmode="numeric" autocomplete="off" spellcheck="false" value="8"- placeholder="8" aria-describedby="durHint" />- <div class="presets" role="group" aria-label="Chọn nhanh thời lượng" data-i18n-aria="dur.presets">- <button type="button" class="pre on" data-dur="8">8s</button>- <button type="button" class="pre" data-dur="15">15s</button>- <button type="button" class="pre" data-dur="30">30s</button>- <button type="button" class="pre" data-dur="60">60s</button>- </div>- </div>- <div class="hint" id="durHint">Gõ số giây (90) hoặc phút:giây (1:30).</div>- <div class="warn" id="durWarn" hidden></div>- <div id="audioPanel" aria-label="Âm thanh" data-i18n-aria="audio.aria"></div>- <div class="row">- <div class="span2">- <label class="field" for="mode" data-i18n="mode.label">Ai dựng cảnh</label>- <select id="mode">- <option value="auto" data-i18n="mode.auto">Tự động</option>- <option value="api">Claude API</option>- <option value="claude">Claude Code</option>- <option value="manual" data-i18n="mode.manual">Agent ngoài</option>- </select>- </div>- <div class="span2">- <label class="field" for="model" data-i18n="model.label">Model viết cảnh</label>- <select id="model">- <option value="auto">Tự chọn theo mẫu</option>- <option value="opus" data-i18n="model.opus">Opus (đẹp nhất, tốn nhất)</option>- <option value="sonnet" data-i18n="model.sonnet">Sonnet (cân bằng)</option>- <option value="haiku" data-i18n="model.haiku">Haiku (rẻ nhất)</option>- </select>- </div>- </div>- <div class="hint" id="modelHint"></div>- <label class="field" for="runAt"><span data-i18n="runAt.label">Hẹn giờ dựng</span> <span class="opt" data-i18n="runAt.opt">(bỏ trống = dựng ngay)</span></label>- <div class="when">- <input id="runAt" type="datetime-local" step="60" />- <button type="button" id="clearAt" class="mini" aria-label="Bỏ hẹn giờ" data-i18n-aria="runAt.clearAria" data-i18n="runAt.clear">Bỏ hẹn</button>- </div>- <div class="hint" id="modeHint"></div>- <p class="err" id="formErr" role="alert"></p>- <button id="go" class="go" disabled>- <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 4v16l13-8z"/></svg>- <span>Dựng video</span>- </button>- </div>- </aside>-- <section class="jobs" aria-labelledby="h-jobs">- <div class="sec-head"><h2 id="h-jobs" data-i18n="jobs.h">Video đã dựng</h2></div>- <div id="jobs" class="job-list"></div>- </section>-</main>--<section class="edit-wrap" id="editTab" role="tabpanel" aria-label="Edit video của bạn" data-i18n-aria="ed.aria" hidden>- <div class="ed-card ed-setup" id="edSetup" hidden>- <h3 data-i18n="ed.setupH">Chưa cài phần Edit video</h3>- <p id="edSetupText"></p>- <div class="ed-setup-act">- <button type="button" class="ed-install" id="edInstall" data-i18n="ed.install">Cài ngay</button>- <span class="ed-install-note" data-i18n="ed.installNote">Tải khoảng 6 GB, mất 5–20 phút tuỳ mạng. Cứ để trang mở.</span>- </div>- <div class="ed-install-prog" id="edInstallProg" hidden>- <div class="ed-install-step" id="edInstallStep" role="status" aria-live="polite"></div>- <div class="ed-install-bar" aria-hidden="true"><span></span></div>- <div class="ed-install-hint" id="edInstallHint" hidden></div>- <details><summary data-i18n="ed.installDetails">Xem chi tiết</summary><pre id="edInstallLog"></pre></details>- </div>- <details class="ed-setup-manual"><summary data-i18n="ed.installManual">Hoặc tự cài bằng lệnh</summary><div class="cmd" id="edSetupCmd">node edit/setup.mjs</div></details>- </div>- <div class="ed-card">- <h2><span class="step">1</span><span data-i18n="ed.h">Video của bạn</span></h2>- <div class="drop" id="edDrop" role="button" tabindex="0" aria-label="Chọn hoặc kéo thả video" data-i18n-aria="ed.dropAria">- <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 16V4m0 0-4 4m4-4 4 4"/><path d="M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3"/></svg>- <span class="big">Kéo thả video vào đây</span>- <span class="small">hoặc bấm để chọn · mp4, mov, mkv… tối đa 2 GB · nói trước máy, tiếng Việt</span>- </div>- <label class="sr" for="edVideo" data-i18n="ed.fileLabel">File video</label><input type="file" id="edVideo" accept="video/*,.mkv,.mov" hidden />- <div class="sty-head"><span class="field" id="edStyleLbl" data-i18n="ed.style">Kiểu edit</span><span class="sty-count" id="edStyleCount"></span></div>- <div class="styles" id="edStyles" role="radiogroup" aria-labelledby="edStyleLbl" aria-describedby="edStyleDesc"></div>- <p class="sty-desc" id="edStyleDesc" aria-live="polite"></p>- <label class="field" for="edMusic"><span data-i18n="ed.music">Nhạc nền</span> <span class="opt" data-i18n="ed.musicOpt">(tự hạ khi bạn nói)</span></label>- <select id="edMusic"><option value="none" data-i18n="ed.noMusic">Không nhạc</option></select>- <label class="sr" for="edMusicFile" data-i18n="ed.musicFileLabel">File nhạc</label><input type="file" id="edMusicFile" accept="audio/*" hidden />- <div class="ed-file" id="edMusicName"></div>- <label class="field" for="edNames"><span data-i18n="ed.names">Tên riêng, thuật ngữ</span> <span class="opt" data-i18n="ed.namesOpt">(để AI viết phụ đề đúng)</span></label>- <input class="ed-in" id="edNames" type="text" maxlength="400" placeholder="Ví dụ: Lumfin, Hà Nội, ETF" data-i18n-placeholder="ed.namesPh" autocomplete="off" />- <label class="field" for="edNotes"><span data-i18n="ed.notes">Dặn thêm</span> <span class="opt" data-i18n="ed.notesOpt">(không bắt buộc)</span></label>- <textarea id="edNotes" rows="3" maxlength="2000" placeholder="Ví dụ: bỏ câu chào đầu, giữ đoạn cuối kêu gọi theo dõi" data-i18n-placeholder="ed.notesPh"></textarea>- <label class="ed-check" for="edDraft"><input type="checkbox" id="edDraft" /> <span data-i18n="ed.draft">Bản nháp nhanh (phụ đề đơn giản, nhanh hơn ~1 phút)</span></label>- <p class="err" id="edErr" role="alert"></p>- <button id="edGo" class="go" disabled>- <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 4v16l13-8z"/></svg>- <span data-i18n="ed.go">Dựng</span>- </button>- </div>- <div class="ed-main">- <div class="ed-empty" id="edEmpty" data-i18n="ed.empty">Chọn video bên trái rồi bấm Dựng.</div>- <div class="ed-card ed-res" id="edView" hidden>- <div class="ed-rhead">- <div class="ed-rtitle"><span class="tt" id="edTitle"></span><span class="ed-dur" id="edDur"></span><span class="st" id="edStatus" hidden></span></div>- <div class="ed-ract">- <button type="button" class="ed-review" id="edReviewBtn" aria-expanded="false" aria-controls="edReviewPop" hidden>- <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 9v4m0 4h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z"/></svg><span id="edReviewL"></span>- </button>- <a class="ed-dl" id="edDl" download hidden><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4v12m0 0-5-5m5 5 5-5M4 20h16"/></svg><span data-i18n="ed.mp4">Tải MP4</span></a>- <button type="button" class="ed-moreb" id="edMoreBtn" aria-expanded="false" aria-controls="edMorePop" aria-label="Thêm" data-i18n-aria="ed.more">- <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="5" cy="12" r="1.7"/><circle cx="12" cy="12" r="1.7"/><circle cx="19" cy="12" r="1.7"/></svg>- </button>- </div>- <div class="ed-pop" id="edReviewPop" hidden><ul class="ed-rlist" id="edReviewList"></ul></div>- <div class="ed-pop" id="edMorePop" hidden>- <div class="ed-popmeta" id="edId"></div>- <div class="ed-poplinks" id="edLinks"></div>- <h4 data-i18n="ed.specs">Thông số</h4>- <div class="ed-checks" id="edChecks"></div>- <details class="log"><summary data-i18n="ed.log">Nhật ký</summary><pre id="edLog"></pre></details>- <button type="button" class="ed-delb" id="edDelete" data-i18n="ed.delete">Xoá bản dựng này</button>- </div>- </div>- <div class="ed-prog" id="edProg" hidden><div class="bar"><i id="edBar"></i></div><span class="ed-progt" id="edProgText" aria-live="polite"></span></div>- <div class="errmsg" id="edViewErr" role="alert"></div>- <div class="ed-body">- <div class="ed-stage">- <div class="ed-media" id="edMedia"></div>- <div class="ed-tl" id="edTl" hidden>- <div class="ed-tltrack" id="edTlTrack" aria-hidden="true"><i class="ed-tlh" id="edTlHead"></i></div>- <div class="ed-tlleg" aria-hidden="true"><span class="z" data-i18n="man.zooms">Zoom</span><span class="g" data-i18n="man.gfx">Đồ hoạ</span></div>- </div>- </div>- <section class="ed-side" id="edMan" hidden aria-label="Chỉnh" data-i18n-aria="man.h">- <div class="ed-mtabs" role="tablist" aria-label="Chỉnh" data-i18n-aria="man.h">- <button type="button" role="tab" id="edMtCap" aria-controls="edMpCap" aria-selected="true" data-i18n="man.tabCap">Phụ đề</button>- <button type="button" role="tab" id="edMtAud" aria-controls="edMpAud" aria-selected="false" tabindex="-1" data-i18n="man.tabAud">Nhạc & tiếng</button>- <button type="button" role="tab" id="edMtFx" aria-controls="edMpFx" aria-selected="false" tabindex="-1" data-i18n="man.tabFx">Zoom & đồ hoạ</button>- <button type="button" role="tab" id="edMtRev" aria-controls="edMpRev" aria-selected="false" tabindex="-1" data-i18n="ed.reviseH">Sửa bằng lời</button>- </div>- <div role="tabpanel" id="edMpCap" aria-labelledby="edMtCap" class="ed-mpanel">- <div class="ed-captop">- <label class="ed-mini" for="edManLook" data-i18n="man.look">Kiểu chữ</label>- <select class="ed-sm" id="edManLook"></select>- <label class="ed-minichk" title="Bọc *chữ* để đổi màu" data-i18n-title="man.hiTip"><input type="checkbox" id="edManHi" /> <span data-i18n="man.hiShort">Chữ nhấn</span></label>- </div>- <p class="hint" id="edManDraft" hidden data-i18n="man.draftNote">Bản nháp vẽ phụ đề thẳng vào nền nên chưa sửa tay được. Bỏ "nháp" rồi dựng lại.</p>- <ol class="ed-lines" id="edLines" aria-label="Phụ đề" data-i18n-aria="man.tabCap"></ol>- </div>- <div role="tabpanel" id="edMpAud" aria-labelledby="edMtAud" class="ed-mpanel" hidden>- <div class="ed-arow">- <label class="ed-mini" for="edManMusic" data-i18n="man.music">Nhạc</label>- <select class="ed-sm" id="edManMusic"></select>- <input type="file" id="edManMusicFile" accept="audio/*,.mp3,.wav,.m4a,.aac,.ogg,.flac,.opus" hidden />- </div>- <div class="ed-file" id="edManMusicMsg" aria-live="polite"></div>- <div class="ed-agrp" id="edManMusicBox">- <div class="ed-arow"><label class="ed-mini" for="edManGain" data-i18n="man.gainS">Âm lượng</label><input type="range" id="edManGain" min="-40" max="0" step="1" /><output id="edManGainV" for="edManGain"></output></div>- <div class="ed-arow"><label class="ed-mini" for="edManFade" data-i18n="man.fadeS">Fade cuối</label><input type="range" id="edManFade" min="0" max="10" step="0.5" /><output id="edManFadeV" for="edManFade"></output></div>- <div class="ed-arow"><label class="ed-mini" for="edManStart" data-i18n="man.startS">Bắt đầu (s)</label><input class="ed-sm ed-num" id="edManStart" type="number" min="0" max="600" step="0.5" inputmode="decimal" /></div>- <label class="ed-minichk"><input type="checkbox" id="edManDuck" /> <span data-i18n="man.duckS">Tự hạ khi nói</span></label>- </div>- <div class="ed-agrp">- <div class="ed-arow" title="Cả bản luôn chuẩn về −14 LUFS: tăng giọng tức là nhạc và tiếng động nhỏ đi tương đối." data-i18n-title="man.loudHint"><label class="ed-mini" for="edManVoice" data-i18n="man.voiceS">Giọng</label><input type="range" id="edManVoice" min="-12" max="12" step="1" /><output id="edManVoiceV" for="edManVoice"></output></div>- <label class="ed-minichk"><input type="checkbox" id="edManSfx" /> <span id="edManSfxL">Tiếng động</span></label>- </div>- </div>- <div role="tabpanel" id="edMpFx" aria-labelledby="edMtFx" class="ed-mpanel" hidden>- <h5 data-i18n="man.zooms">Zoom</h5>- <ul class="ed-fxlist" id="edManZooms"></ul>- <h5 data-i18n="man.gfx">Đồ hoạ</h5>- <ul class="ed-fxlist" id="edManGfx"></ul>- </div>- <div role="tabpanel" id="edMpRev" aria-labelledby="edMtRev" class="ed-mpanel" hidden>- <form id="edReviseForm" class="ed-revf">- <label class="sr" for="edReviseText" data-i18n="ed.reviseLabel">Lời sửa</label>- <input class="ed-in" id="edReviseText" type="text" maxlength="1000" placeholder="bỏ 3 giây đầu…" data-i18n-placeholder="ed.revisePhS" autocomplete="off" />- <button type="submit" id="edReviseBtn" data-i18n="ed.reviseBtn">Render lại</button>- </form>- <div class="ed-presets" id="edPresets"><button type="button" data-i18n="ed.p1">bỏ 3 giây đầu</button><button type="button" data-i18n="ed.p2">zoom ít lại</button><button type="button" data-i18n="ed.p3">nhạc nhỏ lại</button></div>- <div class="ed-hist" id="edHist" hidden><h5 data-i18n="ed.histH">Các lần sửa</h5><ol id="edHistList"></ol></div>- </div>- <div class="errmsg" id="edManErr" role="alert"></div>- <div class="ed-mbar" id="edManBar" hidden>- <span class="ed-mdirty" id="edManDirty" aria-live="polite"></span>- <button type="button" class="ed-mreset" id="edManReset" data-i18n="man.reset">Bỏ thay đổi</button>- <button type="button" class="ed-mapply" id="edManApply" data-i18n="man.apply">Áp dụng</button>- </div>- </section>- </div>- </div>- <h2 data-i18n="ed.listH">Các bản đã dựng</h2>- <div class="ed-list" id="edList"></div>- </div>-</section>--<dialog id="viewer" aria-label="Video minh hoạ của mẫu" data-i18n-aria="viewer.aria">- <div class="dlg-head"><strong id="vTitle"></strong><button class="x" id="vClose" aria-label="Đóng" data-i18n-aria="viewer.close">×</button></div>- <video id="vVideo" controls playsinline preload="metadata"></video>- <p class="dlg-desc" id="vDesc"></p>-</dialog>--<script src="/i18n.js"></script>-<script src="/audio-panel.js"></script>-<script src="/voice-clone.js"></script>-<script src="/app.js"></script>-<script src="/edit-panel.js"></script>-<script src="/packs-panel.js"></script>-<script src="/learn-panel.js"></script>-</body>-</html>+<!doctype html>+<html lang="vi">+<head>+<meta charset="UTF-8" />+<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />+<title data-i18n="meta.title">LumReels — dựng video dọc từ mẫu</title>+<link rel="icon" href="data:," />+<link rel="stylesheet" href="/fonts/fonts.css" />+<link rel="stylesheet" href="/style.css" />+<link rel="stylesheet" href="/studio/create.css" />+<link rel="stylesheet" href="/studio/studio.css" />+<link rel="stylesheet" href="/packs-panel.css" />+</head>+<body>+<header class="top">+ <div class="brand"><span class="mark" aria-hidden="true"></span>LumReels</div>+ <p class="tag" data-i18n="top.tag">Chọn mẫu, dán nội dung, AI dựng cảnh, ra MP4 dọc 1080×1920.</p>+ <button type="button" class="ghost packs-open" id="packsOpen" data-packs-open><span data-i18n="pack.mineBtn">Gói của tôi</span></button>+ <div class="lang-sw" role="group" aria-label="Ngôn ngữ giao diện" data-i18n-aria="lang.group">+ <button type="button" data-lang="vi" aria-pressed="true" aria-label="Tiếng Việt" data-i18n-aria="lang.vi">VI</button>+ <button type="button" data-lang="en" aria-pressed="false" aria-label="Tiếng Anh" data-i18n-aria="lang.en">EN</button>+ </div>+</header>+<div id="update-banner" class="update-banner" role="status" hidden>+ <span class="ub-text"></span>+ <button type="button" class="ub-close" aria-label="Ẩn thông báo" data-i18n-aria="update.hide">×</button>+</div>++<nav class="tabs" role="tablist" aria-label="Chế độ" data-i18n-aria="tabs.aria">+ <button type="button" class="tab" role="tab" data-tab="tpl" aria-selected="true" aria-controls="tplTab"><span data-i18n="tabs.tpl">Dựng từ mẫu</span></button>+ <button type="button" class="tab" role="tab" data-tab="edit" aria-selected="false" aria-controls="editTab"><span data-i18n="tabs.edit">Edit video của bạn</span><span class="new" data-i18n="tabs.new">MỚI</span></button>+</nav>++<main class="layout" id="tplTab" role="tabpanel">+ <section class="pick" aria-labelledby="h-pick">+ <div class="sec-head">+ <h2 id="h-pick"><span class="step">1</span><span data-i18n="pick.h">Chọn mẫu</span></h2>+ <span class="count" id="tplCount"></span>+ </div>+ <div class="filters">+ <label class="search">+ <span class="sr" data-i18n="pick.searchLabel">Tìm mẫu theo tên</span>+ <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>+ <input id="q" type="search" placeholder="Tìm theo tên, thể loại…" data-i18n-placeholder="pick.searchPh" autocomplete="off" />+ </label>+ <div class="pack-act">+ <button type="button" class="ghost" id="packImport" data-pack-import aria-haspopup="dialog">+ <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4v12m0 0-4-4m4 4 4-4"/><path d="M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3"/></svg>+ <span data-i18n="pack.importBtn">Nhập gói</span>+ </button>+ </div>+ <div class="chips" role="radiogroup" aria-label="Lọc theo nhóm" data-i18n-aria="pick.chipsAria">+ <button class="chip on" data-cat="" role="radio" aria-checked="true" data-i18n="cat.all">Tất cả</button>+ <button class="chip" data-cat="faceless" role="radio" aria-checked="false" data-i18n="cat.faceless">Faceless</button>+ <button class="chip" data-cat="ads" role="radio" aria-checked="false" data-i18n="cat.ads">Quảng cáo</button>+ <button class="chip" data-cat="multi-style" role="radio" aria-checked="false" data-i18n="cat.multi-style">Đa phong cách</button>+ <button class="chip" data-cat="viet-nam" role="radio" aria-checked="false" data-i18n="cat.viet-nam">Việt Nam hoá</button>+ <button class="chip" data-src="local" role="radio" aria-checked="false" data-i18n="src.local">Của tôi</button>+ <button class="chip" data-src="pack" role="radio" aria-checked="false" data-i18n="src.pack">Cộng đồng</button>+ </div>+ <label class="toggle"><input type="checkbox" id="readyOnly" /> <span data-i18n="pick.readyOnly">Chỉ mẫu dùng được</span></label>+ <label class="toggle switch"><input type="checkbox" id="multiPick" role="switch" aria-describedby="multiHint" /> <span data-i18n="pick.multi">Chọn nhiều mẫu</span></label>+ <span class="sr" id="multiHint" data-i18n="pick.multiHint">Bật lên thì bấm mẫu để chọn hoặc bỏ, tối đa 12 mẫu, mỗi mẫu ra 1 video cùng nội dung.</span>+ </div>+ <p class="pick-note" id="pickNote" role="status" aria-live="polite"></p>+ <div id="grid" class="grid" aria-live="polite"></div>+ </section>++ <aside class="compose" aria-labelledby="h-compose">+ <div class="sticky">+ <h2 id="h-compose"><span class="step">2</span><span data-i18n="compose.h">Nội dung</span></h2>+ <div id="picked" class="picked empty">Chưa chọn mẫu. Bấm 1 mẫu sáng màu bên trái.</div>+ <div class="field-head">+ <label class="field" for="content" data-i18n="compose.label">Nội dung video</label>+ <button type="button" id="rewrite" class="ghost" disabled aria-describedby="rwHint">+ <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 20h4L19 9l-4-4L4 16z"/><path d="m13.5 6.5 4 4"/></svg>+ <span data-i18n="rw.btn">Viết lại kịch bản</span>+ </button>+ </div>+ <textarea id="content" rows="7" maxlength="4000" data-i18n-placeholder="compose.ph" placeholder="Ví dụ: Mỗi tháng bỏ 3 triệu vào quỹ chỉ số, lãi giả định 10%/năm, sau 20 năm có bao nhiêu? Kênh: Lumfin. CTA: Theo dõi để biết thêm mẹo tiền"></textarea>+ <div class="hint"><span id="chars">0</span><span data-i18n="compose.charsTail">/4000 ký tự · ghi luôn tên kênh và CTA nếu có</span></div>+ <div class="hint" id="rwHint">Viết lại kịch bản: AI xếp nội dung vào đúng ô của mẫu đang chọn và thời lượng bên dưới, giữ nguyên số liệu, tên kênh, CTA.</div>+ <div id="rwBox" class="rw" hidden aria-live="polite"></div>++ <label class="field" for="duration"><span data-i18n="dur.label">Thời lượng</span> <span class="opt" data-i18n="dur.range">(3 giây – 10 phút)</span></label>+ <div class="dur">+ <input id="duration" type="text" inputmode="numeric" autocomplete="off" spellcheck="false" value="8"+ placeholder="8" aria-describedby="durHint" />+ <div class="presets" role="group" aria-label="Chọn nhanh thời lượng" data-i18n-aria="dur.presets">+ <button type="button" class="pre on" data-dur="8">8s</button>+ <button type="button" class="pre" data-dur="15">15s</button>+ <button type="button" class="pre" data-dur="30">30s</button>+ <button type="button" class="pre" data-dur="60">60s</button>+ </div>+ </div>+ <div class="hint" id="durHint">Gõ số giây (90) hoặc phút:giây (1:30).</div>+ <div class="warn" id="durWarn" hidden></div>+ <div id="audioPanel" aria-label="Âm thanh" data-i18n-aria="audio.aria"></div>+ <div class="row">+ <div class="span2">+ <label class="field" for="mode" data-i18n="mode.label">Ai dựng cảnh</label>+ <select id="mode">+ <option value="auto" data-i18n="mode.auto">Tự động</option>+ <option value="api">Claude API</option>+ <option value="claude">Claude Code</option>+ <option value="manual" data-i18n="mode.manual">Agent ngoài</option>+ </select>+ </div>+ <div class="span2">+ <label class="field" for="model" data-i18n="model.label">Model viết cảnh</label>+ <select id="model">+ <option value="auto">Tự chọn theo mẫu</option>+ <option value="opus" data-i18n="model.opus">Opus (đẹp nhất, tốn nhất)</option>+ <option value="sonnet" data-i18n="model.sonnet">Sonnet (cân bằng)</option>+ <option value="haiku" data-i18n="model.haiku">Haiku (rẻ nhất)</option>+ </select>+ </div>+ </div>+ <div class="hint" id="modelHint"></div>+ <label class="field" for="runAt"><span data-i18n="runAt.label">Hẹn giờ dựng</span> <span class="opt" data-i18n="runAt.opt">(bỏ trống = dựng ngay)</span></label>+ <div class="when">+ <input id="runAt" type="datetime-local" step="60" />+ <button type="button" id="clearAt" class="mini" aria-label="Bỏ hẹn giờ" data-i18n-aria="runAt.clearAria" data-i18n="runAt.clear">Bỏ hẹn</button>+ </div>+ <div class="hint" id="modeHint"></div>+ <p class="err" id="formErr" role="alert"></p>+ <button id="go" class="go" disabled>+ <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 4v16l13-8z"/></svg>+ <span>Dựng video</span>+ </button>+ </div>+ </aside>++ <section class="jobs" aria-labelledby="h-jobs">+ <div class="sec-head"><h2 id="h-jobs" data-i18n="jobs.h">Video đã dựng</h2></div>+ <div id="jobs" class="job-list"></div>+ </section>+</main>++<section class="edit-wrap cr" id="editTab" role="tabpanel" aria-label="Edit video của bạn" data-i18n-aria="ed.aria" hidden>+ <div class="ed-card ed-setup" id="edSetup" hidden>+ <h3 data-i18n="ed.setupH">Chưa cài phần Edit video</h3>+ <p id="edSetupText"></p>+ <div class="ed-setup-act">+ <button type="button" class="ed-install" id="edInstall" data-i18n="ed.install">Cài ngay</button>+ <span class="ed-install-note" data-i18n="ed.installNote">Tải khoảng 6 GB, mất 5–20 phút tuỳ mạng. Cứ để trang mở.</span>+ </div>+ <div class="ed-install-prog" id="edInstallProg" hidden>+ <div class="ed-install-step" id="edInstallStep" role="status" aria-live="polite"></div>+ <div class="ed-install-bar" aria-hidden="true"><span></span></div>+ <div class="ed-install-hint" id="edInstallHint" hidden></div>+ <details><summary data-i18n="ed.installDetails">Xem chi tiết</summary><pre id="edInstallLog"></pre></details>+ </div>+ <details class="ed-setup-manual"><summary data-i18n="ed.installManual">Hoặc tự cài bằng lệnh</summary><div class="cmd" id="edSetupCmd">node edit/setup.mjs</div></details>+ </div>++ <div class="cr-shell">+ <div class="cr-top">+ <button type="button" class="cr-back" id="crBack" aria-label="Về bước trước" data-i18n-aria="cr.backStep" hidden>+ <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 19l-7-7 7-7M19 12H5"/></svg>+ </button>+ <b data-i18n="cr.title">Dự án mới</b>+ <ol class="cr-steps" id="crSteps" aria-label="Các bước" data-i18n-aria="cr.stepsAria">+ <li data-step="1"><button type="button"><i class="n">1</i><span data-i18n="cr.s1">Clip</span></button></li>+ <li class="ln" aria-hidden="true"></li>+ <li data-step="2"><button type="button"><i class="n">2</i><span data-i18n="cr.s2">Cách dựng</span></button></li>+ <li class="ln" aria-hidden="true"></li>+ <li data-step="3"><button type="button"><i class="n">3</i><span data-i18n="cr.s3">Dựng</span></button></li>+ </ol>+ </div>+ <div class="cr-body">+ <aside class="cr-side" id="crSide" aria-label="Thiết lập" data-i18n-aria="cr.sideAria">+ <div class="cr-blk">+ <div class="cr-h"><span data-i18n="cr.yourClip">Clip của bạn</span><button type="button" class="cr-link" id="crChange" data-i18n="cr.changeClip" hidden>Đổi clip</button></div>+ <div class="cr-clip" id="crClip">+ <div class="th"><video id="crClipVid" muted playsinline preload="metadata"></video><span class="d mono" id="crClipDur"></span></div>+ <div class="meta"><div><b id="crClipName"></b><span id="crClipInfo"></span></div><span class="ok" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M20 6L9 17l-5-5"/></svg></span></div>+ </div>+ <p class="cr-none" id="crClipNone" data-i18n="cr.noClip">Chưa chọn clip.</p>+ </div>+ <div class="cr-blk">+ <div class="cr-h"><span id="crMusicH" data-i18n="ed.music">Nhạc nền</span><small data-i18n="ed.musicOpt">(tự hạ khi bạn nói)</small></div>+ <div class="cr-chips" id="crMusic" role="radiogroup" aria-labelledby="crMusicH"></div>+ <label class="sr" for="edMusicFile" data-i18n="ed.musicFileLabel">File nhạc</label><input type="file" id="edMusicFile" accept="audio/*" hidden />+ <div class="ed-file" id="edMusicName"></div>+ </div>+ <div class="cr-blk">+ <div class="cr-h"><label for="crLen" data-i18n="cr.len">Độ dài bản ra</label><button type="button" class="cr-link" id="crLenAuto" data-i18n="cr.lenAuto">Tự động</button></div>+ <div class="cr-range"><input type="range" id="crLen" min="15" max="180" step="5" value="40" aria-describedby="crLenV" /><output id="crLenV" for="crLen" class="mono"></output></div>+ </div>+ <div class="cr-blk">+ <div class="cr-h"><span id="crNamesH" data-i18n="cr.names">Tên riêng</span><small data-i18n="cr.namesWhy">để phụ đề viết đúng</small></div>+ <div class="cr-chips" id="crNames" aria-labelledby="crNamesH"></div>+ <input class="ed-in cr-namein" id="edNames" type="text" maxlength="60" placeholder="Ví dụ: Lumfin" data-i18n-placeholder="cr.namePh" autocomplete="off" hidden aria-label="Thêm tên riêng" data-i18n-aria="cr.addName" />+ </div>+ <div class="cr-blk">+ <div class="cr-h"><label for="edNotes" data-i18n="ed.notes">Dặn thêm</label><small data-i18n="ed.notesOpt">(không bắt buộc)</small></div>+ <textarea id="edNotes" rows="3" maxlength="2000" placeholder="Ví dụ: bỏ câu chào đầu, giữ đoạn cuối kêu gọi theo dõi" data-i18n-placeholder="ed.notesPh"></textarea>+ <label class="ed-check" for="edDraft"><input type="checkbox" id="edDraft" /> <span data-i18n="ed.draft">Bản nháp nhanh (phụ đề đơn giản, nhanh hơn ~1 phút)</span></label>+ </div>+ </aside>++ <main class="cr-main">+ <div class="cr-pane" data-pane="1">+ <h1 data-i18n="cr.h1">Chọn clip</h1>+ <p class="cr-sub" data-i18n="cr.sub1">Video nói trước máy, tiếng Việt. AI cắt khoảng lặng, làm phụ đề, zoom và đồ hoạ.</p>+ <div class="drop" id="edDrop" role="button" tabindex="0" aria-label="Chọn hoặc kéo thả video" data-i18n-aria="ed.dropAria">+ <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 16V4m0 0-4 4m4-4 4 4"/><path d="M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3"/></svg>+ <span class="big">Kéo thả video vào đây</span>+ <span class="small">hoặc bấm để chọn · mp4, mov, mkv… tối đa 2 GB · nói trước máy, tiếng Việt</span>+ </div>+ <label class="sr" for="edVideo" data-i18n="ed.fileLabel">File video</label><input type="file" id="edVideo" accept="video/*,.mkv,.mov" hidden />+ <div class="cr-listh"><h2 data-i18n="ed.listH">Các bản đã dựng</h2><span class="cr-count mono" id="crCount"></span></div>+ <div class="cr-list" id="edList"></div>+ </div>+ <div class="cr-pane" data-pane="2" hidden>+ <h1 id="edStyleLbl" data-i18n="cr.h2">Chọn cách dựng</h1>+ <p class="cr-sub" data-i18n="cr.sub2">Mỗi cách là một kiểu cắt, phụ đề và đồ hoạ. Đổi lại được sau khi dựng.</p>+ <div class="cr-grid" id="edStyles" role="radiogroup" aria-labelledby="edStyleLbl" aria-describedby="edStyleDesc"></div>+ <p class="sty-desc" id="edStyleDesc" aria-live="polite"></p>+ </div>+ <div class="cr-pane" data-pane="3" hidden>+ <h1 data-i18n="cr.h3">Đang dựng</h1>+ <p class="cr-sub" id="crBuildSub"></p>+ <div class="cr-build" id="crBuild">+ <div class="cr-bthumb" id="crBuildThumb" aria-hidden="true"></div>+ <div class="cr-binfo">+ <b id="crBuildName"></b>+ <span class="st" id="crBuildStatus" role="status" aria-live="polite"></span>+ <div class="cr-bar"><i id="crBuildBar"></i></div>+ <span class="cr-bstep mono" id="crBuildStep"></span>+ <p class="err" id="crBuildErr" role="alert"></p>+ <div class="cr-bact">+ <a class="btn pri" id="crOpen" hidden><span data-i18n="cr.open">Mở Studio</span></a>+ <button type="button" class="btn ghost" id="crAnother" data-i18n="cr.another">Dựng clip khác</button>+ </div>+ </div>+ </div>+ </div>+ </main>+ </div>+ <div class="cr-foot">+ <div class="cr-sum" id="crSum"></div>+ <span class="cr-eta" id="crEta"></span>+ <p class="err" id="edErr" role="alert"></p>+ <button id="edGo" class="btn pri cr-go" disabled>+ <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M11 3.5l1.8 5.2 5.2 1.8-5.2 1.8L11 17.5l-1.8-5.2L4 10.5l5.2-1.8zM19 15v5M16.5 17.5h5"/></svg>+ <span>Dựng video</span>+ </button>+ </div>+ </div>+</section>++<dialog id="viewer" aria-label="Video minh hoạ của mẫu" data-i18n-aria="viewer.aria">+ <div class="dlg-head"><strong id="vTitle"></strong><button class="x" id="vClose" aria-label="Đóng" data-i18n-aria="viewer.close">×</button></div>+ <video id="vVideo" controls playsinline preload="metadata"></video>+ <p class="dlg-desc" id="vDesc"></p>+</dialog>++<script src="/i18n.js"></script>+<script src="/audio-panel.js"></script>+<script src="/voice-clone.js"></script>+<script src="/app.js"></script>+<script type="module" src="/studio/create.js"></script>+<script type="module" src="/studio/studio.js"></script>+<script src="/packs-panel.js"></script>+<script src="/learn-panel.js"></script>+</body>+</html>diff --git a/server/public/studio/create.css b/server/public/studio/create.cssnew file mode 100644index 0000000..034c003--- /dev/null+++ b/server/public/studio/create.css@@ -0,0 +1,208 @@+/* Tab "Edit video của bạn" — màn tạo mới 3 bước (mẫu _final/18-ui-edit-mau/1-studio-tao-moi.png). Token ở style.css. */+:root {+ --bg-2: #131210; --panel-3: #2A2924; --line-2: #36342E; --ink-4: #5E5C55;+ --accent-2: #FF8A55; --accent-soft: rgba(255,107,44,.14); --warn-soft: rgba(242,201,76,.14); --ok-soft: rgba(93,211,158,.14);+ --violet: #A78BFA; --violet-soft: rgba(167,139,250,.16); --sky: #6CC4F0; --sky-soft: rgba(108,196,240,.15);+}+.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }+/* tab trên cùng */+.tabs { display: flex; gap: 8px; padding: 4px 24px 0; flex-wrap: wrap; }+.tab { min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); font: 700 18px/1 var(--cond); text-transform: uppercase; letter-spacing: .04em; cursor: pointer; transition: background .15s, color .15s; }+.tab:hover { color: var(--ink); }+.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }+.tab .new { font: 600 11px/1 var(--mono); color: var(--accent); margin-left: 6px; vertical-align: 2px; }++/* nút chung */+.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font: 600 14px/1 var(--sans); white-space: nowrap; cursor: pointer; text-decoration: none; color: var(--ink); background: var(--panel-2); transition: filter .15s, background .15s, transform .1s; }+.btn svg, .btn .ic { width: 18px; height: 18px; flex: none; }+.btn:active:not(:disabled) { transform: scale(.98); }+.btn:disabled { opacity: .45; cursor: not-allowed; }+.btn.pri { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -6px rgba(255,107,44,.55); }+.btn.pri:hover:not(:disabled) { filter: brightness(1.08); }+.btn.ghost { background: var(--panel-2); border-color: var(--line-2); }+.btn.ghost:hover:not(:disabled) { background: var(--panel-3); }+.btn.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(242,201,76,.3); }+.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }+.btn.danger { color: #FF8B8B; }+.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 11px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--panel-2); color: var(--ink-2); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }+.pill.acc { color: var(--accent); background: var(--accent-soft); }++/* thẻ cài đặt (giữ từ bản cũ) */+.edit-wrap[hidden], .layout[hidden] { display: none !important; }+.ed-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }+.ed-setup { margin: 0 0 16px; border-left: 3px solid var(--warn); }+.ed-setup h3 { margin: 0 0 6px; font: 700 20px/1.2 var(--cond); text-transform: uppercase; letter-spacing: .03em; }+.ed-setup p { margin: 0; color: var(--ink-2); font-size: 15px; }+.ed-setup-act { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 14px; }+.ed-install { min-height: 44px; padding: 0 22px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font: 800 18px/1 var(--cond); text-transform: uppercase; letter-spacing: .04em; cursor: pointer; }+.ed-install:disabled { opacity: .5; cursor: not-allowed; }+.ed-install-note { color: var(--ink-3); font-size: 14px; }+.ed-install-prog { margin-top: 14px; }+.ed-install-step { font-weight: 600; font-size: 15px; }+.ed-install-step.ok { color: var(--ok); } .ed-install-step.bad { color: var(--bad); }+.ed-install-bar { height: 4px; margin: 8px 0 10px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }+.ed-install-bar span { display: block; width: 30%; height: 100%; background: var(--accent); animation: edbar 1.4s ease-in-out infinite; }+.ed-install-prog.stop .ed-install-bar { display: none; }+@keyframes edbar { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }+.ed-install-hint { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; font: 400 13px/1.5 var(--mono); white-space: pre-wrap; color: var(--warn); background: rgba(242,201,76,.08); border: 1px solid rgba(242,201,76,.3); }+.ed-install-prog summary, .ed-setup-manual summary { cursor: pointer; color: var(--ink-3); font-size: 14px; }+.ed-install-prog pre { max-height: 220px; overflow: auto; margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--bg); font: 400 12px/1.45 var(--mono); color: var(--ink-2); white-space: pre-wrap; word-break: break-all; }+.ed-setup-manual { margin-top: 12px; }+.ed-file { font-size: 13px; color: var(--ink-3); margin-top: 6px; word-break: break-all; }+.ed-in { width: 100%; min-height: 40px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; padding: 0 12px; }+.ed-check { display: flex; gap: 8px; align-items: center; min-height: 44px; color: var(--ink-2); font-size: 14px; cursor: pointer; }+.ed-check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }++/* ===== khung 3 bước ===== */+.edit-wrap.cr { padding: 16px 24px 32px; }+.cr-shell { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--bg); display: flex; flex-direction: column; height: max(600px, calc(100vh - 170px)); }+.cr-body, .cr-main, .cr-side { min-height: 0; }+.cr-top { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px 0 14px; border-bottom: 1px solid var(--line); background: var(--bg-2); }+.cr-top > b { font-size: 15px; font-weight: 600; }+.cr-back { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; border: 0; background: none; color: var(--ink-2); cursor: pointer; }+.cr-back:hover { background: var(--panel-2); }+.cr-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }+.cr-steps { margin: 0 auto; padding: 0; list-style: none; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-3); transform: translateX(-40px); }+.cr-steps li { display: flex; }+.cr-steps button { display: flex; align-items: center; gap: 8px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; min-height: 36px; padding: 0 4px; border-radius: 8px; }+.cr-steps button:disabled { cursor: default; }+.cr-steps .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 700; background: var(--panel-3); color: var(--ink-2); }+.cr-steps .done .n { background: var(--ok); color: #06210f; }+.cr-steps .on { color: var(--ink); font-weight: 600; }+.cr-steps .on .n { background: var(--accent); color: var(--accent-ink); }+.cr-steps .ln { width: 36px; height: 1px; background: var(--line-2); }+.cr-body { flex: 1; display: flex; min-height: 0; }+.cr-side { width: 372px; flex: none; border-right: 1px solid var(--line); padding: 24px; display: flex; flex-direction: column; gap: 26px; background: var(--bg-2); overflow-y: auto; }+.cr-h { font: 700 15px/1.2 var(--cond); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }+.cr-h small { font: 500 12.5px var(--sans); text-transform: none; letter-spacing: 0; color: var(--ink-4); }+.cr-h label { cursor: default; }+.cr-link { border: 0; background: none; color: var(--ink-3); font: 500 12.5px var(--sans); text-transform: none; letter-spacing: 0; cursor: pointer; min-height: 32px; padding: 0 4px; border-radius: 6px; }+.cr-link:hover { color: var(--ink); }+.cr-link[aria-pressed="true"] { color: var(--accent); }+.cr-clip { border-radius: 14px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); }+.cr-clip[hidden] { display: none; }+.cr-clip .th { height: 182px; position: relative; background: #000; }+.cr-clip .th video { width: 100%; height: 100%; object-fit: cover; display: block; }+.cr-clip .th .d { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.7); border-radius: 6px; padding: 2px 7px; font-size: 12px; }+.cr-clip .d:empty { display: none; }+.cr-clip .meta { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }+.cr-clip .meta > div { min-width: 0; }+.cr-clip .meta b { font-size: 14px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.cr-clip .meta span { font-size: 12.5px; color: var(--ink-3); }+.cr-clip .ok { margin-left: auto; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; }+.cr-clip .ok svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }+.cr-none { margin: 0; color: var(--ink-4); font-size: 14px; }+.cr-chips { display: flex; flex-wrap: wrap; gap: 8px; }+.cr-chips .chip { min-height: 36px; padding: 0 13px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line-2); font-size: 13px; font-weight: 500; color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px; max-width: 100%; }+.cr-chips .chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.cr-chips .chip:hover { color: var(--ink); background: var(--panel-3); }+.cr-chips .chip.on { background: var(--accent-soft); border-color: rgba(255,107,44,.6); color: var(--accent); font-weight: 600; }+.cr-chips .chip.add { border-style: dashed; color: var(--ink-3); }+.cr-chips .chip .x { color: var(--ink-4); font-size: 16px; line-height: 1; }+.cr-namein { margin-top: 8px; }+.cr-namein[hidden] { display: none; }+.cr-range { display: flex; align-items: center; gap: 12px; }+.cr-range input { flex: 1; accent-color: var(--accent); height: 28px; --p: 15%; }+.cr-range output { font-size: 14px; font-weight: 600; min-width: 78px; text-align: right; }+.cr-range.auto input { opacity: .45; }+.cr-side textarea { width: 100%; min-height: 76px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; resize: vertical; font-size: 14px; }++.cr-main { flex: 1; min-width: 0; padding: 24px 32px; overflow-y: auto; }+.cr-pane[hidden] { display: none; }+.cr-main h1 { font: 800 30px/1.1 var(--cond); letter-spacing: .01em; text-transform: uppercase; margin: 0 0 6px; }+.cr-main h2 { font: 700 20px/1.2 var(--cond); margin: 0; }+.cr-sub { color: var(--ink-3); font-size: 14px; margin: 0 0 20px; }+.drop { display: grid; place-items: center; text-align: center; gap: 6px; min-height: 170px; padding: 18px; border: 2px dashed var(--line-2); border-radius: 16px; background: var(--bg-2); cursor: pointer; transition: border-color .15s, background .15s; }+.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg-2)); }+.drop svg { width: 34px; height: 34px; fill: none; stroke: var(--accent); stroke-width: 1.8; }+.drop .big { font-weight: 700; font-size: 16px; }+.drop .small { font-size: 13px; color: var(--ink-3); }+.drop.has { border-style: solid; border-color: var(--ok); }+.drop.has .big { color: var(--ok); word-break: break-all; }+.cr-listh { display: flex; align-items: baseline; gap: 10px; margin: 28px 0 12px; }+.cr-count { color: var(--ink-4); font-size: 13px; }+.cr-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 14px; }+.cr-item { position: relative; }+.cr-open { display: flex; flex-direction: column; gap: 8px; color: var(--ink); text-decoration: none; border-radius: 12px; }+.cr-open .th { aspect-ratio: 9 / 16; border-radius: 12px; background: #000 center / 400% 400% no-repeat; background-position: 33.333% 0; box-shadow: 0 0 0 1px rgba(255,255,255,.06); position: relative; transition: box-shadow .15s, transform .15s; }+.cr-open:hover .th { box-shadow: 0 0 0 2px var(--accent); }+.cr-open .th .d { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.72); border-radius: 6px; padding: 2px 6px; font-size: 11.5px; }+.cr-open .meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }+.cr-open .meta b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.cr-open .meta .s { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.cr-open .f { display: flex; gap: 6px; align-items: center; margin-top: 2px; }+.cr-open .v { font-size: 11px; color: var(--ink-3); }+.cr .st { display: inline-flex; align-items: center; min-height: 20px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; }+.cr .st.done { background: var(--ok-soft); color: var(--ok); }+.cr .st.error { background: rgba(255,100,100,.14); color: var(--bad); }+.cr .st.run { background: var(--warn-soft); color: var(--warn); }+.cr-del { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(0,0,0,.6); color: var(--ink-2); font-size: 18px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s; }+.cr-item:hover .cr-del, .cr-del:focus-visible { opacity: 1; }+.cr-del:disabled { display: none; }+.cr-empty { color: var(--ink-3); padding: 28px; border: 1px dashed var(--line-2); border-radius: 14px; text-align: center; grid-column: 1 / -1; margin: 0; }++/* lưới cách dựng 7 cột */+.cr-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 16px 14px; }+.sty { display: flex; flex-direction: column; gap: 8px; text-align: left; padding: 0; border: 0; background: none; cursor: pointer; color: var(--ink-2); min-width: 0; }+.sty .pic { display: block; aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden; position: relative; background: #000; box-shadow: 0 0 0 1px rgba(255,255,255,.06); transition: box-shadow .15s, transform .15s; }+.sty .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }+.sty .ph { display: grid; place-items: center; height: 100%; padding: 8px; text-align: center; font: 700 15px/1.15 var(--cond); text-transform: uppercase; color: var(--sty-acc); background: radial-gradient(120% 80% at 50% 100%, color-mix(in srgb, var(--sty-acc) 28%, #000), #0b0b0d 70%); }+.sty .src { position: absolute; left: 6px; bottom: 6px; font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 5px; background: rgba(0,0,0,.7); color: var(--ink-2); }+.sty .n { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }+.sty:hover .pic { box-shadow: 0 0 0 1px rgba(255,255,255,.25); }+.sty.on .pic { box-shadow: 0 0 0 2.5px var(--accent), 0 12px 30px -10px rgba(255,107,44,.5); }+.sty.on .pic::after { content: ""; position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231A0B03' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M20 6 9 17l-5-5'/></svg>") center / 14px no-repeat; }+.sty.on .n { color: var(--ink); }+.sty:focus-visible { outline: none; }+.sty:focus-visible .pic { outline: 2px solid var(--accent); outline-offset: 3px; }+.sty-desc { margin: 14px 0 0; min-height: 2.8em; font-size: 14px; line-height: 1.45; color: var(--ink-2); }++/* bước 3 */+.cr-build { display: flex; gap: 24px; align-items: flex-start; max-width: 760px; }+.cr-bthumb { width: 180px; aspect-ratio: 9 / 16; border-radius: 14px; background: var(--panel) center / 400% 400% no-repeat; background-position: 33.333% 0; flex: none; box-shadow: 0 0 0 1px rgba(255,255,255,.06); }+.cr-binfo { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; padding-top: 8px; }+.cr-binfo b { font-size: 18px; overflow-wrap: anywhere; }+.cr-binfo .st { align-self: flex-start; }+.cr-bar { height: 4px; border-radius: 2px; background: var(--panel-3); overflow: hidden; }+.cr-bar i { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); transition: transform .4s ease-out; }+.cr-bstep { font-size: 13px; color: var(--ink-3); min-height: 18px; }+.cr-bact { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }+.cr-bact a[hidden] { display: none; }++/* chân */+.cr-foot { height: 76px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 24px; background: var(--bg-2); }+.cr-foot[hidden] { display: none; }+.cr-sum { display: flex; gap: 8px; min-width: 0; overflow: hidden; }+.cr-eta { margin-left: auto; color: var(--ink-3); font-size: 13px; white-space: nowrap; }+.cr-foot .err { margin: 0; min-height: 0; font-size: 13px; max-width: 360px; }+.cr-foot .err:empty { display: none; }+.cr-go { height: 48px; padding: 0 26px; font-size: 16px; border-radius: 12px; }+.cr-go svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }+.cr-sum:empty + .cr-eta { margin-left: auto; }++@media (max-width: 1280px) { .cr-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }+@media (max-width: 1024px) { .cr-side { width: 300px; } .cr-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }+@media (max-width: 767px) {+ .edit-wrap.cr { padding: 8px 8px 24px; }+ .cr-shell { border-radius: 14px; height: auto; min-height: 0; }+ .cr-top { padding: 0 8px; gap: 6px; }+ .cr-top > b { display: none; }+ .cr-steps { transform: none; gap: 4px; }+ .cr-steps .ln { width: 12px; }+ .cr-body { flex-direction: column-reverse; }+ .cr-side { width: auto; border-right: 0; border-top: 1px solid var(--line); padding: 16px; gap: 20px; }+ .edit-wrap.cr[data-step="1"] .cr-side { display: none; }+ .cr-main { padding: 16px; }+ .cr-main h1 { font-size: 24px; }+ .cr-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; }+ .cr-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }+ .cr-del { opacity: 1; }+ .cr-build { flex-direction: column; }+ .cr-bthumb { width: 140px; }+ .cr-foot { position: sticky; bottom: 0; z-index: 5; height: auto; min-height: 64px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); flex-wrap: wrap; gap: 8px; }+ .cr-sum { display: none; }+ .cr-eta { margin-left: 0; }+ .cr-go { margin-left: auto; height: 46px; }+}+@media (prefers-reduced-motion: reduce) { .ed-install-bar span { animation: none; width: 100%; opacity: .5; } .cr-bar i, .sty .pic, .btn { transition: none; } }+.cr-back[hidden] { display: none; }diff --git a/server/public/studio/create.js b/server/public/studio/create.jsnew file mode 100644index 0000000..45b9b49--- /dev/null+++ b/server/public/studio/create.js@@ -0,0 +1,399 @@+// Tab "Edit video của bạn" = màn TẠO MỚI 3 bước: Clip → Cách dựng (lưới thẻ dọc) → Dựng (tiến độ, xong mở Studio).+// Bước 1 có luôn danh sách các bản đã dựng (bấm → Studio #/edit/<id>). Cột trái: clip, nhạc nền, độ dài, tên riêng, dặn thêm.+// API: GET /api/edit-options, GET/POST /api/edit-setup, GET/POST /api/edits, GET/DELETE /api/edits/:id (edit/http.mjs).+// Chữ từ server / gói (tên cách dựng, tên file) chỉ vào DOM qua textContent (luật P2, L9).+import { $, $$, el, t, I, fmtMB, fmtDur, safeUrl, store as ls } from './util.js';++const S = { opts: null, style: null, video: null, videoDur: null, music: null, musicSel: 'style', names: [], target: null, step: 1, uploading: false, list: null, noServer: false, job: null, timer: null };+const HEX = /^#[0-9A-Fa-f]{6}$/;+const SRC = ['builtin', 'local', 'pack'];+const srcOf = (s) => (SRC.includes(s?.source) ? s.source : 'builtin');+const styleName = (s) => (I.lang === 'en' && s.nameEn ? s.nameEn : s.name);+const styleSummary = (s) => (I.lang === 'en' && s.summaryEn ? s.summaryEn : s.summary);+const styleById = (id) => (S.opts?.styles || []).find((s) => s.id === id);+const stLabel = (s) => (['queued', 'running', 'done', 'error'].includes(s) ? t('ed.st.' + s) : s);++// ---- tab Dựng từ mẫu / Edit video của bạn ----+const tabs = $$('.tab');+function show(which) {+ tabs.forEach((x) => x.setAttribute('aria-selected', String(x.dataset.tab === which)));+ $('main.layout').hidden = which !== 'tpl';+ $('#editTab').hidden = which !== 'edit';+ try { localStorage.setItem('lumreels.tab', which); } catch { /* bỏ qua */ }+ if (which === 'edit' && !S.opts && !S.noServer) init();+ if (which === 'edit' && location.hash !== '#edit' && !/^#\/edit\//.test(location.hash)) history.replaceState(null, '', '#edit');+ if (which === 'tpl' && location.hash === '#edit') history.replaceState(null, '', location.pathname + location.search);+}+tabs.forEach((x) => x.addEventListener('click', () => show(x.dataset.tab)));+document.addEventListener('keydown', (e) => {+ if (!e.target.closest?.('.tabs') || !['ArrowLeft', 'ArrowRight'].includes(e.key)) return;+ const list = [...tabs]; const i = list.indexOf(document.activeElement);+ const n = list[(i + (e.key === 'ArrowRight' ? 1 : list.length - 1)) % list.length]; n.focus(); n.click();+});+window.addEventListener('hashchange', () => { if (location.hash === '#edit') show('edit'); });+// đóng Studio → về màn tạo mới, tải lại danh sách (có thể vừa xuất bản mới)+window.addEventListener('lumreels:studio', (e) => { if (!e.detail.open) { show('edit'); if (S.opts) loadList(); } });++// ---- nạp ----+async function init() {+ try { S.opts = await fetch('/api/edit-options').then((r) => r.json()); } catch { S.noServer = true; $('#edSetup').hidden = false; $('#edSetupText').textContent = t('ed.noServer'); return; }+ const o = S.opts;+ if (!o.ready) {+ $('#edSetup').hidden = false; $('#edSetupText').textContent = t('ed.setupText'); $('#edSetupCmd').textContent = o.setup;+ fetch('/api/edit-setup').then((r) => r.json()).then((st) => { if (st.running) watchInstall(); }).catch(() => {});+ } else $('#edSetup').hidden = true;+ S.style = ls.get('lumreels.cr.style') || o.styles[0]?.id || null;+ if (!styleById(S.style)) S.style = o.styles[0]?.id || null;+ renderStyles(); renderMusic(); renderNames(); renderLen(); renderClip(); setStep(1); loadList();+}++// ---- bước ----+function setStep(n) {+ if (n === 2 && !S.video) n = 1;+ S.step = n;+ $$('.cr-pane').forEach((p) => { p.hidden = Number(p.dataset.pane) !== n; });+ $$('#crSteps li[data-step]').forEach((li) => {+ const k = Number(li.dataset.step);+ li.className = k < n || (k === 1 && S.video && n !== 1) ? 'done' : k === n ? 'on' : '';+ const b = li.querySelector('button');+ b.disabled = (k === 2 && !S.video) || (k === 3 && !S.job);+ if (k === n) b.setAttribute('aria-current', 'step'); else b.removeAttribute('aria-current');+ b.querySelector('.n').textContent = li.className === 'done' && k !== n ? '✓' : String(k);+ });+ $('#crBack').hidden = n === 1;+ $('#editTab').dataset.step = String(n);+ refreshFoot();+}+$('#crSteps').addEventListener('click', (e) => { const li = e.target.closest('li[data-step]'); if (li && !li.querySelector('button').disabled) setStep(Number(li.dataset.step)); });+$('#crBack').addEventListener('click', () => setStep(Math.max(1, S.step - 1)));++// ---- lưới cách dựng ----+function styleCard(s) {+ const on = s.id === S.style;+ const b = el('button', 'sty' + (on ? ' on' : ''), null, { type: 'button', role: 'radio', 'aria-checked': String(on), 'data-id': s.id });+ b.tabIndex = on ? 0 : -1;+ b.setAttribute('aria-label', t('ed.styleAria', { name: styleName(s), summary: styleSummary(s) }) + ' · ' + t('src.' + srcOf(s)));+ const pic = el('span', 'pic');+ const thumb = safeUrl(s.thumb);+ if (thumb) { const img = el('img', null, null, { alt: '', loading: 'lazy', decoding: 'async', width: '360', height: '640' }); img.src = thumb; pic.append(img); }+ else { const ph = el('span', 'ph', styleName(s)); ph.style.setProperty('--sty-acc', HEX.test(String(s.accent || '')) ? s.accent : '#FF6B2C'); pic.append(ph); }+ if (srcOf(s) !== 'builtin') pic.append(el('span', 'src src-' + srcOf(s), t('src.' + srcOf(s))));+ b.append(pic, el('span', 'n', styleName(s)));+ return b;+}+function renderStyles() {+ const list = S.opts?.styles || [];+ $('#edStyles').replaceChildren(...list.map(styleCard));+ renderStyleDesc();+}+function renderStyleDesc() { const s = styleById(S.style); $('#edStyleDesc').textContent = s ? styleSummary(s) : ''; }+function pickStyle(b, focus) {+ S.style = b.dataset.id; ls.set('lumreels.cr.style', S.style);+ $$('#edStyles .sty').forEach((x) => { const on = x === b; x.setAttribute('aria-checked', String(on)); x.classList.toggle('on', on); x.tabIndex = on ? 0 : -1; });+ renderStyleDesc(); refreshFoot();+ const s = styleById(S.style); if (s?.target && S.target == null) renderLen();+ if (focus) { b.focus(); b.scrollIntoView({ block: 'nearest' }); }+}+$('#edStyles').addEventListener('click', (e) => { const b = e.target.closest('.sty'); if (b) pickStyle(b); });+$('#edStyles').addEventListener('dblclick', (e) => { if (e.target.closest('.sty') && !$('#edGo').disabled) $('#edGo').click(); });+$('#edStyles').addEventListener('keydown', (e) => {+ const list = $$('#edStyles .sty'); const i = list.indexOf(document.activeElement); if (i < 0) return;+ const cols = Math.max(1, getComputedStyle($('#edStyles')).gridTemplateColumns.split(' ').length);+ const step = { ArrowDown: cols, ArrowRight: 1, ArrowUp: -cols, ArrowLeft: -1 }[e.key];+ if (step) { e.preventDefault(); pickStyle(list[(i + step + list.length) % list.length], true); }+ else if (e.key === 'Home' || e.key === 'End') { e.preventDefault(); pickStyle(e.key === 'Home' ? list[0] : list[list.length - 1], true); }+});+window.addEventListener('lumreels:packs', async () => {+ if (!S.opts) return;+ try {+ const o = await fetch('/api/edit-options').then((r) => r.json());+ S.opts = { ...S.opts, styles: o.styles };+ if (!styleById(S.style)) S.style = o.styles[0]?.id || null;+ renderStyles(); refreshFoot();+ } catch { /* bỏ qua */ }+});++// ---- nhạc nền: chip ----+function renderMusic() {+ const box = $('#crMusic');+ const chips = [['style', t('cr.musicStyle')], ...(S.opts?.music || []).map((m) => [m.id, m.id.charAt(0).toUpperCase() + m.id.slice(1), I.srv(m.desc)]), ['none', t('ed.noMusic')]];+ const kids = chips.map(([v, label, title]) => {+ const on = S.musicSel === v;+ const b = el('button', 'chip' + (on ? ' on' : ''), label, { type: 'button', role: 'radio', 'aria-checked': String(on), 'data-v': v });+ if (title) b.title = title;+ return b;+ });+ const up = el('button', 'chip add' + (S.musicSel === 'file' ? ' on' : ''), S.music ? S.music.name : t('cr.musicUpload'), { type: 'button', role: 'radio', 'aria-checked': String(S.musicSel === 'file'), 'data-v': 'file' });+ kids.push(up);+ box.replaceChildren(...kids);+ $('#edMusicName').textContent = S.music && S.musicSel === 'file' ? fmtMB(S.music.size) : '';+}+$('#crMusic').addEventListener('click', (e) => {+ const b = e.target.closest('.chip'); if (!b) return;+ if (b.dataset.v === 'file') { $('#edMusicFile').click(); return; }+ S.musicSel = b.dataset.v; renderMusic(); refreshFoot();+});+$('#edMusicFile').addEventListener('change', (e) => { const f = e.target.files[0]; e.target.value = ''; if (!f) return; S.music = f; S.musicSel = 'file'; renderMusic(); refreshFoot(); });++// ---- độ dài bản ra ----+function renderLen() {+ const r = $('#crLen'); const auto = S.target == null;+ const s = styleById(S.style);+ if (auto) r.value = String(s?.target || 40);+ $('#crLenAuto').textContent = t(auto ? 'cr.lenAutoOn' : 'cr.lenAuto');+ $('#crLenV').textContent = auto ? t('cr.lenAutoV') : t('cr.lenV', { s: r.value });+ r.closest('.cr-range').classList.toggle('auto', auto);+ const pct = ((Number(r.value) - 15) / (180 - 15)) * 100;+ r.style.setProperty('--p', pct + '%');+ refreshFoot();+}+$('#crLen').addEventListener('input', () => { S.target = Number($('#crLen').value); renderLen(); });+$('#crLenAuto').addEventListener('click', () => { S.target = S.target == null ? Number($('#crLen').value) : null; renderLen(); });++// ---- tên riêng: chip + Thêm ----+function renderNames() {+ const box = $('#crNames');+ const kids = S.names.map((n, i) => {+ const b = el('button', 'chip', null, { type: 'button', 'data-i': String(i), 'aria-label': t('cr.removeName', { n }) });+ b.append(el('span', null, n), el('span', 'x', '×', { 'aria-hidden': 'true' }));+ return b;+ });+ const add = el('button', 'chip add', '+ ' + t('cr.addName'), { type: 'button', 'data-add': '1' });+ kids.push(add);+ box.replaceChildren(...kids);+}+$('#crNames').addEventListener('click', (e) => {+ const b = e.target.closest('.chip'); if (!b) return;+ if (b.dataset.add) { const i = $('#edNames'); i.hidden = false; i.focus(); return; }+ S.names.splice(Number(b.dataset.i), 1); saveNames(); renderNames();+});+function addNames(v) {+ for (const n of String(v).split(/[,;\n]/).map((x) => x.trim()).filter(Boolean)) if (!S.names.includes(n) && S.names.length < 40) S.names.push(n.slice(0, 60));+ saveNames(); renderNames();+}+const saveNames = () => ls.set('lumreels.cr.names', S.names);+$('#edNames').addEventListener('keydown', (e) => {+ if (e.key === 'Enter' || e.key === ',') { e.preventDefault(); addNames(e.target.value); e.target.value = ''; }+ else if (e.key === 'Escape') { e.target.value = ''; e.target.hidden = true; }+});+$('#edNames').addEventListener('blur', (e) => { if (e.target.value.trim()) addNames(e.target.value); e.target.value = ''; e.target.hidden = true; });+S.names = (ls.get('lumreels.cr.names', []) || []).filter((x) => typeof x === 'string').slice(0, 40);++// ---- clip ----+const drop = $('#edDrop');+function pickVideo(f) {+ if (!f) return;+ if (!/^video\//.test(f.type) && !/\.(mp4|mov|m4v|mkv|webm|avi|3gp)$/i.test(f.name)) { setErr(t('ed.notVideo')); return; }+ if (S.opts && f.size > S.opts.maxUploadBytes) { setErr(t('ed.tooBig', { size: fmtMB(f.size) })); return; }+ S.video = f; S.videoDur = null; setErr('');+ renderClip(); setStep(2);+}+function renderClip() {+ const f = S.video;+ $('#crClip').hidden = !f; $('#crClipNone').hidden = !!f; $('#crChange').hidden = !f;+ drop.classList.toggle('has', !!f);+ $('.big', drop).textContent = f ? f.name : t('ed.dropBig');+ $('.small', drop).textContent = f ? t('ed.changeFile', { size: fmtMB(f.size) }) : t('ed.dropSmall');+ if (!f) return;+ $('#crClipName').textContent = f.name;+ $('#crClipInfo').textContent = fmtMB(f.size) + (S.videoDur ? ` · ${fmtDur(S.videoDur)}` : '');+ const v = $('#crClipVid');+ if (v.dataset.name !== f.name + f.size) {+ if (v.src) URL.revokeObjectURL(v.src);+ v.dataset.name = f.name + f.size; v.src = URL.createObjectURL(f);+ v.onloadedmetadata = () => { S.videoDur = v.duration; v.currentTime = Math.min(v.duration / 3, 20); $('#crClipDur').textContent = fmtDur(v.duration); renderClip(); refreshFoot(); };+ }+}+drop.addEventListener('click', () => $('#edVideo').click());+drop.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); $('#edVideo').click(); } });+$('#edVideo').addEventListener('change', (e) => { pickVideo(e.target.files[0]); e.target.value = ''; });+$('#crChange').addEventListener('click', () => $('#edVideo').click());+['dragenter', 'dragover'].forEach((ev) => drop.addEventListener(ev, (e) => { e.preventDefault(); drop.classList.add('over'); }));+['dragleave', 'drop'].forEach((ev) => drop.addEventListener(ev, (e) => { e.preventDefault(); drop.classList.remove('over'); }));+drop.addEventListener('drop', (e) => pickVideo(e.dataTransfer.files[0]));+const setErr = (x) => { $('#edErr').textContent = x; };++// ---- chân trang: tóm tắt + nút chính ----+function refreshFoot() {+ const sum = [];+ const s = styleById(S.style);+ if (S.video) sum.push(el('span', 'pill', S.video.name));+ if (s && S.step >= 2) sum.push(el('span', 'pill acc', styleName(s)));+ if (S.step >= 2) {+ sum.push(el('span', 'pill', S.musicSel === 'style' ? t('cr.musicStyle') : S.musicSel === 'none' ? t('ed.noMusic') : S.musicSel === 'file' ? (S.music?.name || '') : S.musicSel));+ sum.push(el('span', 'pill', S.target == null ? t('cr.lenAutoV') : t('cr.lenV', { s: S.target })));+ }+ $('#crSum').replaceChildren(...sum);+ const go = $('#edGo'); const lab = $('#edGo span');+ const ready = !!(S.opts?.ready && S.video && S.style) && !S.uploading;+ $('#crEta').textContent = S.step === 2 && S.videoDur ? t('cr.eta', { m: Math.max(2, Math.round(2 + (S.videoDur / 60) * 0.7)) }) : '';+ if (S.step === 1) { go.disabled = !S.video; if (!S.uploading) lab.textContent = t('cr.next'); }+ else if (S.step === 2) { go.disabled = !ready; if (!S.uploading) lab.textContent = t('ed.go'); }+ else { go.disabled = true; if (!S.uploading) lab.textContent = t('ed.go'); }+ $('.cr-foot').hidden = S.step === 3 && !S.uploading;+}+$('#edGo').addEventListener('click', () => {+ if (S.step === 1) { setStep(2); return; }+ if (S.step !== 2) return;+ if (S.musicSel === 'file' && !S.music) { setErr(t('ed.needMusic')); return; }+ const fd = new FormData();+ fd.append('style', S.style);+ fd.append('content', $('#edNotes').value.trim());+ fd.append('names', S.names.join(', '));+ fd.append('draft', $('#edDraft').checked ? '1' : '0');+ if (S.target != null) fd.append('target', String(S.target));+ if (S.musicSel === 'none') fd.append('musicStyle', 'none');+ else if (S.musicSel !== 'style' && S.musicSel !== 'file') fd.append('musicStyle', S.musicSel);+ if (S.musicSel === 'file' && S.music) fd.append('music', S.music, S.music.name);+ fd.append('video', S.video, S.video.name); // file sau cùng: trường chữ tới server trước+ S.uploading = true; setErr(''); refreshFoot();+ const lab = $('#edGo span');+ const xhr = new XMLHttpRequest();+ xhr.open('POST', '/api/edits');+ xhr.upload.onprogress = (e) => { if (e.lengthComputable) lab.textContent = t('ed.uploading', { p: Math.round((e.loaded / e.total) * 100) }); };+ xhr.onload = () => {+ S.uploading = false; refreshFoot();+ let j = {}; try { j = JSON.parse(xhr.responseText); } catch { /* bỏ qua */ }+ if (xhr.status !== 202) { setErr(j.error ? I.srv(j.error) : t('err.status', { s: xhr.status })); return; }+ follow(j); loadList();+ };+ xhr.onerror = () => { S.uploading = false; refreshFoot(); setErr(t('ed.uploadCut')); };+ xhr.send(fd);+});++// ---- bước 3: tiến độ dựng ----+function follow(job) { S.job = job; setStep(3); paintBuild(job); poll(); }+async function poll() {+ clearTimeout(S.timer);+ const id = S.job?.id; if (!id) return;+ let v;+ try { v = await fetch(`/api/edits/${encodeURIComponent(id)}`).then((r) => r.json()); } catch { S.timer = setTimeout(poll, 3000); return; }+ if (S.job?.id !== id) return;+ S.job = v; paintBuild(v);+ if (['queued', 'running'].includes(v.status)) S.timer = setTimeout(poll, 1500);+ else { loadList(); if (v.status === 'done' && v.links?.out && S.step === 3 && !$('#editTab').hidden) setTimeout(() => { if (S.job?.id === id && S.step === 3) location.hash = `#/edit/${id}`; }, 900); }+}+function paintBuild(v) {+ const busy = ['queued', 'running'].includes(v.status);+ $('#crBuildName').textContent = v.sourceName || v.id;+ $('#crBuildSub').textContent = `${v.styleName || v.style || ''}`;+ const st = $('#crBuildStatus'); st.className = 'st ' + (v.status === 'done' ? 'done' : v.status === 'error' ? 'error' : 'run');+ st.textContent = v.status === 'queued' ? t('ed.waitTurn') : stLabel(v.status);+ const steps = v.steps || []; const i = Math.max(0, Math.min(steps.length - 1, v.stepIndex ?? 0));+ const p = v.status === 'done' ? 100 : busy ? Math.min(100, ((i + (v.pct || 0) / 100) / Math.max(1, steps.length)) * 100) : 0;+ $('#crBuildBar').style.transform = `scaleX(${p / 100})`;+ $('#crBuildStep').textContent = busy && steps.length && v.status !== 'queued' ? t('ed.stepOf', { i: i + 1, n: steps.length, step: I.srv(steps[i]), p: v.pct || 0 }) : '';+ $('#crBuildErr').textContent = v.status === 'error' ? I.srv(v.error || t('ed.err')) : '';+ const o = $('#crOpen'); o.hidden = !(v.status === 'done' && v.links?.out); o.href = `#/edit/${encodeURIComponent(v.id)}`;+ const th = $('#crBuildThumb'); const pv = safeUrl(v.links?.previewFinal || v.links?.preview);+ th.style.backgroundImage = pv ? `url("${pv}")` : '';+}+$('#crAnother').addEventListener('click', () => { clearTimeout(S.timer); S.job = null; S.video = null; renderClip(); setStep(1); });++// ---- danh sách bản đã dựng ----+async function loadList() {+ let list = [];+ try { list = await fetch('/api/edits').then((r) => r.json()); } catch { return; }+ S.list = Array.isArray(list) ? list : [];+ renderList();+}+const viewStyleName = (v) => { const s = styleById(v.style); return s ? styleName(s) : v.styleName || v.style; };+function renderList() {+ const list = S.list || [];+ $('#crCount').textContent = list.length ? String(list.length) : '';+ $('#edList').replaceChildren(...(list.length ? list.map((v) => {+ const card = el('div', 'cr-item');+ const a = el('a', 'cr-open', null, { href: v.status === 'done' && v.links?.out ? `#/edit/${encodeURIComponent(v.id)}` : '#edit', 'data-id': v.id });+ const th = el('span', 'th', null, { 'aria-hidden': 'true' });+ const pv = safeUrl(v.links?.previewFinal || v.links?.preview);+ if (pv) th.style.backgroundImage = `url("${pv}")`;+ const dur = v.checks?.edl?.outSeconds;+ if (Number.isFinite(dur)) th.append(el('span', 'd mono', fmtDur(dur)));+ const meta = el('span', 'meta');+ meta.append(el('b', null, v.sourceName || v.id), el('span', 's', viewStyleName(v)));+ const foot = el('span', 'f');+ const busy = ['queued', 'running'].includes(v.status);+ foot.append(el('span', 'st ' + (v.status === 'done' ? 'done' : v.status === 'error' ? 'error' : 'run'), busy && v.action !== 'edit' ? t('st.publishing') : stLabel(v.status)));+ const nr = (v.revisions || []).length;+ if (nr) foot.append(el('span', 'v mono', `r${nr}`));+ meta.append(foot);+ a.append(th, meta);+ const del = el('button', 'cr-del', null, { type: 'button', 'aria-label': t('cr.delete', { name: v.sourceName || v.id }), 'data-id': v.id, title: t('ed.delete') });+ del.append(el('span', null, '×', { 'aria-hidden': 'true' }));+ del.disabled = busy;+ card.append(a, del);+ return card;+ }) : [el('p', 'cr-empty', t('ed.listEmpty'))]));+}+$('#edList').addEventListener('click', async (e) => {+ const d = e.target.closest('.cr-del');+ if (d) {+ if (!confirm(t('ed.confirmDel'))) return;+ const r = await fetch(`/api/edits/${encodeURIComponent(d.dataset.id)}`, { method: 'DELETE' });+ if (!r.ok) { const j = await r.json().catch(() => ({})); setErr(I.srv(j.error || t('err.status', { s: r.status }))); }+ loadList(); return;+ }+ const a = e.target.closest('.cr-open'); if (!a) return;+ const v = (S.list || []).find((x) => x.id === a.dataset.id);+ if (v && !(v.status === 'done' && v.links?.out)) { e.preventDefault(); follow(v); }+});++// ---- cài phần Edit video ----+const INSTALL_FAIL = new Set(['NEED_PYTHON', 'NEED_FFMPEG', 'NEED_NETWORK', 'NEED_NPM']);+let installTimer = null; let lastInstall = null;+function paintInstall(st) {+ lastInstall = st;+ const prog = $('#edInstallProg'); const step = $('#edInstallStep'); const btn = $('#edInstall');+ prog.hidden = false;+ const mm = (s) => `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;+ step.className = 'ed-install-step';+ if (st.running) { step.textContent = t('ed.installStep', { step: st.step ? I.srv(st.step) : t('ed.installStepDefault'), t: mm(st.elapsedS || 0) }); btn.disabled = true; btn.textContent = t('ed.installing'); }+ else if (st.ok) { step.classList.add('ok'); step.textContent = t('ed.installDone', { t: mm(st.elapsedS || 0) }); }+ else { step.classList.add('bad'); step.textContent = INSTALL_FAIL.has(st.word) ? t('ed.fail.' + st.word) : t('ed.installFail'); btn.disabled = false; btn.textContent = t('ed.installRetry'); }+ prog.classList.toggle('stop', !st.running);+ $('#edInstallHint').hidden = !st.hint; $('#edInstallHint').textContent = st.hint || '';+ const log = $('#edInstallLog'); const atEnd = log.scrollTop + log.clientHeight >= log.scrollHeight - 8;+ log.textContent = (st.log || []).join('\n');+ if (atEnd) log.scrollTop = log.scrollHeight;+}+function watchInstall() {+ clearTimeout(installTimer);+ const tick = async () => {+ let st;+ try { st = await fetch('/api/edit-setup').then((r) => r.json()); } catch { installTimer = setTimeout(tick, 3000); return; }+ paintInstall(st);+ if (st.running) { installTimer = setTimeout(tick, 1500); return; }+ if (st.ok && st.ready) setTimeout(() => { S.opts = null; $('#edSetup').hidden = true; init(); }, 1200);+ };+ tick();+}+$('#edInstall').addEventListener('click', async () => {+ $('#edInstall').disabled = true;+ try {+ const r = await fetch('/api/edit-setup', { method: 'POST' });+ if (!r.ok && r.status !== 409) throw new Error((await r.json().catch(() => ({}))).error || 'HTTP ' + r.status);+ watchInstall();+ } catch (e) {+ $('#edInstall').disabled = false;+ $('#edInstallProg').hidden = false; $('#edInstallStep').className = 'ed-install-step bad';+ $('#edInstallStep').textContent = t('ed.installCantStart', { e: e.message });+ }+});++// ---- đổi VI/EN: vẽ lại phần JS sinh ----+window.addEventListener('lumreels:lang', () => {+ if (S.noServer) $('#edSetupText').textContent = t('ed.noServer');+ else if (S.opts && !S.opts.ready) $('#edSetupText').textContent = t('ed.setupText');+ if (lastInstall) paintInstall(lastInstall);+ if (S.opts) { const had = document.activeElement?.closest?.('#edStyles'); renderStyles(); renderMusic(); renderNames(); renderLen(); if (had) $('#edStyles .sty[aria-checked="true"]')?.focus(); }+ renderClip(); refreshFoot();+ if (S.list) renderList();+ if (S.job && S.step === 3) paintBuild(S.job);+});+renderClip(); renderNames();++// mở lại tab đã chọn lần trước; #/edit/<id> (Studio) cũng thuộc tab Edit+let saved = 'tpl';+try { saved = localStorage.getItem('lumreels.tab') || 'tpl'; } catch { /* bỏ qua */ }+if (location.hash === '#edit' || /^#\/edit\//.test(location.hash)) saved = 'edit';+show(saved);diff --git a/server/public/studio/inspector.js b/server/public/studio/inspector.jsnew file mode 100644index 0000000..5af28c5--- /dev/null+++ b/server/public/studio/inspector.js@@ -0,0 +1,442 @@+// Bảng phải của Studio: đổi theo icon cột trái (Phụ đề · Nhạc · Zoom · Đồ hoạ · Sửa bằng lời) và theo khối đang chọn.+// Chữ từ server (dòng phụ đề, tên nhạc, ô đồ hoạ, lời sửa) chỉ vào DOM qua textContent / value / new Option.+import { el, tx, icon, iconBtn, fmtT, fmtDb, paintWords, plain, clamp, r2, t, I } from './util.js';++const GFX_KEYS = ['kicker', 'title', 'unit', 'label', 'prefix', 'value', 'suffix', 'old', 'text', 'a', 'b'];+const ROW_KEYS = { items: ['text', 'label', 'value', 'ok'], rows: ['label', 'value', 'a', 'b'], points: ['label', 'value'] };++export class Inspector {+ constructor(ctx) {+ this.ctx = ctx; // {store, player, seek, select, getSel, review, mode(), setMode, uploadMusic(file), revise(text), musicName(src)}+ this.root = el('aside', 'st-insp');+ this.head = el('h3', 'st-ih');+ this.body = el('div', 'st-ib');+ this.grab = el('button', 'st-grab', null, { type: 'button', 'aria-label': t('st.closeSheet') }); this.grab.dataset.i18nAria = 'st.closeSheet';+ this.grab.addEventListener('click', () => this.ctx.closeSheet?.());+ this.root.append(this.grab, this.head, this.body);+ this.capTab = 'lines';+ this.nowU = null;+ }+ setHead(iconName, key, extra) {+ const h = [icon(iconName), tx('span', null, key)];+ if (extra) h.push(extra);+ this.head.replaceChildren(...h);+ }+ /** Vẽ lại bảng theo chế độ. light=true: chỉ cập nhật chữ, không dựng lại ô đang gõ. */+ render() {+ const mode = this.ctx.mode();+ const a = document.activeElement;+ if (this.root.contains(a) && a.matches('input[type=text],input[type=number],input[type=range],textarea') && this.lastMode === mode && this.lastSel === JSON.stringify(this.ctx.getSel())) { this.lightUpdate(); return; }+ this.lastMode = mode; this.lastSel = JSON.stringify(this.ctx.getSel());+ const ro = !!this.ctx.store.view?.readOnly;+ this.root.classList.toggle('ro', ro);+ if (mode === 'cap') this.renderCap();+ else if (mode === 'music') this.renderMusic();+ else if (mode === 'zoom') this.renderZoom();+ else if (mode === 'gfx') this.renderGfx();+ else if (mode === 'ai') this.renderAi();+ else if (mode === 'review') this.renderReview();+ if (ro && mode !== 'ai') this.body.prepend(tx('p', 'st-note', 'st.readOnly'));+ }+ lightUpdate() {+ // dòng đang gõ: cập nhật chữ ở danh sách (nếu có) — giữ nguyên ô nhập+ for (const li of this.body.querySelectorAll('.st-ln[data-u]')) {+ const l = this.ctx.store.doc.lines.find((x) => x.u === li.dataset.u); if (!l) continue;+ const tm = li.querySelector('.tm'); if (tm) tm.textContent = fmtT(l.start);+ const s = li.querySelector('.tx'); if (s) paintWords(s, l.text);+ }+ }+ commit(fn, key) { return key ? this.ctx.store.commitTyping(key, fn) : this.ctx.store.commit(fn); }++ // ---- Phụ đề ----+ renderCap() {+ const st = this.ctx.store; const n = this.ctx.review.pending();+ this.setHead('cap', 'st.trCap');+ const seg = el('div', 'st-seg', null, { role: 'tablist' });+ const tabs = [['lines', 'st.capLines'], ['look', 'st.capLook'], ['review', null]];+ for (const [id, key] of tabs) {+ const b = el('button', id === this.capTab ? 'on' : '', key ? t(key) : t('st.capReview', { n }), { type: 'button', role: 'tab', 'aria-selected': String(id === this.capTab) });+ if (key) b.dataset.i18n = key;+ b.addEventListener('click', () => { this.capTab = id; this.render(); });+ seg.append(b);+ }+ const kids = [seg];+ if (this.capTab === 'lines') kids.push(this.linesList());+ else if (this.capTab === 'look') kids.push(this.lookPicker());+ else kids.push(this.reviewBody());+ this.body.replaceChildren(...kids);+ if (this.capTab === 'lines') this.scrollSel();+ if (st.view?.draft) this.body.prepend(tx('p', 'st-note warn', 'man.draftNote'));+ }+ linesList() {+ const st = this.ctx.store; const sel = this.ctx.getSel(); const L = st.doc.lines; const bad = st.lineErrors();+ const ol = el('ol', 'st-lines');+ ol.setAttribute('aria-label', t('st.trCap'));+ if (!L.length) { ol.append(tx('li', 'none', 'man.noLines')); return ol; }+ L.forEach((l, k) => {+ const on = sel?.kind === 'cap' && sel.u === l.u;+ const li = el('li', 'st-ln' + (on ? ' sel' : '') + (l.u === this.nowU ? ' now' : '') + (bad.has(l.u) ? ' bad' : ''), null, { 'data-u': l.u });+ if (!on) {+ const b = el('button', 'row', null, { type: 'button' });+ const s = el('span', 'tx'); paintWords(s, l.text);+ b.append(el('span', 'tm mono', fmtT(l.start)), s);+ if (this.ctx.flagged(l.u)) b.append(el('span', 'flag', null, { 'aria-label': t('st.flagged') }));+ b.addEventListener('click', () => { this.ctx.select({ kind: 'cap', u: l.u }); this.ctx.seek(l.start + 0.01); });+ li.append(b);+ } else li.append(...this.lineEditor(l, k, L.length, bad.get(l.u)));+ ol.append(li);+ });+ return ol;+ }+ lineEditor(l, k, n, bad) {+ const ro = !!this.ctx.store.view?.readOnly || !!this.ctx.store.view?.draft;+ const inp = el('input', 'st-ledit', null, { type: 'text', maxlength: '200', spellcheck: 'false', 'aria-label': t('man.lineText', { n: k + 1 }) });+ inp.value = l.text; inp.disabled = ro;+ inp.addEventListener('input', () => this.commit((d) => { const x = d.lines.find((y) => y.u === l.u); if (x) x.text = inp.value; }, 'text:' + l.u));+ inp.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); inp.blur(); } });+ setTimeout(() => { if (this.wantFocus === l.u) { this.wantFocus = null; inp.focus(); inp.setSelectionRange(inp.value.length, inp.value.length); } }, 0);+ const num = (f, v) => {+ const w = el('label', 'st-tbox');+ w.append(icon('clock'));+ const i = el('input', 'mono', null, { type: 'number', step: '0.05', min: '0', inputmode: 'decimal', 'aria-label': t(f === 'start' ? 'man.lineStart' : 'man.lineEnd', { n: k + 1 }) });+ i.value = r2(v).toFixed(2); i.disabled = ro;+ i.addEventListener('change', () => { const x = Number(i.value); if (Number.isFinite(x)) this.commit((d) => { const y = d.lines.find((z) => z.u === l.u); if (y) y[f] = clamp(r2(x), 0, this.ctx.store.view.duration); }); });+ w.append(i); return w;+ };+ const row = el('div', 'st-row');+ const acts = el('span', 'st-acts');+ const hiB = iconBtn('hi', 'st.markHi', 'mini'); hiB.disabled = ro;+ hiB.addEventListener('mousedown', (e) => e.preventDefault()); // giữ vùng chọn trong ô chữ+ hiB.addEventListener('click', () => this.toggleHi(inp, l.u));+ const sp = iconBtn('split', 'man.split', 'mini'); sp.disabled = ro;+ sp.addEventListener('click', () => this.ctx.splitAtHead(l.u));+ const mg = iconBtn('merge', 'man.merge', 'mini'); mg.disabled = ro || k + 1 >= n;+ mg.addEventListener('click', () => this.ctx.store.mergeLine(k));+ const del = iconBtn('trash', 'st.del', 'mini danger'); del.disabled = ro;+ del.addEventListener('click', () => this.ctx.deleteSel());+ acts.append(hiB, sp, mg, del);+ row.append(num('start', l.start), el('span', 'arrow', '→', { 'aria-hidden': 'true' }), num('end', l.end), acts);+ const out = [inp, row];+ for (const it of this.ctx.review.inLine(l)) {+ const p = el('p', 'st-ainote');+ p.append(icon('warn'), it.kind === 'fix' ? t('st.aiFixed', { heard: it.heard, text: it.text || '∅' }) : t('st.figCheck', { text: it.text, said: it.heard }));+ out.push(p);+ }+ if (bad) out.push(el('p', 'st-err', t('st.lineErr.' + bad)));+ return out;+ }+ /** Bọc / bỏ bọc *…* quanh chữ đang chọn trong ô (chữ nhấn). Không chọn gì: từ ở con trỏ. */+ toggleHi(inp, u) {+ let a = inp.selectionStart ?? 0; let b = inp.selectionEnd ?? 0; const v = inp.value;+ if (a === b) { while (a > 0 && !/\s/.test(v[a - 1])) a--; while (b < v.length && !/\s/.test(v[b])) b++; }+ if (a === b) return;+ let seg = v.slice(a, b);+ const wrapped = /^\*.*\*$/.test(seg.trim());+ seg = wrapped ? seg.replace(/\*/g, '') : `*${seg.replace(/\*/g, '').trim()}*`;+ const nv = (v.slice(0, a) + seg + v.slice(b)).replace(/\s+/g, ' ');+ this.commit((d) => { const x = d.lines.find((y) => y.u === u); if (x) x.text = nv; });+ this.wantFocus = u;+ }+ scrollSel() {+ const ol = this.body.querySelector('.st-lines'); if (!ol) return;+ const li = ol.querySelector('.st-ln.sel') || ol.querySelector('.st-ln.now'); if (!li) return;+ const br = this.body.getBoundingClientRect(); const r = li.getBoundingClientRect();+ const top = r.top - br.top + this.body.scrollTop; const h = this.body.clientHeight;+ const seg = this.body.querySelector('.st-seg')?.offsetHeight || 0;+ if (r.top < br.top + seg + 8 || r.bottom > br.bottom - 8) this.body.scrollTop = Math.max(0, top - Math.max(seg + 12, (h - r.height) / 3));+ }+ /** Dòng đang phát tô sáng (không dựng lại cả danh sách). */+ onTime(tt) {+ const L = this.ctx.store.doc?.lines || [];+ const l = L.find((x) => tt >= x.start && tt < x.end);+ const u = l ? l.u : null;+ if (u === this.nowU) return;+ this.body.querySelector(`.st-ln[data-u="${this.nowU}"]`)?.classList.remove('now');+ this.nowU = u;+ const li = u && this.body.querySelector(`.st-ln[data-u="${u}"]`);+ if (li) { li.classList.add('now'); if (!this.ctx.player.video.paused && !this.root.contains(document.activeElement)) this.scrollSel(); }+ }+ lookPicker() {+ const st = this.ctx.store; const v = st.view; const ro = !!v.readOnly || !!v.draft;+ const wrap = el('div', 'st-looks');+ const sw = el('label', 'st-switch');+ const cb = el('input', null, null, { type: 'checkbox', role: 'switch' }); cb.checked = st.doc.hi; cb.disabled = ro;+ cb.addEventListener('change', () => this.commit((d) => { d.hi = cb.checked; }));+ sw.append(cb, tx('span', null, 'man.hiShort'), tx('small', null, 'man.hiTip'));+ const grid = el('div', 'st-lookgrid', null, { role: 'radiogroup', 'aria-label': t('man.look') });+ for (const l of v.captions.looks) {+ const on = l.id === st.doc.look;+ const b = el('button', 'st-look' + (on ? ' on' : ''), null, { type: 'button', role: 'radio', 'aria-checked': String(on) });+ b.disabled = ro;+ const smp = el('span', 'smp');+ const c = l.css || {};+ smp.style.fontFamily = `${c.font || "'Be Vietnam Pro'"}, sans-serif`; smp.style.fontWeight = String(c.weight || 800);+ smp.append(el('span', null, c.upper ? 'AB' : 'Ab'));+ const hi = el('span', null, c.upper ? 'C' : 'c'); hi.style.color = c.hi || l.hi; smp.append(hi);+ if (c.box) smp.style.background = c.box.bg;+ b.append(smp, el('span', 'nm', I.lang === 'en' ? l.nameEn : l.name));+ b.addEventListener('click', () => this.commit((d) => { d.look = l.id; }));+ grid.append(b);+ }+ wrap.append(sw, grid);+ return wrap;+ }++ // ---- Cần xem lại ----+ renderReview() { this.setHead('warn', 'st.reviewH'); this.body.replaceChildren(this.reviewBody()); }+ reviewBody() {+ const R = this.ctx.review; const items = R.items();+ const wrap = el('div', 'st-review');+ if (!items.length) { wrap.append(tx('p', 'st-empty', 'st.reviewNone')); return wrap; }+ const cur = R.current();+ if (cur) {+ const card = el('div', 'st-rcard');+ const top = el('div', 'st-rtop');+ top.append(el('span', 'st-rpos mono', `${R.index() + 1}/${items.length}`), el('span', 'mono st-rtm', cur.at != null ? fmtT(cur.at) : '–'));+ const nav = el('span', 'st-rnav');+ const pv = iconBtn('left', 'st.prevItem', 'mini'); pv.addEventListener('click', () => R.go(-1));+ const nx = iconBtn('right', 'st.nextItem', 'mini'); nx.addEventListener('click', () => R.go(1));+ nav.append(pv, nx); top.append(nav);+ const what = el('p', 'st-rwhat');+ if (cur.kind === 'fix') { what.append(tx('span', 'k', 'st.rFix'), ' '); what.append(el('s', null, cur.heard), ' → ', el('b', null, cur.text || t('ed.hidden'))); }+ else { what.append(tx('span', 'k', 'st.rFig'), ' '); what.append(el('b', null, cur.text), ' · ', el('s', null, cur.heard)); }+ card.append(top, what);+ if (cur.why) card.append(el('p', 'st-rwhy', cur.why));+ const st0 = R.status(cur);+ if (st0) card.append(el('p', 'st-rdone', t('st.rStatus.' + st0)));+ const acts = el('div', 'st-racts');+ const keep = tx('button', 'btn ghost', 'st.rKeep', { type: 'button' }); keep.addEventListener('click', () => R.resolve(cur, 'keep'));+ const fix = tx('button', 'btn ghost', 'st.rEdit', { type: 'button' }); fix.addEventListener('click', () => R.edit(cur));+ const back = tx('button', 'btn warn', 'st.rRevert', { type: 'button' }); back.addEventListener('click', () => R.revert(cur));+ back.disabled = !R.canRevert(cur) || !!this.ctx.store.view?.readOnly; if (back.disabled) back.title = t('st.rNoRevert');+ fix.disabled = !!this.ctx.store.view?.readOnly;+ acts.append(keep, fix, back);+ card.append(acts);+ wrap.append(card);+ }+ const ul = el('ul', 'st-rlist');+ items.forEach((it, i) => {+ const b = el('button', 'st-ritem' + (i === R.index() ? ' on' : '') + (R.status(it) ? ' done' : ''), null, { type: 'button' });+ const txt = el('span', 'rx');+ if (it.kind === 'fix') txt.append(el('s', null, it.heard), ' → ', el('b', null, it.text || t('ed.hidden')));+ else txt.append(el('b', null, it.text), ' · ', el('s', null, it.heard));+ b.append(el('span', 'tm mono', it.at != null ? fmtT(it.at) : '–'), txt, R.status(it) ? icon('check') : el('span'));+ b.addEventListener('click', () => R.goto(i));+ const li = el('li'); li.append(b); ul.append(li);+ });+ wrap.append(ul);+ return wrap;+ }++ // ---- Nhạc ----+ renderMusic() {+ const st = this.ctx.store; const v = st.view; const m = st.doc.music; const ro = !!v.readOnly;+ this.setHead('music', 'st.trMusic');+ const sel = el('select', 'st-sel', null, { id: 'stMusicSrc' });+ const opts = [];+ if (v.music.on) opts.push(new Option(t('man.musicKeep', { name: this.ctx.musicName('keep') }), 'keep'));+ opts.push(new Option(t('ed.noMusic'), 'none'));+ for (const s of v.music.synth) opts.push(new Option(t('man.synth', { id: s }), `synth:${s}`));+ for (const u of v.music.uploads) opts.push(new Option(t('man.uploaded', { name: u.name }), `upload:${u.file}`));+ sel.replaceChildren(...opts); sel.value = m.source; sel.disabled = ro;+ sel.addEventListener('change', () => this.commit((d) => { d.music.source = sel.value; }));+ const file = el('input', null, null, { type: 'file', accept: 'audio/*,.mp3,.wav,.m4a,.aac,.ogg,.flac,.opus', hidden: true });+ const up = el('button', 'btn ghost sm', null, { type: 'button' }); up.append(icon('upload'), tx('span', null, 'st.uploadMusic')); up.disabled = ro;+ up.addEventListener('click', () => file.click());+ file.addEventListener('change', () => { const f = file.files[0]; file.value = ''; if (f) this.ctx.uploadMusic(f); });+ this.musicMsg = this.musicMsg || el('p', 'st-note', null, { 'aria-live': 'polite' });+ const g1 = this.field('man.music', sel, 'stMusicSrc');+ const upRow = el('div', 'st-row'); upRow.append(up, file);+ const kids = [g1, upRow, this.musicMsg];+ if (m.source !== 'none') {+ kids.push(this.slider('st.gain', -40, 0, 1, m.gainDb, fmtDb, (x) => (d) => { d.music.gainDb = x; }, 'gain', ro));+ kids.push(this.check('man.duckS', m.duck, (c) => (d) => { d.music.duck = c; }, ro));+ kids.push(this.slider('man.fadeS', 0, 10, 0.5, m.fadeOut, (x) => `${x} s`, (x) => (d) => { d.music.fadeOut = x; }, 'fade', ro));+ kids.push(this.slider('man.startS', 0, 120, 0.5, m.start, (x) => `${x} s`, (x) => (d) => { d.music.start = x; }, 'mstart', ro));+ }+ kids.push(el('hr'));+ kids.push(this.slider('man.voiceS', -12, 12, 1, st.doc.voice.gainDb, fmtDb, (x) => (d) => { d.voice.gainDb = x; }, 'voice', ro, 'man.loudHint'));+ const sfx = this.check('man.sfx', st.doc.sfx.on, (c) => (d) => { d.sfx.on = c; }, ro || !v.sfx.count);+ const sl = sfx.querySelector('span'); delete sl.dataset.i18n; sl.textContent = t('man.sfx', { n: v.sfx.count });+ kids.push(sfx);+ this.body.replaceChildren(...kids);+ }+ field(key, input, id) { const w = el('div', 'st-field'); const l = tx('label', null, key, { for: id }); w.append(l, input); return w; }+ slider(key, min, max, step, val, fmt, mk, tkey, ro, hintKey) {+ const id = 'st-' + tkey;+ const w = el('div', 'st-field st-slide');+ const l = tx('label', null, key, { for: id });+ const r = el('input', null, null, { type: 'range', id, min: String(min), max: String(max), step: String(step) }); r.value = String(val); r.disabled = !!ro;+ const o = el('output', 'mono', fmt(val), { for: id });+ r.addEventListener('input', () => { const x = Number(r.value); o.textContent = fmt(x); this.commit(mk(x), tkey); });+ w.append(l, r, o);+ if (hintKey) { w.title = t(hintKey); w.dataset.i18nTitle = hintKey; }+ return w;+ }+ check(key, val, mk, ro) {+ const w = el('label', 'st-switch');+ const c = el('input', null, null, { type: 'checkbox', role: 'switch' }); c.checked = !!val; c.disabled = !!ro;+ c.addEventListener('change', () => this.commit(mk(c.checked)));+ w.append(c, tx('span', null, key));+ return w;+ }++ // ---- Zoom ----+ renderZoom() {+ const st = this.ctx.store; const sel = this.ctx.getSel(); const ro = !!st.view.readOnly;+ const add = el('button', 'btn ghost sm', null, { type: 'button' }); add.append(icon('plus'), tx('span', null, 'st.addZoom')); add.disabled = ro;+ add.addEventListener('click', () => this.ctx.addZoom());+ this.setHead('zoom', 'st.trZoom', add);+ const kids = [];+ const z = sel?.kind === 'zoom' && st.doc.zooms.find((x) => x.u === sel.u);+ if (z) {+ const box = el('div', 'st-card');+ const kinds = el('div', 'st-seg sm', null, { role: 'radiogroup', 'aria-label': t('st.zoomKind') });+ for (const k of ['push', 'punch']) {+ const b = tx('button', z.kind === k ? 'on' : '', k === 'push' ? 'st.push' : 'st.punch', { type: 'button', role: 'radio', 'aria-checked': String(z.kind === k) });+ b.disabled = ro;+ b.addEventListener('click', () => this.commit((d) => { const y = d.zooms.find((q) => q.u === z.u); if (y) y.kind = k; }));+ kinds.append(b);+ }+ box.append(kinds, tx('p', 'st-hint', z.kind === 'push' ? 'st.pushHint' : 'st.punchHint'));+ box.append(this.slider('st.zStrength', 1.02, 1.6, 0.01, z.scale, (x) => `${Number(x).toFixed(2)}×`, (x) => (d) => { const y = d.zooms.find((q) => q.u === z.u); if (y) y.scale = x; }, 'zs-' + z.u, ro));+ const maxDur = this.zoomRoom(z);+ box.append(this.slider('st.zLength', 0.2, Math.max(0.2, Math.min(8, maxDur)), 0.1, Math.min(z.dur, maxDur), (x) => `${Number(x).toFixed(1)} s`, (x) => (d) => { const y = d.zooms.find((q) => q.u === z.u); if (y) y.dur = x; }, 'zd-' + z.u, ro));+ const tr = el('div', 'st-row');+ const go = el('button', 'btn ghost sm', fmtT(z.at), { type: 'button' }); go.prepend(icon('clock'));+ go.addEventListener('click', () => this.ctx.seek(z.at));+ const del = el('button', 'btn ghost sm danger', null, { type: 'button' }); del.append(icon('trash'), tx('span', null, 'st.del')); del.disabled = ro;+ del.addEventListener('click', () => this.ctx.deleteSel());+ tr.append(go, del); box.append(tr);+ kids.push(box);+ } else kids.push(tx('p', 'st-hint', 'st.zoomPick'));+ kids.push(this.blockList(st.doc.zooms.map((x) => ({ u: x.u, at: x.at, label: `${t(x.kind === 'punch' ? 'st.punch' : 'st.push')} · ${x.scale.toFixed(2)}× · ${x.dur.toFixed(1)} s` })), 'zoom', 'man.noZoom'));+ this.body.replaceChildren(...kids);+ }+ zoomRoom(z) {+ const next = this.ctx.store.doc.zooms.filter((x) => x.u !== z.u && x.at >= z.at).sort((a, b) => a.at - b.at)[0];+ return Math.min(next ? next.at - z.at : Infinity, this.ctx.store.view.duration - z.at);+ }+ blockList(list, kind, emptyKey) {+ const sel = this.ctx.getSel();+ const ul = el('ul', 'st-blist');+ if (!list.length) { ul.append(tx('li', 'none', emptyKey)); return ul; }+ for (const it of list.sort((a, b) => a.at - b.at)) {+ const b = el('button', sel?.u === it.u ? 'on' : '', null, { type: 'button' });+ b.append(el('span', 'tm mono', fmtT(it.at)), el('span', 'lb', it.label));+ b.addEventListener('click', () => { this.ctx.select({ kind, u: it.u }); this.ctx.seek(it.at + 0.01); });+ const li = el('li'); li.append(b); ul.append(li);+ }+ return ul;+ }++ // ---- Đồ hoạ ----+ renderGfx() {+ const st = this.ctx.store; const sel = this.ctx.getSel(); const ro = !!st.view.readOnly;+ this.setHead('gfx', 'st.trGfx');+ const kids = [];+ const g = sel?.kind === 'gfx' && st.doc.gfx.find((x) => x.u === sel.u);+ if (g) {+ const box = el('div', 'st-card');+ const top = el('div', 'st-row');+ top.append(el('b', 'st-gtype', t('gfx.' + g.type)));+ if (g.estimate) top.append(tx('span', 'st-pill warn', 'st.estimate'));+ box.append(top);+ const times = el('div', 'st-row');+ const tnum = (f, v) => {+ const w = el('label', 'st-tbox'); w.append(icon('clock'));+ const i = el('input', 'mono', null, { type: 'number', step: '0.05', min: '0', inputmode: 'decimal', 'aria-label': t(f === 'at' ? 'st.gStart' : 'st.gEnd') });+ i.value = r2(v).toFixed(2); i.disabled = ro;+ i.addEventListener('change', () => { const x = Number(i.value); if (!Number.isFinite(x)) return; this.ctx.setGfxTime(g.u, f, x); });+ w.append(i); return w;+ };+ times.append(tnum('at', g.at), el('span', 'arrow', '→', { 'aria-hidden': 'true' }), tnum('until', g.until));+ box.append(times);+ const d = g.data || {};+ for (const k of GFX_KEYS) if (k in d && (typeof d[k] === 'string' || typeof d[k] === 'number')) box.append(this.gfxInput(g, [k], d[k], t('gf.' + k), ro));+ for (const arr of Object.keys(ROW_KEYS)) {+ if (!Array.isArray(d[arr])) continue;+ d[arr].forEach((row, i) => {+ const grp = el('fieldset', 'st-grow');+ grp.append(el('legend', null, t('gf.row', { n: i + 1 })));+ for (const f of ROW_KEYS[arr]) {+ if (!(f in row)) continue;+ if (typeof row[f] === 'boolean') {+ const w = el('label', 'st-switch sm');+ const c = el('input', null, null, { type: 'checkbox' }); c.checked = row[f]; c.disabled = ro;+ c.addEventListener('change', () => this.commit((dd) => { const y = dd.gfx.find((q) => q.u === g.u); if (y) y.data[arr][i][f] = c.checked; }));+ w.append(c, tx('span', null, 'gf.ok')); grp.append(w);+ } else grp.append(this.gfxInput(g, [arr, i, f], row[f], t('gf.' + f), ro));+ }+ box.append(grp);+ });+ }+ const del = el('button', 'btn ghost sm danger', null, { type: 'button' }); del.append(icon('trash'), tx('span', null, 'st.delGfx')); del.disabled = ro;+ del.addEventListener('click', () => this.ctx.deleteSel());+ box.append(del);+ kids.push(box);+ } else kids.push(tx('p', 'st-hint', 'st.gfxPick'));+ kids.push(this.blockList(st.doc.gfx.map((x) => ({ u: x.u, at: x.at, label: `${t('gfx.' + x.type)}${x.data?.title || x.data?.text || x.data?.label ? ' · ' + (x.data.title || x.data.text || x.data.label) : ''}` })), 'gfx', 'man.noGfx'));+ this.body.replaceChildren(...kids);+ }+ gfxInput(g, pathKeys, val, label, ro) {+ const w = el('label', 'st-field');+ w.append(el('span', null, label));+ const isNum = typeof val === 'number';+ const i = el('input', isNum ? 'mono' : null, null, { type: isNum ? 'number' : 'text', step: isNum ? 'any' : null, inputmode: isNum ? 'decimal' : null, maxlength: isNum ? null : '30' });+ i.value = String(val); i.disabled = ro;+ i.addEventListener('input', () => {+ let x = i.value; if (isNum) { x = Number(x); if (!Number.isFinite(x) || i.value === '') return; }+ this.commit((d) => {+ const y = d.gfx.find((q) => q.u === g.u); if (!y) return;+ let o = y.data; for (let k = 0; k < pathKeys.length - 1; k++) o = o[pathKeys[k]];+ o[pathKeys[pathKeys.length - 1]] = x;+ }, 'g:' + g.u + pathKeys.join('.'));+ });+ w.append(i);+ return w;+ }++ // ---- Sửa bằng lời (AI) ----+ renderAi() {+ const st = this.ctx.store; const v = this.ctx.job();+ this.setHead('ai', 'st.aiH');+ const busy = this.ctx.busy();+ const changes = st.changes;+ const form = el('form', 'st-ai');+ const ta = el('textarea', null, null, { rows: '3', maxlength: '1000', id: 'stAiText', placeholder: t('ed.revisePhS') });+ ta.dataset.i18nPlaceholder = 'ed.revisePhS';+ ta.value = this.aiDraft || '';+ ta.addEventListener('input', () => { this.aiDraft = ta.value; });+ const lab = tx('label', 'sr', 'ed.reviseLabel', { for: 'stAiText' });+ const chips = el('div', 'st-chips');+ for (const k of ['ed.p1', 'ed.p2', 'ed.p3']) {+ const c = tx('button', 'chip', k, { type: 'button' });+ c.addEventListener('click', () => { ta.value = t(k); this.aiDraft = ta.value; ta.focus(); });+ chips.append(c);+ }+ const go = el('button', 'btn pri', null, { type: 'submit' }); go.append(icon('ai'), tx('span', null, 'st.aiGo'));+ go.disabled = busy || !!st.view.readOnly || changes > 0 || v?.status !== 'done';+ form.append(lab, ta, chips, go);+ form.addEventListener('submit', (e) => { e.preventDefault(); const s = ta.value.trim(); if (s) { this.ctx.revise(s); this.aiDraft = ''; } });+ const kids = [tx('p', 'st-hint', 'st.aiHint'), form];+ if (changes > 0) kids.push(el('p', 'st-note warn', t('st.aiPending', { n: changes })));+ if (st.view.readOnly) kids.push(tx('p', 'st-note', 'st.readOnly'));+ // các lần sửa+ const revs = v?.revisions || [];+ if (revs.length) {+ kids.push(tx('h4', 'st-h4', 'ed.histH'));+ const ol = el('ol', 'st-hist');+ for (const r of [...revs].reverse()) {+ const li = el('li');+ li.append(el('b', 'mono', `r${r.n}`), ' ');+ if (r.manual) li.append(tx('span', 'st-pill', 'man.tag'), ' ', r.instruction || '');+ else li.append(`“${r.instruction || ''}”`);+ if (r.notes) li.append(el('small', null, r.notes));+ ol.append(li);+ }+ kids.push(ol);+ }+ this.body.replaceChildren(...kids);+ }+}diff --git a/server/public/studio/player.js b/server/public/studio/player.jsnew file mode 100644index 0000000..8bad5e0--- /dev/null+++ b/server/public/studio/player.js@@ -0,0 +1,243 @@+// Player giữa Studio: video nền KHÔNG chữ (base.mp4) + lớp HTML vẽ phụ đề theo look đang chọn, thẻ đồ hoạ gần đúng,+// zoom xem trước bằng CSS transform, nhạc phát song song (<audio>, âm lượng theo dB, tự hạ khi có lời).+// Không có base (bản cũ / chưa dựng lại nền) hoặc bấm "Bản xuất" → phát thẳng MP4 đã xuất, không vẽ đè.+import { el, tx, icon, iconBtn, fmtT, tokens, clamp, t } from './util.js';++const FPS = 30;+const ease = (x) => { x = clamp(x, 0, 1); return x * x * (3 - 2 * x); };+/** Như lumedit Zooms.scale_at: punch (vào 0,08 s, giữ, ra 0,12 s) / push (đẩy chậm, lùi 0,3 s cuối). */+export function zoomScale(zs, tt) {+ for (const z of zs) {+ if (tt < z.at || tt >= z.at + z.dur) continue;+ const u = tt - z.at; let k;+ if (z.kind === 'punch') { k = u < 0.08 ? ease(u / 0.08) : 1; if (u > z.dur - 0.12) k = Math.min(k, ease((z.dur - u) / 0.12)); }+ else { const back = Math.min(0.3, z.dur * 0.2); k = u < z.dur - back ? ease(u / (z.dur - back)) : ease((z.dur - u) / back); }+ return 1 + (z.scale - 1) * k;+ }+ return 1;+}++export class Player {+ constructor(ctx) {+ this.ctx = ctx; // {store, onTime(t), onPlay(bool), getSel()}+ this.root = el('section', 'st-stage');+ this.box = el('div', 'st-vid');+ this.video = el('video', null, null, { playsinline: true, preload: 'auto' });+ this.video.playsInline = true;+ this.zoomWrap = el('div', 'st-zw'); this.zoomWrap.append(this.video);+ this.gfxLayer = el('div', 'st-gfx', null, { 'aria-hidden': 'true' });+ this.capLayer = el('div', 'st-cap', null, { 'aria-hidden': 'true' });+ this.capText = el('div', 'st-capt'); this.capLayer.append(this.capText);+ this.capSel = el('div', 'st-capsel'); this.capSel.hidden = true;+ this.badge = el('div', 'st-vbadge'); this.badge.hidden = true;+ this.box.append(this.zoomWrap, this.gfxLayer, this.capLayer, this.capSel, this.badge);+ this.audio = el('audio', null, null, { preload: 'auto' });+ // điều khiển+ const ctrl = el('div', 'st-ctrl');+ this.tm = el('span', 'st-time mono');+ this.tmNow = el('b', null, '0:00.0'); this.tmDur = el('span', null, '0:00.0');+ this.tm.append(this.tmNow, ' / ', this.tmDur);+ this.bPrev = iconBtn('prev', 'st.prevFrame', 'st-tbtn');+ this.bPlay = el('button', 'st-play', null, { type: 'button' });+ this.bNext = iconBtn('next', 'st.nextFrame', 'st-tbtn');+ this.bRatio = el('span', 'st-pill mono', '9:16');+ this.bOut = tx('button', 'st-pill st-outsw', 'st.viewOut', { type: 'button', 'aria-pressed': 'false' });+ ctrl.append(this.tm, this.bPrev, this.bPlay, this.bNext, this.bRatio, this.bOut);+ this.root.append(this.box, ctrl, this.audio);+ this.paintPlay();+ this.mode = 'edit'; // 'edit' (nền + vẽ đè) | 'out' (MP4 đã xuất)+ this.src = { base: null, out: null };+ this.lastCap = null; this.lastGfx = ''; this.raf = 0; this.musicDur = 0;+ this.bPlay.addEventListener('click', () => this.toggle());+ this.bPrev.addEventListener('click', () => this.step(-1 / FPS));+ this.bNext.addEventListener('click', () => this.step(1 / FPS));+ this.bOut.addEventListener('click', () => this.setMode(this.mode === 'out' ? 'edit' : 'out'));+ this.box.addEventListener('click', () => this.toggle());+ const v = this.video;+ v.addEventListener('play', () => { this.paintPlay(); this.syncAudio(true); this.loop(); this.ctx.onPlay?.(true); });+ v.addEventListener('pause', () => { this.paintPlay(); this.audio.pause(); this.ctx.onPlay?.(false); this.tick(); });+ v.addEventListener('seeked', () => { this.syncAudio(true); this.tick(); });+ v.addEventListener('loadedmetadata', () => { this.tick(); this.fit(); });+ v.addEventListener('ended', () => this.paintPlay());+ this.audio.addEventListener('loadedmetadata', () => { this.musicDur = this.audio.duration || 0; this.syncAudio(true); });+ this.ro = new ResizeObserver(() => this.fit());+ this.ro.observe(this.root);+ }+ get time() { return this.video.currentTime || 0; }+ get duration() { return this.ctx.store.view?.duration || this.video.duration || 0; }+ paintPlay() {+ const playing = !this.video.paused && !this.video.ended;+ this.bPlay.replaceChildren(icon(playing ? 'pause' : 'play'));+ this.bPlay.setAttribute('aria-label', t(playing ? 'st.pause' : 'st.play'));+ this.bPlay.title = `${t(playing ? 'st.pause' : 'st.play')} (Space)`;+ }+ /** Nạp nguồn: base (không chữ) nếu có, out (MP4 đã xuất). */+ setSources({ base, out, music }) {+ this.src = { base, out };+ this.bOut.hidden = !base || !out;+ this.setMode(base && this.mode !== 'out' ? 'edit' : 'out', true);+ this.setMusic(music);+ }+ setMode(m, force) {+ if (m === 'edit' && !this.src.base) m = 'out';+ if (m === this.mode && !force) return;+ const at = this.time; const was = !this.video.paused;+ this.mode = m;+ const url = m === 'edit' ? this.src.base : this.src.out;+ this.bOut.setAttribute('aria-pressed', String(m === 'out'));+ this.box.classList.toggle('raw', m === 'out');+ if (url && this.video.getAttribute('src') !== url) {+ this.video.src = url;+ this.video.addEventListener('loadedmetadata', () => { this.video.currentTime = Math.min(at, this.video.duration || at); if (was) this.video.play().catch(() => {}); }, { once: true });+ }+ this.badge.hidden = m === 'edit' || !this.src.base;+ this.badge.textContent = t('st.viewingOut'); this.badge.dataset.i18n = 'st.viewingOut';+ this.lastCap = null; this.lastGfx = ''; this.tick();+ }+ setMusic(url) {+ if (!url) { this.audio.pause(); this.audio.removeAttribute('src'); this.audio.load(); this.musicUrl = null; return; }+ if (url === this.musicUrl) return;+ this.musicUrl = url; this.audio.src = url; this.audio.load();+ }+ /** Nhả file (Windows giữ khoá file đang phát): trước khi server ghi đè base.mp4. */+ release() {+ this.video.pause(); this.video.removeAttribute('src'); this.video.load();+ this.audio.pause(); this.audio.removeAttribute('src'); this.audio.load(); this.musicUrl = null;+ this.src = { base: null, out: null };+ }+ toggle() { if (!this.video.getAttribute('src')) return; if (this.video.paused || this.video.ended) this.video.play().catch(() => {}); else this.video.pause(); }+ pause() { this.video.pause(); }+ seek(tt) {+ const d = this.duration;+ const x = clamp(tt, 0, Math.max(0, d - 1 / FPS / 2));+ if (Number.isFinite(x)) this.video.currentTime = x;+ this.tick(x);+ }+ step(dt) { this.pause(); this.seek(Math.round((this.time + dt) * FPS) / FPS); }++ // ---- nhạc song song: âm lượng theo dB (gần đúng), tự hạ khi có lời ----+ musicVolume(tt) {+ const m = this.ctx.store.doc?.music; if (!m || m.source === 'none' || this.mode !== 'edit') return 0;+ let db = m.gainDb + 12; // nền tiếng gốc ~ −12 dBFS+ if (m.duck && this.ctx.store.lineAt(tt) >= 0) db -= this.ctx.store.view?.music?.duckDb || 10;+ const d = this.duration; if (m.fadeOut > 0 && tt > d - m.fadeOut) db += 20 * Math.log10(Math.max(0.001, (d - tt) / m.fadeOut));+ return clamp(10 ** (db / 20), 0, 1);+ }+ syncAudio(hard) {+ const a = this.audio; const m = this.ctx.store.doc?.music;+ if (!this.musicUrl || !m || m.source === 'none' || this.mode !== 'edit') { a.pause(); return; }+ const md = this.musicDur || a.duration || 0; if (!md) return;+ const want = (m.start + this.time) % md;+ if (hard || Math.abs(a.currentTime - want) > 0.25) a.currentTime = want;+ a.volume = this.musicVolume(this.time);+ const vg = this.ctx.store.doc?.voice?.gainDb || 0;+ this.video.volume = clamp(10 ** (Math.min(0, vg) / 20), 0, 1);+ if (!this.video.paused && a.paused) a.play().catch(() => {});+ }+ loop() {+ cancelAnimationFrame(this.raf);+ const f = () => { this.tick(); if (!this.video.paused && !this.video.ended) { this.syncAudio(false); this.raf = requestAnimationFrame(f); } };+ this.raf = requestAnimationFrame(f);+ }+ /** Vẽ mỗi khung: giờ, lớp chữ (chỉ khi đổi dòng), zoom CSS, đồ hoạ. */+ tick(at) {+ const tt = at ?? this.time;+ this.tmNow.textContent = fmtT(tt); this.tmDur.textContent = fmtT(this.duration);+ this.ctx.onTime?.(tt);+ const edit = this.mode === 'edit';+ const doc = this.ctx.store.doc;+ // zoom: nền đã có zoom của bản gốc → chỉ zoom mới/đổi mới phóng thêm bằng CSS+ let s = 1;+ if (edit && doc) {+ const orig = this.ctx.store.orig?.zooms || [];+ const fresh = doc.zooms.filter((z) => !orig.some((o) => o.n === z.n && Math.abs(o.at - z.at) < 0.005 && o.dur === z.dur && o.scale === z.scale && o.kind === z.kind));+ s = zoomScale(fresh, tt);+ }+ this.zoomWrap.style.transform = s > 1.0005 ? `scale(${s.toFixed(4)})` : '';+ this.paintCap(edit && doc ? doc.lines.findIndex((l) => tt >= l.start && tt < l.end) : -1);+ this.paintGfx(edit && doc ? doc.gfx.filter((g) => tt >= g.at && tt < g.until) : []);+ this.paintSel();+ }+ /** Khung chữ theo look: cỡ chữ (px trên 1080) × tỉ lệ khung đang hiện. */+ fit() {+ const w = this.box.clientWidth || 1;+ this.k = w / 1080;+ this.box.style.setProperty('--k', String(this.k));+ this.lastCap = null; this.lastGfx = '';+ this.tick();+ }+ lookCss() {+ const s = this.ctx.store; const id = s.doc?.look;+ return s.view?.captions.looks.find((l) => l.id === id)?.css || null;+ }+ paintCap(idx) {+ const s = this.ctx.store; const L = s.doc?.lines || [];+ const line = L[idx];+ const look = this.lookCss();+ const key = line ? `${line.u}|${line.text}|${s.doc.look}|${s.doc.hi}|${this.k}` : '';+ if (key === this.lastCap) return;+ this.lastCap = key;+ const box = this.capText;+ if (!line || !look) { box.replaceChildren(); box.hidden = true; return; }+ box.hidden = false;+ const k = this.k || 0.25;+ box.style.fontFamily = `${look.font}, 'Be Vietnam Pro', sans-serif`;+ box.style.fontWeight = String(look.weight);+ box.style.fontSize = `${Math.round(look.size * k * 10) / 10}px`;+ box.style.color = look.color;+ box.style.textTransform = look.upper ? 'uppercase' : 'none';+ box.style.top = `${look.cy * 100}%`;+ const sw = (look.stroke ?? 8) * k;+ box.style.webkitTextStroke = look.box ? '0' : `${sw.toFixed(2)}px rgba(0,0,0,.9)`;+ box.style.textShadow = look.shadow || `0 ${(4 * k).toFixed(1)}px ${(14 * k).toFixed(1)}px rgba(0,0,0,.55)`;+ box.classList.toggle('boxed', !!look.box);+ box.style.background = look.box ? look.box.bg : '';+ const kids = [];+ if (look.box?.tag) { const tg = el('span', 'tag', look.box.tag); tg.style.background = look.box.tagBg || '#E8202A'; kids.push(tg); }+ const ws = tokens(line.text);+ ws.forEach((w, i) => {+ if (i) kids.push(' ');+ const sp = el('span', null, w.w);+ if (w.hi && s.doc.hi) sp.style.color = look.hi;+ kids.push(sp);+ });+ box.replaceChildren(...kids);+ }+ /** Khung chọn quanh dòng chữ đang chọn (như mẫu) — chỉ khi dòng đó đang hiện. */+ paintSel() {+ const sel = this.ctx.getSel?.();+ const show = this.mode === 'edit' && sel?.kind === 'cap' && !this.capText.hidden && (this.lastCap || '').startsWith(sel.u + '|');+ this.capSel.hidden = !show;+ if (!show) return;+ const b = this.box.getBoundingClientRect(); const r = this.capText.getBoundingClientRect();+ this.capSel.style.transform = `translate(${(r.left - b.left - 6).toFixed(1)}px, ${(r.top - b.top - 4).toFixed(1)}px)`;+ this.capSel.style.width = `${(r.width + 12).toFixed(1)}px`; this.capSel.style.height = `${(r.height + 8).toFixed(1)}px`;+ }+ /** Thẻ đồ hoạ gần đúng (bản ra mới vẽ bằng HyperFrames): khung tối, tiêu đề, các dòng. */+ paintGfx(list) {+ const key = list.map((g) => `${g.id}|${JSON.stringify(g.data)}|${JSON.stringify(g.box)}`).join('#') + '|' + this.k;+ if (key === this.lastGfx) return;+ this.lastGfx = key;+ const k = this.k || 0.25;+ this.gfxLayer.replaceChildren(...list.map((g) => {+ const b = g.box || { x: 120, y: 200, w: 840, h: 300, scale: 1 };+ const c = el('div', 'st-gcard st-g-' + g.type);+ c.style.transform = `translate(${(b.x * k).toFixed(1)}px, ${(b.y * k).toFixed(1)}px)`;+ c.style.width = `${(b.w * k).toFixed(1)}px`; c.style.minHeight = `${(b.h * k * 0.6).toFixed(1)}px`;+ c.style.fontSize = `${(30 * b.scale * k).toFixed(2)}px`;+ const d = g.data || {};+ if (d.title || d.kicker) {+ const h = el('div', 'h'); if (d.kicker) h.append(el('span', 'kick', d.kicker + ' '));+ h.append(d.title || ''); if (d.unit) h.append(el('span', 'u', ' · ' + d.unit)); c.append(h);+ }+ const big = (txt) => c.append(el('div', 'big', txt));+ if (g.type === 'sticker') big(d.text || '');+ if (g.type === 'counter' || g.type === 'price_tag') { if (d.label) c.append(el('div', 'lbl', d.label)); big(`${d.prefix || ''}${d.value ?? ''}${d.suffix ? ' ' + d.suffix : ''}`); }+ for (const r of d.rows || []) { const row = el('div', 'row'); row.append(el('span', null, r.label ?? ''), el('b', null, r.value ?? (r.a != null ? `${r.a} · ${r.b}` : ''))); c.append(row); }+ for (const r of d.items || []) { const row = el('div', 'row'); row.append(el('span', null, (r.ok === false ? '✕ ' : r.ok ? '✓ ' : '') + (r.text ?? r.label ?? '')), el('b', null, r.value != null ? String(r.value) : '')); c.append(row); }+ for (const r of d.points || []) { const row = el('div', 'row'); row.append(el('span', null, r.label ?? ''), el('b', null, String(r.value ?? ''))); c.append(row); }+ return c;+ }));+ }+ destroy() { cancelAnimationFrame(this.raf); this.ro.disconnect(); this.release(); }+}diff --git a/server/public/studio/store.js b/server/public/studio/store.jsnew file mode 100644index 0000000..60796bf--- /dev/null+++ b/server/public/studio/store.js@@ -0,0 +1,180 @@+// Trạng thái chỉnh của 1 bản edit trong Studio: bản gốc (từ GET /manual) + bản đang sửa + Undo/Redo.+// Mọi thay đổi giữ ở máy (localStorage theo id + tên bản ra mới nhất) tới khi "Xuất bản mới" gửi 1 bản vá+// (POST /api/edits/:id/manual, schema edit/manual.mjs).+import { store, r2, tokens, untokens, plain } from './util.js';++const KEY = (id) => `lumreels.studio.v1.${id}`;+const MAX_HIST = 200;+let uid = 0;+const nid = (p) => `${p}${++uid}`;++/** View server → doc (đơn vị: giây bản ra). */+function toDoc(v) {+ return {+ lines: v.captions.lines.map((l) => ({ u: nid('l'), start: l.start, end: l.end, text: l.text })),+ look: v.captions.look, hi: !!v.captions.highlights,+ music: { source: v.music.on ? 'keep' : 'none', gainDb: v.music.gainDb, duck: !!v.music.duck, fadeOut: v.music.fadeOut, start: v.music.start || 0 },+ voice: { gainDb: v.voice.gainDb }, sfx: { on: !!v.sfx.on },+ zooms: v.zooms.map((z) => ({ u: nid('z'), n: z.n, at: z.at, dur: z.dur, scale: z.scale, kind: z.kind })),+ gfx: v.graphics.map((g) => ({ u: 'g:' + g.id, id: g.id, type: g.type, at: g.at, until: g.until, data: JSON.parse(JSON.stringify(g.data || {})), box: g.box, estimate: !!g.estimate })),+ };+}+const snap = (d) => JSON.stringify(d);+const eqT = (a, b) => Math.abs(a - b) < 0.005;++export class Store {+ constructor() { this.view = null; this.orig = null; this.doc = null; this.undo = []; this.redo = []; this.subs = new Set(); this.id = null; this.outKey = null; this.pending = null; }+ on(f) { this.subs.add(f); return () => this.subs.delete(f); }+ emit(what) { for (const f of this.subs) f(what); }++ /** Nạp view; khôi phục bản nháp cục bộ nếu cùng bản ra mới nhất. */+ load(id, view) {+ this.id = id; this.view = view;+ this.outKey = `${view.latest}|${view.versions?.[view.latest]?.out || ''}`;+ this.orig = toDoc(view);+ this.doc = JSON.parse(snap(this.orig));+ this.undo = []; this.redo = [];+ if (!view.readOnly) {+ const saved = store.get(KEY(id));+ if (saved && saved.outKey === this.outKey && saved.doc) {+ try {+ // giữ uid gốc của dòng/zoom bản gốc (để so) — doc lưu đủ trường+ this.orig = saved.orig || this.orig; this.doc = saved.doc; this.undo = saved.undo || []; this.redo = saved.redo || [];+ for (const l of this.doc.lines) l.u = l.u || nid('l');+ } catch { /* hỏng: dùng bản server */ }+ } else if (saved) store.del(KEY(id));+ }+ this.emit('load');+ }+ persist() {+ if (!this.id || this.view?.readOnly) return;+ if (!this.undo.length && !this.redo.length) { store.del(KEY(this.id)); return; }+ store.set(KEY(this.id), { outKey: this.outKey, orig: this.orig, doc: this.doc, undo: this.undo.slice(-60), redo: this.redo.slice(-60) });+ }+ clearDraft() { if (this.id) store.del(KEY(this.id)); }++ /** Thay đổi 1 bước (undo được). fn(doc) sửa tại chỗ. */+ commit(fn, what = 'doc') {+ if (this.view?.readOnly) return false;+ this.typing = null;+ const before = snap(this.doc);+ fn(this.doc);+ if (snap(this.doc) === before) return false;+ this.undo.push(before); if (this.undo.length > MAX_HIST) this.undo.shift();+ this.redo = [];+ this.persist(); this.emit(what);+ return true;+ }+ /** Gõ / kéo thanh trượt liên tục cùng 1 ô: gộp thành 1 bước Undo nếu cách nhau < 1,5 s. */+ commitTyping(key, fn) {+ const now = Date.now();+ if (this.typing?.key === key && now - this.typing.at < 1500 && this.undo.length) {+ const before = snap(this.doc); fn(this.doc);+ this.typing.at = now;+ if (snap(this.doc) !== before) { this.redo = []; this.persist(); this.emit('doc'); }+ return true;+ }+ const ok = this.commit(fn);+ this.typing = ok ? { key, at: now } : null;+ return ok;+ }+ /** Kéo trên timeline: chụp trước khi kéo, tới lúc thả mới thành 1 bước. */+ begin() { this.pending = snap(this.doc); }+ end() {+ if (this.pending == null) return false;+ const before = this.pending; this.pending = null;+ if (snap(this.doc) === before) return false;+ this.undo.push(before); this.redo = []; this.persist(); this.emit('doc');+ return true;+ }+ cancel() { if (this.pending != null) { this.doc = JSON.parse(this.pending); this.pending = null; this.emit('doc'); } }+ doUndo() { this.typing = null; if (!this.undo.length) return false; this.redo.push(snap(this.doc)); this.doc = JSON.parse(this.undo.pop()); this.persist(); this.emit('doc'); return true; }+ doRedo() { this.typing = null; if (!this.redo.length) return false; this.undo.push(snap(this.doc)); this.doc = JSON.parse(this.redo.pop()); this.persist(); this.emit('doc'); return true; }+ reset() { if (this.view?.readOnly) return; this.undo.push(snap(this.doc)); this.doc = JSON.parse(snap(this.orig)); this.redo = []; this.persist(); this.emit('doc'); }+ get changes() { return Object.keys(this.patch()).length ? this.undo.length || 1 : 0; }++ // ---- phụ đề ----+ lineAt(tt) { return this.doc.lines.findIndex((l) => tt >= l.start - 1e-3 && tt < l.end); }+ /** Tách dòng k tại giây tt (chữ chia theo tỉ lệ thời gian). Trả false nếu không tách được. */+ splitLine(k, tt) {+ const l = this.doc.lines[k]; if (!l) return false;+ const ws = tokens(l.text); if (ws.length < 2) return false;+ if (tt == null || tt <= l.start + 0.1 || tt >= l.end - 0.1) tt = l.start + (l.end - l.start) / 2;+ const cut = Math.min(ws.length - 1, Math.max(1, Math.round((ws.length * (tt - l.start)) / (l.end - l.start))));+ const m = r2(tt);+ return this.commit((d) => {+ d.lines.splice(k, 1, { u: l.u, start: l.start, end: m, text: untokens(ws.slice(0, cut)) }, { u: nid('l'), start: m, end: l.end, text: untokens(ws.slice(cut)) });+ });+ }+ mergeLine(k) {+ const a = this.doc.lines[k]; const b = this.doc.lines[k + 1]; if (!a || !b) return false;+ return this.commit((d) => { d.lines.splice(k, 2, { u: a.u, start: a.start, end: b.end, text: `${a.text} ${b.text}`.trim() }); });+ }++ // ---- bản vá (chỉ phần khác bản gốc) ----+ patch() {+ const o = this.orig; const c = this.doc; if (!o || !c) return {};+ const p = {};+ const cap = {};+ const ls = (x) => JSON.stringify(x.map((l) => [Math.round(l.start * 100), Math.round(l.end * 100), l.text.trim()]));+ if (ls(o.lines) !== ls(c.lines)) cap.lines = c.lines.map((l) => ({ start: r2(l.start), end: r2(l.end), text: l.text.trim() }));+ if (o.hi !== c.hi) cap.highlights = c.hi;+ if (o.look !== c.look) cap.look = c.look;+ if (Object.keys(cap).length) p.captions = cap;+ const mu = {}; const src0 = o.music.source; const src = c.music.source;+ if (src !== src0) mu.source = src;+ if (src !== 'none') for (const k of ['gainDb', 'duck', 'fadeOut', 'start']) if (c.music[k] !== o.music[k] || mu.source) mu[k] = c.music[k];+ if (Object.keys(mu).length) p.music = mu;+ if (c.voice.gainDb !== o.voice.gainDb) p.voice = { gainDb: c.voice.gainDb };+ if (c.sfx.on !== o.sfx.on) p.sfx = { on: c.sfx.on };+ // zoom: n = số thứ tự trong bản gốc; zoom mới không có n+ const zr = o.zooms.filter((z) => !c.zooms.some((x) => x.n === z.n)).map((z) => z.n);+ const zs = []; const za = [];+ for (const z of c.zooms) {+ if (z.n == null) { za.push({ at: r2(z.at), dur: r2(z.dur), scale: r2(z.scale), kind: z.kind }); continue; }+ const oz = o.zooms.find((x) => x.n === z.n); if (!oz) continue;+ const s = { n: z.n };+ if (!eqT(oz.at, z.at)) s.at = r2(z.at);+ if (!eqT(oz.dur, z.dur)) s.dur = r2(z.dur);+ if (!eqT(oz.scale, z.scale)) s.scale = r2(z.scale);+ if (oz.kind !== z.kind) s.kind = z.kind;+ if (Object.keys(s).length > 1) zs.push(s);+ }+ if (zr.length || zs.length || za.length) p.zooms = { ...(zr.length ? { remove: zr } : {}), ...(zs.length ? { set: zs } : {}), ...(za.length ? { add: za } : {}) };+ const gr = o.gfx.filter((g) => !c.gfx.some((x) => x.id === g.id)).map((g) => g.id);+ const gs = [];+ for (const g of c.gfx) {+ const og = o.gfx.find((x) => x.id === g.id); if (!og) continue;+ const s = { id: g.id };+ if (!eqT(og.at, g.at)) s.start = r2(g.at);+ if (!eqT(og.until, g.until)) s.end = r2(g.until);+ const dd = dataDiff(og.data, g.data); if (dd) s.data = dd;+ if (Object.keys(s).length > 1) gs.push(s);+ }+ if (gr.length || gs.length) p.graphics = { ...(gr.length ? { remove: gr } : {}), ...(gs.length ? { set: gs } : {}) };+ return p;+ }+ /** Lỗi chặn xuất bản (dòng rỗng/ngắn/đè). Map uid → lý do. */+ lineErrors() {+ const bad = new Map(); const L = this.doc?.lines || []; const dur = this.view?.duration || 0;+ L.forEach((l, k) => {+ if (!(l.end - l.start >= 0.1)) bad.set(l.u, 'short');+ else if (l.start >= dur) bad.set(l.u, 'after');+ else if (k && l.start < L[k - 1].end - 1e-6) bad.set(l.u, 'overlap');+ else if (!plain(l.text).trim()) bad.set(l.u, 'empty');+ });+ return bad;+ }+}++function dataDiff(a = {}, b = {}) {+ const out = {};+ for (const k of Object.keys(b)) {+ if (Array.isArray(b[k])) {+ const rows = [];+ b[k].forEach((row, i) => { const r = { k: i }; for (const f of Object.keys(row)) if (a[k]?.[i]?.[f] !== row[f]) r[f] = row[f]; if (Object.keys(r).length > 1) rows.push(r); });+ if (rows.length) out[k] = rows;+ } else if (a[k] !== b[k]) out[k] = b[k];+ }+ return Object.keys(out).length ? out : null;+}diff --git a/server/public/studio/studio.css b/server/public/studio/studio.cssnew file mode 100644index 0000000..f938975--- /dev/null+++ b/server/public/studio/studio.css@@ -0,0 +1,323 @@+/* Studio — trình edit toàn màn hình (mẫu _final/18-ui-edit-mau/1-studio.png). Token chung ở style.css + create.css. */+body.studio-on { overflow: hidden; }+body.studio-on > :not(.studio):not(script):not(dialog) { display: none !important; }+.studio { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; --tl-h: 290px; }+.studio[hidden] { display: none; }+.studio button { font: inherit; color: inherit; }+.studio .ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }+.studio .ic .fill { fill: currentColor; stroke: none; }+.studio :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }+.ib { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; border: 0; background: none; color: var(--ink-2); cursor: pointer; transition: background .12s, color .12s; }+.ib:hover:not(:disabled) { background: var(--panel-2); color: var(--ink); }+.ib:disabled { opacity: .35; cursor: default; }+.ib.mini { width: 30px; height: 30px; border-radius: 7px; background: var(--panel-3); }+.ib.mini .ic { width: 15px; height: 15px; }+.ib.mini.danger:hover:not(:disabled) { color: #FF8B8B; }++/* ---- thanh trên ---- */+.st-top { height: 56px; flex: none; display: flex; align-items: center; gap: 14px; padding: 0 16px 0 12px; border-bottom: 1px solid var(--line); background: var(--bg-2); }+.st-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; max-width: 300px; }+.st-title b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.st-title span { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.st-vers { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-left: 10px; overflow-x: auto; max-width: 340px; scrollbar-width: none; }+.st-vers[hidden] { display: none; }+.st-vers button { min-width: 34px; height: 28px; padding: 0 11px; border-radius: 7px; border: 0; background: none; font-size: 12.5px; font-weight: 600; color: var(--ink-3); cursor: pointer; white-space: nowrap; }+.st-vers button:hover { color: var(--ink); }+.st-vers button.on { background: var(--panel-3); color: var(--ink); }+.st-mid { margin: 0 auto; display: flex; gap: 4px; }+.st-top .btn { min-height: 38px; }+.st-top .btn[hidden] { display: none; }+.st-revb .num { font-variant-numeric: tabular-nums; }+.st-revb[aria-pressed="true"] { background: rgba(242,201,76,.24); }+.st-dl.pri { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -6px rgba(255,107,44,.55); }+.st-pub { min-width: 0; }+.st-prog { height: 2px; flex: none; background: transparent; position: relative; margin-top: -2px; z-index: 3; }+.st-prog[hidden] { display: block; visibility: hidden; }+.st-prog i { position: absolute; inset: 0; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); transition: transform .5s ease-out; box-shadow: 0 0 10px rgba(255,107,44,.7); }++/* ---- giữa: cột icon · player · bảng ---- */+.st-main { flex: 1; min-height: 0; display: flex; }+.st-rail { width: 76px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding-top: 12px; gap: 4px; background: var(--bg-2); }+.st-rail button { width: 60px; height: 62px; border-radius: 12px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; font-size: 11.5px; font-weight: 500; color: var(--ink-3); position: relative; cursor: pointer; transition: background .12s, color .12s; }+.st-rail button .ic { width: 22px; height: 22px; }+.st-rail button:hover { color: var(--ink); background: var(--panel); }+.st-rail button.on { background: var(--accent-soft); color: var(--accent); }+.st-rail .l { line-height: 1.1; text-align: center; }+.st-rail .sep { width: 32px; height: 1px; background: var(--line); margin: 6px 0; }+.st-rail .dot { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; border-radius: 9px; background: var(--warn); color: #1b1503; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }+.st-rail .dot[hidden] { display: none; }++.st-stage { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 12px; background: radial-gradient(ellipse at 50% 40%, #1a1815 0%, var(--bg) 70%); }+.st-vid { position: relative; height: min(100%, calc(100% - 54px)); aspect-ratio: 9 / 16; max-width: 100%; border-radius: 14px; overflow: hidden; background: #000; box-shadow: 0 30px 60px -20px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.06); cursor: pointer; flex: 1 1 auto; min-height: 0; }+.st-zw { position: absolute; inset: 0; transform-origin: 50% 40%; will-change: transform; }+.st-zw video { width: 100%; height: 100%; object-fit: cover; display: block; }+.st-cap, .st-gfx { position: absolute; inset: 0; pointer-events: none; }+.st-capt { position: absolute; left: calc(120 / 1080 * 100%); right: calc(120 / 1080 * 100%); transform: translateY(-50%); text-align: center; line-height: 1.12; paint-order: stroke fill; overflow-wrap: anywhere; }+.st-capt[hidden] { display: none; }+.st-capt.boxed { left: 0; right: 0; text-align: left; padding: .2em .5em; }+.st-capt .tag { display: inline-block; padding: 0 .35em; margin-right: .4em; color: #fff; font-size: .62em; vertical-align: middle; }+.st-capsel { position: absolute; left: 0; top: 0; border: 1.5px solid var(--accent); border-radius: 6px; pointer-events: none; }+.st-capsel::before, .st-capsel::after { content: ""; position: absolute; width: 8px; height: 8px; background: #fff; border: 1.5px solid var(--accent); border-radius: 2px; top: -5px; left: -5px; }+.st-capsel::after { left: auto; right: -5px; top: auto; bottom: -5px; }+.st-capsel[hidden] { display: none; }+.st-vbadge { position: absolute; top: 10px; left: 10px; padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.7); font-size: 11.5px; font-weight: 600; color: var(--ink-2); }+.st-vbadge[hidden] { display: none; }+/* thẻ đồ hoạ xem trước (gần đúng thẻ HyperFrames) */+.st-gcard { position: absolute; left: 0; top: 0; border-radius: .7em; padding: .7em .9em; background: rgba(22,24,32,.86); color: #fff; box-shadow: 0 .4em 1.2em rgba(0,0,0,.4); font-family: 'Be Vietnam Pro', sans-serif; line-height: 1.25; }+.st-gcard .h { font-weight: 700; margin-bottom: .45em; }+.st-gcard .h .u, .st-gcard .kick { color: var(--violet); font-weight: 600; }+.st-gcard .row { display: flex; justify-content: space-between; gap: .6em; padding: .3em 0 .3em .5em; border-left: 2px solid rgba(255,255,255,.25); margin-top: .25em; font-size: .9em; }+.st-gcard .row b { font-variant-numeric: tabular-nums; }+.st-gcard .big { font: 800 2.2em/1.05 'Barlow Condensed', sans-serif; text-transform: uppercase; color: var(--accent); }+.st-gcard .lbl { font-size: .85em; color: rgba(255,255,255,.7); }+.st-ctrl { display: flex; align-items: center; gap: 16px; color: var(--ink-2); flex: none; }+.st-time { font-size: 13px; color: var(--ink-2); min-width: 122px; text-align: right; }+.st-time b { color: var(--ink); font-weight: 600; }+.st-play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); display: grid; place-items: center; cursor: pointer; transition: transform .1s; }+.st-play:active { transform: scale(.94); }+.st-play .ic { width: 18px; height: 18px; }+.st-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: var(--panel-2); color: var(--ink-2); border: 0; white-space: nowrap; }+.st-pill.warn { color: var(--warn); background: var(--warn-soft); }+button.st-pill { cursor: pointer; min-height: 30px; }+button.st-pill:hover { color: var(--ink); }+.st-outsw[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }+.st-outsw[hidden] { display: none; }++/* ---- bảng thuộc tính ---- */+.st-insp { width: 364px; flex: none; border-left: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; }+.st-grab { display: none; }+.st-ih { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; padding: 16px 18px 12px; margin: 0; flex: none; }+.st-ih > .btn { margin-left: auto; }+.st-ib { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 16px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; }+.st-ib > .st-seg { position: sticky; top: 0; z-index: 2; box-shadow: 0 -10px 0 var(--bg-2), 0 8px 10px -4px var(--bg-2); }+.st-seg { display: flex; margin: 0 8px; background: var(--panel); border-radius: 10px; padding: 3px; gap: 2px; flex: none; }+.st-seg button { flex: 1; min-height: 30px; border-radius: 7px; border: 0; background: none; font-size: 13px; font-weight: 500; color: var(--ink-3); cursor: pointer; }+.st-seg button.on { background: var(--panel-3); color: var(--ink); }+.st-seg.sm { margin: 0; }+.st-lines { list-style: none; margin: 0; padding: 2px 0 0; display: flex; flex-direction: column; gap: 2px; position: relative; }+.st-ln .row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 36px; padding: 0 10px; border-radius: 9px; border: 0; background: none; color: var(--ink-2); text-align: left; cursor: pointer; }+.st-ln .row:hover { background: var(--panel); }+.st-ln.now .row { color: var(--ink); background: rgba(255,255,255,.035); }+.st-ln .tm { font-size: 11.5px; color: var(--ink-4); width: 44px; flex: none; }+.st-ln .tx { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.st-ln em { font-style: normal; color: var(--accent); }+.st-ln .flag { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }+.st-ln.bad .row { box-shadow: inset 2px 0 0 var(--bad); }+.st-ln.sel { background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-2); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; margin: 2px 0; }+.st-ledit { width: 100%; min-height: 40px; background: var(--bg); border: 1px solid var(--accent); border-radius: 8px; padding: 0 12px; font-size: 15px; font-weight: 500; color: var(--ink); outline: none; }+.st-ledit:focus { box-shadow: 0 0 0 3px rgba(255,107,44,.18); }+.st-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }+.st-row .arrow { color: var(--ink-4); }+.st-acts { margin-left: auto; display: flex; gap: 6px; }+.st-tbox { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 4px 0 9px; border-radius: 7px; background: var(--bg); border: 1px solid var(--line-2); color: var(--ink-2); }+.st-tbox .ic { width: 13px; height: 13px; }+.st-tbox input { width: 58px; border: 0; background: none; font-size: 12px; color: var(--ink-2); outline: none; -moz-appearance: textfield; }+.st-tbox input::-webkit-inner-spin-button { opacity: .4; }+.st-ainote { margin: 0; font-size: 12px; color: var(--warn); display: flex; gap: 6px; align-items: center; }+.st-ainote .ic { width: 14px; height: 14px; }+.st-err { margin: 0; font-size: 12px; color: var(--bad); }+.st-note { margin: 0 8px; font-size: 12.5px; color: var(--ink-3); background: var(--panel); border-radius: 8px; padding: 8px 10px; }+.st-note.warn { color: var(--warn); background: var(--warn-soft); }+.st-note:empty { display: none; }+.st-hint { margin: 0 8px; font-size: 12.5px; color: var(--ink-3); }+.st-empty { color: var(--ink-3); text-align: center; padding: 24px 8px; margin: 0; }+.st-lines .none, .st-blist .none { color: var(--ink-3); padding: 12px 10px; font-size: 13px; }+/* kiểu chữ */+.st-looks { padding: 4px 8px; display: flex; flex-direction: column; gap: 12px; }+.st-lookgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }+.st-look { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 6px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; text-align: center; }+.st-look:hover:not(:disabled) { border-color: var(--ink-4); }+.st-look.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,107,44,.25); }+.st-look .smp { height: 46px; display: grid; place-items: center; border-radius: 7px; background: #0b0b0a; font-size: 24px; color: #fff; grid-auto-flow: column; justify-content: center; gap: 1px; }+.st-look .nm { font-size: 11.5px; color: var(--ink-2); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }+.st-switch { display: flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; flex-wrap: wrap; font-size: 13.5px; color: var(--ink-2); }+.st-switch input { width: 34px; height: 20px; appearance: none; -webkit-appearance: none; border-radius: 20px; background: var(--panel-3); position: relative; cursor: pointer; flex: none; transition: background .15s; }+.st-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink-2); transition: transform .15s; }+.st-switch input:checked { background: var(--accent); }+.st-switch input:checked::after { transform: translateX(14px); background: #fff; }+.st-switch input:disabled { opacity: .4; }+.st-switch small { flex-basis: 100%; color: var(--ink-4); font-size: 12px; margin-top: -6px; padding-left: 44px; }+.st-switch.sm { min-height: 30px; }+/* ô chung */+.st-field { display: flex; flex-direction: column; gap: 6px; padding: 0 8px; font-size: 12.5px; color: var(--ink-3); }+.st-field > span, .st-field > label { font-weight: 600; }+.st-field input[type=text], .st-field input[type=number], .st-sel, .st-ai textarea { width: 100%; min-height: 36px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; font-size: 14px; color: var(--ink); }+.st-field input:focus, .st-sel:focus, .st-ai textarea:focus { border-color: var(--accent); outline: none; }+.st-slide { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; }+.st-slide label { grid-column: 1 / -1; }+.st-slide input { accent-color: var(--accent); width: 100%; height: 24px; }+.st-slide output { font-size: 12.5px; color: var(--ink); min-width: 56px; text-align: right; }+.st-ib > .st-row, .st-ib > .st-switch { padding: 0 8px; }+.st-ib hr { border: 0; border-top: 1px solid var(--line); margin: 4px 8px; width: auto; }+.st-card { margin: 0 8px; padding: 12px 4px; border-radius: 12px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-2); display: flex; flex-direction: column; gap: 12px; }+.st-card > .st-row, .st-card > .st-seg, .st-card > .btn, .st-card > .st-hint { margin: 0 8px; }+.st-card > .btn { align-self: flex-start; }+.st-gtype { font-size: 14px; }+.st-grow { margin: 0 8px; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 0 10px; display: flex; flex-direction: column; gap: 8px; }+.st-grow legend { font-size: 11.5px; color: var(--ink-4); padding: 0 6px; margin-left: 6px; }+.st-blist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }+.st-blist button { width: 100%; display: flex; gap: 12px; align-items: center; min-height: 36px; padding: 0 10px; border-radius: 9px; border: 0; background: none; color: var(--ink-2); text-align: left; cursor: pointer; }+.st-blist button:hover { background: var(--panel); }+.st-blist button.on { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }+.st-blist .tm { font-size: 11.5px; color: var(--ink-4); width: 44px; flex: none; }+.st-blist .lb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+/* xem lại */+.st-review { display: flex; flex-direction: column; gap: 12px; }+.st-rcard { margin: 0 8px; padding: 12px; border-radius: 12px; background: var(--panel-2); box-shadow: inset 0 0 0 1px rgba(242,201,76,.35); display: flex; flex-direction: column; gap: 8px; }+.st-rtop { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-3); }+.st-rnav { margin-left: auto; display: flex; gap: 6px; }+.st-rwhat { margin: 0; font-size: 15px; }+.st-rwhat .k { font-size: 11.5px; color: var(--warn); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; }+.st-rwhat s { color: var(--ink-3); }+.st-rwhy { margin: 0; font-size: 12px; color: var(--ink-3); }+.st-rdone { margin: 0; font-size: 12px; color: var(--ok); }+.st-racts { display: flex; gap: 6px; flex-wrap: wrap; }+.st-racts .btn { flex: 1; min-height: 34px; font-size: 13px; padding: 0 10px; }+.st-rlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }+.st-ritem { width: 100%; display: flex; gap: 10px; align-items: center; min-height: 34px; padding: 0 10px; border-radius: 9px; border: 0; background: none; color: var(--ink-2); text-align: left; cursor: pointer; font-size: 13px; }+.st-ritem:hover { background: var(--panel); }+.st-ritem.on { background: var(--panel-2); color: var(--ink); }+.st-ritem.done { color: var(--ink-4); }+.st-ritem .tm { font-size: 11.5px; color: var(--ink-4); width: 44px; flex: none; }+.st-ritem .rx { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.st-ritem s { color: var(--ink-4); }+.st-ritem .ic { color: var(--ok); width: 15px; height: 15px; }+/* AI */+.st-ai { margin: 0 8px; display: flex; flex-direction: column; gap: 10px; }+.st-ai textarea { padding: 10px; min-height: 84px; resize: vertical; font-size: 14px; line-height: 1.45; }+.st-chips { display: flex; flex-wrap: wrap; gap: 6px; }+.st-chips .chip { min-height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--panel); font-size: 12.5px; color: var(--ink-2); }+.st-chips .chip:hover { color: var(--ink); }+.st-ai .btn { align-self: flex-start; }+.st-h4 { margin: 8px 8px 0; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }+.st-hist { margin: 0 8px; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink-2); }+.st-hist li { padding: 8px 10px; background: var(--panel); border-radius: 8px; overflow-wrap: anywhere; }+.st-hist small { display: block; color: var(--ink-4); margin-top: 3px; }+.st-insp.ro .st-ln .row { cursor: pointer; }++/* ---- timeline ---- */+.st-tl { height: var(--tl-h); flex: none; border-top: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; }+.tl-bar { height: 42px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 14px; border-bottom: 1px solid var(--line); }+.tl-bar .ib.mini { background: transparent; }+.tl-bar .ib.mini:hover:not(:disabled) { background: var(--panel-2); }+.tl-bar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }+.tl-hint { font-size: 12px; color: var(--ink-4); margin-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.tl-zoomer { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--ink-3); }+.tl-zoomer > .ic { width: 15px; height: 15px; }+.tl-zoomer input { width: 120px; accent-color: var(--ink-2); }+.tl-main { flex: 1; min-height: 0; display: flex; }+.tl-labs { width: 96px; flex: none; display: flex; flex-direction: column; }+.tl-labs .lab { display: flex; align-items: center; gap: 7px; padding-left: 16px; font-size: 12px; color: var(--ink-3); border: 0; background: none; text-align: left; cursor: pointer; transition: color .12s, opacity .12s; }+.tl-labs .lab .ic { width: 15px; height: 15px; }+.tl-labs .lab:hover { color: var(--ink); }+.tl-labs .lab.on { color: var(--accent); }+.tl-labs .lab.ruler { cursor: default; }+.tl-sc { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; position: relative; scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }+.tl-in { position: relative; height: 100%; min-width: 100%; }+/* chiều cao hàng: thước 26 · video 66 · phụ đề 34 · zoom 30 · đồ hoạ 32 · nhạc 50 */+.tl-labs .lab.ruler, .tl-ruler { height: 26px; flex: none; }+.tl-labs .lab[data-k="video"], .r-video { height: 66px; }+.tl-labs .lab[data-k="cap"], .r-cap { height: 34px; }+.tl-labs .lab[data-k="zoom"], .r-zoom { height: 30px; }+.tl-labs .lab[data-k="gfx"], .r-gfx { height: 32px; }+.tl-labs .lab[data-k="music"], .r-music { height: 50px; }+.tl-ruler { position: relative; cursor: pointer; }+.tl-ruler i { position: absolute; left: 0; bottom: 0; width: 1px; height: 5px; background: var(--line-2); }+.tl-ruler i.mj { height: 9px; background: var(--ink-4); }+.tl-ruler span { position: absolute; left: 0; top: 4px; font-size: 10.5px; color: var(--ink-4); pointer-events: none; }+.tl-row { position: relative; transition: opacity .15s; }+.st-tl[data-focus] .tl-row:not(.r-video) { opacity: .55; }+.st-tl[data-focus="cap"] .r-cap, .st-tl[data-focus="zoom"] .r-zoom, .st-tl[data-focus="gfx"] .r-gfx, .st-tl[data-focus="music"] .r-music { opacity: 1; }+.st-tl[data-focus="cap"] .lab[data-k="cap"], .st-tl[data-focus="zoom"] .lab[data-k="zoom"], .st-tl[data-focus="gfx"] .lab[data-k="gfx"], .st-tl[data-focus="music"] .lab[data-k="music"] { color: var(--accent); }+.st-tl[data-focus="cap"] .r-cap, .st-tl[data-focus="zoom"] .r-zoom, .st-tl[data-focus="gfx"] .r-gfx, .st-tl[data-focus="music"] .r-music { background: linear-gradient(90deg, rgba(255,107,44,.05), rgba(255,107,44,.02)); }+.tl-cv { position: sticky; left: 0; display: block; pointer-events: none; margin-top: 4px; z-index: 2; }+.blk { position: absolute; left: 0; top: 4px; bottom: 4px; border-radius: 7px; overflow: hidden; display: flex; align-items: center; padding: 0 7px; font-size: 11px; font-weight: 500; white-space: nowrap; cursor: grab; will-change: transform; touch-action: none; }+.blk .t { overflow: hidden; text-overflow: ellipsis; min-width: 0; pointer-events: none; }+.blk::before, .blk::after { content: ""; position: absolute; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }+.blk::before { left: 0; } .blk::after { right: 0; }+.blk.on::before, .blk.on::after { background: rgba(255,255,255,.35); }+.blk.drag { cursor: grabbing; z-index: 3; box-shadow: 0 6px 16px rgba(0,0,0,.45); }+.blk.narrow { padding: 0 3px; }+.blk.narrow .t { text-overflow: clip; }+.blk.ro { cursor: pointer; }+.blk.ro::before, .blk.ro::after { cursor: pointer; }+.blk.cap { background: #3B2A1F; border: 1px solid #5a3a25; color: #F5C9A8; }+.blk.cap.w { background: #3a3218; border-color: #6b5a1c; color: var(--warn); }+.blk.cap.bad { border-color: var(--bad); }+.blk.cap.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }+.blk.zoom { top: 4px; bottom: 4px; background: var(--sky-soft); border: 1px solid rgba(108,196,240,.45); color: var(--sky); font-weight: 600; }+.blk.zoom.on { background: rgba(108,196,240,.32); border-color: var(--sky); color: #fff; }+.blk.gfx { background: var(--violet-soft); border: 1px solid rgba(167,139,250,.45); color: #C9B8FF; font-weight: 600; }+.blk.gfx.on { background: rgba(167,139,250,.34); border-color: var(--violet); color: #fff; }+.blk.mu { top: 4px; bottom: 4px; background: rgba(93,211,158,.08); border: 1px solid rgba(93,211,158,.35); cursor: pointer; align-items: flex-start; padding-top: 3px; z-index: 1; }+.blk.mu.on { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }+.blk.mu::before, .blk.mu::after { display: none; }+.blk[hidden] { display: none; }+.tl-mlab { font-size: 11px; font-weight: 600; color: var(--ok); text-shadow: 0 1px 2px rgba(0,0,0,.6); }+.r-music.empty::after { content: attr(data-empty); position: sticky; left: 14px; top: 0; display: inline-block; padding: 16px 0 0 14px; font-size: 12px; color: var(--ink-4); }+.tl-head { position: absolute; top: 6px; bottom: 6px; left: 0; width: 2px; background: var(--accent); z-index: 6; cursor: ew-resize; touch-action: none; }+.tl-head .knob { position: absolute; top: -4px; left: -6px; width: 14px; height: 14px; background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 55%, 50% 100%, 0 55%); }+.tl-head::after { content: ""; position: absolute; inset: 0 -6px; }+.tl-guide { position: absolute; top: 26px; bottom: 0; left: 0; width: 1px; background: #fff; opacity: .8; z-index: 5; pointer-events: none; }+.tl-guide[hidden] { display: none; }+.tl-tip { position: absolute; left: 0; top: 0; padding: 2px 6px; border-radius: 5px; background: #000; color: #fff; font: 600 11px/1.4 var(--mono); z-index: 7; pointer-events: none; white-space: nowrap; }+.tl-tip[hidden] { display: none; }+.tl-edit { position: absolute; left: 0; top: 0; height: 30px; z-index: 8; background: var(--bg); border: 1.5px solid var(--accent); border-radius: 7px; padding: 0 8px; font-size: 13px; color: var(--ink); outline: none; box-shadow: 0 8px 24px rgba(0,0,0,.5); }++/* ---- lớp chờ, thông báo ---- */+.st-wait { position: absolute; inset: 56px 0 0 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(14,13,11,.92); text-align: center; padding: 24px; }+.st-wait[hidden] { display: none; }+.st-wait p { margin: 0; font-size: 15px; color: var(--ink-2); max-width: 520px; }+.st-wbar { width: 280px; height: 3px; border-radius: 2px; background: var(--panel-3); overflow: hidden; }+.st-wbar[hidden] { display: none; }+.st-wbar i { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); transition: transform .5s; }+.st-toast { position: absolute; left: 50%; bottom: calc(var(--tl-h) + 16px); transform: translateX(-50%); z-index: 30; max-width: min(640px, calc(100% - 32px)); padding: 10px 16px; border-radius: 10px; background: #26241f; color: var(--ink); box-shadow: 0 12px 30px rgba(0,0,0,.5); font-size: 13.5px; border: 1px solid var(--line-2); }+.st-toast[hidden] { display: none; }+.st-toast.ok { border-color: rgba(93,211,158,.5); color: var(--ok); }+.st-toast.bad { border-color: rgba(255,100,100,.5); color: #FFB0B0; }+.st-scrim { display: none; }++@media (max-width: 1180px) { .st-insp { width: 320px; } .st-title { max-width: 200px; } .st-reset { display: none; } }++/* ---- điện thoại < 768: player trên, công cụ ngang, timeline cuộn ngang, bảng thành sheet dưới ---- */+@media (max-width: 767px) {+ .studio { --tl-h: 262px; }+ .st-top { height: 52px; gap: 6px; padding: 0 8px 0 4px; }+ .st-title { max-width: none; flex: 1; }+ .st-title span { display: none; }+ .st-vers { display: none; }+ .st-mid { margin: 0; }+ .st-mid .ib { width: 34px; }+ .st-revb > span:not(.num), .st-dl span, .st-pub span { display: none; }+ .st-top .btn { min-height: 36px; padding: 0 10px; }+ .st-main { flex-direction: column; }+ .st-rail { width: auto; height: 52px; flex-direction: row; justify-content: space-around; padding: 4px 6px; border-right: 0; border-top: 1px solid var(--line); order: 2; }+ .st-rail button { width: auto; flex: 1; height: 46px; gap: 2px; font-size: 10.5px; border-radius: 10px; }+ .st-rail .l { white-space: nowrap; }+ .st-rail button .ic { width: 18px; height: 18px; }+ .st-rail .sep { width: 1px; height: 24px; margin: 0 2px; }+ .st-rail .dot { top: 1px; right: calc(50% - 20px); }+ .st-stage { order: 1; flex: 1; min-height: 0; padding: 8px; gap: 8px; }+ .st-ctrl { gap: 10px; }+ .st-time { min-width: 0; font-size: 12px; }+ .st-ratio, .st-ctrl .mono.st-pill { display: none; }+ .st-insp { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 62vh; border-left: 0; border-top: 1px solid var(--line-2); border-radius: 16px 16px 0 0; z-index: 40; transform: translateY(105%); transition: transform .22s ease-out; box-shadow: 0 -16px 40px rgba(0,0,0,.5); padding-bottom: env(safe-area-inset-bottom); }+ .st-insp.open { transform: none; }+ .st-grab { display: block; width: 100%; height: 22px; border: 0; background: none; cursor: pointer; flex: none; position: relative; }+ .st-grab::after { content: ""; position: absolute; left: 50%; top: 9px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--ink-4); }+ .st-ih { padding-top: 4px; }+ .st-scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }+ .st-scrim.on { opacity: 1; pointer-events: auto; }+ .tl-bar { padding: 0 8px; gap: 2px; overflow-x: auto; }+ .tl-hint { display: none; }+ .tl-zoomer input { width: 70px; }+ .tl-labs { width: 40px; }+ .tl-labs .lab { padding-left: 12px; }+ .tl-labs .lab span { display: none; }+ .r-video, .tl-labs .lab[data-k="video"] { height: 50px; }+ .r-music, .tl-labs .lab[data-k="music"] { height: 40px; }+ .st-toast { bottom: calc(var(--tl-h) + 60px); }+}+@media (prefers-reduced-motion: reduce) {+ .st-prog i, .st-wbar i, .st-insp, .tl-row, .st-rail button { transition: none; }+}diff --git a/server/public/studio/studio.js b/server/public/studio/studio.jsnew file mode 100644index 0000000..21fb494--- /dev/null+++ b/server/public/studio/studio.js@@ -0,0 +1,535 @@+// Studio: mở 1 bản edit toàn màn hình (#/edit/<id> hoặc #/edit/<id>/r<n>) — trình edit kiểu CapCut.+// Thanh trên (← tên · cách dựng · thời lượng, r0…rN, Undo/Redo, Cần xem lại, Xuất bản mới, Tải MP4) · cột icon trái ·+// player giữa (xem trước tức thì, không render) · bảng thuộc tính phải · timeline đáy.+// API: GET /api/edits/:id, GET /api/edits/:id/manual[?rev=], POST …/manual (bản vá), POST …/revise, POST …/music,+// GET …/strip, GET …/wave (edit/http.mjs).+import { $, el, tx, icon, iconBtn, fmtT, fmtDur, plain, clamp, r2, t, I, getJSON, postJSON, safeUrl, ID_RE, store as ls, narrow, tokens, untokens } from './util.js';+import { Store } from './store.js';+import { Player } from './player.js';+import { Timeline } from './timeline.js';+import { Inspector } from './inspector.js';++const RAIL = [['cap', 'cap', 'st.trCap'], ['music', 'music', 'st.trMusic'], ['zoom', 'zoom', 'st.trZoom'], ['gfx', 'gfx', 'st.trGfx'], null, ['ai', 'ai', 'st.railAi']];+const busyOf = (v) => !!v && ['queued', 'running'].includes(v.status);++class Studio {+ constructor() {+ this.store = new Store();+ this.id = null; this.rev = null; this.job = null; this.sel = null; this.mode = 'cap'; this.edl = null;+ this.review = this.makeReview();+ this.build();+ this.store.on((what) => this.onStore(what));+ window.addEventListener('hashchange', () => this.route());+ window.addEventListener('lumreels:lang', () => { if (this.id) this.repaintAll(); });+ document.addEventListener('keydown', (e) => this.onKey(e), true);+ this.route();+ }++ // ---- khung ----+ build() {+ const R = el('div', 'studio', null, { id: 'studio', hidden: true, role: 'application', 'aria-roledescription': 'video editor' });+ // thanh trên+ const top = el('header', 'st-top');+ this.bBack = iconBtn('back', 'st.back', 'st-back');+ this.bBack.addEventListener('click', () => this.leave());+ const ttl = el('div', 'st-title');+ this.tName = el('b'); this.tSub = el('span');+ ttl.append(this.tName, this.tSub);+ this.vers = el('div', 'st-vers', null, { role: 'radiogroup' });+ this.vers.setAttribute('aria-label', t('st.versions')); this.vers.dataset.i18nAria = 'st.versions';+ const mid = el('div', 'st-mid');+ this.bUndo = iconBtn('undo', 'st.undo'); this.bRedo = iconBtn('redo', 'st.redo');+ this.bUndo.addEventListener('click', () => this.store.doUndo());+ this.bRedo.addEventListener('click', () => this.store.doRedo());+ mid.append(this.bUndo, this.bRedo);+ this.bReview = el('button', 'btn warn st-revb', null, { type: 'button' });+ this.bReview.addEventListener('click', () => this.setMode(this.mode === 'review' ? 'cap' : 'review', true));+ this.bReset = tx('button', 'btn ghost st-reset', 'man.reset', { type: 'button' });+ this.bReset.addEventListener('click', () => { if (confirm(t('st.resetAsk'))) this.store.reset(); });+ this.bPub = el('button', 'btn pri st-pub', null, { type: 'button' });+ this.bPub.addEventListener('click', () => this.publish());+ this.aDl = el('a', 'btn st-dl', null, { download: '' });+ this.aDl.append(icon('dl'), tx('span', null, 'ed.mp4'));+ top.append(this.bBack, ttl, this.vers, mid, this.bReview, this.bReset, this.bPub, this.aDl);+ this.prog = el('div', 'st-prog', null, { role: 'progressbar', 'aria-valuemin': '0', 'aria-valuemax': '100' }); this.prog.append(el('i')); this.prog.hidden = true;+ // giữa+ const main = el('div', 'st-main');+ this.rail = el('nav', 'st-rail');+ this.rail.setAttribute('aria-label', t('st.tools')); this.rail.dataset.i18nAria = 'st.tools';+ this.railBtns = {};+ for (const r of RAIL) {+ if (!r) { this.rail.append(el('span', 'sep')); continue; }+ const [k, ic, key] = r;+ const b = el('button', null, null, { type: 'button', 'data-k': k, 'aria-pressed': 'false' });+ b.append(icon(ic), tx('span', 'l', key));+ if (k === 'cap') { this.capDot = el('span', 'dot'); b.append(this.capDot); }+ b.addEventListener('click', () => this.setMode(k, true));+ this.railBtns[k] = b; this.rail.append(b);+ }+ this.player = new Player({ store: this.store, onTime: (tt) => this.onTime(tt), onPlay: (p) => { this.timeline.follow = p; }, getSel: () => this.sel });+ this.insp = new Inspector(this.ctx());+ main.append(this.rail, this.player.root, this.insp.root);+ this.timeline = new Timeline(this.ctx());+ // lớp chờ (đang dựng / đang xuất) + thông báo+ this.wait = el('div', 'st-wait', null, { role: 'status', 'aria-live': 'polite' }); this.wait.hidden = true;+ this.waitT = el('p'); this.waitBar = el('div', 'st-wbar'); this.waitBar.append(el('i'));+ this.wait.append(this.waitT, this.waitBar);+ this.toastEl = el('div', 'st-toast', null, { role: 'status', 'aria-live': 'polite' }); this.toastEl.hidden = true;+ this.scrim = el('div', 'st-scrim'); this.scrim.addEventListener('click', () => this.closeSheet());+ R.append(top, this.prog, main, this.timeline.root, this.wait, this.toastEl, this.scrim);+ document.body.append(R);+ this.R = R;+ }+ ctx() {+ const self = this;+ return {+ store: this.store,+ get player() { return self.player; },+ seek: (tt) => this.seek(tt),+ select: (s, o) => this.select(s, o),+ getSel: () => this.sel,+ mode: () => this.mode,+ focusKind: (k, quiet) => { if (k !== 'video') this.setMode(k, !quiet); },+ flagged: (u) => this.review.flagged(u),+ review: this.review,+ musicLabel: () => this.musicName(this.store.doc?.music.source),+ musicName: (s) => this.musicName(s),+ splitAtHead: (u) => this.splitAtHead(u),+ mergeSel: () => this.mergeSel(),+ deleteSel: () => this.deleteSel(),+ onZoomAdd: () => this.addZoom(),+ addZoom: () => this.addZoom(),+ setGfxTime: (u, f, x) => this.setGfxTime(u, f, x),+ uploadMusic: (f) => this.uploadMusic(f),+ revise: (s) => this.revise(s),+ job: () => this.job,+ busy: () => busyOf(this.job) || !!this.publishing,+ closeSheet: () => this.closeSheet(),+ afterInline: () => this.insp.render(),+ onDrag: () => {},+ };+ }++ // ---- định tuyến ----+ route() {+ const m = /^#\/edit\/([\w-]{1,80})(?:\/r(\d{1,4}))?$/.exec(location.hash);+ if (!m) { if (this.id) this.close(); return; }+ const id = m[1]; const rev = m[2] != null ? Number(m[2]) : null;+ if (!ID_RE.test(id)) return;+ if (id === this.id && rev === this.rev && this.store.view) return;+ this.open(id, rev);+ }+ leave() { location.hash = '#edit'; }+ close() {+ this.player.release(); clearTimeout(this.pollT);+ this.id = null; this.rev = null; this.job = null; this.store.view = null; this.sel = null;+ this.R.hidden = true; document.body.classList.remove('studio-on');+ document.title = t('meta.title');+ window.dispatchEvent(new CustomEvent('lumreels:studio', { detail: { open: false } }));+ }+ async open(id, rev) {+ const same = id === this.id;+ this.id = id; this.rev = rev;+ this.R.hidden = false; document.body.classList.add('studio-on');+ if (!same) { this.sel = null; this.edl = null; this.player.release(); this.timeline.setStrip(null); this.timeline.setWave(null); this.review.reset(id); }+ try {+ this.job = await getJSON(`/api/edits/${encodeURIComponent(id)}`);+ } catch (e) { this.showWait(t('st.notFound', { e: I.srv(e.message) }), null); return; }+ if (this.id !== id) return;+ this.paintTop();+ if (busyOf(this.job)) { this.watchJob(); return; }+ if (!this.job.links?.out) { this.showWait(this.job.status === 'error' ? t('st.buildErr', { e: I.srv(this.job.error || '') }) : t('ed.mediaEmpty'), null); return; }+ await this.loadView();+ }+ async loadView() {+ const id = this.id; const rev = this.rev;+ let v;+ try { v = await getJSON(`/api/edits/${encodeURIComponent(id)}/manual${rev != null ? `?rev=${rev}` : ''}`); } catch (e) { this.showWait(t('man.loadErr', { e: I.srv(e.message) }), null); return; }+ if (this.id !== id || this.rev !== rev) return;+ this.hideWait();+ this.store.load(id, v);+ if (this.sel && !this.findSel(this.sel)) this.sel = null;+ this.player.setSources({ base: safeUrl(v.media.base), out: safeUrl(v.media.out), music: null });+ this.timeline.fitAll();+ this.loadMedia(v);+ if (!v.readOnly) this.loadEdl();+ this.repaintAll();+ document.title = `${this.job.sourceName || id} · Studio`;+ window.dispatchEvent(new CustomEvent('lumreels:studio', { detail: { open: true, id } }));+ }+ async loadMedia(v) {+ const id = this.id;+ if (v.media.outName) getJSON(`/api/edits/${encodeURIComponent(id)}/strip?out=${encodeURIComponent(v.media.outName)}`).then((s) => { if (this.id === id) this.timeline.setStrip({ ...s, url: safeUrl(s.url) }); }).catch(() => {});+ this.loadWave(true);+ }+ /** Sóng + file nhạc cho nguồn đang chọn (đổi bài → tải sóng mới). */+ async loadWave(force) {+ const v = this.store.view; const src = this.store.doc?.music.source; const id = this.id;+ if (!v || !src || src === 'none') { this.timeline.setWave(null); this.player.setMusic(null); this.waveSrc = src; return; }+ if (!force && src === this.waveSrc) return;+ this.waveSrc = src;+ const q = v.readOnly && v.media.musicFile ? `file=${encodeURIComponent(v.media.musicFile)}` : `src=${encodeURIComponent(src)}`;+ try {+ const w = await getJSON(`/api/edits/${encodeURIComponent(id)}/wave?${q}`);+ if (this.id !== id || this.waveSrc !== src) return;+ this.timeline.setWave(w); this.player.setMusic(safeUrl(w.url));+ } catch { this.timeline.setWave(null); }+ }+ async loadEdl() {+ const url = safeUrl(this.job?.links?.edl); const id = this.id; if (!url) return;+ try { const e = await getJSON(url); if (this.id === id) { this.edl = e; this.review.build(); this.repaintAll(); } } catch { /* không có EDL: không có mục xem lại */ }+ }++ // ---- vẽ ----+ repaintAll() {+ if (!this.store.view) return;+ this.paintTop(); this.paintRail();+ this.timeline.setFocus(['cap', 'zoom', 'gfx', 'music'].includes(this.mode) ? this.mode : 'cap');+ this.timeline.layout();+ this.insp.render();+ this.player.tick();+ }+ paintTop() {+ const j = this.job; const v = this.store.view;+ const name = j?.sourceName || this.id || '';+ this.tName.textContent = name; this.tName.title = name;+ const style = j?.styleName || j?.style || '';+ this.tSub.textContent = [style, v ? fmtDur(v.duration) : ''].filter(Boolean).join(' · ');+ // phiên bản+ const vs = v?.versions || [];+ this.vers.replaceChildren(...vs.filter((x) => x.out).map((x) => {+ const on = x.n === v.rev;+ const b = el('button', on ? 'on' : '', x.n === 0 ? t('st.r0') : `r${x.n}`, { type: 'button', role: 'radio', 'aria-checked': String(on) });+ b.title = x.n === 0 ? t('st.r0Tip') : (x.manual ? t('man.tag') + ': ' : '') + (x.instruction || '');+ b.addEventListener('click', () => { if (!on) location.hash = x.n === v.latest ? `#/edit/${this.id}` : `#/edit/${this.id}/r${x.n}`; });+ return b;+ }));+ this.vers.hidden = vs.length < 2;+ const n = this.store.view ? this.store.changes : 0;+ const busy = busyOf(j) || !!this.publishing;+ this.bUndo.disabled = !this.store.undo.length || busy; this.bRedo.disabled = !this.store.redo.length || busy;+ const pend = this.review.pending();+ this.bReview.hidden = !v || v.readOnly || !this.review.items().length;+ this.bReview.replaceChildren(icon('warn'), el('span', null, t('st.needReview')), el('span', 'num', String(pend)));+ this.bReview.setAttribute('aria-pressed', String(this.mode === 'review'));+ this.bReset.hidden = !n || busy;+ this.bPub.hidden = !n && !this.publishing;+ this.bPub.disabled = busy || !n;+ this.bPub.replaceChildren(icon('upload'), el('span', null, this.publishing ? t('st.publishing') : t('st.publish', { n })));+ const out = safeUrl(v?.media?.out || j?.links?.out);+ this.aDl.hidden = !out;+ if (out) { this.aDl.href = out; this.aDl.setAttribute('download', `${(name || 'video').replace(/\.[^.]+$/, '')}${v?.rev ? '-r' + v.rev : ''}.mp4`); }+ this.aDl.classList.toggle('pri', !n); this.aDl.classList.toggle('ghost', !!n);+ }+ paintRail() {+ for (const [k, b] of Object.entries(this.railBtns)) {+ const on = k === this.mode || (k === 'cap' && this.mode === 'review');+ b.classList.toggle('on', on); b.setAttribute('aria-pressed', String(on));+ }+ const n = this.review.pending();+ this.capDot.hidden = !n; this.capDot.textContent = String(n);+ }+ setMode(m, user) {+ this.mode = m;+ if (['cap', 'zoom', 'gfx', 'music'].includes(m)) this.timeline.setFocus(m);+ if (m === 'review') { this.timeline.setFocus('cap'); this.review.goto(this.review.index(), true); }+ this.paintRail(); this.paintTop(); this.insp.render();+ if (user && narrow()) this.openSheet();+ }+ openSheet() { this.insp.root.classList.add('open'); this.scrim.classList.add('on'); }+ closeSheet() { this.insp.root.classList.remove('open'); this.scrim.classList.remove('on'); }++ onStore(what) {+ if (what === 'load') return;+ if (this.sel && !this.findSel(this.sel)) this.sel = null;+ this.timeline.renderBlocks();+ this.insp.render();+ this.player.lastCap = null; this.player.lastGfx = ''; this.player.tick();+ this.paintTop(); this.paintRail();+ if (this.store.doc?.music.source !== this.waveSrc) this.loadWave();+ else this.player.syncAudio(false);+ }+ onTime(tt) { this.timeline.setTime(tt); this.insp.onTime(tt); }+ seek(tt) { this.player.seek(tt); }++ // ---- chọn khối ----+ findSel(s) {+ const d = this.store.doc; if (!d || !s) return null;+ if (s.kind === 'cap') return d.lines.find((x) => x.u === s.u);+ if (s.kind === 'zoom') return d.zooms.find((x) => x.u === s.u);+ if (s.kind === 'gfx') return d.gfx.find((x) => x.u === s.u);+ if (s.kind === 'music') return d.music.source !== 'none' ? d.music : null;+ return null;+ }+ select(s, { quiet } = {}) {+ this.sel = s && this.findSel(s) ? s : null;+ if (this.sel) {+ this.mode = this.sel.kind;+ if (this.sel.kind === 'cap') this.insp.capTab = 'lines';+ this.timeline.setFocus(this.sel.kind);+ }+ this.timeline.renderBlocks();+ this.paintRail();+ if (!quiet || this.sel) this.insp.render();+ this.player.tick();+ if (this.sel && narrow() && !quiet) this.openSheet();+ }++ // ---- thao tác ----+ splitAtHead(u) {+ const st = this.store; const tt = this.player.time;+ let k = u ? st.doc.lines.findIndex((l) => l.u === u) : st.lineAt(tt);+ if (k < 0 && this.sel?.kind === 'cap') k = st.doc.lines.findIndex((l) => l.u === this.sel.u);+ if (k < 0) { this.toast(t('st.noLineHere')); return; }+ const l = st.doc.lines[k];+ if (!st.splitLine(k, tt >= l.start && tt < l.end ? tt : null)) { this.toast(t('man.cantSplit')); return; }+ this.select({ kind: 'cap', u: st.doc.lines[k + 1].u }, { quiet: true });+ this.insp.render();+ }+ mergeSel() {+ const st = this.store;+ const k = this.sel?.kind === 'cap' ? st.doc.lines.findIndex((l) => l.u === this.sel.u) : st.lineAt(this.player.time);+ if (k < 0 || k + 1 >= st.doc.lines.length) { this.toast(t('st.noMerge')); return; }+ st.mergeLine(k);+ }+ deleteSel() {+ const s = this.sel; if (!s || this.store.view?.readOnly) { this.toast(t('st.selFirst')); return; }+ if (s.kind === 'cap') this.store.commit((d) => { d.lines = d.lines.filter((x) => x.u !== s.u); });+ else if (s.kind === 'zoom') this.store.commit((d) => { d.zooms = d.zooms.filter((x) => x.u !== s.u); });+ else if (s.kind === 'gfx') this.store.commit((d) => { d.gfx = d.gfx.filter((x) => x.u !== s.u); });+ else if (s.kind === 'music') this.store.commit((d) => { d.music.source = 'none'; });+ this.sel = null; this.repaintAll();+ }+ /** Zoom mới tại đầu phát: đẩy chậm 1,1× dài 1,5 s (ngắn lại nếu sát zoom sau / cuối video). */+ addZoom() {+ const st = this.store; if (st.view?.readOnly) return;+ const tt = r2(this.player.time); const dur = st.view.duration;+ const hit = st.doc.zooms.find((z) => tt >= z.at - 1e-3 && tt < z.at + z.dur);+ if (hit) { this.select({ kind: 'zoom', u: hit.u }); this.toast(t('st.zoomHere')); return; }+ const next = st.doc.zooms.filter((z) => z.at > tt).sort((a, b) => a.at - b.at)[0];+ const room = Math.min(next ? next.at - tt : Infinity, dur - tt - 0.25);+ if (room < 0.3) { this.toast(t('st.zoomNoRoom')); return; }+ const z = { u: `zn${Date.now().toString(36)}`, n: null, at: tt, dur: r2(Math.min(1.5, room)), scale: 1.1, kind: 'push' };+ st.commit((d) => { d.zooms.push(z); d.zooms.sort((a, b) => a.at - b.at); });+ this.select({ kind: 'zoom', u: z.u });+ }+ setGfxTime(u, f, x) {+ const st = this.store; const g = st.doc.gfx.find((y) => y.u === u); if (!g) return;+ let a = f === 'at' ? x : g.at; let b = f === 'until' ? x : g.until;+ const others = st.doc.gfx.filter((y) => y.u !== u);+ const prev = others.filter((y) => y.until <= g.at + 1e-3).reduce((m, y) => Math.max(m, y.until), 0);+ const next = others.filter((y) => y.at >= g.until - 1e-3).reduce((m, y) => Math.min(m, y.at), st.view.duration);+ a = clamp(r2(a), prev, next - 1.5); b = clamp(r2(b), a + 1.5, Math.min(next, a + 14));+ st.commit((d) => { const y = d.gfx.find((q) => q.u === u); if (y) { y.at = a; y.until = b; } });+ }+ async uploadMusic(f) {+ const id = this.id; const msg = this.insp.musicMsg;+ if (msg) msg.textContent = t('man.uploading', { name: f.name, size: (f.size / 1e6).toFixed(1) + ' MB' });+ const fd = new FormData(); fd.append('music', f, f.name);+ try {+ const r = await fetch(`/api/edits/${encodeURIComponent(id)}/music`, { method: 'POST', body: fd });+ const j = await r.json().catch(() => ({}));+ if (!r.ok) throw new Error(j.error || 'HTTP ' + r.status);+ if (this.id !== id) return;+ this.store.view.music.uploads.push({ file: j.file, name: j.name });+ this.store.commit((d) => { d.music.source = `upload:${j.file}`; });+ if (this.insp.musicMsg) this.insp.musicMsg.textContent = t('man.uploadOk', { name: j.name });+ } catch (e) { if (this.insp.musicMsg) this.insp.musicMsg.textContent = t('man.uploadErr', { e: I.srv(e.message) }); }+ }+ musicName(src) {+ const v = this.store.view; if (!src || src === 'none') return t('ed.noMusic');+ if (src === 'keep') src = v?.music.name || '';+ if (src.startsWith('synth:')) { const s = src.slice(6); return s.charAt(0).toUpperCase() + s.slice(1); }+ if (src.startsWith('upload:')) return v?.music.uploads.find((u) => u.file === src.slice(7))?.name || src.slice(7);+ return src;+ }++ // ---- Xuất bản mới: bản vá → server dựng lại phần cần thiết → r<n+1> ----+ async publish() {+ const st = this.store; const id = this.id;+ const p = st.patch(); if (!Object.keys(p).length || this.publishing) return;+ const bad = st.lineErrors();+ if (bad.size) {+ const u = [...bad.keys()][0];+ this.select({ kind: 'cap', u }); this.toast(t('st.fixFirst', { n: bad.size }), 'bad'); return;+ }+ this.publishing = true; this.paintTop();+ this.player.release(); // Windows: nhả base.mp4 trước khi server ghi lại+ this.setProg(2);+ try {+ this.job = await postJSON(`/api/edits/${encodeURIComponent(id)}/manual`, p);+ } catch (e) {+ this.publishing = false; this.setProg(null); this.paintTop();+ this.toast(I.srv(e.message), 'bad'); this.reloadSources();+ return;+ }+ this.watchJob(true);+ }+ reloadSources() { const v = this.store.view; if (!v) return; this.player.setSources({ base: safeUrl(v.media.base), out: safeUrl(v.media.out) }); this.loadWave(true); }+ async revise(text) {+ const id = this.id;+ this.player.release();+ try { this.job = await postJSON(`/api/edits/${encodeURIComponent(id)}/revise`, { instruction: text }); }+ catch (e) { this.toast(I.srv(e.message), 'bad'); this.reloadSources(); return; }+ this.publishing = 'revise'; this.paintTop(); this.watchJob(true);+ }+ /** Theo dõi job (dựng / xuất / sửa bằng lời): thanh mảnh dưới thanh trên; xong thì tự chuyển sang bản mới. */+ watchJob(mine) {+ clearTimeout(this.pollT);+ const id = this.id;+ const before = this.store.view?.latest;+ const tick = async () => {+ let v;+ try { v = await getJSON(`/api/edits/${encodeURIComponent(id)}`); } catch { this.pollT = setTimeout(tick, 2500); return; }+ if (this.id !== id) return;+ this.job = v;+ if (busyOf(v)) {+ const steps = v.steps || []; const from = Number.isInteger(v.stepFrom) ? v.stepFrom : 0;+ const i = Math.max(from, v.stepIndex ?? from);+ const pct = clamp(((i - from) + (v.pct || 0) / 100) / Math.max(1, steps.length - from), 0, 1) * 100;+ const line = v.status === 'queued' ? t('ed.waitTurn') : t('ed.stepOf', { i: i + 1, n: steps.length, step: I.srv(steps[i] || ''), p: v.pct || 0 });+ if (mine || this.store.view) { this.setProg(Math.max(3, pct)); this.prog.title = line; this.toast(`${t(this.publishing === 'revise' ? 'ed.revising' : 'st.publishing')} · ${line}`, null, true); }+ else this.showWait(`${t(v.action === 'edit' ? 'ed.st.running' : 'st.publishing')} · ${line}`, pct);+ this.paintTop();+ this.pollT = setTimeout(tick, 1200); return;+ }+ const was = this.publishing; this.publishing = false; this.setProg(null);+ if (v.status === 'error' && !v.links?.out) { this.showWait(t('st.buildErr', { e: I.srv(v.error || '') }), null); this.paintTop(); return; }+ const err = v.status === 'error' ? v.error : v.reviseError;+ if (err && (mine || was)) { this.toast(I.srv(err), 'bad'); this.paintTop(); this.reloadSources(); return; }+ if (mine || was) this.store.clearDraft();+ const latest = (v.revisions || []).length;+ if (location.hash !== `#/edit/${id}`) history.replaceState(null, '', `#/edit/${id}`);+ this.rev = null;+ await this.loadView();+ if ((mine || was) && latest !== before) this.toast(t('st.published', { n: latest }), 'ok');+ };+ tick();+ }+ setProg(p) {+ this.prog.hidden = p == null;+ if (p != null) { this.prog.firstChild.style.transform = `scaleX(${clamp(p, 0, 100) / 100})`; this.prog.setAttribute('aria-valuenow', String(Math.round(p))); }+ }+ showWait(text, pct) {+ this.wait.hidden = false; this.waitT.textContent = text;+ this.waitBar.hidden = pct == null;+ if (pct != null) this.waitBar.firstChild.style.transform = `scaleX(${clamp(pct, 0, 100) / 100})`;+ }+ hideWait() { this.wait.hidden = true; }+ toast(text, kind, sticky) {+ clearTimeout(this.toastT);+ this.toastEl.hidden = false; this.toastEl.textContent = text; this.toastEl.className = 'st-toast' + (kind ? ' ' + kind : '');+ if (!sticky) this.toastT = setTimeout(() => { this.toastEl.hidden = true; }, kind === 'bad' ? 7000 : 3200);+ }++ // ---- phím tắt ----+ onKey(e) {+ if (!this.id || this.R.hidden) return;+ const tg = e.target; const typing = tg.closest?.('input, textarea, select, [contenteditable="true"]');+ const mod = e.ctrlKey || e.metaKey;+ if (mod && (e.key === 'z' || e.key === 'Z' || e.key === 'y')) {+ if (typing) return; // ô nhập tự Undo chữ của nó+ e.preventDefault();+ if (e.key === 'y' || e.shiftKey) this.store.doRedo(); else this.store.doUndo();+ return;+ }+ if (typing || mod || e.altKey) { if (e.key === 'Escape' && typing) tg.blur(); return; }+ if (e.key === ' ' || e.code === 'Space') { e.preventDefault(); this.player.toggle(); return; }+ if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {+ if (tg.closest?.('[role=radiogroup], [role=tablist]')) return;+ e.preventDefault();+ const d = (e.key === 'ArrowLeft' ? -1 : 1) * (e.shiftKey ? 1 : 1 / 30);+ this.player.step(d); this.timeline.scrollToTime(this.player.time); return;+ }+ if (e.key === 's' || e.key === 'S') { e.preventDefault(); this.splitAtHead(); return; }+ if (e.key === 'Delete' || e.key === 'Backspace') { e.preventDefault(); this.deleteSel(); return; }+ if (e.key === 'Escape') { if (this.sel) { this.select(null); } else this.closeSheet(); }+ }++ // ---- "Cần xem lại": chữ AI sửa + số nghe không chắc; đi lần lượt, đầu phát nhảy tới đúng chỗ ----+ makeReview() {+ const S = this; let list = []; let idx = 0; let id = null; let res = {};+ const key = () => `lumreels.studio.review.${id}`;+ const toOut = (src) => {+ const e = S.edl; if (!e || !Number.isFinite(src)) return null;+ const h = e.hook; const hd = h ? h.end - h.start : 0;+ let acc = hd;+ for (const k of e.keep) { if (src < k.start - 1e-6) return r2(acc); if (src <= k.end + 1e-6) return r2(acc + src - k.start); acc += k.end - k.start; }+ if (h && src >= h.start && src <= h.end) return r2(src - h.start);+ return null;+ };+ const R = {+ reset(nid) { id = nid; list = []; idx = 0; res = ls.get(key(), {}) || {}; },+ build() {+ const j = S.job || {}; const e = S.edl; if (!e) { list = []; return; }+ const words = new Map((e.captions?.words || []).map((w) => [w.i, w]));+ const fx = [...(j.fixes || [])].sort((a, b) => a.word - b.word);+ const out = [];+ for (let i = 0; i < fx.length; i++) {+ const f = fx[i]; let heard = f.heard || '';+ // "vờ" + "ga" → "VGA": chữ sau bị gộp (text rỗng) nối vào chữ trước+ while (fx[i + 1] && fx[i + 1].word === fx[i].word + 1 && !fx[i + 1].text && f.text) { heard += ' ' + (fx[i + 1].heard || ''); i++; }+ const w = words.get(f.word);+ out.push({ key: `fix:${f.word}`, kind: 'fix', at: toOut(w ? w.start : null), heard: heard.trim(), text: f.text || '', why: '' });+ }+ for (const f of j.checks?.figures || []) out.push({ key: `fig:${f.at}:${f.text}`, kind: 'fig', at: toOut(f.at), heard: f.said || f.heard || '', text: f.text || '', why: f.why || '' });+ list = out.filter((x) => x.at != null).sort((a, b) => a.at - b.at);+ idx = Math.max(0, list.findIndex((x) => !res[x.key]));+ },+ items: () => list,+ pending: () => list.filter((x) => !res[x.key]).length,+ index: () => idx,+ current: () => list[idx] || null,+ status: (it) => res[it.key] || null,+ lineOf(it) { const L = S.store.doc?.lines || []; return L.find((l) => it.at >= l.start - 0.05 && it.at < l.end) || L.find((l) => it.at < l.end) || null; },+ inLine(l) { return list.filter((it) => !res[it.key] && it.at >= l.start - 0.05 && it.at < l.end); },+ flagged(u) { const l = S.store.doc?.lines.find((x) => x.u === u); return !!l && R.inLine(l).length > 0; },+ goto(i, noRender) {+ if (!list.length) return;+ idx = clamp(i, 0, list.length - 1); const it = list[idx];+ S.player.pause(); S.seek(it.at); S.timeline.scrollToTime(it.at);+ const l = R.lineOf(it); if (l) { S.sel = { kind: 'cap', u: l.u }; S.timeline.renderBlocks(); }+ if (!noRender) S.insp.render();+ },+ go(d) { R.goto(idx + d); },+ resolve(it, how) {+ res[it.key] = how; ls.set(key(), res);+ const next = list.findIndex((x, i) => i > idx && !res[x.key]);+ const any = next >= 0 ? next : list.findIndex((x) => !res[x.key]);+ if (any >= 0) R.goto(any, true);+ S.paintTop(); S.paintRail(); S.timeline.renderBlocks(); S.insp.render();+ },+ edit(it) {+ const l = R.lineOf(it); if (!l) return;+ res[it.key] = 'edit'; ls.set(key(), res);+ S.mode = 'cap'; S.insp.capTab = 'lines'; S.insp.wantFocus = l.u;+ S.seek(it.at); S.select({ kind: 'cap', u: l.u });+ S.paintTop(); S.paintRail();+ },+ canRevert(it) {+ if (!it.text || !it.heard) return false;+ const l = R.lineOf(it); return !!l && plain(l.text).toLowerCase().includes(it.text.toLowerCase());+ },+ revert(it) {+ const l = R.lineOf(it); if (!l || !R.canRevert(it)) return;+ S.store.commit((d) => {+ const x = d.lines.find((y) => y.u === l.u); if (!x) return;+ const ws = tokens(x.text); const tw = tokens(it.text).map((w) => w.w.toLowerCase());+ for (let i = 0; i + tw.length <= ws.length; i++) {+ if (tw.every((w, k) => ws[i + k].w.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '') === w.replace(/[^\p{L}\p{N}]/gu, ''))) {+ ws.splice(i, tw.length, ...tokens(it.heard).map((w) => ({ w: w.w, hi: ws[i].hi })));+ break;+ }+ }+ x.text = untokens(ws);+ });+ R.resolve(it, 'revert');+ },+ };+ return R;+ }+}++let studio = null;+function boot() { studio = new Studio(); window.LumStudio = studio; }+if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot); else boot();diff --git a/server/public/studio/timeline.js b/server/public/studio/timeline.jsnew file mode 100644index 0000000..f19f12a--- /dev/null+++ b/server/public/studio/timeline.js@@ -0,0 +1,360 @@+// Timeline đáy Studio: thước giờ, đầu phát kéo được, 5 track (Video dải ảnh khung · Phụ đề · Zoom · Đồ hoạ · Nhạc sóng thật).+// Khối phụ đề/zoom/đồ hoạ: kéo thân để dời, kéo mép để đổi giờ, không đè nhau, hít vào mép khối bên cạnh + đầu phát.+// Mượt: khi kéo chỉ đổi transform/width của đúng 1 khối (rAF), thả tay mới ghi vào store (1 bước Undo) và vẽ lại track.+// Dải ảnh + sóng nhạc vẽ trên canvas "dính" (sticky) đúng bề rộng khung nhìn, vẽ lại khi cuộn/phóng.+import { el, tx, icon, iconBtn, fmtT, fmtDb, plain, clamp, t } from './util.js';++const PAD = 14;+const ROWS = ['video', 'cap', 'zoom', 'gfx', 'music'];+const ICON = { video: 'film', cap: 'cap', zoom: 'zoom', gfx: 'gfx', music: 'music' };+const LABEL = { video: 'st.trVideo', cap: 'st.trCap', zoom: 'st.trZoom', gfx: 'st.trGfx', music: 'st.trMusic' };+const LIMIT = { cap: [0.15, 30], zoom: [0.2, 8], gfx: [1.5, 14] };+const SNAP_PX = 8;+const PPS_MIN = 12; const PPS_MAX = 400;++export class Timeline {+ constructor(ctx) {+ this.ctx = ctx; // {store, player, select(sel), getSel(), seek(t), flagged(u), musicLabel(), onZoomAdd()}+ this.pps = 60; this.t = 0; this.focus = 'cap';+ this.root = el('section', 'st-tl');+ this.root.setAttribute('aria-label', t('st.timeline')); this.root.dataset.i18nAria = 'st.timeline';+ // ---- thanh công cụ ----+ const bar = el('div', 'tl-bar');+ this.bSplit = iconBtn('cut', 'st.splitS', 'mini');+ this.bMerge = iconBtn('merge', 'st.mergeNext', 'mini');+ this.bDel = iconBtn('trash', 'st.delSel', 'mini');+ this.bAddZ = iconBtn('plus', 'st.addZoom', 'mini');+ const sep = el('span', 'sep');+ const zm = el('div', 'tl-zoomer');+ this.bOutZ = iconBtn('minus', 'st.zoomOut', 'mini');+ this.range = el('input', null, null, { type: 'range', min: '0', max: '1000', step: '1', 'aria-label': t('st.tlZoom') });+ this.range.dataset.i18nAria = 'st.tlZoom';+ this.bInZ = iconBtn('plus', 'st.zoomIn', 'mini');+ zm.append(icon('mag'), this.bOutZ, this.range, this.bInZ);+ this.hint = el('span', 'tl-hint');+ bar.append(this.bSplit, this.bMerge, this.bDel, sep, this.bAddZ, this.hint, zm);+ // ---- nhãn track + vùng cuộn ----+ const main = el('div', 'tl-main');+ this.labs = el('div', 'tl-labs');+ this.labs.append(el('div', 'lab ruler'));+ this.labEls = {};+ for (const k of ROWS) {+ const b = el('button', 'lab', null, { type: 'button', 'data-k': k });+ b.append(icon(ICON[k]), tx('span', null, LABEL[k]));+ b.addEventListener('click', () => this.ctx.focusKind?.(k));+ this.labEls[k] = b; this.labs.append(b);+ }+ this.sc = el('div', 'tl-sc');+ this.inner = el('div', 'tl-in');+ this.ruler = el('div', 'tl-ruler');+ this.rows = {};+ for (const k of ROWS) { const r = el('div', `tl-row r-${k}`, null, { 'data-k': k }); this.rows[k] = r; }+ this.vCanvas = el('canvas', 'tl-cv'); this.rows.video.append(this.vCanvas);+ this.mCanvas = el('canvas', 'tl-cv'); this.mLabel = el('span', 'tl-mlab');+ this.mBlock = el('div', 'blk mu', null, { 'data-u': 'music' }); this.mBlock.append(this.mLabel);+ this.rows.music.append(this.mCanvas, this.mBlock);+ this.head = el('div', 'tl-head'); this.head.append(el('i', 'knob'));+ this.guide = el('div', 'tl-guide'); this.guide.hidden = true;+ this.tip = el('div', 'tl-tip'); this.tip.hidden = true;+ this.inner.append(this.ruler, ...ROWS.map((k) => this.rows[k]), this.head, this.guide, this.tip);+ this.sc.append(this.inner);+ main.append(this.labs, this.sc);+ this.root.append(bar, main);+ this.els = { cap: new Map(), zoom: new Map(), gfx: new Map() };+ this.strip = null; this.wave = null; this.drawQ = 0;+ this.bind();+ this.setPps(60, true);+ }+ get dur() { return this.ctx.store.view?.duration || 0; }+ x(tt) { return PAD + tt * this.pps; }+ tAt(clientX) { const r = this.inner.getBoundingClientRect(); return (clientX - r.left - PAD) / this.pps; }++ // ---- phóng to/thu nhỏ ngang ----+ ppsToRange(p) { return Math.round((Math.log(p / PPS_MIN) / Math.log(PPS_MAX / PPS_MIN)) * 1000); }+ rangeToPps(v) { return PPS_MIN * (PPS_MAX / PPS_MIN) ** (v / 1000); }+ setPps(p, quiet, anchorX) {+ const old = this.pps;+ this.pps = clamp(p, PPS_MIN, PPS_MAX);+ this.range.value = String(this.ppsToRange(this.pps));+ const ax = anchorX ?? this.sc.clientWidth / 2;+ const tAnchor = (this.sc.scrollLeft + ax - PAD) / old;+ this.layout();+ if (!quiet) this.sc.scrollLeft = Math.max(0, PAD + tAnchor * this.pps - ax);+ this.draw();+ }+ /** Mở bản: ≥ 60 px/giây (đọc được chữ phụ đề), video ngắn thì vừa khung. */+ fitAll() { const w = this.sc.clientWidth || 900; if (this.dur > 0) { this.setPps(Math.max(60, (w - PAD * 2 - 20) / this.dur), true); this.sc.scrollLeft = 0; } }++ // ---- vẽ toàn bộ (nạp / đổi doc / phóng) ----+ layout() {+ const W = Math.ceil(this.x(this.dur) + PAD + 40);+ this.inner.style.width = W + 'px';+ this.paintRuler();+ this.renderBlocks();+ this.setTime(this.t);+ }+ paintRuler() {+ const steps = [0.5, 1, 2, 5, 10, 15, 30, 60];+ const step = steps.find((s) => s * this.pps >= 64) || 60;+ const minor = step >= 5 ? step / 5 : step / 2;+ const kids = [];+ for (let s = 0; s <= this.dur + 1e-6; s += minor) {+ const major = Math.abs(s / step - Math.round(s / step)) < 1e-6;+ const i = el('i', major ? 'mj' : null); i.style.transform = `translateX(${this.x(s).toFixed(1)}px)`; kids.push(i);+ if (major) { const sp = el('span', 'mono', step < 1 ? fmtT(s) : `${Math.floor(s / 60)}:${String(Math.round(s % 60)).padStart(2, '0')}`); sp.style.transform = `translateX(${(this.x(s) + 4).toFixed(1)}px)`; kids.push(sp); }+ }+ this.ruler.replaceChildren(...kids);+ }+ items(kind) {+ const d = this.ctx.store.doc; if (!d) return [];+ if (kind === 'cap') return d.lines.map((l) => ({ u: l.u, a: l.start, b: l.end, label: plain(l.text), ref: l }));+ if (kind === 'zoom') return d.zooms.map((z) => ({ u: z.u, a: z.at, b: z.at + z.dur, label: `${t(z.kind === 'punch' ? 'st.punchS' : 'st.pushS')} ${z.scale.toFixed(2)}×`, ref: z }));+ return d.gfx.map((g) => ({ u: g.u, a: g.at, b: g.until, label: `${t('gfx.' + g.type)}${g.data?.title || g.data?.text || g.data?.label ? ' · ' + (g.data.title || g.data.text || g.data.label) : ''}`, ref: g }));+ }+ renderBlocks() {+ const sel = this.ctx.getSel?.();+ const ro = !!this.ctx.store.view?.readOnly;+ const errs = this.ctx.store.doc ? this.ctx.store.lineErrors() : new Map();+ for (const kind of ['cap', 'zoom', 'gfx']) {+ const map = this.els[kind]; const seen = new Set();+ for (const it of this.items(kind)) {+ seen.add(it.u);+ let b = map.get(it.u);+ if (!b) {+ b = el('div', 'blk', null, { 'data-u': it.u, 'data-k': kind });+ b.append(el('span', 't'));+ map.set(it.u, b); this.rows[kind].append(b);+ }+ this.place(b, it.a, it.b);+ const lab = b.firstChild; if (lab.textContent !== it.label) lab.textContent = it.label;+ b.title = `${it.label} · ${fmtT(it.a)}–${fmtT(it.b)}`;+ b.className = `blk ${kind}` + (sel?.kind === kind && sel.u === it.u ? ' on' : '') + (kind === 'cap' && this.ctx.flagged?.(it.u) ? ' w' : '')+ + (kind === 'cap' && errs.has(it.u) ? ' bad' : '') + (ro ? ' ro' : '');+ }+ for (const [u, b] of map) if (!seen.has(u)) { b.remove(); map.delete(u); }+ }+ // nhạc: 1 khối suốt video+ const m = this.ctx.store.doc?.music;+ const on = m && m.source !== 'none';+ this.mBlock.hidden = !on;+ if (on) {+ this.place(this.mBlock, 0, this.dur);+ this.mLabel.textContent = `${this.ctx.musicLabel?.() || ''} · ${fmtDb(m.gainDb)}`;+ this.mBlock.classList.toggle('on', this.ctx.getSel?.()?.kind === 'music');+ }+ this.rows.music.classList.toggle('empty', !on);+ this.rows.music.dataset.empty = on ? '' : t('st.noMusic');+ this.draw();+ }+ place(b, a, z) {+ const x = this.x(a); const w = Math.max(3, (z - a) * this.pps - 2);+ b.style.transform = `translateX(${x.toFixed(1)}px)`; b.style.width = `${w.toFixed(1)}px`;+ b.classList.toggle('narrow', w < 34);+ }+ setTime(tt) {+ this.t = tt;+ const x = this.x(tt);+ this.head.style.transform = `translateX(${(x - 1).toFixed(1)}px)`;+ // đang phát: giữ đầu phát trong khung nhìn+ if (this.follow) {+ const v0 = this.sc.scrollLeft; const w = this.sc.clientWidth;+ if (x > v0 + w - 60 || x < v0) this.sc.scrollLeft = Math.max(0, x - 80);+ }+ }+ setFocus(kind) {+ this.focus = kind; this.root.dataset.focus = kind;+ for (const k of ROWS) this.labEls[k].classList.toggle('on', k === kind);+ }+ setStrip(meta) {+ this.strip = null;+ if (!meta?.url) { this.draw(); return; }+ const img = new Image(); img.decoding = 'async';+ img.onload = () => { this.strip = { img, ...meta }; this.draw(); };+ img.src = meta.url;+ }+ setWave(w) { this.wave = w || null; this.draw(); }++ // ---- canvas: chỉ vẽ phần đang nhìn ----+ draw() { cancelAnimationFrame(this.drawQ); this.drawQ = requestAnimationFrame(() => { this.drawVideo(); this.drawMusic(); }); }+ sizeCanvas(c, h) {+ const w = this.sc.clientWidth; const dpr = Math.min(2, window.devicePixelRatio || 1);+ if (c.width !== Math.round(w * dpr) || c.height !== Math.round(h * dpr)) { c.width = Math.round(w * dpr); c.height = Math.round(h * dpr); c.style.width = w + 'px'; c.style.height = h + 'px'; }+ const g = c.getContext('2d'); g.setTransform(dpr, 0, 0, dpr, 0, 0); g.clearRect(0, 0, w, h);+ return { g, w };+ }+ drawVideo() {+ const c = this.vCanvas; const h = this.rows.video.clientHeight - 8; if (h <= 0) return;+ const { g, w } = this.sizeCanvas(c, h);+ const sl = this.sc.scrollLeft;+ const x0 = this.x(0) - sl; const x1 = this.x(this.dur) - sl;+ if (x1 < 0 || x0 > w) return;+ g.save();+ g.beginPath(); g.roundRect(x0, 0, x1 - x0, h, 7); g.clip();+ g.fillStyle = '#26241f'; g.fillRect(x0, 0, x1 - x0, h);+ const s = this.strip;+ if (s) {+ const tw = (h * s.tileW) / s.tileH;+ const from = Math.max(x0, Math.floor((0 - x0) / tw) * tw + x0);+ for (let x = from; x < Math.min(w, x1); x += tw) {+ const tt = (x + tw / 2 - x0) / this.pps;+ const i = clamp(Math.floor(tt / s.every), 0, s.n - 1);+ g.drawImage(s.img, i * s.tileW, 0, s.tileW, s.tileH, x, 0, tw + 0.5, h);+ }+ }+ // vết cắt+ g.fillStyle = '#131210';+ for (const ct of this.ctx.store.view?.cuts || []) { const x = this.x(ct) - sl; if (x > -2 && x < w + 2) g.fillRect(x - 1, 0, 2, h); }+ g.restore();+ g.strokeStyle = 'rgba(255,255,255,.16)'; g.lineWidth = 1.5; g.beginPath(); g.roundRect(x0 + 0.75, 0.75, x1 - x0 - 1.5, h - 1.5, 7); g.stroke();+ }+ drawMusic() {+ const c = this.mCanvas; const h = this.rows.music.clientHeight - 8; if (h <= 0) return;+ const { g, w } = this.sizeCanvas(c, h);+ const m = this.ctx.store.doc?.music; const wv = this.wave;+ if (!m || m.source === 'none' || !wv?.peaks?.length) return;+ const sl = this.sc.scrollLeft;+ const amp = clamp(10 ** ((m.gainDb + 18) / 20) * 0.85, 0.06, 1);+ const mid = h / 2 + 5; const half = (h - 18) / 2;+ g.fillStyle = 'rgba(93,211,158,.85)';+ const x0 = Math.max(0, this.x(0) - sl); const x1 = Math.min(w, this.x(this.dur) - sl);+ for (let x = Math.floor(x0); x < x1; x += 2) {+ const tt = (x + sl - PAD) / this.pps;+ const mt = (m.start + tt) % (wv.seconds || 1);+ const p = wv.peaks[Math.min(wv.peaks.length - 1, Math.floor(mt * wv.rate))] || 0;+ let k = 1; if (m.fadeOut > 0 && tt > this.dur - m.fadeOut) k = Math.max(0, (this.dur - tt) / m.fadeOut);+ const y = Math.max(0.5, p * half * amp * k);+ g.fillRect(x, mid - y, 1.3, y * 2);+ }+ }++ // ---- thao tác ----+ bind() {+ this.sc.addEventListener('scroll', () => this.draw(), { passive: true });+ new ResizeObserver(() => this.draw()).observe(this.sc);+ this.range.addEventListener('input', () => this.setPps(this.rangeToPps(Number(this.range.value))));+ this.bInZ.addEventListener('click', () => this.setPps(this.pps * 1.4));+ this.bOutZ.addEventListener('click', () => this.setPps(this.pps / 1.4));+ this.sc.addEventListener('wheel', (e) => {+ if (e.ctrlKey || e.metaKey) {+ e.preventDefault();+ const r = this.sc.getBoundingClientRect();+ this.setPps(this.pps * Math.exp(-e.deltaY * 0.0022), false, e.clientX - r.left);+ } else if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) { e.preventDefault(); this.sc.scrollLeft += e.deltaY; }+ }, { passive: false });+ this.bSplit.addEventListener('click', () => this.ctx.splitAtHead?.());+ this.bMerge.addEventListener('click', () => this.ctx.mergeSel?.());+ this.bDel.addEventListener('click', () => this.ctx.deleteSel?.());+ this.bAddZ.addEventListener('click', () => this.ctx.onZoomAdd?.());+ // thước + đầu phát: bấm để tua, kéo để rê+ const scrub = (e) => {+ e.preventDefault();+ const target = e.currentTarget; target.setPointerCapture(e.pointerId);+ this.ctx.player.pause();+ const go = (ev) => this.ctx.seek(clamp(this.tAt(ev.clientX), 0, this.dur));+ go(e);+ const mv = (ev) => go(ev);+ const up = () => { target.removeEventListener('pointermove', mv); target.removeEventListener('pointerup', up); target.removeEventListener('pointercancel', up); this.head.classList.remove('drag'); };+ this.head.classList.add('drag');+ target.addEventListener('pointermove', mv); target.addEventListener('pointerup', up); target.addEventListener('pointercancel', up);+ };+ this.ruler.addEventListener('pointerdown', scrub);+ this.head.addEventListener('pointerdown', scrub);+ this.inner.addEventListener('pointerdown', (e) => {+ if (e.button !== 0) return;+ const b = e.target.closest('.blk');+ if (b && b.dataset.k) return this.down(e, b);+ if (b === this.mBlock) { this.ctx.select({ kind: 'music', u: 'music' }); return; }+ const row = e.target.closest('.tl-row');+ if (row) { this.ctx.player.pause(); this.ctx.seek(clamp(this.tAt(e.clientX), 0, this.dur)); this.ctx.select(null); this.ctx.focusKind?.(row.dataset.k, true); }+ });+ this.inner.addEventListener('dblclick', (e) => {+ const b = e.target.closest('.blk.cap'); if (b) this.inlineEdit(b.dataset.u);+ });+ // phím trên khối đang focus: Enter sửa chữ (thay bấm đúp)+ }+ /** Bắt đầu kéo 1 khối: mode l (mép trái) / r (mép phải) / move (thân). */+ down(e, b) {+ const kind = b.dataset.k; const u = b.dataset.u;+ const it = this.items(kind).find((x) => x.u === u); if (!it) return;+ const ro = !!this.ctx.store.view?.readOnly;+ const r = b.getBoundingClientRect(); const off = e.clientX - r.left;+ const edge = Math.min(8, r.width / 3);+ const mode = off <= edge ? 'l' : off >= r.width - edge ? 'r' : 'move';+ const sorted = this.items(kind).filter((x) => x.u !== u).sort((p, q) => p.a - q.a);+ const prev = sorted.filter((x) => x.b <= it.a + 1e-3).pop(); const next = sorted.find((x) => x.a >= it.b - 1e-3);+ const lo = prev ? prev.b : 0; const hi = next ? next.a : this.dur;+ const [minL, maxL] = LIMIT[kind];+ const snaps = [this.t, ...sorted.flatMap((x) => [x.a, x.b])];+ const st = { kind, u, mode, x0: e.clientX, a0: it.a, b0: it.b, moved: false, lo, hi, minL, maxL, snaps, b, ref: it.ref };+ b.setPointerCapture(e.pointerId);+ let raf = 0; let last = null;+ const mv = (ev) => {+ const dx = ev.clientX - st.x0;+ if (!st.moved) { if (Math.abs(dx) < 3 || ro) return; st.moved = true; this.ctx.store.begin(); b.classList.add('drag'); this.ctx.select({ kind, u }, { quiet: true }); }+ last = dx;+ if (!raf) raf = requestAnimationFrame(() => { raf = 0; this.dragTo(st, last); });+ };+ const up = () => {+ b.removeEventListener('pointermove', mv); b.removeEventListener('pointerup', up); b.removeEventListener('pointercancel', up);+ cancelAnimationFrame(raf);+ if (st.moved) { if (last != null) this.dragTo(st, last); b.classList.remove('drag'); this.guide.hidden = true; this.tip.hidden = true; this.ctx.store.end(); }+ else this.ctx.select({ kind, u });+ };+ b.addEventListener('pointermove', mv); b.addEventListener('pointerup', up); b.addEventListener('pointercancel', up);+ }+ /** 1 khung kéo: tính giờ mới (kẹp + hít), ghi tạm vào doc, chỉ đổi transform/width của khối đó. */+ dragTo(st, dx) {+ const dt = dx / this.pps; const thr = SNAP_PX / this.pps;+ let a = st.a0; let z = st.b0; let snapAt = null;+ const snap = (v) => { let best = null; for (const s of st.snaps) if (Math.abs(s - v) <= thr && (best == null || Math.abs(s - v) < Math.abs(best - v))) best = s; return best; };+ if (st.mode === 'move') {+ const len = st.b0 - st.a0;+ a = st.a0 + dt;+ const sa = snap(a); const sb = snap(a + len);+ if (sa != null && (sb == null || Math.abs(sa - a) <= Math.abs(sb - a - len))) { a = sa; snapAt = sa; } else if (sb != null) { a = sb - len; snapAt = sb; }+ a = clamp(a, st.lo, Math.max(st.lo, st.hi - len)); z = a + len;+ } else if (st.mode === 'l') {+ a = st.a0 + dt; const s = snap(a); if (s != null) { a = s; snapAt = s; }+ a = clamp(a, Math.max(st.lo, st.b0 - st.maxL), st.b0 - st.minL);+ } else {+ z = st.b0 + dt; const s = snap(z); if (s != null) { z = s; snapAt = s; }+ z = clamp(z, st.a0 + st.minL, Math.min(st.hi, st.a0 + st.maxL));+ }+ a = Math.round(a * 100) / 100; z = Math.round(z * 100) / 100;+ // ghi tạm vào doc (store.begin đã chụp bản trước)+ const r = st.ref;+ if (st.kind === 'cap') { r.start = a; r.end = z; } else if (st.kind === 'zoom') { r.at = a; r.dur = Math.round((z - a) * 100) / 100; } else { r.at = a; r.until = z; }+ this.place(st.b, a, z);+ this.guide.hidden = snapAt == null || (Math.abs(snapAt - a) > 1e-3 && Math.abs(snapAt - z) > 1e-3);+ if (!this.guide.hidden) this.guide.style.transform = `translateX(${this.x(snapAt).toFixed(1)}px)`;+ this.tip.hidden = false;+ this.tip.textContent = st.mode === 'l' ? fmtT(a) : st.mode === 'r' ? fmtT(z) : `${fmtT(a)} – ${fmtT(z)}`;+ this.tip.style.transform = `translate(${this.x(st.mode === 'r' ? z : a).toFixed(1)}px, ${st.b.parentElement.offsetTop + st.b.offsetTop - 24}px)`;+ this.ctx.onDrag?.(st.kind, st.u);+ }+ /** Bấm đúp khối phụ đề: ô sửa chữ ngay trên khối (Enter lưu, Esc huỷ). */+ inlineEdit(u) {+ if (this.ctx.store.view?.readOnly) return;+ const b = this.els.cap.get(u); const l = this.ctx.store.doc.lines.find((x) => x.u === u); if (!b || !l) return;+ this.ctx.select({ kind: 'cap', u }, { quiet: true });+ const inp = el('input', 'tl-edit', null, { type: 'text', maxlength: '200', spellcheck: 'false', 'aria-label': t('st.lineText') });+ inp.value = l.text;+ const x = this.x(l.start);+ inp.style.transform = `translate(${x.toFixed(1)}px, ${b.offsetTop + this.rows.cap.offsetTop - 2}px)`;+ inp.style.width = `${Math.max((l.end - l.start) * this.pps, 200)}px`;+ this.inner.append(inp); inp.focus(); inp.select();+ let done = false;+ const finish = (save) => {+ if (done) return; done = true;+ const v = inp.value.trim(); inp.remove();+ if (save && v && v !== l.text) this.ctx.store.commit((d) => { const x2 = d.lines.find((y) => y.u === u); if (x2) x2.text = v; });+ this.ctx.afterInline?.();+ };+ inp.addEventListener('keydown', (e) => { e.stopPropagation(); if (e.key === 'Enter') finish(true); else if (e.key === 'Escape') finish(false); });+ inp.addEventListener('blur', () => finish(true));+ }+ scrollToTime(tt) {+ const x = this.x(tt); const v0 = this.sc.scrollLeft; const w = this.sc.clientWidth;+ if (x < v0 + 40 || x > v0 + w - 40) this.sc.scrollLeft = Math.max(0, x - w / 3);+ }+}diff --git a/server/public/studio/util.js b/server/public/studio/util.jsnew file mode 100644index 0000000..8b376df--- /dev/null+++ b/server/public/studio/util.js@@ -0,0 +1,121 @@+// Tiện ích chung của Studio + màn tạo mới. Chữ từ server chỉ vào DOM qua textContent (luật P2): el(tag, cls, text).+export const $ = (s, r = document) => r.querySelector(s);+export const $$ = (s, r = document) => [...r.querySelectorAll(s)];+export const I = window.I18N;+export const t = (k, v) => I.t(k, v);++/** Tạo phần tử; text đi qua textContent. attrs: {data-*, aria-*, type…} (giá trị là chuỗi, không phải HTML). */+export function el(tag, cls, text, attrs) {+ const e = document.createElement(tag);+ if (cls) e.className = cls;+ if (text != null) e.textContent = text;+ if (attrs) for (const [k, v] of Object.entries(attrs)) if (v != null && v !== false) e.setAttribute(k, v === true ? '' : String(v));+ return e;+}+/** Phần tử có chữ dịch được: data-i18n (I18N.apply đổi lại khi đổi VI/EN). */+export function tx(tag, cls, key, attrs) { const e = el(tag, cls, t(key), attrs); e.dataset.i18n = key; return e; }++// bộ icon nét (Lucide-like), hằng số của app — không có dữ liệu người dùng+const P = {+ back: 'M12 19l-7-7 7-7M19 12H5',+ cap: 'M5 5h14a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3H5a3 3 0 0 1-3-3V8a3 3 0 0 1 3-3zM7 14.5h4M14 14.5h3M7 10.5h2M12 10.5h5',+ music: 'M9 18V5l12-2v13M9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM21 16a3 3 0 1 1-6 0 3 3 0 0 1 6 0z',+ zoom: 'M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7',+ gfx: 'M6 3h12a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6a3 3 0 0 1 3-3zM3 9h18M9 21V9',+ ai: 'M11 3.5l1.8 5.2 5.2 1.8-5.2 1.8L11 17.5l-1.8-5.2L4 10.5l5.2-1.8zM19 15v5M16.5 17.5h5',+ dl: 'M12 15V3M7 10l5 5 5-5M5 21h14',+ warn: 'M21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3zM12 9v4M12 17h.01',+ pause: 'M8 5v14M16 5v14',+ prev: 'M19 20L9 12l10-8zM5 19V5',+ next: 'M5 4l10 8-10 8zM19 5v14',+ undo: 'M9 14L4 9l5-5M4 9h11a5 5 0 0 1 0 10h-4',+ redo: 'M15 14l5-5-5-5M20 9H9a5 5 0 0 0 0 10h4',+ cut: 'M9 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM20 4L8.12 15.88M14.47 14.48L20 20M8.12 8.12L12 12',+ trash: 'M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6',+ merge: 'M7 4v4a4 4 0 0 0 4 4h2a4 4 0 0 1 4 4v4M17 4v4a4 4 0 0 1-4 4',+ split: 'M12 3v18M7 8l-4 4 4 4M17 8l4 4-4 4',+ plus: 'M12 5v14M5 12h14',+ check: 'M20 6L9 17l-5-5',+ x: 'M18 6L6 18M6 6l12 12',+ upload: 'M12 15V3M17 8l-5-5-5 5M5 21h14',+ film: 'M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zM7 3v18M17 3v18M3 7.5h4M3 12h18M3 16.5h4M17 7.5h4M17 16.5h4',+ mag: 'M18 11a7 7 0 1 1-14 0 7 7 0 0 1 14 0zM21 21l-4.3-4.3',+ clock: 'M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0zM12 7v5l3 2',+ minus: 'M5 12h14',+ eye: 'M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12zM15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z',+ pen: 'M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5z',+ rotate: 'M3 12a9 9 0 1 0 3-6.7L3 8M3 3v5h5',+ hi: 'M4 20h16M7 16l5-12 5 12M9 11h6',+ right: 'M9 6l6 6-6 6',+ left: 'M15 6l-6 6 6 6',+ more: 'M5 12h.01M12 12h.01M19 12h.01',+ send: 'M22 2L11 13M22 2l-7 20-4-9-9-4z',+};+const PLAY = 'M7 4.5v15l12.5-7.5z';+const NS = 'http://www.w3.org/2000/svg';+export function icon(name, cls) {+ const s = document.createElementNS(NS, 'svg');+ s.setAttribute('viewBox', '0 0 24 24'); s.setAttribute('aria-hidden', 'true'); s.setAttribute('focusable', 'false');+ s.setAttribute('class', 'ic' + (cls ? ' ' + cls : ''));+ const p = document.createElementNS(NS, 'path');+ if (name === 'play') { p.setAttribute('d', PLAY); p.setAttribute('class', 'fill'); } else p.setAttribute('d', P[name] || '');+ s.append(p);+ return s;+}+/** Nút chỉ có icon: luôn có aria-label (+ title) dịch được. */+export function iconBtn(name, labelKey, cls, extra) {+ const b = el('button', 'ib' + (cls ? ' ' + cls : ''), null, { type: 'button', ...(extra || {}) });+ b.append(icon(name));+ b.setAttribute('aria-label', t(labelKey)); b.title = t(labelKey);+ b.dataset.i18nAria = labelKey; b.dataset.i18nTitle = labelKey;+ return b;+}++export const clamp = (x, a, b) => Math.min(b, Math.max(a, x));+export const r2 = (x) => Math.round(x * 100) / 100;+/** 0:01.6 */+export const fmtT = (s) => { const x = Math.max(0, Math.round(s * 10) / 10); const m = Math.floor(x / 60); return `${m}:${(x - m * 60).toFixed(1).padStart(4, '0')}`; };+/** 0:36 */+export const fmtDur = (s) => { const x = Math.max(0, Math.round(s)); return `${Math.floor(x / 60)}:${String(x % 60).padStart(2, '0')}`; };+export const fmtDb = (x) => `${x > 0 ? '+' : x < 0 ? '−' : ''}${Math.abs(x)} dB`;+export const fmtMB = (b) => (b >= 1e9 ? (b / 1e9).toFixed(2) + ' GB' : Math.max(1, Math.round(b / 1e6)) + ' MB');+/** chỉ nhận đường dẫn cùng gốc ("/edits/…"), không nhận javascript:, //host… */+export const safeUrl = (u) => (typeof u === 'string' && /^\/(?!\/)/.test(u) ? u : null);+export const ID_RE = /^[\w-]{1,80}$/;++export async function getJSON(url) {+ const r = await fetch(url, { cache: 'no-store' });+ const j = await r.json().catch(() => ({}));+ if (!r.ok) throw Object.assign(new Error(j.error || 'HTTP ' + r.status), { status: r.status });+ return j;+}+export async function postJSON(url, body) {+ const r = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });+ const j = await r.json().catch(() => ({}));+ if (!r.ok) throw Object.assign(new Error(j.error || 'HTTP ' + r.status), { status: r.status });+ return j;+}+export const store = {+ get(k, d = null) { try { const v = localStorage.getItem(k); return v == null ? d : JSON.parse(v); } catch { return d; } },+ set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch { /* đầy / riêng tư: bỏ qua */ } },+ del(k) { try { localStorage.removeItem(k); } catch { /* bỏ qua */ } },+};+/** "*Giá* tăng" → [{w, hi}] (như edit/manual.mjs lineTokens) */+export function tokens(text) {+ const out = []; const re = /\*([^*]+)\*|([^*]+)/g; let m;+ while ((m = re.exec(String(text)))) { const hi = !!m[1]; for (const w of (m[1] || m[2]).split(/\s+/)) if (w.trim()) out.push({ w: w.trim(), hi }); }+ return out;+}+export const untokens = (ws) => ws.map((w) => (w.hi ? `*${w.w}*` : w.w)).join(' ');+export const plain = (text) => String(text).replace(/\*/g, '');+/** Gắn chữ (có chữ nhấn) vào phần tử: chữ nhấn bọc <em>, tất cả qua textContent. */+export function paintWords(node, text, { hiClass = null } = {}) {+ const ws = tokens(text);+ node.replaceChildren();+ ws.forEach((w, i) => {+ if (i) node.append(' ');+ if (w.hi) { const e = el('em', hiClass, w.w); node.append(e); } else node.append(w.w);+ });+}+export const reduceMotion = () => window.matchMedia('(prefers-reduced-motion: reduce)').matches;+export const narrow = () => window.matchMedia('(max-width: 767px)').matches;