Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.
Rust downloadmanagerguihacktoberfesthomebrewlightweightlinuxlinux-distributionlocal-firstmacosmacos-packagemedia-toolboxopen-sourcerustsveltetauritrendingtrending-repositorieswindowswindows-desktopytdlp
feat(remake): D3 downloads + D8 about hero + D9-D11 diálogos, toasts, banners e onboarding no sistema v2
tonhowtf24bcda2c12a9
diff --git a/src/components/dialog/ChangelogDialog.svelte b/src/components/dialog/ChangelogDialog.svelteindex 5b6aca4a..3451f918 100644--- a/src/components/dialog/ChangelogDialog.svelte+++ b/src/components/dialog/ChangelogDialog.svelte@@ -1,369 +1,369 @@-<script lang="ts">- import { t } from "$lib/i18n";- import {- getChangelogVisible,- getChangelogBody,- getCurrentVersion,- dismissChangelog,- } from "$lib/stores/changelog-store.svelte";-- let visible = $derived(getChangelogVisible());- let body = $derived(getChangelogBody());- let version = $derived(getCurrentVersion());-- let dialogEl = $state<HTMLDialogElement | null>(null);- let closing = $state(false);- let previousFocusEl = $state<HTMLElement | null>(null);-- $effect(() => {- if (visible && dialogEl && !dialogEl.open) {- previousFocusEl = document.activeElement as HTMLElement;- dialogEl.showModal();- }- });-- function handleClose() {- closing = true;- setTimeout(() => {- closing = false;- dialogEl?.close();- dismissChangelog();- previousFocusEl?.focus();- previousFocusEl = null;- }, 150);- }-- function handleBackdropClick(e: MouseEvent) {- if (e.target === dialogEl) {- handleClose();- }- }-- function renderMarkdown(md: string): string {- return md- .split("\n")- .map((line) => {- if (line.startsWith("### ")) {- return `<h4>${escapeHtml(line.slice(4))}</h4>`;- }- if (line.startsWith("## ")) {- return `<h3>${escapeHtml(line.slice(3))}</h3>`;- }- if (line.startsWith("# ")) {- return `<h2>${escapeHtml(line.slice(2))}</h2>`;- }- if (line.startsWith("- ") || line.startsWith("* ")) {- return `<li>${formatInline(line.slice(2))}</li>`;- }- if (line.trim() === "") {- return "<br />";- }- return `<p>${formatInline(line)}</p>`;- })- .join("");- }-- function escapeHtml(str: string): string {- return str- .replace(/&/g, "&")- .replace(/</g, "<")- .replace(/>/g, ">")- .replace(/"/g, """);- }-- function formatInline(str: string): string {- let result = escapeHtml(str);- result = result.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>");- result = result.replace(/`(.+?)`/g, "<code>$1</code>");- result = result.replace(- /\[(.+?)\]\((.+?)\)/g,- '<a href="$2" target="_blank" rel="noopener">$1</a>'- );- return result;- }-</script>--{#if visible}- <dialog- bind:this={dialogEl}- class="changelog-dialog"- class:closing- aria-labelledby="changelog-title"- aria-modal="true"- onclick={handleBackdropClick}- oncancel={(e) => {- e.preventDefault();- handleClose();- }}- >- <div class="dialog-content">- <div class="dialog-header">- <div class="dialog-title-row">- <h3 id="changelog-title">{$t("changelog.title")}</h3>- {#if version}- <span class="version-badge">v{version}</span>- {/if}- </div>- <button class="close-btn" onclick={handleClose} aria-label={$t("common.close")}>- <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M18 6L6 18M6 6l12 12" />- </svg>- </button>- </div>-- <div class="dialog-body">- {#if body}- <div class="markdown-content">- {@html renderMarkdown(body)}- </div>- {:else}- <p class="empty-text">{$t("changelog.empty")}</p>- {/if}- </div>-- <div class="dialog-footer">- <button class="button dismiss-btn" onclick={handleClose}>- {$t("common.close")}- </button>- </div>- </div>- </dialog>-{/if}--<style>- .changelog-dialog {- border: none;- border-radius: var(--border-radius);- background: var(--popup-bg);- color: var(--secondary);- padding: 0;- width: 90%;- max-width: 480px;- max-height: 80vh;- animation: dialog-in 0.15s ease-out;- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);- }-- .changelog-dialog::backdrop {- background: var(--dialog-backdrop);- animation: backdrop-in 0.15s ease-out;- }-- .changelog-dialog.closing {- animation: dialog-out 0.15s ease-in forwards;- }-- .changelog-dialog.closing::backdrop {- animation: backdrop-out 0.15s ease-in forwards;- }-- @keyframes dialog-in {- from {- opacity: 0;- transform: scale(0.96) translateY(8px);- }- to {- opacity: 1;- transform: scale(1) translateY(0);- }- }-- @keyframes dialog-out {- from {- opacity: 1;- transform: scale(1) translateY(0);- }- to {- opacity: 0;- transform: scale(0.96) translateY(8px);- }- }-- @keyframes backdrop-in {- from {- opacity: 0;- }- to {- opacity: 1;- }- }-- @keyframes backdrop-out {- from {- opacity: 1;- }- to {- opacity: 0;- }- }-- .dialog-content {- display: flex;- flex-direction: column;- max-height: 80vh;- }-- .dialog-header {- display: flex;- align-items: center;- justify-content: space-between;- padding: calc(var(--padding) + 4px) calc(var(--padding) + 4px) 0;- flex-shrink: 0;- }-- .dialog-title-row {- display: flex;- align-items: center;- gap: calc(var(--padding) / 2);- }-- .dialog-title-row h3 {- margin: 0;- }-- .version-badge {- font-size: 11px;- font-weight: 500;- color: var(--blue);- background: rgba(47, 138, 249, 0.12);- padding: 2px 8px;- border-radius: 6px;- }-- .close-btn {- width: 32px;- height: 32px;- display: flex;- align-items: center;- justify-content: center;- border-radius: calc(var(--border-radius) / 2);- color: var(--gray);- cursor: pointer;- border: none;- background: none;- flex-shrink: 0;- }-- .close-btn :global(svg) {- pointer-events: none;- }-- @media (hover: hover) {- .close-btn:hover {- color: var(--secondary);- background: var(--button-elevated);- }- }-- .close-btn:active {- background: var(--button-elevated-press);- }-- .close-btn:focus-visible {- outline: var(--focus-ring);- outline-offset: var(--focus-ring-offset);- }-- .dialog-body {- flex: 1;- overflow-y: auto;- padding: calc(var(--padding) + 4px);- scrollbar-width: none;- }-- .dialog-body::-webkit-scrollbar {- display: none;- }-- .markdown-content {- font-size: 13px;- font-weight: 400;- line-height: 1.7;- color: var(--secondary);- }-- .markdown-content :global(h2) {- font-size: 18px;- font-weight: 500;- margin: 0 0 calc(var(--padding) / 2);- letter-spacing: -0.5px;- }-- .markdown-content :global(h3) {- font-size: 15px;- font-weight: 500;- margin: var(--padding) 0 calc(var(--padding) / 2);- }-- .markdown-content :global(h4) {- font-size: 13px;- font-weight: 500;- margin: var(--padding) 0 calc(var(--padding) / 4);- color: var(--gray);- }-- .markdown-content :global(p) {- margin: 0 0 4px;- }-- .markdown-content :global(li) {- margin: 0 0 4px;- padding-left: calc(var(--padding) / 2);- list-style: none;- }-- .markdown-content :global(li::before) {- content: "•";- color: var(--blue);- margin-right: 6px;- }-- .markdown-content :global(strong) {- font-weight: 600;- }-- .markdown-content :global(code) {- font-size: 12px;- padding: 1px 5px;- background: var(--button-elevated);- border-radius: 4px;- }-- .markdown-content :global(a) {- color: var(--blue);- text-decoration: none;- }-- @media (hover: hover) {- .markdown-content :global(a:hover) {- text-decoration: underline;- }- }-- .markdown-content :global(br) {- display: block;- content: "";- margin-top: 4px;- }-- .empty-text {- font-size: 14.5px;- font-weight: 500;- color: var(--gray);- text-align: center;- padding: calc(var(--padding) * 2) 0;- }-- .dialog-footer {- display: flex;- justify-content: flex-end;- padding: 0 calc(var(--padding) + 4px) calc(var(--padding) + 4px);- flex-shrink: 0;- }-- .dismiss-btn {- padding: calc(var(--padding) / 2) calc(var(--padding) * 1.5);- font-size: 13px;- font-weight: 500;- }-</style>+<script lang="ts">+ import { t } from "$lib/i18n";+ import {+ getChangelogVisible,+ getChangelogBody,+ getCurrentVersion,+ dismissChangelog,+ } from "$lib/stores/changelog-store.svelte";++ let visible = $derived(getChangelogVisible());+ let body = $derived(getChangelogBody());+ let version = $derived(getCurrentVersion());++ let dialogEl = $state<HTMLDialogElement | null>(null);+ let closing = $state(false);+ let previousFocusEl = $state<HTMLElement | null>(null);++ $effect(() => {+ if (visible && dialogEl && !dialogEl.open) {+ previousFocusEl = document.activeElement as HTMLElement;+ dialogEl.showModal();+ }+ });++ function handleClose() {+ closing = true;+ setTimeout(() => {+ closing = false;+ dialogEl?.close();+ dismissChangelog();+ previousFocusEl?.focus();+ previousFocusEl = null;+ }, 150);+ }++ function handleBackdropClick(e: MouseEvent) {+ if (e.target === dialogEl) {+ handleClose();+ }+ }++ function renderMarkdown(md: string): string {+ return md+ .split("\n")+ .map((line) => {+ if (line.startsWith("### ")) {+ return `<h4>${escapeHtml(line.slice(4))}</h4>`;+ }+ if (line.startsWith("## ")) {+ return `<h3>${escapeHtml(line.slice(3))}</h3>`;+ }+ if (line.startsWith("# ")) {+ return `<h2>${escapeHtml(line.slice(2))}</h2>`;+ }+ if (line.startsWith("- ") || line.startsWith("* ")) {+ return `<li>${formatInline(line.slice(2))}</li>`;+ }+ if (line.trim() === "") {+ return "<br />";+ }+ return `<p>${formatInline(line)}</p>`;+ })+ .join("");+ }++ function escapeHtml(str: string): string {+ return str+ .replace(/&/g, "&")+ .replace(/</g, "<")+ .replace(/>/g, ">")+ .replace(/"/g, """);+ }++ function formatInline(str: string): string {+ let result = escapeHtml(str);+ result = result.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>");+ result = result.replace(/`(.+?)`/g, "<code>$1</code>");+ result = result.replace(+ /\[(.+?)\]\((.+?)\)/g,+ '<a href="$2" target="_blank" rel="noopener">$1</a>'+ );+ return result;+ }+</script>++{#if visible}+ <dialog+ bind:this={dialogEl}+ class="changelog-dialog"+ class:closing+ aria-labelledby="changelog-title"+ aria-modal="true"+ onclick={handleBackdropClick}+ oncancel={(e) => {+ e.preventDefault();+ handleClose();+ }}+ >+ <div class="dialog-content">+ <div class="dialog-header">+ <div class="dialog-title-row">+ <h3 id="changelog-title">{$t("changelog.title")}</h3>+ {#if version}+ <span class="version-badge">v{version}</span>+ {/if}+ </div>+ <button class="close-btn" onclick={handleClose} aria-label={$t("common.close")}>+ <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ </button>+ </div>++ <div class="dialog-body">+ {#if body}+ <div class="markdown-content">+ {@html renderMarkdown(body)}+ </div>+ {:else}+ <p class="empty-text">{$t("changelog.empty")}</p>+ {/if}+ </div>++ <div class="dialog-footer">+ <button class="button dismiss-btn" onclick={handleClose}>+ {$t("common.close")}+ </button>+ </div>+ </div>+ </dialog>+{/if}++<style>+ .changelog-dialog {+ border: none;+ border-radius: var(--border-radius);+ background: var(--popup-bg);+ color: var(--secondary);+ padding: 0;+ width: 90%;+ max-width: 480px;+ max-height: 80vh;+ animation: dialog-in 0.15s ease-out;+ box-shadow: var(--elev-3);+ }++ .changelog-dialog::backdrop {+ background: var(--dialog-backdrop);+ animation: backdrop-in 0.15s ease-out;+ }++ .changelog-dialog.closing {+ animation: dialog-out 0.15s ease-in forwards;+ }++ .changelog-dialog.closing::backdrop {+ animation: backdrop-out 0.15s ease-in forwards;+ }++ @keyframes dialog-in {+ from {+ opacity: 0;+ transform: scale(0.96) translateY(8px);+ }+ to {+ opacity: 1;+ transform: scale(1) translateY(0);+ }+ }++ @keyframes dialog-out {+ from {+ opacity: 1;+ transform: scale(1) translateY(0);+ }+ to {+ opacity: 0;+ transform: scale(0.96) translateY(8px);+ }+ }++ @keyframes backdrop-in {+ from {+ opacity: 0;+ }+ to {+ opacity: 1;+ }+ }++ @keyframes backdrop-out {+ from {+ opacity: 1;+ }+ to {+ opacity: 0;+ }+ }++ .dialog-content {+ display: flex;+ flex-direction: column;+ max-height: 80vh;+ }++ .dialog-header {+ display: flex;+ align-items: center;+ justify-content: space-between;+ padding: calc(var(--padding) + 4px) calc(var(--padding) + 4px) 0;+ flex-shrink: 0;+ }++ .dialog-title-row {+ display: flex;+ align-items: center;+ gap: calc(var(--padding) / 2);+ }++ .dialog-title-row h3 {+ margin: 0;+ }++ .version-badge {+ font-size: var(--text-xs);+ font-weight: 500;+ color: var(--accent-hi);+ background: var(--accent-soft);+ padding: 2px 8px;+ border-radius: var(--radius-full);+ }++ .close-btn {+ width: 32px;+ height: 32px;+ display: flex;+ align-items: center;+ justify-content: center;+ border-radius: calc(var(--border-radius) / 2);+ color: var(--gray);+ cursor: pointer;+ border: none;+ background: none;+ flex-shrink: 0;+ }++ .close-btn :global(svg) {+ pointer-events: none;+ }++ @media (hover: hover) {+ .close-btn:hover {+ color: var(--secondary);+ background: var(--button-elevated);+ }+ }++ .close-btn:active {+ background: var(--button-elevated-press);+ }++ .close-btn:focus-visible {+ outline: var(--focus-ring);+ outline-offset: var(--focus-ring-offset);+ }++ .dialog-body {+ flex: 1;+ overflow-y: auto;+ padding: calc(var(--padding) + 4px);+ scrollbar-width: none;+ }++ .dialog-body::-webkit-scrollbar {+ display: none;+ }++ .markdown-content {+ font-size: 13px;+ font-weight: 400;+ line-height: 1.7;+ color: var(--secondary);+ }++ .markdown-content :global(h2) {+ font-size: 18px;+ font-weight: 500;+ margin: 0 0 calc(var(--padding) / 2);+ letter-spacing: -0.5px;+ }++ .markdown-content :global(h3) {+ font-size: 15px;+ font-weight: 500;+ margin: var(--padding) 0 calc(var(--padding) / 2);+ }++ .markdown-content :global(h4) {+ font-size: 13px;+ font-weight: 500;+ margin: var(--padding) 0 calc(var(--padding) / 4);+ color: var(--gray);+ }++ .markdown-content :global(p) {+ margin: 0 0 4px;+ }++ .markdown-content :global(li) {+ margin: 0 0 4px;+ padding-left: calc(var(--padding) / 2);+ list-style: none;+ }++ .markdown-content :global(li::before) {+ content: "•";+ color: var(--blue);+ margin-right: 6px;+ }++ .markdown-content :global(strong) {+ font-weight: 600;+ }++ .markdown-content :global(code) {+ font-size: 12px;+ padding: 1px 5px;+ background: var(--button-elevated);+ border-radius: 4px;+ }++ .markdown-content :global(a) {+ color: var(--blue);+ text-decoration: none;+ }++ @media (hover: hover) {+ .markdown-content :global(a:hover) {+ text-decoration: underline;+ }+ }++ .markdown-content :global(br) {+ display: block;+ content: "";+ margin-top: 4px;+ }++ .empty-text {+ font-size: 14.5px;+ font-weight: 500;+ color: var(--gray);+ text-align: center;+ padding: calc(var(--padding) * 2) 0;+ }++ .dialog-footer {+ display: flex;+ justify-content: flex-end;+ padding: 0 calc(var(--padding) + 4px) calc(var(--padding) + 4px);+ flex-shrink: 0;+ }++ .dismiss-btn {+ padding: calc(var(--padding) / 2) calc(var(--padding) * 1.5);+ font-size: 13px;+ font-weight: 500;+ }+</style>diff --git a/src/components/dialog/ConfirmCloseDialog.svelte b/src/components/dialog/ConfirmCloseDialog.svelteindex 2659a5b6..ff0b6850 100644--- a/src/components/dialog/ConfirmCloseDialog.svelte+++ b/src/components/dialog/ConfirmCloseDialog.svelte@@ -95,12 +95,12 @@}.button-danger {- background: var(--red, #ed2236);- color: var(--on-accent, #fff);+ background: var(--danger);+ color: var(--on-status);}.button-danger:hover {- filter: brightness(1.08);+ background: color-mix(in srgb, var(--danger) 88%, var(--bg-overlay));}.button:focus-visible {diff --git a/src/components/dialog/DialogContainer.svelte b/src/components/dialog/DialogContainer.svelteindex 4806f76b..1b51f895 100644--- a/src/components/dialog/DialogContainer.svelte+++ b/src/components/dialog/DialogContainer.svelte@@ -1,164 +1,162 @@-<script lang="ts">- import type { Snippet } from "svelte";-- let {- isOpen = $bindable(false),- titleId = "dialog-title",- onClose,- children,- }: {- isOpen?: boolean;- titleId?: string;- onClose?: () => void;- children?: Snippet;- } = $props();-- let dialogEl = $state<HTMLDialogElement | null>(null);- let previousFocusEl = $state<HTMLElement | null>(null);- let closing = $state(false);-- $effect(() => {- if (!dialogEl) return;- if (isOpen && !dialogEl.open) {- previousFocusEl = document.activeElement as HTMLElement;- dialogEl.showModal();- } else if (!isOpen && dialogEl.open && !closing) {- closing = true;- setTimeout(() => {- closing = false;- dialogEl?.close();- previousFocusEl?.focus();- previousFocusEl = null;- }, 150);- }- });-- function handleClose() {- closing = true;- setTimeout(() => {- closing = false;- dialogEl?.close();- isOpen = false;- onClose?.();- previousFocusEl?.focus();- previousFocusEl = null;- }, 150);- }-- function handleBackdropClick(e: MouseEvent) {- if (e.target === dialogEl) {- handleClose();- }- }-</script>--<dialog- bind:this={dialogEl}- class="dialog-container"- class:closing- aria-labelledby={titleId}- aria-modal="true"- onclick={handleBackdropClick}- oncancel={(e) => {- e.preventDefault();- handleClose();- }}->- <div class="dialog-content">- {@render children?.()}- </div>-</dialog>--<style>- .dialog-container {- border: none;- border-radius: var(--radius-lg);- background: var(--surface);- color: var(--text);- padding: 0;- width: 92%;- max-width: 540px;- max-height: 80vh;- animation: dialog-in var(--duration-base) var(--ease-out);- box-shadow: var(--elev-3);- }-- .dialog-container::backdrop {- background: rgba(0, 0, 0, 0.55);- backdrop-filter: blur(8px);- -webkit-backdrop-filter: blur(8px);- animation: backdrop-in var(--duration-base) var(--ease-out);- }-- .dialog-container.closing {- animation: dialog-out var(--duration-base) var(--ease-out) forwards;- }-- .dialog-container.closing::backdrop {- animation: backdrop-out var(--duration-base) var(--ease-out) forwards;- }-- @keyframes dialog-in {- from {- opacity: 0;- transform: scale(0.95);- }- to {- opacity: 1;- transform: scale(1);- }- }-- @keyframes dialog-out {- from {- opacity: 1;- transform: scale(1);- }- to {- opacity: 0;- transform: scale(0.96);- }- }-- @keyframes backdrop-in {- from {- opacity: 0;- }- to {- opacity: 1;- }- }-- @keyframes backdrop-out {- from {- opacity: 1;- }- to {- opacity: 0;- }- }-- .dialog-content {- display: flex;- flex-direction: column;- max-height: 80vh;- }-- @media (prefers-reduced-motion: reduce) {- .dialog-container {- animation: none;- }-- .dialog-container::backdrop {- animation: none;- }-- .dialog-container.closing {- animation: none;- }-- .dialog-container.closing::backdrop {- animation: none;- }- }-</style>+<script lang="ts">+ import type { Snippet } from "svelte";++ let {+ isOpen = $bindable(false),+ titleId = "dialog-title",+ onClose,+ children,+ }: {+ isOpen?: boolean;+ titleId?: string;+ onClose?: () => void;+ children?: Snippet;+ } = $props();++ let dialogEl = $state<HTMLDialogElement | null>(null);+ let previousFocusEl = $state<HTMLElement | null>(null);+ let closing = $state(false);++ $effect(() => {+ if (!dialogEl) return;+ if (isOpen && !dialogEl.open) {+ previousFocusEl = document.activeElement as HTMLElement;+ dialogEl.showModal();+ } else if (!isOpen && dialogEl.open && !closing) {+ closing = true;+ setTimeout(() => {+ closing = false;+ dialogEl?.close();+ previousFocusEl?.focus();+ previousFocusEl = null;+ }, 150);+ }+ });++ function handleClose() {+ closing = true;+ setTimeout(() => {+ closing = false;+ dialogEl?.close();+ isOpen = false;+ onClose?.();+ previousFocusEl?.focus();+ previousFocusEl = null;+ }, 150);+ }++ function handleBackdropClick(e: MouseEvent) {+ if (e.target === dialogEl) {+ handleClose();+ }+ }+</script>++<dialog+ bind:this={dialogEl}+ class="dialog-container"+ class:closing+ aria-labelledby={titleId}+ aria-modal="true"+ onclick={handleBackdropClick}+ oncancel={(e) => {+ e.preventDefault();+ handleClose();+ }}+>+ <div class="dialog-content">+ {@render children?.()}+ </div>+</dialog>++<style>+ .dialog-container {+ border: 1px solid var(--border);+ border-radius: var(--radius-xl);+ background: var(--popup-bg);+ color: var(--text);+ padding: 0;+ width: 92%;+ max-width: 540px;+ max-height: 80vh;+ animation: dialog-in var(--duration-base) var(--ease-out);+ box-shadow: var(--elev-3);+ }++ .dialog-container::backdrop {+ background: var(--dialog-backdrop);+ animation: backdrop-in var(--duration-base) var(--ease-out);+ }++ .dialog-container.closing {+ animation: dialog-out var(--duration-base) var(--ease-out) forwards;+ }++ .dialog-container.closing::backdrop {+ animation: backdrop-out var(--duration-base) var(--ease-out) forwards;+ }++ @keyframes dialog-in {+ from {+ opacity: 0;+ transform: scale(0.95);+ }+ to {+ opacity: 1;+ transform: scale(1);+ }+ }++ @keyframes dialog-out {+ from {+ opacity: 1;+ transform: scale(1);+ }+ to {+ opacity: 0;+ transform: scale(0.96);+ }+ }++ @keyframes backdrop-in {+ from {+ opacity: 0;+ }+ to {+ opacity: 1;+ }+ }++ @keyframes backdrop-out {+ from {+ opacity: 1;+ }+ to {+ opacity: 0;+ }+ }++ .dialog-content {+ display: flex;+ flex-direction: column;+ max-height: 80vh;+ }++ @media (prefers-reduced-motion: reduce) {+ .dialog-container {+ animation: none;+ }++ .dialog-container::backdrop {+ animation: none;+ }++ .dialog-container.closing {+ animation: none;+ }++ .dialog-container.closing::backdrop {+ animation: none;+ }+ }+</style>diff --git a/src/components/onboarding/OnboardingWizard.svelte b/src/components/onboarding/OnboardingWizard.svelteindex cb3902c4..16ff38c9 100644--- a/src/components/onboarding/OnboardingWizard.svelte+++ b/src/components/onboarding/OnboardingWizard.svelte@@ -626,22 +626,20 @@.install-all-btn {margin-top: calc(var(--padding) / 2);padding: calc(var(--padding) / 2) var(--padding);- font-size: 13px;- background: var(--blue);- color: #fff;+ font-size: var(--text-base);+ background: var(--cta);+ color: var(--on-cta);box-shadow: none;}@media (hover: hover) {.install-all-btn:hover {- opacity: 0.9;- background: var(--blue);+ background: var(--cta-hover);}}.install-all-btn:active {- opacity: 0.85;- background: var(--blue);+ background: var(--cta-press);}.wizard-footer {@@ -666,7 +664,7 @@}.dot.active {- background: var(--blue);+ background: var(--accent);}.footer-actions {@@ -683,25 +681,23 @@.next-btn,.finish-btn {padding: calc(var(--padding) / 2) calc(var(--padding) * 1.5);- font-size: 13px;+ font-size: var(--text-base);font-weight: 500;- background: var(--secondary);- color: var(--secondary);+ background: var(--cta);+ color: var(--on-cta);box-shadow: none;}@media (hover: hover) {.next-btn:hover,.finish-btn:hover {- opacity: 0.9;- background: var(--secondary);+ background: var(--cta-hover);}}.next-btn:active,.finish-btn:active {- opacity: 0.85;- background: var(--secondary);+ background: var(--cta-press);}.next-btn:focus-visible,diff --git a/src/components/toast/Toast.svelte b/src/components/toast/Toast.svelteindex 57a69dc9..5b7d86aa 100644--- a/src/components/toast/Toast.svelte+++ b/src/components/toast/Toast.svelte@@ -1,160 +1,156 @@-<script lang="ts">- import { getToasts, dismissToast, type ToastType } from "$lib/stores/toast-store.svelte";- import { t } from "$lib/i18n";-- let toasts = $derived(getToasts());-- function iconPath(type: ToastType): string {- switch (type) {- case "success":- return "M5 12l5 5L20 7";- case "error":- return "M18 6L6 18M6 6l12 12";- case "info":- return "M12 8v4m0 4h.01M12 2a10 10 0 100 20 10 10 0 000-20z";- }- }-</script>--{#if toasts.length > 0}- <div class="toast-container" aria-live="polite" aria-atomic="false">- {#each toasts as toast (toast.id)}- <div- class="toast"- data-type={toast.type}- class:closing={toast.closing}- role={toast.type === "error" ? "alert" : "status"}- aria-live={toast.type === "error" ? "assertive" : "polite"}- >- <svg class="toast-icon" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">- <path d={iconPath(toast.type)} />- </svg>- <span class="toast-message">{toast.message}</span>- <button class="toast-close" onclick={() => dismissToast(toast.id)} aria-label={$t("common.close") as string}>- <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">- <path d="M18 6L6 18M6 6l12 12" />- </svg>- </button>- </div>- {/each}- </div>-{/if}--<style>- .toast-container {- position: fixed;- bottom: var(--space-3);- right: var(--space-3);- z-index: 9999;- display: flex;- flex-direction: column-reverse;- gap: var(--space-2);- pointer-events: none;- max-width: 400px;- }-- .toast {- display: flex;- align-items: center;- gap: var(--space-3);- padding: var(--space-4);- background: var(--surface-hi);- border-radius: var(--radius-md);- box-shadow: var(--elev-3);- border-left: 3px solid var(--info);- pointer-events: auto;- animation: toast-in var(--duration-bounce) var(--ease-spring);- }-- .toast[data-type="success"] { border-left-color: var(--success); }- .toast[data-type="error"] { border-left-color: var(--danger); }- .toast[data-type="info"] { border-left-color: var(--info); }-- .toast.closing {- animation: toast-out var(--duration-base) var(--ease-out) forwards;- }-- @keyframes toast-in {- from {- opacity: 0;- transform: translateY(-12px);- }- to {- opacity: 1;- transform: translateY(0);- }- }-- @keyframes toast-out {- from { opacity: 1; transform: translateY(0); }- to { opacity: 0; transform: translateY(-4px); }- }-- @media (prefers-reduced-motion: reduce) {- .toast {- animation: toast-fade-in var(--duration-base) ease-out;- }- .toast.closing {- animation: toast-fade-out var(--duration-base) ease-out forwards;- }- @keyframes toast-fade-in {- from { opacity: 0; }- to { opacity: 1; }- }- @keyframes toast-fade-out {- from { opacity: 1; }- to { opacity: 0; }- }- }-- .toast-icon {- flex-shrink: 0;- pointer-events: none;- }-- .toast[data-type="success"] .toast-icon { color: var(--success); }- .toast[data-type="error"] .toast-icon { color: var(--danger); }- .toast[data-type="info"] .toast-icon { color: var(--info); }-- .toast-message {- flex: 1;- font-size: var(--text-sm);- font-weight: 500;- color: var(--text);- min-width: 0;- word-break: break-word;- display: -webkit-box;- -webkit-line-clamp: 4;- line-clamp: 4;- -webkit-box-orient: vertical;- overflow: hidden;- }-- .toast-close {- flex-shrink: 0;- width: 24px;- height: 24px;- display: flex;- align-items: center;- justify-content: center;- border-radius: var(--radius-xs);- color: var(--text-dim);- cursor: pointer;- transition: color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);- }-- .toast-close :global(svg) {- pointer-events: none;- }-- @media (hover: hover) {- .toast-close:hover {- color: var(--secondary);- background: var(--button-stroke);- }- }-- .toast-close:active {- background: var(--content-border);- }-</style>+<script lang="ts">+ import { getToasts, dismissToast, type ToastType } from "$lib/stores/toast-store.svelte";+ import { t } from "$lib/i18n";++ let toasts = $derived(getToasts());++ function iconPath(type: ToastType): string {+ switch (type) {+ case "success":+ return "M5 12l5 5L20 7";+ case "error":+ return "M18 6L6 18M6 6l12 12";+ case "info":+ return "M12 8v4m0 4h.01M12 2a10 10 0 100 20 10 10 0 000-20z";+ }+ }+</script>++{#if toasts.length > 0}+ <div class="toast-container" aria-live="polite" aria-atomic="false">+ {#each toasts as toast (toast.id)}+ <div+ class="toast"+ data-type={toast.type}+ class:closing={toast.closing}+ role={toast.type === "error" ? "alert" : "status"}+ aria-live={toast.type === "error" ? "assertive" : "polite"}+ >+ <svg class="toast-icon" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">+ <path d={iconPath(toast.type)} />+ </svg>+ <span class="toast-message">{toast.message}</span>+ <button class="toast-close" onclick={() => dismissToast(toast.id)} aria-label={$t("common.close") as string}>+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ </button>+ </div>+ {/each}+ </div>+{/if}++<style>+ .toast-container {+ position: fixed;+ bottom: var(--space-3);+ right: var(--space-3);+ z-index: 9999;+ display: flex;+ flex-direction: column-reverse;+ gap: var(--space-2);+ pointer-events: none;+ max-width: 400px;+ }++ .toast {+ display: flex;+ align-items: center;+ gap: var(--space-2);+ padding: var(--space-3) var(--space-4);+ background: var(--popup-bg);+ border: 1px solid var(--border);+ border-radius: var(--radius-lg);+ box-shadow: var(--elev-2);+ pointer-events: auto;+ animation: toast-in var(--duration-bounce) var(--ease-spring);+ }++ .toast.closing {+ animation: toast-out var(--duration-base) var(--ease-out) forwards;+ }++ @keyframes toast-in {+ from {+ opacity: 0;+ transform: translateY(-12px);+ }+ to {+ opacity: 1;+ transform: translateY(0);+ }+ }++ @keyframes toast-out {+ from { opacity: 1; transform: translateY(0); }+ to { opacity: 0; transform: translateY(-4px); }+ }++ @media (prefers-reduced-motion: reduce) {+ .toast {+ animation: toast-fade-in var(--duration-base) ease-out;+ }+ .toast.closing {+ animation: toast-fade-out var(--duration-base) ease-out forwards;+ }+ @keyframes toast-fade-in {+ from { opacity: 0; }+ to { opacity: 1; }+ }+ @keyframes toast-fade-out {+ from { opacity: 1; }+ to { opacity: 0; }+ }+ }++ .toast-icon {+ flex-shrink: 0;+ pointer-events: none;+ }++ .toast[data-type="success"] .toast-icon { color: var(--success); }+ .toast[data-type="error"] .toast-icon { color: var(--danger); }+ .toast[data-type="info"] .toast-icon { color: var(--info); }++ .toast-message {+ flex: 1;+ font-size: var(--text-sm);+ font-weight: 500;+ color: var(--text);+ min-width: 0;+ word-break: break-word;+ display: -webkit-box;+ -webkit-line-clamp: 4;+ line-clamp: 4;+ -webkit-box-orient: vertical;+ overflow: hidden;+ }++ .toast-close {+ flex-shrink: 0;+ width: 24px;+ height: 24px;+ display: flex;+ align-items: center;+ justify-content: center;+ border-radius: var(--radius-xs);+ color: var(--text-dim);+ cursor: pointer;+ transition: color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);+ }++ .toast-close :global(svg) {+ pointer-events: none;+ }++ @media (hover: hover) {+ .toast-close:hover {+ color: var(--secondary);+ background: var(--button-stroke);+ }+ }++ .toast-close:active {+ background: var(--content-border);+ }+</style>diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelteindex 4a9dde15..cecee196 100644--- a/src/routes/+layout.svelte+++ b/src/routes/+layout.svelte@@ -418,12 +418,13 @@}.ytdlp-banner-link {- background: var(--warning);- color: #fff;+ background: var(--cta);+ color: var(--on-cta);border: none;- font-size: 12px;+ font-size: var(--text-sm);+ font-weight: 500;padding: 4px 10px;- border-radius: calc(var(--border-radius) - 4px);+ border-radius: var(--radius-sm);cursor: pointer;white-space: nowrap;box-shadow: none;@@ -431,10 +432,19 @@@media (hover: hover) {.ytdlp-banner-link:hover {- background: color-mix(in srgb, var(--warning) 65%, black);+ background: var(--cta-hover);}}+ .ytdlp-banner-link:active {+ background: var(--cta-press);+ }++ .ytdlp-banner-link:focus-visible {+ outline: var(--focus-ring);+ outline-offset: var(--focus-ring-offset);+ }+.ytdlp-banner-close {background: none;border: none;diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelteindex b482c977..f1855485 100644--- a/src/routes/about/+page.svelte+++ b/src/routes/about/+page.svelte@@ -32,10 +32,12 @@<header class="about-hero"><img src="/favicon.png" alt="" class="about-app-icon" width="64" height="64" draggable="false" /><div class="about-identity">- <h1>OmniGet</h1>- {#if version}- <span class="about-version">{$t("about.version")} {version}</span>- {/if}+ <div class="about-name-row">+ <h1>OmniGet</h1>+ {#if version}+ <span class="tag about-version">{$t("about.version")} {version}</span>+ {/if}+ </div><p class="about-tagline">{$t("about.tagline")}</p><p class="about-desc">{$t("about.description")}</p>{#if buildDetails}@@ -46,22 +48,26 @@<div class="about-cards">{#each cards as card}- <a href={card.href} class="about-card">- <span class="about-card-title">{$t(card.titleKey)}</span>- <span class="about-card-desc">{$t(card.descKey)}</span>- <span class="about-card-chevron" aria-hidden="true">›</span>+ <a href={card.href} class="surface-card interactive about-card">+ <span class="list-row">+ <span class="list-row-content">+ <span class="list-row-title">{$t(card.titleKey)}</span>+ <span class="list-row-sub about-card-desc">{$t(card.descKey)}</span>+ </span>+ <span class="list-row-trailing about-card-chevron" aria-hidden="true">›</span>+ </span></a>{/each}</div><div class="about-external">- <a href="https://github.com/tonhowtf/omniget" target="_blank" rel="noopener" class="about-ext-link">+ <a href="https://github.com/tonhowtf/omniget" target="_blank" rel="noopener" class="btn about-ext-link"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"/></svg>{$t("about.star_button")}</a>- <a href="https://discord.gg/jgdxyPy7Vn" target="_blank" rel="noopener" class="about-ext-link">+ <a href="https://discord.gg/jgdxyPy7Vn" target="_blank" rel="noopener" class="btn about-ext-link"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18.9 5.3a16.6 16.6 0 0 0-4.1-1.3 12.2 12.2 0 0 0-.5 1.1 15.4 15.4 0 0 0-4.6 0A12.2 12.2 0 0 0 9.2 4a16.6 16.6 0 0 0-4.1 1.3A17.3 17.3 0 0 0 2 17.2a16.7 16.7 0 0 0 5.1 2.6 12.5 12.5 0 0 0 1.1-1.8 10.8 10.8 0 0 1-1.7-.8l.4-.3a11.9 11.9 0 0 0 10.2 0l.4.3a10.8 10.8 0 0 1-1.7.8 12.5 12.5 0 0 0 1.1 1.8 16.7 16.7 0 0 0 5.1-2.6A17.3 17.3 0 0 0 18.9 5.3zM8.7 14.8c-1 0-1.8-.9-1.8-2s.8-2 1.8-2 1.8.9 1.8 2-.8 2-1.8 2zm6.6 0c-1 0-1.8-.9-1.8-2s.8-2 1.8-2 1.8.9 1.8 2-.8 2-1.8 2z"/></svg>@@ -70,6 +76,7 @@</div><footer class="about-footer">+ <hr class="separator" /><p class="about-credit">{$t("about.credit")}</p><a href="https://github.com/tonhowtf" class="about-watermark" onclick={openAuthorGithub} title="@tonhowtf">@tonhowtf@@ -81,13 +88,14 @@.about-overview {display: flex;flex-direction: column;- gap: calc(var(--padding) * 2);+ gap: var(--space-6);}.about-hero {display: flex;align-items: flex-start;- gap: var(--space-4);+ gap: var(--space-5);+ padding: var(--space-6) 0 var(--space-2);}.about-app-icon {@@ -102,133 +110,96 @@.about-identity {display: flex;flex-direction: column;- gap: var(--space-1);+ gap: var(--space-2);min-width: 0;}+ .about-name-row {+ display: flex;+ align-items: center;+ gap: var(--space-3);+ flex-wrap: wrap;+ }+.about-identity h1 {font-family: var(--font-display);- font-size: var(--text-display);- line-height: var(--leading-display);- font-weight: 600;- letter-spacing: -0.03em;+ font-size: var(--text-2xl);+ line-height: var(--leading-2xl);+ font-weight: 700;+ letter-spacing: var(--track-tight);margin: 0;}.about-tagline {font-size: var(--text-md);+ line-height: var(--leading-md);color: var(--text-muted);margin: 0;}.about-desc {- font-size: var(--text-sm);- color: var(--text);+ font-size: var(--text-base);+ line-height: var(--leading-base);+ color: var(--text-muted);margin: 0;- max-width: 420px;- line-height: 1.5;- }-- .about-version {- font-size: var(--text-xs);- color: var(--text-dim);- width: fit-content;+ max-width: 60ch;}.about-build {font-family: var(--font-mono);font-size: var(--text-xs);color: var(--text-dim);- opacity: 0.75;- letter-spacing: 0.3px;user-select: all;}.about-cards {- display: grid;- grid-template-columns: repeat(2, minmax(0, 1fr));- gap: var(--space-3);+ display: flex;+ flex-direction: column;+ gap: var(--space-2);}.about-card {- position: relative;- display: flex;- flex-direction: column;- gap: var(--space-1);- padding: var(--space-4);- background: var(--surface);- border: 1px solid var(--border);- border-radius: var(--radius-md);+ display: block;text-decoration: none;color: inherit;- transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);}- @media (hover: hover) {- .about-card:hover {- background: var(--surface-hi);- border-color: color-mix(in srgb, var(--accent) 25%, var(--border));- }- }-- .about-card-title {- font-size: var(--text-sm);- font-weight: 600;- color: var(--text);+ .about-card .list-row {+ padding: var(--space-3) var(--space-4);}.about-card-desc {- font-size: var(--text-xs);- color: var(--text-muted);- line-height: 1.45;- padding-right: var(--space-4);+ white-space: normal;}.about-card-chevron {- position: absolute;- top: var(--space-4);- right: var(--space-3);- font-size: 18px;- color: var(--text-dim);+ font-size: var(--text-lg);line-height: 1;}.about-external {display: flex;- gap: var(--space-3);+ gap: var(--space-2);flex-wrap: wrap;}.about-ext-link {- display: flex;- align-items: center;- gap: var(--space-2);- padding: var(--space-2) var(--space-4);- background: var(--surface);- border: 1px solid var(--border);- border-radius: var(--radius-sm);- color: var(--text);- font-size: var(--text-sm);text-decoration: none;- transition: background var(--duration-fast) var(--ease-out);- }-- @media (hover: hover) {- .about-ext-link:hover {- background: var(--surface-hi);- }}.about-footer {display: flex;flex-direction: column;gap: var(--space-1);- padding-top: var(--space-2);- border-top: 1px solid var(--border);+ }++ .about-footer .separator {+ margin-bottom: var(--space-3);}.about-credit {font-size: var(--text-xs);+ line-height: var(--leading-xs);color: var(--text-muted);margin: 0;}@@ -236,31 +207,32 @@.about-watermark {font-size: var(--text-xs);color: var(--text-dim);- opacity: 0.6;text-decoration: none;width: fit-content;- transition: opacity var(--duration-fast) var(--ease-out);+ transition: color var(--duration-fast) var(--ease-out);}@media (hover: hover) {.about-watermark:hover {- opacity: 1;+ color: var(--text);}}- @media (max-width: 520px) {- .about-cards {- grid-template-columns: 1fr;+ @media (prefers-reduced-motion: reduce) {+ .about-watermark {+ transition: none;}+ }+ @media (max-width: 520px) {.about-hero {flex-direction: column;align-items: center;text-align: center;}- .about-desc {- max-width: none;+ .about-name-row {+ justify-content: center;}}</style>diff --git a/src/routes/downloads/+page.svelte b/src/routes/downloads/+page.svelteindex d1a03b58..fd1e568d 100644--- a/src/routes/downloads/+page.svelte+++ b/src/routes/downloads/+page.svelte@@ -1,1731 +1,1756 @@-<script lang="ts">- import { onMount } from "svelte";- import { goto } from "$app/navigation";- import { invoke } from "@tauri-apps/api/core";- import { pluginInvoke } from "$lib/plugin-invoke";- import { t } from "$lib/i18n";- import { translateBackendError } from "$lib/error-translate";- import { showToast } from "$lib/stores/toast-store.svelte";- import {- getDownloads,- formatBytes,- formatSpeed,- formatEta,- getFinishedCount,- getSpeedHistory,- type CourseDownloadItem,- type GenericDownloadItem,- type QueueKind,- } from "$lib/stores/download-store.svelte";- import { getDownloadStats } from "$lib/stores/download-stats.svelte";- import PlatformIcon from "$components/icons/PlatformIcon.svelte";- import QueueKindBadge from "$lib/study-components/QueueKindBadge.svelte";- import Mascot from "$components/mascot/Mascot.svelte";- import ContextHint from "$components/hints/ContextHint.svelte";- import DownloadSpeedGraph from "$components/download/DownloadSpeedGraph.svelte";- import DownloadLog from "$components/download/DownloadLog.svelte";- import ReencodeDialog from "$components/dialog/ReencodeDialog.svelte";- import ToolsPanel from "$components/downloads/ToolsPanel.svelte";- import VideoOpsOverlay from "$components/downloads/VideoOpsOverlay.svelte";- import { locale as i18nLocale } from "$lib/i18n";- import { get } from "svelte/store";- import timeAgo from "$lib/time-ago";-- let studyAvailable = $state(false);-- onMount(async () => {- try {- const plugins = await invoke<{- id: string;- enabled: boolean;- loaded: boolean;- }[]>("list_plugins");- studyAvailable = plugins.some(- (p) => p.id === "study" && p.enabled && p.loaded,- );- } catch {- studyAvailable = false;- }- });-- const VIDEO_EXTENSIONS = new Set([- "mp4", "mkv", "webm", "mov", "avi", "ts", "m4v", "flv", "wmv", "mpg", "mpeg", "3gp", "ogv", "m2ts", "mts",- ]);-- function fileExtension(path: string): string | null {- const name = path.replace(/\\/g, "/").split("/").pop() ?? "";- const dot = name.lastIndexOf(".");- if (dot <= 0 || dot === name.length - 1) return null;- return name.slice(dot + 1).toLowerCase();- }-- function isVideoItem(item: GenericDownloadItem): boolean {- if (item.filePath && (item.fileCount ?? 1) <= 1) {- const ext = fileExtension(item.filePath);- if (ext) return VIDEO_EXTENSIONS.has(ext);- }- if (item.downloadMode === "video") return true;- return item.queueKind === "video";- }-- function qualityChip(item: GenericDownloadItem): string | null {- if (item.downloadMode === "audio") return $t('omnibox.quality_audio') as string;- if (!item.quality) return null;- const q = item.quality.toLowerCase();- if (q === "audio") return $t('omnibox.quality_audio') as string;- if (!isVideoItem(item)) return null;- if (q === "best" || q === "highest") return $t('omnibox.quality_best_short') as string;- return item.quality;- }-- function canOpenInStudy(item: GenericDownloadItem): boolean {- return (- studyAvailable &&- item.status === "complete" &&- !!item.filePath &&- (item.queueKind === "video" || item.queueKind === "audio")- );- }-- function openInStudy(filePath: string) {- const parts = filePath.replace(/\\/g, "/").split("/");- const name = parts[parts.length - 1] ?? "";- const url = `/study/watch?path=${encodeURIComponent(filePath)}&name=${encodeURIComponent(name)}`;- goto(url);- }-- let downloads = $derived(getDownloads());- let courseList = $derived(- [...downloads.values()].filter((d): d is CourseDownloadItem => d.kind === "course")- );- let genericList = $derived(- [...downloads.values()].filter((d): d is GenericDownloadItem => d.kind === "generic")- );-- let grouped = $derived.by(() => {- const active: GenericDownloadItem[] = [];- const paused: GenericDownloadItem[] = [];- const queued: GenericDownloadItem[] = [];- const finished: GenericDownloadItem[] = [];- const errored: GenericDownloadItem[] = [];- const completed: GenericDownloadItem[] = [];- for (const d of genericList) {- if (d.status === "downloading" || d.status === "seeding") active.push(d);- else if (d.status === "paused") paused.push(d);- else if (d.status === "queued") queued.push(d);- else {- finished.push(d);- if (d.status === "error") errored.push(d);- else if (d.status === "complete") completed.push(d);- }- }- return { active, paused, queued, finished, errored, completed };- });-- type StatusFilter = "all" | "active" | "queued" | "completed" | "failed";- let statusFilter = $state<StatusFilter>("all");-- let filterCounts = $derived({- all: genericList.length,- active: grouped.active.length + grouped.paused.length,- queued: grouped.queued.length,- completed: grouped.completed.length,- failed: grouped.errored.length,- });-- let showSection = $derived({- active: statusFilter === "all" || statusFilter === "active",- queued: statusFilter === "all" || statusFilter === "queued",- completed: statusFilter === "all" || statusFilter === "completed",- failed: statusFilter === "all" || statusFilter === "failed",- });-- let finishedFiltered = $derived.by(() => {- if (statusFilter === "completed") return grouped.completed;- if (statusFilter === "failed") return grouped.errored;- return grouped.finished;- });-- const FINISHED_PAGE_SIZE = 20;- let finishedVisibleCount = $state(FINISHED_PAGE_SIZE);-- let visibleFinished = $derived(- finishedFiltered.length <= finishedVisibleCount- ? finishedFiltered- : finishedFiltered.slice(0, finishedVisibleCount)- );-- let hasDownloads = $derived(courseList.length > 0 || genericList.length > 0);- let finishedCount = $derived(getFinishedCount());- let dlStats = $derived(getDownloadStats());-- async function cancelDownload(courseId: number) {- try {- await pluginInvoke("courses", "cancel_course_download", { courseId });- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- async function cancelGenericDownload(id: number) {- try {- await invoke("cancel_generic_download", { downloadId: id });- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- async function pauseDownload(id: number) {- try {- await invoke("pause_download", { downloadId: id });- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- async function resumeDownload(id: number) {- try {- await invoke("resume_download", { downloadId: id });- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- async function retryDownload(id: number) {- try {- await invoke("retry_download", { downloadId: id });- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- let pendingRemove = $state<number | null>(null);- let pendingRemoveTimer = $state<ReturnType<typeof setTimeout> | null>(null);-- function removeItem(id: number) {- if (pendingRemove === id) {- if (pendingRemoveTimer) clearTimeout(pendingRemoveTimer);- pendingRemove = null;- pendingRemoveTimer = null;- invoke("remove_download", { downloadId: id }).catch((e: any) => {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- });- } else {- if (pendingRemoveTimer) clearTimeout(pendingRemoveTimer);- pendingRemove = id;- pendingRemoveTimer = setTimeout(() => {- pendingRemove = null;- pendingRemoveTimer = null;- }, 3000);- }- }-- async function removeItemWithFile(id: number) {- if (!confirm($t("downloads.delete_file_confirm"))) return;- try {- await invoke("remove_download", { downloadId: id, deleteFile: true });- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- async function clearFinished() {- if (!confirm($t("downloads.clear_confirm"))) return;- try {- await invoke("clear_finished_downloads");- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- async function pauseAll() {- try {- await invoke("pause_all_downloads");- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- async function resumeAll() {- try {- await invoke("resume_all_downloads");- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- async function revealFile(path: string) {- try {- await invoke("reveal_file", { path });- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- let reencodePath = $state<string | null>(null);-- function openReencode(path: string) {- reencodePath = path;- }-- let vopPath = $state<string | null>(null);-- type HistoryEntry = {- id: number;- url: string;- platform: string;- title: string;- file_path: string | null;- file_size_bytes: number | null;- total_bytes: number | null;- success: boolean;- error: string | null;- completed_at: number;- thumbnail_url: string | null;- kind: QueueKind | null;- };-- let viewMode = $state<"active" | "history" | "tools">("active");- let historyEntries = $state<HistoryEntry[]>([]);- let historyLoading = $state(false);-- async function loadHistory() {- historyLoading = true;- try {- historyEntries = await invoke<HistoryEntry[]>("get_download_history");- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- } finally {- historyLoading = false;- }- }-- async function clearHistory() {- if (!confirm($t("downloads.history_clear_confirm") as string)) return;- try {- await invoke("clear_download_history");- historyEntries = [];- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- function toggleHistoryView() {- if (viewMode === "history") {- viewMode = "active";- } else {- viewMode = "history";- loadHistory();- }- }-- function toggleToolsView() {- viewMode = viewMode === "tools" ? "active" : "tools";- }-- async function historyRetry(url: string, platform: string) {- try {- const settings = (await import("$lib/stores/settings-store.svelte")).getSettings();- const outputDir = settings?.download.default_output_dir ?? "";- if (!outputDir) {- showToast("error", $t("common.error") as string);- return;- }- await invoke("download_from_url", {- url,- outputDir,- downloadMode: null,- quality: settings?.download.video_quality ?? "best",- formatId: null,- referer: null,- });- viewMode = "active";- showToast("info", $t("downloads.history_requeued") as string);- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- function fmtHistoryTime(unixSec: number): string {- const ms = unixSec * 1000;- const loc = get(i18nLocale) || "en";- const lookup = loc.startsWith("pt") ? "pt" : "en";- return timeAgo(ms, lookup);- }-- function canPlayInStudyHistory(entry: HistoryEntry): boolean {- return (- studyAvailable &&- entry.success &&- !!entry.file_path &&- (entry.kind === "video" || entry.kind === "audio")- );- }-- function openHistoryInStudy(filePath: string) {- const parts = filePath.replace(/\\/g, "/").split("/");- const name = parts[parts.length - 1] ?? "";- const url = `/study/watch?path=${encodeURIComponent(filePath)}&name=${encodeURIComponent(name)}`;- goto(url);- }-- let dragId = $state<number | null>(null);- let dropTargetId = $state<number | null>(null);- let dropPosition = $state<"before" | "after">("before");-- function onDragStart(e: DragEvent, id: number) {- dragId = id;- if (e.dataTransfer) {- e.dataTransfer.effectAllowed = "move";- e.dataTransfer.setData("text/plain", String(id));- }- }-- function onDragOver(e: DragEvent, id: number) {- if (dragId === null || dragId === id) return;- e.preventDefault();- if (e.dataTransfer) e.dataTransfer.dropEffect = "move";- const target = e.currentTarget as HTMLElement;- const rect = target.getBoundingClientRect();- const midpoint = rect.top + rect.height / 2;- dropPosition = e.clientY < midpoint ? "before" : "after";- dropTargetId = id;- }-- function onDragLeave(e: DragEvent, id: number) {- if (dropTargetId === id) {- dropTargetId = null;- }- }-- async function onDrop(e: DragEvent, targetId: number) {- e.preventDefault();- const movingId = dragId;- const position = dropPosition;- dragId = null;- dropTargetId = null;- if (movingId === null || movingId === targetId) return;-- const order = grouped.queued.map((q) => q.id);- const fromIdx = order.indexOf(movingId);- if (fromIdx === -1) return;- order.splice(fromIdx, 1);- let targetIdx = order.indexOf(targetId);- if (targetIdx === -1) return;- if (position === "after") targetIdx += 1;- order.splice(targetIdx, 0, movingId);-- try {- await invoke<boolean>("reorder_queue", { ids: order });- } catch (e: any) {- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");- showToast("error", msg);- }- }-- function onDragEnd() {- dragId = null;- dropTargetId = null;- }-- function onKeydown(e: KeyboardEvent) {- const target = e.target as HTMLElement | null;- const tag = target?.tagName?.toLowerCase();- const isEditable =- tag === "input" ||- tag === "textarea" ||- tag === "select" ||- target?.isContentEditable;- if (isEditable) return;- if (e.ctrlKey && !e.altKey && !e.metaKey && !e.shiftKey && (e.key === "h" || e.key === "H")) {- e.preventDefault();- toggleHistoryView();- }- }-- onMount(() => {- window.addEventListener("keydown", onKeydown);- return () => window.removeEventListener("keydown", onKeydown);- });-</script>--{#if hasDownloads || viewMode !== "active"}- <div class="downloads-page">- <div class="downloads-header">- <div class="downloads-title-row">- <h2 class="page-title">{$t('downloads.title')}</h2>- {#if dlStats.totalDownloads > 0}- <span class="downloads-stats">{$t('downloads.stats_line', { count: String(dlStats.totalDownloads), size: formatBytes(dlStats.totalBytes) })}</span>- {/if}- </div>- <div class="bulk-actions">- {#if viewMode === "active"}- {#if grouped.active.length > 0}- <button class="clear-btn" onclick={pauseAll} title={$t('downloads.pause_all') as string}>- {$t('downloads.pause_all')}- </button>- {/if}- {#if grouped.paused.length > 0}- <button class="clear-btn" onclick={resumeAll} title={$t('downloads.resume_all') as string}>- {$t('downloads.resume_all')}- </button>- {/if}- {#if finishedCount > 0}- <button class="clear-btn" onclick={clearFinished}>- {$t('downloads.clear_finished')}- </button>- {/if}- {:else if historyEntries.length > 0}- <button class="clear-btn" onclick={clearHistory}>- {$t('downloads.history_clear')}- </button>- {/if}- <button- class="history-toggle"- class:on={viewMode === "history"}- onclick={toggleHistoryView}- aria-label={$t('downloads.history_toggle') as string}- title={$t('downloads.history_toggle_hint') as string}- >- <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <circle cx="12" cy="12" r="9" />- <polyline points="12 7 12 12 15 14" />- </svg>- </button>- <button- class="history-toggle"- class:on={viewMode === "tools"}- onclick={toggleToolsView}- aria-label={$t('tools.tab') as string}- title={$t('tools.tab') as string}- >- <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.6 2.6-2.4-2.4z" />- </svg>- </button>- </div>- </div>-- {#if viewMode === "active"}- <div class="filter-pills" role="tablist" aria-label={$t('downloads.filter_label')}>- {#each [- { value: 'all', labelKey: 'downloads.filter.all', count: filterCounts.all },- { value: 'active', labelKey: 'downloads.filter.active', count: filterCounts.active },- { value: 'queued', labelKey: 'downloads.filter.queued', count: filterCounts.queued },- { value: 'completed', labelKey: 'downloads.filter.completed', count: filterCounts.completed },- { value: 'failed', labelKey: 'downloads.filter.failed', count: filterCounts.failed },- ] as pill}- <button- type="button"- class="filter-pill"- class:active={statusFilter === pill.value}- role="tab"- aria-selected={statusFilter === pill.value}- onclick={() => { statusFilter = pill.value as StatusFilter; finishedVisibleCount = FINISHED_PAGE_SIZE; }}- >- <span>{$t(pill.labelKey)}</span>- <span class="filter-count">{pill.count}</span>- </button>- {/each}- </div>-- <div class="download-list">- {#if showSection.active}- {#each grouped.active as item (item.id)}- {@render genericItem(item)}- {/each}-- {#each grouped.paused as item (item.id)}- {@render genericItem(item)}- {/each}-- {#each courseList as item (item.id)}- {@render courseItem(item)}- {/each}- {/if}-- {#if showSection.queued && grouped.queued.length > 0}- <h5 class="section-label">- {$t('downloads.section_queued')}- {#if grouped.queued.length > 1}- <span class="queue-reorder-hint">{$t('downloads.reorder_hint')}</span>- {/if}- </h5>- {#each grouped.queued as item (item.id)}- <div- class="queue-drop-zone"- class:drop-before={dropTargetId === item.id && dropPosition === "before"}- class:drop-after={dropTargetId === item.id && dropPosition === "after"}- class:dragging={dragId === item.id}- draggable="true"- role="listitem"- ondragstart={(e) => onDragStart(e, item.id)}- ondragover={(e) => onDragOver(e, item.id)}- ondragleave={(e) => onDragLeave(e, item.id)}- ondrop={(e) => onDrop(e, item.id)}- ondragend={onDragEnd}- >- {@render genericItem(item)}- </div>- {/each}- {/if}-- {#if (showSection.completed || showSection.failed) && finishedFiltered.length > 0}- <h5 class="section-label">{$t('downloads.section_finished')}</h5>- {#each visibleFinished as item (item.id)}- {@render genericItem(item)}- {/each}- {#if finishedFiltered.length > finishedVisibleCount}- <button- class="button show-more-btn"- onclick={() => { finishedVisibleCount += FINISHED_PAGE_SIZE; }}- >- {$t('downloads.show_more', { count: finishedFiltered.length - finishedVisibleCount })}- </button>- {/if}- {/if}- </div>- {:else if viewMode === "history"}- <div class="history-view">- {#if historyLoading}- <p class="history-empty">{$t('downloads.history_loading')}</p>- {:else if historyEntries.length === 0}- <div class="history-empty-state">- <svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">- <circle cx="12" cy="12" r="9" />- <polyline points="12 7 12 12 15 14" />- </svg>- <p class="history-empty-text">{$t('downloads.history_empty')}</p>- </div>- {:else}- <ul class="history-list">- {#each historyEntries as entry (entry.id)}- <li class="history-item" data-success={entry.success}>- <div class="history-item-head">- {#if entry.thumbnail_url}- <img- src={entry.thumbnail_url}- alt=""- class="queue-thumb"- loading="lazy"- onerror={(e) => { (e.target as HTMLImageElement).style.display = 'none'; }}- />- {/if}- <PlatformIcon platform={entry.platform} size={16} />- {#if entry.kind}- <QueueKindBadge kind={entry.kind} size={14} />- {/if}- <span class="history-title">{entry.title || entry.url}</span>- <span class="history-time">{fmtHistoryTime(entry.completed_at)}</span>- </div>- <div class="history-item-meta">- {#if entry.success && entry.file_size_bytes}- <span class="history-meta-chip">{formatBytes(entry.file_size_bytes)}</span>- {/if}- {#if !entry.success && entry.error}- <span class="history-meta-chip history-meta-error">{entry.error}</span>- {/if}- </div>- <div class="history-item-actions">- {#if canPlayInStudyHistory(entry) && entry.file_path}- <button- class="action-icon-btn"- onclick={() => openHistoryInStudy(entry.file_path!)}- aria-label={$t('downloads.open_in_study')}- title={$t('downloads.open_in_study')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <circle cx="12" cy="12" r="10" />- <polygon points="10 8 16 12 10 16 10 8" fill="currentColor" stroke="none" />- </svg>- </button>- {/if}- {#if entry.success && entry.file_path}- <button- class="action-icon-btn"- onclick={() => revealFile(entry.file_path!)}- aria-label={$t('downloads.open_folder')}- title={$t('downloads.open_folder')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />- </svg>- </button>- {/if}- {#if entry.success && entry.file_path && entry.kind === "video"}- <button- class="action-icon-btn"- onclick={() => openReencode(entry.file_path!)}- aria-label={$t('reencode.action_label')}- title={$t('reencode.action_label')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <polyline points="4 14 10 14 10 20" />- <polyline points="20 10 14 10 14 4" />- <line x1="14" y1="10" x2="21" y2="3" />- <line x1="3" y1="21" x2="10" y2="14" />- </svg>- </button>- {/if}- <button- class="action-icon-btn"- onclick={() => historyRetry(entry.url, entry.platform)}- aria-label={$t('downloads.history_redownload')}- title={$t('downloads.history_redownload')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <polyline points="23 4 23 10 17 10" />- <path d="M20.49 15a9 9 0 11-2.12-9.36L23 10" />- </svg>- </button>- </div>- </li>- {/each}- </ul>- {/if}- </div>- {:else}- <ToolsPanel />- {/if}- </div>-{:else}- <div class="downloads-empty">- <Mascot emotion="idle" />- <p class="empty-text">{$t('downloads.empty')} <ContextHint text={$t('hints.downloads_empty')} dismissKey="downloads_empty" /></p>- <div class="empty-links">- <button class="history-link" onclick={toggleHistoryView}>- <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">- <circle cx="12" cy="12" r="9" />- <polyline points="12 7 12 12 15 14" />- </svg>- {$t('downloads.history_view_link')}- </button>- <button class="history-link" onclick={toggleToolsView}>- <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">- <path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.6 2.6-2.4-2.4z" />- </svg>- {$t('tools.tab')}- </button>- </div>- </div>-{/if}--<ReencodeDialog bind:inputPath={reencodePath} />--{#if vopPath}- <VideoOpsOverlay filePath={vopPath} onClose={() => (vopPath = null)} />-{/if}--{#snippet genericItem(item: GenericDownloadItem)}- <div class="download-item" data-status={item.status}>- <div class="item-header">- <div class="item-header-left">- {#if item.thumbnail_url}- <img- src={item.thumbnail_url}- alt=""- class="queue-thumb"- loading="lazy"- onerror={(e) => {- (e.target as HTMLImageElement).style.display = 'none';- }}- />- {/if}- <PlatformIcon platform={item.platform} size={16} />- <QueueKindBadge kind={item.queueKind} size={14} />- <span class="item-name">{item.name}</span>- {#if qualityChip(item)}- <span class="quality-chip" title={$t('downloads.quality_hint')}>{qualityChip(item)}</span>- {/if}- </div>- <div class="item-header-actions">- {#if item.status === "downloading"}- <button- class="action-icon-btn"- onclick={() => pauseDownload(item.id)}- aria-label={$t('downloads.pause')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <rect x="6" y="4" width="4" height="16" />- <rect x="14" y="4" width="4" height="16" />- </svg>- </button>- <button- class="action-icon-btn"- onclick={() => cancelGenericDownload(item.id)}- aria-label={$t('downloads.cancel')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M18 6L6 18M6 6l12 12" />- </svg>- </button>- {:else if item.status === "seeding"}- {#if item.filePath}- <button- class="action-icon-btn"- onclick={() => revealFile(item.filePath!)}- aria-label={$t('downloads.open_folder')}- title={$t('downloads.open_folder')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />- </svg>- </button>- {/if}- <button- class="action-icon-btn"- onclick={() => removeItem(item.id)}- aria-label={$t('downloads.stop')}- title={$t('downloads.stop')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">- <rect x="6" y="6" width="12" height="12" />- </svg>- </button>- {:else if item.status === "paused"}- <button- class="action-icon-btn"- onclick={() => resumeDownload(item.id)}- aria-label={$t('downloads.resume')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <polygon points="5 3 19 12 5 21 5 3" />- </svg>- </button>- <button- class="action-icon-btn"- onclick={() => cancelGenericDownload(item.id)}- aria-label={$t('downloads.cancel')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M18 6L6 18M6 6l12 12" />- </svg>- </button>- {:else if item.status === "error"}- <button- class="action-icon-btn"- onclick={() => retryDownload(item.id)}- aria-label={$t('downloads.retry')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <polyline points="23 4 23 10 17 10" />- <path d="M20.49 15a9 9 0 11-2.12-9.36L23 10" />- </svg>- </button>- <button- class="action-icon-btn"- class:confirm-remove={pendingRemove === item.id}- onclick={() => removeItem(item.id)}- aria-label={pendingRemove === item.id ? $t('downloads.confirm_remove') : $t('common.close')}- title={pendingRemove === item.id ? $t('downloads.confirm_remove') : undefined}- >- {#if pendingRemove === item.id}- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M5 12l5 5L20 7" />- </svg>- {:else}- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M18 6L6 18M6 6l12 12" />- </svg>- {/if}- </button>- {:else if item.status === "complete" && item.filePath}- {#if canOpenInStudy(item)}- <button- class="action-icon-btn"- onclick={() => openInStudy(item.filePath!)}- aria-label={$t('downloads.open_in_study')}- title={$t('downloads.open_in_study')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <circle cx="12" cy="12" r="10" />- <polygon points="10 8 16 12 10 16 10 8" fill="currentColor" stroke="none" />- </svg>- </button>- {/if}- <button- class="action-icon-btn"- onclick={() => revealFile(item.filePath!)}- aria-label={$t('downloads.open_folder')}- title={$t('downloads.open_folder')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />- </svg>- </button>- {#if item.queueKind === "video"}- <button- class="action-icon-btn"- onclick={() => openReencode(item.filePath!)}- aria-label={$t('reencode.action_label')}- title={$t('reencode.action_label')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <polyline points="4 14 10 14 10 20" />- <polyline points="20 10 14 10 14 4" />- <line x1="14" y1="10" x2="21" y2="3" />- <line x1="3" y1="21" x2="10" y2="14" />- </svg>- </button>- {/if}- <button- class="action-icon-btn"- class:confirm-remove={pendingRemove === item.id}- onclick={() => removeItem(item.id)}- aria-label={pendingRemove === item.id ? $t('downloads.confirm_remove') : $t('common.close')}- title={pendingRemove === item.id ? $t('downloads.confirm_remove') : undefined}- >- {#if pendingRemove === item.id}- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M5 12l5 5L20 7" />- </svg>- {:else}- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M18 6L6 18M6 6l12 12" />- </svg>- {/if}- </button>- {:else if item.status === "complete"}- {#if item.filePath && item.queueKind === "video"}- <button- class="action-icon-btn"- onclick={() => (vopPath = item.filePath!)}- aria-label={$t('downloads.vop.action_label')}- title={$t('downloads.vop.action_label')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M12 2 2 7l10 5 10-5-10-5Z" />- <path d="m2 17 10 5 10-5M2 12l10 5 10-5" />- </svg>- </button>- {/if}- {#if item.filePath}- <button- class="action-icon-btn"- onclick={() => removeItemWithFile(item.id)}- aria-label={$t('downloads.delete_file')}- title={$t('downloads.delete_file')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <polyline points="3 6 5 6 21 6" />- <path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />- <line x1="10" y1="11" x2="10" y2="17" />- <line x1="14" y1="11" x2="14" y2="17" />- </svg>- </button>- {/if}- <button- class="action-icon-btn"- class:confirm-remove={pendingRemove === item.id}- onclick={() => removeItem(item.id)}- aria-label={pendingRemove === item.id ? $t('downloads.confirm_remove') : $t('common.close')}- title={pendingRemove === item.id ? $t('downloads.confirm_remove') : undefined}- >- {#if pendingRemove === item.id}- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M5 12l5 5L20 7" />- </svg>- {:else}- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M18 6L6 18M6 6l12 12" />- </svg>- {/if}- </button>- {:else if item.status === "queued"}- <button- class="action-icon-btn"- onclick={() => cancelGenericDownload(item.id)}- aria-label={$t('downloads.cancel')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M18 6L6 18M6 6l12 12" />- </svg>- </button>- {/if}- <span class="item-status" data-status={item.status}>- {$t(`downloads.status.${item.status}`)}- </span>- </div>- </div>-- {#if item.status === "downloading"}- {#if item.phase === "preparing"}- <span class="item-detail">{$t('downloads.phase_preparing')}</span>- {:else if item.phase === "fetching_info"}- <span class="item-detail">{$t('downloads.phase_fetching_info')}</span>- {:else if item.phase === "starting"}- <span class="item-detail">{$t('downloads.phase_starting')}</span>- {:else if item.phase === "connecting"}- <span class="item-detail">{$t('downloads.phase_connecting')}</span>- {:else}- <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>- <div class="item-stats">- {#if item.downloadedBytes > 0}- <span>- {formatBytes(item.downloadedBytes)}{#if item.totalBytes} / {formatBytes(item.totalBytes)}{/if}- </span>- <span class="stats-sep">·</span>- {/if}- {#if item.speed > 0}- <span>{formatSpeed(item.speed)}</span>- {#if formatEta(item.etaSeconds)}- <span class="stats-sep">·</span>- <span>ETA {formatEta(item.etaSeconds)}</span>- {/if}- <DownloadSpeedGraph points={getSpeedHistory(item.id)} />- {/if}- </div>- {/if}- {:else if item.status === "seeding"}- <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>- <div class="item-stats">- {#if item.totalBytes}- <span>{formatBytes(item.totalBytes)}</span>- <span class="stats-sep">·</span>- {/if}- {#if item.speed > 0}- <span>{formatSpeed(item.speed)}</span>- <DownloadSpeedGraph points={getSpeedHistory(item.id)} />- {/if}- </div>- {:else if item.status === "paused"}- <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>- {#if item.downloadedBytes > 0}- <div class="item-stats">- <span>{formatBytes(item.downloadedBytes)}{#if item.totalBytes} / {formatBytes(item.totalBytes)}{/if}</span>- </div>- {/if}- {:else if item.status === "queued"}- <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>- {:else}- <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>- {/if}-- {#if item.status === "complete" && item.totalBytes}- <span class="item-detail">{formatBytes(item.totalBytes)}</span>- {/if}-- {#if item.status === "error" && item.error}- <span class="item-error">{translateBackendError(item.error, $t)}</span>- {/if}-- {#if item.status !== "queued"}- <div class="progress-track">- <div- class="progress-fill"- data-status={item.status}- style="width: {Math.max(0, item.percent).toFixed(1)}%"- ></div>- </div>- <span class="item-percent">{Math.max(0, item.percent).toFixed(0)}%</span>- {/if}-- {#if item.status !== "queued"}- <DownloadLog id={item.id} />- {/if}- </div>-{/snippet}--{#snippet courseItem(item: CourseDownloadItem)}- <div class="download-item" data-status={item.status}>- <div class="item-header">- <span class="item-name">{item.name}</span>- <div class="item-header-actions">- {#if item.status === "downloading"}- <button- class="action-icon-btn"- onclick={() => cancelDownload(item.id)}- aria-label={$t('downloads.cancel')}- >- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">- <path d="M18 6L6 18M6 6l12 12" />- </svg>- </button>- {/if}- <span class="item-status" data-status={item.status}>- {$t(`downloads.status.${item.status}`)}- </span>- </div>- </div>-- {#if item.status === "downloading"}- {#if item.currentModule}- <span class="item-detail">- {item.currentModule} · {item.currentPage}- </span>- {/if}-- <div class="item-stats">- {#if item.totalPages > 0}- <span>{$t('downloads.page_progress', { current: item.completedPages, total: item.totalPages })}</span>- <span class="stats-sep">·</span>- <span>{$t('downloads.module_progress', { current: item.currentModuleIndex, total: item.totalModules })}</span>- {/if}- {#if item.bytesDownloaded > 0}- <span class="stats-sep">·</span>- <span>{formatBytes(item.bytesDownloaded)}</span>- {/if}- </div>-- <div class="item-stats">- <span>{formatSpeed(item.speed)}</span>- {#if item.speed > 0}- <DownloadSpeedGraph points={getSpeedHistory(item.id)} />- {/if}- </div>- {/if}-- {#if item.status === "complete" && item.bytesDownloaded > 0}- <span class="item-detail">{formatBytes(item.bytesDownloaded)}</span>- {/if}-- {#if item.status === "error" && item.error}- <span class="item-error">{translateBackendError(item.error, $t)}</span>- {/if}-- <div class="progress-track">- <div- class="progress-fill"- data-status={item.status}- style="width: {Math.max(0, item.percent).toFixed(1)}%"- ></div>- </div>-- <span class="item-percent">{Math.max(0, item.percent).toFixed(1)}%</span>-- {#if item.status !== "queued"}- <DownloadLog id={item.id} />- {/if}- </div>-{/snippet}--<style>- .downloads-empty {- display: flex;- flex-direction: column;- align-items: center;- justify-content: center;- min-height: calc(100vh - var(--padding) * 4);- gap: calc(var(--padding) * 1.5);- color: var(--gray);- }-- .empty-text {- font-size: 14.5px;- }-- .downloads-page {- display: flex;- flex-direction: column;- gap: calc(var(--padding) * 1.5);- padding: calc(var(--padding) * 1.5);- max-width: 800px;- margin: 0 auto;- width: 100%;- }-- .downloads-page h2 {- margin-block: 0;- }-- .downloads-header {- display: flex;- align-items: center;- justify-content: space-between;- gap: var(--padding);- }-- .downloads-title-row {- display: flex;- align-items: baseline;- gap: 10px;- }-- .downloads-stats {- font-size: 12px;- color: var(--tertiary);- font-weight: 400;- }-- .bulk-actions {- display: flex;- align-items: center;- gap: calc(var(--padding) / 3);- flex-shrink: 0;- }-- .clear-btn {- font-size: 12.5px;- font-weight: 500;- padding: calc(var(--padding) / 3) calc(var(--padding) * 0.75);- background: var(--button-elevated);- color: var(--gray);- border: none;- border-radius: calc(var(--border-radius) / 2);- cursor: pointer;- flex-shrink: 0;- }-- @media (hover: hover) {- .clear-btn:hover {- background: var(--button-elevated-hover);- color: var(--secondary);- }- }-- .clear-btn:active {- background: var(--button-elevated-press);- }-- .clear-btn:focus-visible {- outline: var(--focus-ring);- outline-offset: var(--focus-ring-offset);- }-- .section-label {- color: var(--gray);- text-transform: uppercase;- letter-spacing: 0.5px;- margin-block: 0;- padding-top: calc(var(--padding) / 2);- }-- .filter-pills {- display: flex;- flex-wrap: wrap;- gap: 6px;- margin-bottom: var(--padding);- }-- .filter-pill {- display: inline-flex;- align-items: center;- gap: var(--space-2);- padding: var(--space-2) var(--space-3);- font-size: var(--text-sm);- font-weight: 500;- border: 1px solid var(--border);- border-radius: var(--radius-full);- background: var(--surface);- color: var(--text-dim);- cursor: pointer;- transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);- }-- @media (hover: hover) {- .filter-pill:hover {- background: var(--surface-hi);- color: var(--text);- }- }-- .filter-pill.active {- background: var(--accent-soft);- color: var(--accent);- border-color: transparent;- }-- @media (prefers-reduced-motion: reduce) {- .filter-pill {- transition: none;- }- }-- .filter-pill:focus-visible {- outline: var(--focus-ring);- outline-offset: var(--focus-ring-offset);- }-- .filter-count {- display: inline-flex;- align-items: center;- justify-content: center;- min-width: 20px;- padding: 0 5px;- font-size: 10px;- font-weight: 600;- background: color-mix(in srgb, var(--surface) 70%, var(--bg-overlay));- border-radius: 9999px;- }-- .filter-pill.active .filter-count {- background: color-mix(in srgb, var(--on-accent) 22%, transparent);- }-- .download-list {- display: flex;- flex-direction: column;- gap: var(--padding);- }-- .download-item {- background: var(--surface);- border-radius: var(--radius-md);- box-shadow: var(--elev-1);- border-left: 3px solid transparent;- padding: var(--space-4);- display: flex;- flex-direction: column;- gap: var(--space-2);- transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);- }-- @media (hover: hover) {- .download-item:hover {- transform: translateY(-1px);- box-shadow: var(--elev-2);- }- }-- .download-item[data-status="downloading"] { border-left-color: var(--accent); }- .download-item[data-status="seeding"] { border-left-color: var(--success); }- .download-item[data-status="complete"] { border-left-color: var(--success); }- .download-item[data-status="error"] { border-left-color: var(--danger); }- .download-item[data-status="paused"] { border-left-color: var(--warning); }- .download-item[data-status="queued"] { opacity: 0.7; }-- @media (prefers-reduced-motion: reduce) {- .download-item {- transition: none;- }- .download-item:hover {- transform: none;- }- }-- .item-header {- display: flex;- align-items: center;- justify-content: space-between;- gap: var(--padding);- }-- .item-header-actions {- display: flex;- align-items: center;- gap: calc(var(--padding) / 2);- flex-shrink: 0;- }-- .item-header-left {- display: flex;- align-items: center;- gap: calc(var(--padding) / 2);- min-width: 0;- flex: 1;- }-- .queue-thumb {- width: 48px;- height: 48px;- border-radius: 6px;- object-fit: cover;- flex-shrink: 0;- }-- .item-name {- font-size: 14.5px;- font-weight: 500;- color: var(--secondary);- min-width: 0;- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- }-- .action-icon-btn {- width: 28px;- height: 28px;- display: flex;- align-items: center;- justify-content: center;- border-radius: calc(var(--border-radius) / 2);- background: transparent;- color: var(--gray);- border: none;- cursor: pointer;- padding: 0;- }-- @media (hover: hover) {- .action-icon-btn:hover {- background: var(--button-elevated);- color: var(--secondary);- }- }-- .action-icon-btn:active {- background: var(--button-elevated);- color: var(--secondary);- }-- .action-icon-btn:focus-visible {- outline: var(--focus-ring);- outline-offset: var(--focus-ring-offset);- }-- .action-icon-btn svg {- pointer-events: none;- }-- .action-icon-btn.confirm-remove {- color: var(--red);- background: color-mix(in srgb, var(--red) 12%, transparent);- animation: confirm-pulse 1s ease-in-out infinite;- }-- @keyframes confirm-pulse {- 0%, 100% { opacity: 1; }- 50% { opacity: 0.6; }- }-- .item-status {- font-size: var(--text-xs);- font-weight: 500;- text-transform: uppercase;- letter-spacing: 0.04em;- padding: var(--space-1) var(--space-2);- border-radius: var(--radius-xs);- flex-shrink: 0;- }-- .item-status[data-status="downloading"] {- background: var(--accent-soft);- color: var(--accent);- }-- .item-status[data-status="seeding"],- .item-status[data-status="complete"] {- background: color-mix(in srgb, var(--success) 16%, transparent);- color: var(--success);- }-- .item-status[data-status="error"] {- background: color-mix(in srgb, var(--danger) 16%, transparent);- color: var(--danger);- }-- .item-status[data-status="queued"] {- background: var(--surface-hi);- color: var(--text-dim);- }-- .item-status[data-status="paused"] {- background: color-mix(in srgb, var(--warning) 16%, transparent);- color: var(--warning);- }-- .item-detail {- font-size: 12.5px;- font-weight: 500;- color: var(--gray);- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- }-- .item-stats {- display: flex;- align-items: center;- gap: calc(var(--padding) / 3);- font-size: 12.5px;- font-weight: 500;- color: var(--gray);- font-variant-numeric: tabular-nums;- }-- .stats-sep {- opacity: 0.5;- }-- .item-error {- font-size: 12.5px;- font-weight: 500;- color: var(--red);- }-- .progress-track {- width: 100%;- height: 4px;- background: var(--surface-hi);- border-radius: var(--radius-full);- overflow: hidden;- }-- .progress-fill {- height: 100%;- border-radius: var(--radius-full);- transition: width var(--duration-slow) var(--ease-out);- }-- .progress-fill[data-status="downloading"] {- background: var(--blue);- }-- .progress-fill[data-status="seeding"] {- background: var(--green);- }-- .progress-fill[data-status="complete"] {- background: var(--green);- }-- .progress-fill[data-status="error"] {- background: var(--red);- }-- .progress-fill[data-status="paused"] {- background: var(--gray);- }-- .item-percent {- font-size: 12.5px;- font-weight: 500;- color: var(--gray);- font-variant-numeric: tabular-nums;- }-- .quality-chip {- padding: 1px 7px;- font-size: 10.5px;- font-weight: 600;- line-height: 1.4;- color: var(--secondary);- background: var(--button-elevated);- border: 1px solid var(--button-stroke);- border-radius: 999px;- letter-spacing: 0.2px;- flex-shrink: 0;- font-variant-numeric: tabular-nums;- }-- .show-more-btn {- align-self: center;- font-size: 13px;- padding: calc(var(--padding) / 2) var(--padding);- }-- .history-toggle {- display: inline-flex;- align-items: center;- justify-content: center;- width: 26px;- height: 26px;- background: transparent;- border: 1px solid transparent;- border-radius: calc(var(--border-radius) / 2);- color: var(--tertiary);- cursor: pointer;- flex-shrink: 0;- }-- @media (hover: hover) {- .history-toggle:hover {- color: var(--secondary);- background: var(--button-elevated);- }- }-- .history-toggle.on {- color: var(--accent);- background: var(--accent-soft, color-mix(in srgb, var(--accent) 12%, transparent));- border-color: color-mix(in srgb, var(--accent) 25%, transparent);- }-- .history-toggle:focus-visible {- outline: var(--focus-ring);- outline-offset: var(--focus-ring-offset);- }-- .history-view {- display: flex;- flex-direction: column;- gap: 6px;- }-- .history-empty {- color: var(--tertiary);- font-size: 13px;- padding: var(--padding) 0;- }-- .history-empty-state {- display: flex;- flex-direction: column;- align-items: center;- gap: calc(var(--padding) / 2);- padding: calc(var(--padding) * 3) var(--padding);- color: var(--tertiary);- }-- .history-empty-text {- font-size: 13.5px;- margin: 0;- }-- .history-list {- list-style: none;- margin: 0;- padding: 0;- display: flex;- flex-direction: column;- gap: 4px;- }-- .history-item {- display: grid;- grid-template-columns: 1fr auto;- grid-template-areas:- "head actions"- "meta actions";- column-gap: calc(var(--padding) / 2);- align-items: center;- padding: 8px 10px;- border-radius: var(--border-radius);- background: var(--button);- }-- .history-item[data-success="false"] {- background: color-mix(in srgb, var(--error, #c33) 6%, var(--button));- }-- .history-item-head {- grid-area: head;- display: flex;- align-items: center;- gap: 8px;- min-width: 0;- }-- .history-title {- font-size: 13.5px;- color: var(--secondary);- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- flex: 1;- min-width: 0;- }-- .history-time {- font-size: 11.5px;- color: var(--tertiary);- flex-shrink: 0;- }-- .history-item-meta {- grid-area: meta;- display: flex;- gap: 6px;- margin-top: 2px;- padding-left: 24px;- }-- .history-meta-chip {- font-size: 11px;- color: var(--tertiary);- background: var(--button-elevated);- padding: 2px 6px;- border-radius: calc(var(--border-radius) / 2);- }-- .history-meta-error {- color: var(--error, #c33);- background: color-mix(in srgb, var(--error, #c33) 12%, transparent);- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- max-width: 320px;- }-- .history-item-actions {- grid-area: actions;- display: flex;- gap: 2px;- align-items: center;- }-- .empty-links {- display: flex;- gap: 12px;- flex-wrap: wrap;- justify-content: center;- }- .history-link {- margin-top: calc(var(--padding) / 2);- display: inline-flex;- align-items: center;- gap: 5px;- font-size: 12.5px;- color: var(--tertiary);- background: transparent;- border: none;- cursor: pointer;- padding: 4px 6px;- border-radius: calc(var(--border-radius) / 2);- }-- @media (hover: hover) {- .history-link:hover {- color: var(--secondary);- background: var(--button);- }- }-- .queue-reorder-hint {- font-size: 10.5px;- font-weight: 400;- color: var(--tertiary);- text-transform: none;- letter-spacing: 0;- margin-left: 8px;- }-- .queue-drop-zone {- position: relative;- cursor: grab;- transition: opacity 0.12s;- }-- .queue-drop-zone:active {- cursor: grabbing;- }-- .queue-drop-zone.dragging {- opacity: 0.4;- }-- .queue-drop-zone.drop-before::before,- .queue-drop-zone.drop-after::after {- content: "";- position: absolute;- left: 8px;- right: 8px;- height: 2px;- background: var(--accent);- border-radius: 1px;- pointer-events: none;- }-- .queue-drop-zone.drop-before::before {- top: -2px;- }-- .queue-drop-zone.drop-after::after {- bottom: -2px;- }-</style>+<script lang="ts">+ import { onMount } from "svelte";+ import { goto } from "$app/navigation";+ import { invoke } from "@tauri-apps/api/core";+ import { pluginInvoke } from "$lib/plugin-invoke";+ import { t } from "$lib/i18n";+ import { translateBackendError } from "$lib/error-translate";+ import { showToast } from "$lib/stores/toast-store.svelte";+ import {+ getDownloads,+ formatBytes,+ formatSpeed,+ formatEta,+ getFinishedCount,+ getSpeedHistory,+ type CourseDownloadItem,+ type GenericDownloadItem,+ type QueueKind,+ } from "$lib/stores/download-store.svelte";+ import { getDownloadStats } from "$lib/stores/download-stats.svelte";+ import PlatformIcon from "$components/icons/PlatformIcon.svelte";+ import QueueKindBadge from "$lib/study-components/QueueKindBadge.svelte";+ import Mascot from "$components/mascot/Mascot.svelte";+ import ContextHint from "$components/hints/ContextHint.svelte";+ import DownloadSpeedGraph from "$components/download/DownloadSpeedGraph.svelte";+ import DownloadLog from "$components/download/DownloadLog.svelte";+ import ReencodeDialog from "$components/dialog/ReencodeDialog.svelte";+ import ToolsPanel from "$components/downloads/ToolsPanel.svelte";+ import VideoOpsOverlay from "$components/downloads/VideoOpsOverlay.svelte";+ import { locale as i18nLocale } from "$lib/i18n";+ import { get } from "svelte/store";+ import timeAgo from "$lib/time-ago";++ let studyAvailable = $state(false);++ onMount(async () => {+ try {+ const plugins = await invoke<{+ id: string;+ enabled: boolean;+ loaded: boolean;+ }[]>("list_plugins");+ studyAvailable = plugins.some(+ (p) => p.id === "study" && p.enabled && p.loaded,+ );+ } catch {+ studyAvailable = false;+ }+ });++ const VIDEO_EXTENSIONS = new Set([+ "mp4", "mkv", "webm", "mov", "avi", "ts", "m4v", "flv", "wmv", "mpg", "mpeg", "3gp", "ogv", "m2ts", "mts",+ ]);++ function fileExtension(path: string): string | null {+ const name = path.replace(/\\/g, "/").split("/").pop() ?? "";+ const dot = name.lastIndexOf(".");+ if (dot <= 0 || dot === name.length - 1) return null;+ return name.slice(dot + 1).toLowerCase();+ }++ function isVideoItem(item: GenericDownloadItem): boolean {+ if (item.filePath && (item.fileCount ?? 1) <= 1) {+ const ext = fileExtension(item.filePath);+ if (ext) return VIDEO_EXTENSIONS.has(ext);+ }+ if (item.downloadMode === "video") return true;+ return item.queueKind === "video";+ }++ function qualityChip(item: GenericDownloadItem): string | null {+ if (item.downloadMode === "audio") return $t('omnibox.quality_audio') as string;+ if (!item.quality) return null;+ const q = item.quality.toLowerCase();+ if (q === "audio") return $t('omnibox.quality_audio') as string;+ if (!isVideoItem(item)) return null;+ if (q === "best" || q === "highest") return $t('omnibox.quality_best_short') as string;+ return item.quality;+ }++ function canOpenInStudy(item: GenericDownloadItem): boolean {+ return (+ studyAvailable &&+ item.status === "complete" &&+ !!item.filePath &&+ (item.queueKind === "video" || item.queueKind === "audio")+ );+ }++ function openInStudy(filePath: string) {+ const parts = filePath.replace(/\\/g, "/").split("/");+ const name = parts[parts.length - 1] ?? "";+ const url = `/study/watch?path=${encodeURIComponent(filePath)}&name=${encodeURIComponent(name)}`;+ goto(url);+ }++ let downloads = $derived(getDownloads());+ let courseList = $derived(+ [...downloads.values()].filter((d): d is CourseDownloadItem => d.kind === "course")+ );+ let genericList = $derived(+ [...downloads.values()].filter((d): d is GenericDownloadItem => d.kind === "generic")+ );++ let grouped = $derived.by(() => {+ const active: GenericDownloadItem[] = [];+ const paused: GenericDownloadItem[] = [];+ const queued: GenericDownloadItem[] = [];+ const finished: GenericDownloadItem[] = [];+ const errored: GenericDownloadItem[] = [];+ const completed: GenericDownloadItem[] = [];+ for (const d of genericList) {+ if (d.status === "downloading" || d.status === "seeding") active.push(d);+ else if (d.status === "paused") paused.push(d);+ else if (d.status === "queued") queued.push(d);+ else {+ finished.push(d);+ if (d.status === "error") errored.push(d);+ else if (d.status === "complete") completed.push(d);+ }+ }+ return { active, paused, queued, finished, errored, completed };+ });++ type StatusFilter = "all" | "active" | "queued" | "completed" | "failed";+ let statusFilter = $state<StatusFilter>("all");++ let filterCounts = $derived({+ all: genericList.length,+ active: grouped.active.length + grouped.paused.length,+ queued: grouped.queued.length,+ completed: grouped.completed.length,+ failed: grouped.errored.length,+ });++ let showSection = $derived({+ active: statusFilter === "all" || statusFilter === "active",+ queued: statusFilter === "all" || statusFilter === "queued",+ completed: statusFilter === "all" || statusFilter === "completed",+ failed: statusFilter === "all" || statusFilter === "failed",+ });++ let finishedFiltered = $derived.by(() => {+ if (statusFilter === "completed") return grouped.completed;+ if (statusFilter === "failed") return grouped.errored;+ return grouped.finished;+ });++ const FINISHED_PAGE_SIZE = 20;+ let finishedVisibleCount = $state(FINISHED_PAGE_SIZE);++ let visibleFinished = $derived(+ finishedFiltered.length <= finishedVisibleCount+ ? finishedFiltered+ : finishedFiltered.slice(0, finishedVisibleCount)+ );++ let hasDownloads = $derived(courseList.length > 0 || genericList.length > 0);+ let finishedCount = $derived(getFinishedCount());+ let dlStats = $derived(getDownloadStats());++ async function cancelDownload(courseId: number) {+ try {+ await pluginInvoke("courses", "cancel_course_download", { courseId });+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ async function cancelGenericDownload(id: number) {+ try {+ await invoke("cancel_generic_download", { downloadId: id });+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ async function pauseDownload(id: number) {+ try {+ await invoke("pause_download", { downloadId: id });+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ async function resumeDownload(id: number) {+ try {+ await invoke("resume_download", { downloadId: id });+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ async function retryDownload(id: number) {+ try {+ await invoke("retry_download", { downloadId: id });+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ let pendingRemove = $state<number | null>(null);+ let pendingRemoveTimer = $state<ReturnType<typeof setTimeout> | null>(null);++ function removeItem(id: number) {+ if (pendingRemove === id) {+ if (pendingRemoveTimer) clearTimeout(pendingRemoveTimer);+ pendingRemove = null;+ pendingRemoveTimer = null;+ invoke("remove_download", { downloadId: id }).catch((e: any) => {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ });+ } else {+ if (pendingRemoveTimer) clearTimeout(pendingRemoveTimer);+ pendingRemove = id;+ pendingRemoveTimer = setTimeout(() => {+ pendingRemove = null;+ pendingRemoveTimer = null;+ }, 3000);+ }+ }++ async function removeItemWithFile(id: number) {+ if (!confirm($t("downloads.delete_file_confirm"))) return;+ try {+ await invoke("remove_download", { downloadId: id, deleteFile: true });+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ async function clearFinished() {+ if (!confirm($t("downloads.clear_confirm"))) return;+ try {+ await invoke("clear_finished_downloads");+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ async function pauseAll() {+ try {+ await invoke("pause_all_downloads");+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ async function resumeAll() {+ try {+ await invoke("resume_all_downloads");+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ async function revealFile(path: string) {+ try {+ await invoke("reveal_file", { path });+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ let reencodePath = $state<string | null>(null);++ function openReencode(path: string) {+ reencodePath = path;+ }++ let vopPath = $state<string | null>(null);++ type HistoryEntry = {+ id: number;+ url: string;+ platform: string;+ title: string;+ file_path: string | null;+ file_size_bytes: number | null;+ total_bytes: number | null;+ success: boolean;+ error: string | null;+ completed_at: number;+ thumbnail_url: string | null;+ kind: QueueKind | null;+ };++ let viewMode = $state<"active" | "history" | "tools">("active");+ let historyEntries = $state<HistoryEntry[]>([]);+ let historyLoading = $state(false);++ async function loadHistory() {+ historyLoading = true;+ try {+ historyEntries = await invoke<HistoryEntry[]>("get_download_history");+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ } finally {+ historyLoading = false;+ }+ }++ async function clearHistory() {+ if (!confirm($t("downloads.history_clear_confirm") as string)) return;+ try {+ await invoke("clear_download_history");+ historyEntries = [];+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ function toggleHistoryView() {+ if (viewMode === "history") {+ viewMode = "active";+ } else {+ viewMode = "history";+ loadHistory();+ }+ }++ function toggleToolsView() {+ viewMode = viewMode === "tools" ? "active" : "tools";+ }++ async function historyRetry(url: string, platform: string) {+ try {+ const settings = (await import("$lib/stores/settings-store.svelte")).getSettings();+ const outputDir = settings?.download.default_output_dir ?? "";+ if (!outputDir) {+ showToast("error", $t("common.error") as string);+ return;+ }+ await invoke("download_from_url", {+ url,+ outputDir,+ downloadMode: null,+ quality: settings?.download.video_quality ?? "best",+ formatId: null,+ referer: null,+ });+ viewMode = "active";+ showToast("info", $t("downloads.history_requeued") as string);+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ function fmtHistoryTime(unixSec: number): string {+ const ms = unixSec * 1000;+ const loc = get(i18nLocale) || "en";+ const lookup = loc.startsWith("pt") ? "pt" : "en";+ return timeAgo(ms, lookup);+ }++ function canPlayInStudyHistory(entry: HistoryEntry): boolean {+ return (+ studyAvailable &&+ entry.success &&+ !!entry.file_path &&+ (entry.kind === "video" || entry.kind === "audio")+ );+ }++ function openHistoryInStudy(filePath: string) {+ const parts = filePath.replace(/\\/g, "/").split("/");+ const name = parts[parts.length - 1] ?? "";+ const url = `/study/watch?path=${encodeURIComponent(filePath)}&name=${encodeURIComponent(name)}`;+ goto(url);+ }++ let dragId = $state<number | null>(null);+ let dropTargetId = $state<number | null>(null);+ let dropPosition = $state<"before" | "after">("before");++ function onDragStart(e: DragEvent, id: number) {+ dragId = id;+ if (e.dataTransfer) {+ e.dataTransfer.effectAllowed = "move";+ e.dataTransfer.setData("text/plain", String(id));+ }+ }++ function onDragOver(e: DragEvent, id: number) {+ if (dragId === null || dragId === id) return;+ e.preventDefault();+ if (e.dataTransfer) e.dataTransfer.dropEffect = "move";+ const target = e.currentTarget as HTMLElement;+ const rect = target.getBoundingClientRect();+ const midpoint = rect.top + rect.height / 2;+ dropPosition = e.clientY < midpoint ? "before" : "after";+ dropTargetId = id;+ }++ function onDragLeave(e: DragEvent, id: number) {+ if (dropTargetId === id) {+ dropTargetId = null;+ }+ }++ async function onDrop(e: DragEvent, targetId: number) {+ e.preventDefault();+ const movingId = dragId;+ const position = dropPosition;+ dragId = null;+ dropTargetId = null;+ if (movingId === null || movingId === targetId) return;++ const order = grouped.queued.map((q) => q.id);+ const fromIdx = order.indexOf(movingId);+ if (fromIdx === -1) return;+ order.splice(fromIdx, 1);+ let targetIdx = order.indexOf(targetId);+ if (targetIdx === -1) return;+ if (position === "after") targetIdx += 1;+ order.splice(targetIdx, 0, movingId);++ try {+ await invoke<boolean>("reorder_queue", { ids: order });+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");+ showToast("error", msg);+ }+ }++ function onDragEnd() {+ dragId = null;+ dropTargetId = null;+ }++ function onKeydown(e: KeyboardEvent) {+ const target = e.target as HTMLElement | null;+ const tag = target?.tagName?.toLowerCase();+ const isEditable =+ tag === "input" ||+ tag === "textarea" ||+ tag === "select" ||+ target?.isContentEditable;+ if (isEditable) return;+ if (e.ctrlKey && !e.altKey && !e.metaKey && !e.shiftKey && (e.key === "h" || e.key === "H")) {+ e.preventDefault();+ toggleHistoryView();+ }+ }++ onMount(() => {+ window.addEventListener("keydown", onKeydown);+ return () => window.removeEventListener("keydown", onKeydown);+ });++ // Relógio de 1s, ligado apenas enquanto algum item espera por rate limit.+ // Sem isso a contagem regressiva ficaria parada até o próximo evento.+ let nowTick = $state(Date.now());++ let hasWaitingItem = $derived(+ [...getDownloads().values()].some(+ (d) => d.kind === "generic" && d.phase === "waiting_rate_limit" && (d.waitUntil ?? 0) > nowTick,+ ),+ );++ $effect(() => {+ if (!hasWaitingItem) return;+ const timer = setInterval(() => (nowTick = Date.now()), 1000);+ return () => clearInterval(timer);+ });++ function waitRemaining(waitUntil: number | null | undefined): number {+ if (!waitUntil) return 0;+ return Math.max(0, Math.ceil((waitUntil - nowTick) / 1000));+ }+</script>++{#if hasDownloads || viewMode !== "active"}+ <div class="downloads-page downloads-mac">+ <div class="downloads-header">+ {#if dlStats.totalDownloads > 0}+ <span class="downloads-stats">{$t('downloads.stats_line', { count: String(dlStats.totalDownloads), size: formatBytes(dlStats.totalBytes) })}</span>+ {/if}+ <div class="bulk-actions">+ {#if viewMode === "active"}+ {#if grouped.active.length > 0}+ <button class="clear-btn" onclick={pauseAll} title={$t('downloads.pause_all') as string}>+ {$t('downloads.pause_all')}+ </button>+ {/if}+ {#if grouped.paused.length > 0}+ <button class="clear-btn" onclick={resumeAll} title={$t('downloads.resume_all') as string}>+ {$t('downloads.resume_all')}+ </button>+ {/if}+ {#if finishedCount > 0}+ <button class="clear-btn" onclick={clearFinished}>+ {$t('downloads.clear_finished')}+ </button>+ {/if}+ {:else if historyEntries.length > 0}+ <button class="clear-btn" onclick={clearHistory}>+ {$t('downloads.history_clear')}+ </button>+ {/if}+ <button+ class="history-toggle"+ class:on={viewMode === "history"}+ onclick={toggleHistoryView}+ aria-label={$t('downloads.history_toggle') as string}+ title={$t('downloads.history_toggle_hint') as string}+ >+ <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <circle cx="12" cy="12" r="9" />+ <polyline points="12 7 12 12 15 14" />+ </svg>+ </button>+ <button+ class="history-toggle"+ class:on={viewMode === "tools"}+ onclick={toggleToolsView}+ aria-label={$t('tools.tab') as string}+ title={$t('tools.tab') as string}+ >+ <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.6 2.6-2.4-2.4z" />+ </svg>+ </button>+ </div>+ </div>++ {#if viewMode === "active"}+ <div class="filter-pills" role="tablist" aria-label={$t('downloads.filter_label')}>+ {#each [+ { value: 'all', labelKey: 'downloads.filter.all', count: filterCounts.all },+ { value: 'active', labelKey: 'downloads.filter.active', count: filterCounts.active },+ { value: 'queued', labelKey: 'downloads.filter.queued', count: filterCounts.queued },+ { value: 'completed', labelKey: 'downloads.filter.completed', count: filterCounts.completed },+ { value: 'failed', labelKey: 'downloads.filter.failed', count: filterCounts.failed },+ ] as pill}+ <button+ type="button"+ class="filter-pill"+ class:active={statusFilter === pill.value}+ role="tab"+ aria-selected={statusFilter === pill.value}+ onclick={() => { statusFilter = pill.value as StatusFilter; finishedVisibleCount = FINISHED_PAGE_SIZE; }}+ >+ <span>{$t(pill.labelKey)}</span>+ <span class="filter-count">{pill.count}</span>+ </button>+ {/each}+ </div>++ <div class="download-list">+ {#if showSection.active}+ {#each grouped.active as item (item.id)}+ {@render genericItem(item)}+ {/each}++ {#each grouped.paused as item (item.id)}+ {@render genericItem(item)}+ {/each}++ {#each courseList as item (item.id)}+ {@render courseItem(item)}+ {/each}+ {/if}++ {#if showSection.queued && grouped.queued.length > 0}+ <h5 class="section-label">+ {$t('downloads.section_queued')}+ {#if grouped.queued.length > 1}+ <span class="queue-reorder-hint">{$t('downloads.reorder_hint')}</span>+ {/if}+ </h5>+ {#each grouped.queued as item (item.id)}+ <div+ class="queue-drop-zone"+ class:drop-before={dropTargetId === item.id && dropPosition === "before"}+ class:drop-after={dropTargetId === item.id && dropPosition === "after"}+ class:dragging={dragId === item.id}+ draggable="true"+ role="listitem"+ ondragstart={(e) => onDragStart(e, item.id)}+ ondragover={(e) => onDragOver(e, item.id)}+ ondragleave={(e) => onDragLeave(e, item.id)}+ ondrop={(e) => onDrop(e, item.id)}+ ondragend={onDragEnd}+ >+ {@render genericItem(item)}+ </div>+ {/each}+ {/if}++ {#if (showSection.completed || showSection.failed) && finishedFiltered.length > 0}+ <h5 class="section-label">{$t('downloads.section_finished')}</h5>+ {#each visibleFinished as item (item.id)}+ {@render genericItem(item)}+ {/each}+ {#if finishedFiltered.length > finishedVisibleCount}+ <button+ class="button show-more-btn"+ onclick={() => { finishedVisibleCount += FINISHED_PAGE_SIZE; }}+ >+ {$t('downloads.show_more', { count: finishedFiltered.length - finishedVisibleCount })}+ </button>+ {/if}+ {/if}+ </div>+ {:else if viewMode === "history"}+ <div class="history-view">+ {#if historyLoading}+ <p class="history-empty">{$t('downloads.history_loading')}</p>+ {:else if historyEntries.length === 0}+ <div class="history-empty-state">+ <svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">+ <circle cx="12" cy="12" r="9" />+ <polyline points="12 7 12 12 15 14" />+ </svg>+ <p class="history-empty-text">{$t('downloads.history_empty')}</p>+ </div>+ {:else}+ <ul class="history-list">+ {#each historyEntries as entry (entry.id)}+ <li class="history-item" data-success={entry.success}>+ <div class="history-item-head">+ {#if entry.thumbnail_url}+ <img+ src={entry.thumbnail_url}+ alt=""+ class="queue-thumb"+ loading="lazy"+ onerror={(e) => { (e.target as HTMLImageElement).style.display = 'none'; }}+ />+ {/if}+ <PlatformIcon platform={entry.platform} size={16} />+ {#if entry.kind}+ <QueueKindBadge kind={entry.kind} size={14} />+ {/if}+ <span class="history-title">{entry.title || entry.url}</span>+ <span class="history-time">{fmtHistoryTime(entry.completed_at)}</span>+ </div>+ <div class="history-item-meta">+ {#if entry.success && entry.file_size_bytes}+ <span class="history-meta-chip">{formatBytes(entry.file_size_bytes)}</span>+ {/if}+ {#if !entry.success && entry.error}+ <span class="history-meta-chip history-meta-error">{entry.error}</span>+ {/if}+ </div>+ <div class="history-item-actions">+ {#if canPlayInStudyHistory(entry) && entry.file_path}+ <button+ class="action-icon-btn"+ onclick={() => openHistoryInStudy(entry.file_path!)}+ aria-label={$t('downloads.open_in_study')}+ title={$t('downloads.open_in_study')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <circle cx="12" cy="12" r="10" />+ <polygon points="10 8 16 12 10 16 10 8" fill="currentColor" stroke="none" />+ </svg>+ </button>+ {/if}+ {#if entry.success && entry.file_path}+ <button+ class="action-icon-btn"+ onclick={() => revealFile(entry.file_path!)}+ aria-label={$t('downloads.open_folder')}+ title={$t('downloads.open_folder')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />+ </svg>+ </button>+ {/if}+ {#if entry.success && entry.file_path && entry.kind === "video"}+ <button+ class="action-icon-btn"+ onclick={() => openReencode(entry.file_path!)}+ aria-label={$t('reencode.action_label')}+ title={$t('reencode.action_label')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <polyline points="4 14 10 14 10 20" />+ <polyline points="20 10 14 10 14 4" />+ <line x1="14" y1="10" x2="21" y2="3" />+ <line x1="3" y1="21" x2="10" y2="14" />+ </svg>+ </button>+ {/if}+ <button+ class="action-icon-btn"+ onclick={() => historyRetry(entry.url, entry.platform)}+ aria-label={$t('downloads.history_redownload')}+ title={$t('downloads.history_redownload')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <polyline points="23 4 23 10 17 10" />+ <path d="M20.49 15a9 9 0 11-2.12-9.36L23 10" />+ </svg>+ </button>+ </div>+ </li>+ {/each}+ </ul>+ {/if}+ </div>+ {:else}+ <ToolsPanel />+ {/if}+ </div>+{:else}+ <div class="downloads-empty downloads-mac-empty">+ <Mascot emotion="idle" />+ <p class="empty-text">{$t('downloads.empty')} <ContextHint text={$t('hints.downloads_empty')} dismissKey="downloads_empty" /></p>+ <div class="empty-links">+ <button class="history-link" onclick={toggleHistoryView}>+ <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">+ <circle cx="12" cy="12" r="9" />+ <polyline points="12 7 12 12 15 14" />+ </svg>+ {$t('downloads.history_view_link')}+ </button>+ <button class="history-link" onclick={toggleToolsView}>+ <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">+ <path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.6 2.6-2.4-2.4z" />+ </svg>+ {$t('tools.tab')}+ </button>+ </div>+ </div>+{/if}++<ReencodeDialog bind:inputPath={reencodePath} />++{#if vopPath}+ <VideoOpsOverlay filePath={vopPath} onClose={() => (vopPath = null)} />+{/if}++{#snippet genericItem(item: GenericDownloadItem)}+ <div class="download-item" data-status={item.status}>+ <div class="item-header">+ <div class="item-header-left">+ {#if item.thumbnail_url}+ <img+ src={item.thumbnail_url}+ alt=""+ class="queue-thumb"+ loading="lazy"+ onerror={(e) => {+ (e.target as HTMLImageElement).style.display = 'none';+ }}+ />+ {/if}+ <PlatformIcon platform={item.platform} size={16} />+ <QueueKindBadge kind={item.queueKind} size={14} />+ <span class="item-name">{item.name}</span>+ {#if qualityChip(item)}+ <span class="quality-chip" title={$t('downloads.quality_hint')}>{qualityChip(item)}</span>+ {/if}+ </div>+ <div class="item-header-actions">+ {#if item.status === "downloading"}+ <button+ class="action-icon-btn"+ onclick={() => pauseDownload(item.id)}+ aria-label={$t('downloads.pause')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <rect x="6" y="4" width="4" height="16" />+ <rect x="14" y="4" width="4" height="16" />+ </svg>+ </button>+ <button+ class="action-icon-btn"+ onclick={() => cancelGenericDownload(item.id)}+ aria-label={$t('downloads.cancel')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ </button>+ {:else if item.status === "seeding"}+ {#if item.filePath}+ <button+ class="action-icon-btn"+ onclick={() => revealFile(item.filePath!)}+ aria-label={$t('downloads.open_folder')}+ title={$t('downloads.open_folder')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />+ </svg>+ </button>+ {/if}+ <button+ class="action-icon-btn"+ onclick={() => removeItem(item.id)}+ aria-label={$t('downloads.stop')}+ title={$t('downloads.stop')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">+ <rect x="6" y="6" width="12" height="12" />+ </svg>+ </button>+ {:else if item.status === "paused"}+ <button+ class="action-icon-btn"+ onclick={() => resumeDownload(item.id)}+ aria-label={$t('downloads.resume')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <polygon points="5 3 19 12 5 21 5 3" />+ </svg>+ </button>+ <button+ class="action-icon-btn"+ onclick={() => cancelGenericDownload(item.id)}+ aria-label={$t('downloads.cancel')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ </button>+ {:else if item.status === "error"}+ <button+ class="action-icon-btn"+ onclick={() => retryDownload(item.id)}+ aria-label={$t('downloads.retry')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <polyline points="23 4 23 10 17 10" />+ <path d="M20.49 15a9 9 0 11-2.12-9.36L23 10" />+ </svg>+ </button>+ <button+ class="action-icon-btn"+ class:confirm-remove={pendingRemove === item.id}+ onclick={() => removeItem(item.id)}+ aria-label={pendingRemove === item.id ? $t('downloads.confirm_remove') : $t('common.close')}+ title={pendingRemove === item.id ? $t('downloads.confirm_remove') : undefined}+ >+ {#if pendingRemove === item.id}+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M5 12l5 5L20 7" />+ </svg>+ {:else}+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ {/if}+ </button>+ {:else if item.status === "complete" && item.filePath}+ {#if canOpenInStudy(item)}+ <button+ class="action-icon-btn"+ onclick={() => openInStudy(item.filePath!)}+ aria-label={$t('downloads.open_in_study')}+ title={$t('downloads.open_in_study')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <circle cx="12" cy="12" r="10" />+ <polygon points="10 8 16 12 10 16 10 8" fill="currentColor" stroke="none" />+ </svg>+ </button>+ {/if}+ <button+ class="action-icon-btn"+ onclick={() => revealFile(item.filePath!)}+ aria-label={$t('downloads.open_folder')}+ title={$t('downloads.open_folder')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />+ </svg>+ </button>+ {#if item.queueKind === "video"}+ <button+ class="action-icon-btn"+ onclick={() => openReencode(item.filePath!)}+ aria-label={$t('reencode.action_label')}+ title={$t('reencode.action_label')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <polyline points="4 14 10 14 10 20" />+ <polyline points="20 10 14 10 14 4" />+ <line x1="14" y1="10" x2="21" y2="3" />+ <line x1="3" y1="21" x2="10" y2="14" />+ </svg>+ </button>+ {/if}+ <button+ class="action-icon-btn"+ class:confirm-remove={pendingRemove === item.id}+ onclick={() => removeItem(item.id)}+ aria-label={pendingRemove === item.id ? $t('downloads.confirm_remove') : $t('common.close')}+ title={pendingRemove === item.id ? $t('downloads.confirm_remove') : undefined}+ >+ {#if pendingRemove === item.id}+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M5 12l5 5L20 7" />+ </svg>+ {:else}+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ {/if}+ </button>+ {:else if item.status === "complete"}+ {#if item.filePath && item.queueKind === "video"}+ <button+ class="action-icon-btn"+ onclick={() => (vopPath = item.filePath!)}+ aria-label={$t('downloads.vop.action_label')}+ title={$t('downloads.vop.action_label')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M12 2 2 7l10 5 10-5-10-5Z" />+ <path d="m2 17 10 5 10-5M2 12l10 5 10-5" />+ </svg>+ </button>+ {/if}+ {#if item.filePath}+ <button+ class="action-icon-btn"+ onclick={() => removeItemWithFile(item.id)}+ aria-label={$t('downloads.delete_file')}+ title={$t('downloads.delete_file')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <polyline points="3 6 5 6 21 6" />+ <path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />+ <line x1="10" y1="11" x2="10" y2="17" />+ <line x1="14" y1="11" x2="14" y2="17" />+ </svg>+ </button>+ {/if}+ <button+ class="action-icon-btn"+ class:confirm-remove={pendingRemove === item.id}+ onclick={() => removeItem(item.id)}+ aria-label={pendingRemove === item.id ? $t('downloads.confirm_remove') : $t('common.close')}+ title={pendingRemove === item.id ? $t('downloads.confirm_remove') : undefined}+ >+ {#if pendingRemove === item.id}+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M5 12l5 5L20 7" />+ </svg>+ {:else}+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ {/if}+ </button>+ {:else if item.status === "queued"}+ <button+ class="action-icon-btn"+ onclick={() => cancelGenericDownload(item.id)}+ aria-label={$t('downloads.cancel')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ </button>+ {/if}+ <span class="item-status" data-status={item.status}>+ {$t(`downloads.status.${item.status}`)}+ </span>+ </div>+ </div>++ {#if item.status === "downloading"}+ {#if item.phase === "preparing"}+ <span class="item-detail">{$t('downloads.phase_preparing')}</span>+ {:else if item.phase === "fetching_info"}+ <span class="item-detail">{$t('downloads.phase_fetching_info')}</span>+ {:else if item.phase === "starting"}+ <span class="item-detail">{$t('downloads.phase_starting')}</span>+ {:else if item.phase === "connecting"}+ <span class="item-detail">{$t('downloads.phase_connecting')}</span>+ {:else if item.phase === "waiting_rate_limit"}+ <span class="item-detail">+ {#if waitRemaining(item.waitUntil) > 0}+ {$t('downloads.phase_waiting_rate_limit_countdown', { seconds: waitRemaining(item.waitUntil) })}+ {:else}+ {$t('downloads.phase_waiting_rate_limit')}+ {/if}+ </span>+ {:else if item.phase === "merging"}+ <span class="item-detail">{$t('downloads.phase_merging')}</span>+ {:else if item.phase === "extracting_audio"}+ <span class="item-detail">{$t('downloads.phase_extracting_audio')}</span>+ {:else if item.phase === "embedding_subtitles"}+ <span class="item-detail">{$t('downloads.phase_embedding_subtitles')}</span>+ {:else}+ <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>+ <div class="item-stats">+ {#if item.downloadedBytes > 0}+ <span>+ {formatBytes(item.downloadedBytes)}{#if item.totalBytes} / {formatBytes(item.totalBytes)}{/if}+ </span>+ <span class="stats-sep">·</span>+ {/if}+ {#if item.speed > 0}+ <span>{formatSpeed(item.speed)}</span>+ {#if formatEta(item.etaSeconds)}+ <span class="stats-sep">·</span>+ <span>ETA {formatEta(item.etaSeconds)}</span>+ {/if}+ <DownloadSpeedGraph points={getSpeedHistory(item.id)} />+ {/if}+ </div>+ {/if}+ {:else if item.status === "seeding"}+ <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>+ <div class="item-stats">+ {#if item.totalBytes}+ <span>{formatBytes(item.totalBytes)}</span>+ <span class="stats-sep">·</span>+ {/if}+ {#if item.speed > 0}+ <span>{formatSpeed(item.speed)}</span>+ <DownloadSpeedGraph points={getSpeedHistory(item.id)} />+ {/if}+ </div>+ {:else if item.status === "paused"}+ <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>+ {#if item.downloadedBytes > 0}+ <div class="item-stats">+ <span>{formatBytes(item.downloadedBytes)}{#if item.totalBytes} / {formatBytes(item.totalBytes)}{/if}</span>+ </div>+ {/if}+ {:else if item.status === "queued"}+ <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>+ {:else}+ <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>+ {/if}++ {#if item.status === "complete" && item.totalBytes}+ <span class="item-detail">{formatBytes(item.totalBytes)}</span>+ {/if}++ {#if item.status === "error" && item.error}+ <span class="item-error">{translateBackendError(item.error, $t)}</span>+ {/if}++ {#if item.status !== "queued"}+ <div class="progress-track">+ <div+ class="progress-fill"+ data-status={item.status}+ style="width: {Math.max(0, item.percent).toFixed(1)}%"+ ></div>+ </div>+ <span class="item-percent">{Math.max(0, item.percent).toFixed(0)}%</span>+ {/if}++ {#if item.status !== "queued"}+ <DownloadLog id={item.id} />+ {/if}+ </div>+{/snippet}++{#snippet courseItem(item: CourseDownloadItem)}+ <div class="download-item" data-status={item.status}>+ <div class="item-header">+ <span class="item-name">{item.name}</span>+ <div class="item-header-actions">+ {#if item.status === "downloading"}+ <button+ class="action-icon-btn"+ onclick={() => cancelDownload(item.id)}+ aria-label={$t('downloads.cancel')}+ >+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <path d="M18 6L6 18M6 6l12 12" />+ </svg>+ </button>+ {/if}+ <span class="item-status" data-status={item.status}>+ {$t(`downloads.status.${item.status}`)}+ </span>+ </div>+ </div>++ {#if item.status === "downloading"}+ {#if item.currentModule}+ <span class="item-detail">+ {item.currentModule} · {item.currentPage}+ </span>+ {/if}++ <div class="item-stats">+ {#if item.totalPages > 0}+ <span>{$t('downloads.page_progress', { current: item.completedPages, total: item.totalPages })}</span>+ <span class="stats-sep">·</span>+ <span>{$t('downloads.module_progress', { current: item.currentModuleIndex, total: item.totalModules })}</span>+ {/if}+ {#if item.bytesDownloaded > 0}+ <span class="stats-sep">·</span>+ <span>{formatBytes(item.bytesDownloaded)}</span>+ {/if}+ </div>++ <div class="item-stats">+ <span>{formatSpeed(item.speed)}</span>+ {#if item.speed > 0}+ <DownloadSpeedGraph points={getSpeedHistory(item.id)} />+ {/if}+ </div>+ {/if}++ {#if item.status === "complete" && item.bytesDownloaded > 0}+ <span class="item-detail">{formatBytes(item.bytesDownloaded)}</span>+ {/if}++ {#if item.status === "error" && item.error}+ <span class="item-error">{translateBackendError(item.error, $t)}</span>+ {/if}++ <div class="progress-track">+ <div+ class="progress-fill"+ data-status={item.status}+ style="width: {Math.max(0, item.percent).toFixed(1)}%"+ ></div>+ </div>++ <span class="item-percent">{Math.max(0, item.percent).toFixed(1)}%</span>++ {#if item.status !== "queued"}+ <DownloadLog id={item.id} />+ {/if}+ </div>+{/snippet}++<style>+ .downloads-empty {+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ min-height: calc(100vh - var(--padding) * 4);+ gap: calc(var(--padding) * 1.5);+ color: var(--gray);+ }++ .empty-text {+ font-size: 14.5px;+ }++ .downloads-page {+ display: flex;+ flex-direction: column;+ gap: calc(var(--padding) * 1.5);+ padding: calc(var(--padding) * 1.5);+ max-width: 800px;+ margin: 0 auto;+ width: 100%;+ }++ .downloads-page h2 {+ margin-block: 0;+ }++ .downloads-header {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: var(--padding);+ flex-wrap: wrap;+ }++ .downloads-stats {+ font-size: 12px;+ color: var(--tertiary);+ font-weight: 400;+ }++ .bulk-actions {+ display: flex;+ align-items: center;+ gap: calc(var(--padding) / 3);+ flex-shrink: 0;+ }++ .clear-btn {+ font-size: 12.5px;+ font-weight: 500;+ padding: calc(var(--padding) / 3) calc(var(--padding) * 0.75);+ background: var(--button-elevated);+ color: var(--gray);+ border: none;+ border-radius: calc(var(--border-radius) / 2);+ cursor: pointer;+ flex-shrink: 0;+ }++ @media (hover: hover) {+ .clear-btn:hover {+ background: var(--button-elevated-hover);+ color: var(--secondary);+ }+ }++ .clear-btn:active {+ background: var(--button-elevated-press);+ }++ .clear-btn:focus-visible {+ outline: var(--focus-ring);+ outline-offset: var(--focus-ring-offset);+ }++ .section-label {+ color: var(--gray);+ text-transform: uppercase;+ letter-spacing: 0.5px;+ margin-block: 0;+ padding-top: calc(var(--padding) / 2);+ }++ .filter-pills {+ display: flex;+ flex-wrap: wrap;+ gap: 6px;+ margin-bottom: var(--padding);+ }++ .filter-pill {+ display: inline-flex;+ align-items: center;+ gap: var(--space-2);+ padding: var(--space-2) var(--space-3);+ font-size: var(--text-sm);+ font-weight: 500;+ border: 1px solid var(--border);+ border-radius: var(--radius-full);+ background: var(--surface);+ color: var(--text-dim);+ cursor: pointer;+ transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);+ }++ @media (hover: hover) {+ .filter-pill:hover {+ background: var(--surface-hi);+ color: var(--text);+ }+ }++ .filter-pill.active {+ background: var(--accent-soft);+ color: var(--accent);+ border-color: transparent;+ }++ @media (prefers-reduced-motion: reduce) {+ .filter-pill {+ transition: none;+ }+ }++ .filter-pill:focus-visible {+ outline: var(--focus-ring);+ outline-offset: var(--focus-ring-offset);+ }++ .filter-count {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ min-width: 20px;+ padding: 0 5px;+ font-size: 10px;+ font-weight: 600;+ background: color-mix(in srgb, var(--surface) 70%, var(--bg-overlay));+ border-radius: 9999px;+ }++ .filter-pill.active .filter-count {+ background: color-mix(in srgb, var(--on-accent) 22%, transparent);+ }++ .download-list {+ display: flex;+ flex-direction: column;+ gap: var(--padding);+ }++ .download-item {+ background: var(--surface);+ border: 1px solid var(--border);+ border-radius: var(--radius-md);+ padding: var(--space-3) var(--space-4);+ display: flex;+ flex-direction: column;+ gap: var(--space-1);+ transition: background var(--duration-fast) var(--ease-out);+ }++ @media (hover: hover) {+ .download-item:hover {+ background: var(--surface-hi);+ }+ }++ .download-item[data-status="queued"] .item-name {+ color: var(--text-muted);+ }++ @media (prefers-reduced-motion: reduce) {+ .download-item {+ transition: none;+ }+ }++ .item-header {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: var(--padding);+ }++ .item-header-actions {+ display: flex;+ align-items: center;+ gap: calc(var(--padding) / 2);+ flex-shrink: 0;+ }++ .item-header-left {+ display: flex;+ align-items: center;+ gap: calc(var(--padding) / 2);+ min-width: 0;+ flex: 1;+ }++ .queue-thumb {+ width: 48px;+ height: 48px;+ border-radius: 6px;+ object-fit: cover;+ flex-shrink: 0;+ }++ .item-name {+ font-size: var(--text-base);+ font-weight: 500;+ color: var(--secondary);+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ }++ .action-icon-btn {+ width: 28px;+ height: 28px;+ display: flex;+ align-items: center;+ justify-content: center;+ border-radius: calc(var(--border-radius) / 2);+ background: transparent;+ color: var(--gray);+ border: none;+ cursor: pointer;+ padding: 0;+ }++ @media (hover: hover) {+ .action-icon-btn:hover {+ background: var(--button-elevated);+ color: var(--secondary);+ }+ }++ .action-icon-btn:active {+ background: var(--button-elevated);+ color: var(--secondary);+ }++ .action-icon-btn:focus-visible {+ outline: var(--focus-ring);+ outline-offset: var(--focus-ring-offset);+ }++ .action-icon-btn svg {+ pointer-events: none;+ }++ .action-icon-btn.confirm-remove {+ color: var(--red);+ background: color-mix(in srgb, var(--red) 12%, transparent);+ animation: confirm-pulse 1s ease-in-out infinite;+ }++ @keyframes confirm-pulse {+ 0%, 100% { opacity: 1; }+ 50% { opacity: 0.6; }+ }++ .item-status {+ font-size: var(--text-xs);+ font-weight: 500;+ height: 20px;+ display: inline-flex;+ align-items: center;+ padding: 0 var(--space-2);+ border-radius: var(--radius-full);+ flex-shrink: 0;+ }++ .item-status[data-status="downloading"] {+ background: var(--accent-soft);+ color: var(--accent);+ }++ .item-status[data-status="seeding"],+ .item-status[data-status="complete"] {+ background: color-mix(in srgb, var(--success) 16%, transparent);+ color: var(--success);+ }++ .item-status[data-status="error"] {+ background: color-mix(in srgb, var(--danger) 16%, transparent);+ color: var(--danger);+ }++ .item-status[data-status="queued"] {+ background: var(--surface-hi);+ color: var(--text-dim);+ }++ .item-status[data-status="paused"] {+ background: color-mix(in srgb, var(--warning) 16%, transparent);+ color: var(--warning);+ }++ .item-detail {+ font-size: 12.5px;+ font-weight: 500;+ color: var(--gray);+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ }++ .item-stats {+ display: flex;+ align-items: center;+ gap: calc(var(--padding) / 3);+ font-size: 12.5px;+ font-weight: 500;+ color: var(--gray);+ font-variant-numeric: tabular-nums;+ }++ .stats-sep {+ opacity: 0.5;+ }++ .item-error {+ font-size: 12.5px;+ font-weight: 500;+ color: var(--red);+ }++ .progress-track {+ width: 100%;+ height: 4px;+ background: var(--fill-1);+ border-radius: var(--radius-full);+ overflow: hidden;+ }++ .download-item[data-status="complete"] .progress-track,+ .download-item[data-status="complete"] .item-percent {+ display: none;+ }++ .progress-fill {+ height: 100%;+ border-radius: var(--radius-full);+ transition: width var(--duration-slow) var(--ease-out);+ }++ .progress-fill[data-status="downloading"] {+ background: var(--blue);+ }++ .progress-fill[data-status="seeding"] {+ background: var(--green);+ }++ .progress-fill[data-status="complete"] {+ background: var(--green);+ }++ .progress-fill[data-status="error"] {+ background: var(--red);+ }++ .progress-fill[data-status="paused"] {+ background: var(--gray);+ }++ .item-percent {+ font-size: var(--text-sm);+ font-weight: 500;+ color: var(--gray);+ font-variant-numeric: tabular-nums;+ }++ .quality-chip {+ padding: 1px 7px;+ font-size: 10.5px;+ font-weight: 600;+ line-height: 1.4;+ color: var(--secondary);+ background: var(--button-elevated);+ border: 1px solid var(--button-stroke);+ border-radius: 999px;+ letter-spacing: 0.2px;+ flex-shrink: 0;+ font-variant-numeric: tabular-nums;+ }++ .show-more-btn {+ align-self: center;+ font-size: 13px;+ padding: calc(var(--padding) / 2) var(--padding);+ }++ .history-toggle {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 26px;+ height: 26px;+ background: transparent;+ border: 1px solid transparent;+ border-radius: calc(var(--border-radius) / 2);+ color: var(--tertiary);+ cursor: pointer;+ flex-shrink: 0;+ }++ @media (hover: hover) {+ .history-toggle:hover {+ color: var(--secondary);+ background: var(--button-elevated);+ }+ }++ .history-toggle.on {+ color: var(--accent);+ background: var(--accent-soft, color-mix(in srgb, var(--accent) 12%, transparent));+ border-color: color-mix(in srgb, var(--accent) 25%, transparent);+ }++ .history-toggle:focus-visible {+ outline: var(--focus-ring);+ outline-offset: var(--focus-ring-offset);+ }++ .history-view {+ display: flex;+ flex-direction: column;+ gap: 6px;+ }++ .history-empty {+ color: var(--tertiary);+ font-size: 13px;+ padding: var(--padding) 0;+ }++ .history-empty-state {+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: calc(var(--padding) / 2);+ padding: calc(var(--padding) * 3) var(--padding);+ color: var(--tertiary);+ }++ .history-empty-text {+ font-size: 13.5px;+ margin: 0;+ }++ .history-list {+ list-style: none;+ margin: 0;+ padding: 0;+ display: flex;+ flex-direction: column;+ gap: 4px;+ }++ .history-item {+ display: grid;+ grid-template-columns: 1fr auto;+ grid-template-areas:+ "head actions"+ "meta actions";+ column-gap: calc(var(--padding) / 2);+ align-items: center;+ padding: 8px 10px;+ border-radius: var(--border-radius);+ background: var(--button);+ }++ .history-item[data-success="false"] {+ background: color-mix(in srgb, var(--error, #c33) 6%, var(--button));+ }++ .history-item-head {+ grid-area: head;+ display: flex;+ align-items: center;+ gap: 8px;+ min-width: 0;+ }++ .history-title {+ font-size: 13.5px;+ color: var(--secondary);+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ flex: 1;+ min-width: 0;+ }++ .history-time {+ font-size: 11.5px;+ color: var(--tertiary);+ flex-shrink: 0;+ }++ .history-item-meta {+ grid-area: meta;+ display: flex;+ gap: 6px;+ margin-top: 2px;+ padding-left: 24px;+ }++ .history-meta-chip {+ font-size: 11px;+ color: var(--tertiary);+ background: var(--button-elevated);+ padding: 2px 6px;+ border-radius: calc(var(--border-radius) / 2);+ }++ .history-meta-error {+ color: var(--error, #c33);+ background: color-mix(in srgb, var(--error, #c33) 12%, transparent);+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ max-width: 320px;+ }++ .history-item-actions {+ grid-area: actions;+ display: flex;+ gap: 2px;+ align-items: center;+ }++ .empty-links {+ display: flex;+ gap: 12px;+ flex-wrap: wrap;+ justify-content: center;+ }+ .history-link {+ margin-top: calc(var(--padding) / 2);+ display: inline-flex;+ align-items: center;+ gap: 5px;+ font-size: 12.5px;+ color: var(--tertiary);+ background: transparent;+ border: none;+ cursor: pointer;+ padding: 4px 6px;+ border-radius: calc(var(--border-radius) / 2);+ }++ @media (hover: hover) {+ .history-link:hover {+ color: var(--secondary);+ background: var(--button);+ }+ }++ .queue-reorder-hint {+ font-size: 10.5px;+ font-weight: 400;+ color: var(--tertiary);+ text-transform: none;+ letter-spacing: 0;+ margin-left: 8px;+ }++ .queue-drop-zone {+ position: relative;+ cursor: grab;+ transition: opacity 0.12s;+ }++ .queue-drop-zone:active {+ cursor: grabbing;+ }++ .queue-drop-zone.dragging {+ opacity: 0.4;+ }++ .queue-drop-zone.drop-before::before,+ .queue-drop-zone.drop-after::after {+ content: "";+ position: absolute;+ left: 8px;+ right: 8px;+ height: 2px;+ background: var(--accent);+ border-radius: 1px;+ pointer-events: none;+ }++ .queue-drop-zone.drop-before::before {+ top: -2px;+ }++ .queue-drop-zone.drop-after::after {+ bottom: -2px;+ }+</style>