Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: add search and download features to study module

Tonho53acb4e274e3
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 2a4fcdf8..d8a18c28 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -65,7 +65,28 @@ jobs:
with:
tagName: v__VERSION__
releaseName: 'OmniGet v__VERSION__'
- releaseBody: 'Download the installer for your platform below.'
+ releaseBody: |
+ ## Downloads
+
+ **Windows**: `.exe` installer or portable.
+ **macOS**: `.dmg` (Apple Silicon `aarch64` or Intel `x86_64`).
+ **Linux**: `.AppImage` (universal) or `.deb` (Debian/Ubuntu).
+
+ ---
+
+ ### Debian/Ubuntu users — AppImage compatibility
+
+ **Debian 12+ ships without FUSE 2 by default**, which AppImage requires.
+ If `./omniget.AppImage` fails with a libfuse error, run:
+
+ ```bash
+ sudo apt install libfuse2
+ ```
+
+ …or use `./omniget.AppImage --appimage-extract-and-run`.
+
+ **Easier alternative**: download the `.deb` instead — works out of the
+ box on Debian 12+ and Ubuntu 22.04+.
releaseDraft: true
prerelease: false
includeUpdaterJson: false
diff --git a/src/lib/components/PetsManager.svelte b/src/lib/components/PetsManager.svelte
index 46ef902d..11fc0f7b 100644
--- a/src/lib/components/PetsManager.svelte
+++ b/src/lib/components/PetsManager.svelte
@@ -29,6 +29,9 @@
let vibeFilter = $state<PetVibe | "">("");
let lastSyncRelative = $state("");
+ let page = $state(0);
+ const PAGE_SIZE = 24;
+
const ALL_VIBES: PetVibe[] = [
"cozy", "calm", "playful", "cheerful", "focused", "mischievous",
"heroic", "edgy", "mystical", "wholesome", "chaotic", "melancholic",
@@ -82,6 +85,44 @@
});
});
+ const totalPages = $derived(Math.max(1, Math.ceil(filtered.length / PAGE_SIZE)));
+ const visible = $derived.by<LocalPetEntry[]>(() => {
+ const start = page * PAGE_SIZE;
+ return filtered.slice(start, start + PAGE_SIZE);
+ });
+
+ $effect(() => {
+ void query;
+ void kindFilter;
+ void vibeFilter;
+ page = 0;
+ });
+
+ $effect(() => {
+ if (page >= totalPages) page = Math.max(0, totalPages - 1);
+ });
+
+ function nextPage() {
+ if (page + 1 < totalPages) {
+ page += 1;
+ scrollToTop();
+ }
+ }
+ function prevPage() {
+ if (page > 0) {
+ page -= 1;
+ scrollToTop();
+ }
+ }
+ function goToPage(p: number) {
+ page = Math.max(0, Math.min(totalPages - 1, p));
+ scrollToTop();
+ }
+ function scrollToTop() {
+ const el = document.querySelector(".pets-manager");
+ if (el) el.scrollIntoView({ behavior: "smooth", block: "start" });
+ }
+
async function activate(slug: string) {
if (busySlug) return;
busySlug = slug;
@@ -209,8 +250,19 @@
{:else if filtered.length === 0}
<div class="state">Nenhum pet bate com os filtros.</div>
{:else}
+ <div class="result-info">
+ <span>
+ {filtered.length === 1
+ ? "1 pet"
+ : `${filtered.length} pets`}
+ {#if totalPages > 1}
+ · página {page + 1} de {totalPages}
+ {/if}
+ </span>
+ </div>
+
<div class="grid">
- {#each filtered as pet (pet.slug)}
+ {#each visible as pet (pet.slug)}
<PetCard
{pet}
active={pet.slug === activeSlug}
@@ -221,6 +273,47 @@
/>
{/each}
</div>
+
+ {#if totalPages > 1}
+ <nav class="pagination" aria-label="Paginação de pets">
+ <button
+ type="button"
+ class="page-btn"
+ onclick={prevPage}
+ disabled={page === 0}
+ aria-label="Página anterior"
+ >
+ ← Anterior
+ </button>
+
+ <div class="page-nums">
+ {#each Array(totalPages) as _, i (i)}
+ {#if i === 0 || i === totalPages - 1 || Math.abs(i - page) <= 1}
+ <button
+ type="button"
+ class="page-num"
+ class:active={i === page}
+ onclick={() => goToPage(i)}
+ >
+ {i + 1}
+ </button>
+ {:else if Math.abs(i - page) === 2}
+ <span class="page-ellipsis" aria-hidden="true">…</span>
+ {/if}
+ {/each}
+ </div>
+
+ <button
+ type="button"
+ class="page-btn"
+ onclick={nextPage}
+ disabled={page + 1 >= totalPages}
+ aria-label="Próxima página"
+ >
+ Próxima →
+ </button>
+ </nav>
+ {/if}
{/if}
</section>
@@ -385,4 +478,74 @@
opacity: 0.6;
cursor: progress;
}
+
+ .result-info {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ color: var(--text-muted);
+ font-size: var(--text-sm);
+ }
+
+ .pagination {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: var(--space-2);
+ margin-top: var(--space-3);
+ padding-top: var(--space-3);
+ border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
+ }
+
+ .page-btn {
+ padding: 7px 14px;
+ background: var(--surface-hi);
+ border: 1px solid var(--border);
+ border-radius: var(--radius-sm);
+ color: var(--text);
+ font-family: inherit;
+ font-size: var(--text-sm);
+ cursor: pointer;
+ transition: background var(--duration-fast) var(--ease-out);
+ }
+ .page-btn:hover:not(:disabled) {
+ background: var(--surface-mut);
+ border-color: var(--accent);
+ }
+ .page-btn:disabled {
+ opacity: 0.4;
+ cursor: not-allowed;
+ }
+
+ .page-nums {
+ display: flex;
+ gap: 2px;
+ align-items: center;
+ }
+ .page-num {
+ min-width: 32px;
+ padding: 6px 10px;
+ background: transparent;
+ border: 1px solid transparent;
+ border-radius: var(--radius-sm);
+ color: var(--text-muted);
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: var(--text-sm);
+ cursor: pointer;
+ transition: background var(--duration-fast) var(--ease-out);
+ }
+ .page-num:hover {
+ background: color-mix(in srgb, var(--accent) 8%, transparent);
+ color: var(--text);
+ }
+ .page-num.active {
+ background: var(--accent);
+ color: var(--on-accent);
+ font-weight: 600;
+ }
+ .page-ellipsis {
+ color: var(--text-muted);
+ font-size: var(--text-sm);
+ padding: 0 4px;
+ }
</style>
diff --git a/src/lib/i18n/el.json b/src/lib/i18n/el.json
index 89237444..8c37ef0c 100644
--- a/src/lib/i18n/el.json
+++ b/src/lib/i18n/el.json
@@ -844,10 +844,38 @@
"empty": "Δεν έχει γίνει ακόμα ευρετηρίαση μαθημάτων. Εκτελέστε σάρωση από τις Ρυθμίσεις.",
"error_loading_notes": "Couldn't load your notes. Try reloading or contact support if it persists.",
"health_title": "Library health",
- "health_ok": "Library is healthy. No problems detected.",
- "health_zero_byte": "Zero-byte videos ({{count}})",
- "health_missing": "Missing videos ({{count}})",
- "health_orphan_desc": "Orphan description.html ({{count}})",
+ "health_ok": "Όλα στη θέση τους.",
+ "health_banner_one": "1 αρχείο χρειάζεται την προσοχή σας",
+ "health_banner_many": "{{count}} αρχεία χρειάζονται την προσοχή σας",
+ "health_banner_part_empty": "{{count}} κενά",
+ "health_banner_part_missing": "{{count}} λείπουν",
+ "health_banner_part_orphan": "{{count}} ορφανά",
+ "health_banner_cta": "Επισκόπηση",
+ "health_banner_aria": "Άνοιγμα αναφοράς υγείας βιβλιοθήκης",
+ "health_zero_byte": "Κενά βίντεο",
+ "health_zero_byte_hint": "Αυτά δεν ολοκλήρωσαν τη λήψη. Κατεβάστε ξανά το μάθημα ή διαγράψτε το κενό αρχείο και ξανασαρώστε.",
+ "health_missing": "Βίντεο που λείπουν",
+ "health_missing_hint": "Καταγεγραμμένα στη βάση αλλά όχι στον δίσκο — συνήθως μετακινήθηκαν ή διαγράφηκαν εκτός εφαρμογής. Ο καθαρισμός αφαιρεί καταχωρήσεις μόνο όταν ο φάκελος του μαθήματος υπάρχει, άρα οι μη συνδεδεμένοι δίσκοι είναι ασφαλείς.",
+ "health_orphan_desc": "Ορφανά description.html",
+ "health_orphan_hint": "Φάκελοι με περιγραφικό κείμενο αλλά χωρίς βίντεο. Συχνά είναι \"free preview\" που δεν κατέβηκε, ή μάθημα μόνο με κείμενο που παρέλειψε ο σαρωτής.",
+ "health_checking": "Έλεγχος…",
+ "health_recheck": "Επανέλεγχος",
+ "cleanup_busy": "Καθαρισμός…",
+ "filters": "Φίλτρα",
+ "filter_status": "Κατάσταση",
+ "filter_playlist": "Playlist",
+ "filter_tags": "Ετικέτες",
+ "all_courses": "Όλα τα μαθήματα",
+ "manage_playlists": "Διαχείριση playlist →",
+ "clear_filters": "καθαρισμός",
+ "tags_hint": "Click → συμπερίληψη · Shift+Click → αποκλεισμός",
+ "loading_more": "Φόρτωση περισσότερων μαθημάτων…",
+ "status_all": "Όλα",
+ "status_in_progress": "Σε εξέλιξη",
+ "status_not_started": "Δεν ξεκίνησαν",
+ "status_completed": "Ολοκληρωμένα",
+ "view_mode_aria": "Λειτουργία προβολής",
+ "status_aria": "Κατάσταση",
"cleanup_btn": "Clean orphan entries",
"cleanup_orphan_delete": "Delete file",
"cleanup_confirm_title": "Clean missing-video entries",
@@ -881,13 +909,9 @@
"progress_pct": "{{pct}}% ολοκληρωμένο",
"favorite_on": "Κατάργηση από αγαπημένα",
"favorite_off": "Προσθήκη στα αγαπημένα",
- "filters": "Filters",
"platform": "Platform",
"status": "Status",
"status_new": "New",
- "status_not_started": "Not started",
- "status_in_progress": "In progress",
- "status_completed": "Completed",
"status_empty": "Empty",
"has_gaps": "Has gaps",
"has_notes": "Has notes",
@@ -1660,11 +1684,11 @@
"book_metadata_only": "Metadata only",
"book_borrow_only": "Borrow on archive.org",
"book_borrow_only_hint": "This book is under Controlled Digital Lending. Free download is not available; borrowing requires an archive.org account.",
- "annas_manage_link": "Advanced sources (Anna's Archive)",
- "annas_title": "Anna's Archive — advanced source",
+ "annas_manage_link": "Advanced sources (Alt Library)",
+ "annas_title": "Alt Library — advanced source",
"annas_subtitle": "Shadow-library metasearch. Disabled by default. Jurisdiction-dependent.",
"annas_warning_title": "Legal & safety notice",
- "annas_warning_body1": "Anna's Archive aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
+ "annas_warning_body1": "Alt Library aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
"annas_warning_body2": "The legality of accessing, downloading or distributing that content varies per country. In some jurisdictions (Palau, for example) personal use is permitted; in others it is not. You are solely responsible for checking your own laws.",
"annas_warning_body3": "omniget-study merely provides a programmable HTTP client. Enabling this source downloads content that YOU chose to request. Keep your own compliance.",
"annas_status": "Source status",
@@ -1673,8 +1697,8 @@
"annas_on": "Active",
"annas_enable_btn": "Enable source",
"annas_disable_btn": "Disable",
- "annas_enabled": "Anna's Archive enabled.",
- "annas_disabled": "Anna's Archive disabled.",
+ "annas_enabled": "Alt Library enabled.",
+ "annas_disabled": "Alt Library disabled.",
"annas_log_title": "Log mirrors tried",
"annas_log_hint": "Optional local log of which domains/mirrors each download used. Stored locally only.",
"annas_domains_title": "Mirror domains",
@@ -1684,17 +1708,17 @@
"annas_domains_saved": "Domains saved.",
"annas_reset_title": "Reset everything",
"annas_reset_hint": "Clears acknowledgement, disables source, restores default domains. Does NOT remove already-downloaded files.",
- "annas_reset_btn": "Reset Anna's Archive settings",
- "annas_reset_confirm": "Reset all Anna's Archive settings? Source will be disabled and require re-acknowledgement.",
+ "annas_reset_btn": "Reset Alt Library settings",
+ "annas_reset_confirm": "Reset all Alt Library settings? Source will be disabled and require re-acknowledgement.",
"annas_reset_done": "Settings reset.",
- "annas_warning_modal_title": "Before enabling Anna's Archive",
+ "annas_warning_modal_title": "Before enabling Alt Library",
"annas_warning_modal_line1": "This source scrapes shadow libraries.",
"annas_warning_modal_line2": "Most content there is copyrighted. Downloading it may be legal in your jurisdiction, grey-area, or outright illegal — verify with your local laws.",
"annas_warning_modal_line3": "omniget-study does not host content. All downloads go through mirrors YOU configure and YOU trigger.",
"annas_warning_modal_line4": "Tick the box below if you understand and accept personal responsibility for your usage.",
"annas_warning_ack_label": "I understand. I take full responsibility for my use in my jurisdiction.",
"annas_warning_cancel": "Cancel",
- "annas_warning_confirm": "Enable Anna's Archive"
+ "annas_warning_confirm": "Enable Alt Library"
},
"bulk": {
"select_all": "Select all",
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index 3b2aab95..e71e9958 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -844,10 +844,38 @@
"empty": "No courses indexed yet. Run a scan from Settings.",
"error_loading_notes": "Couldn't load your notes. Try reloading or contact support if it persists.",
"health_title": "Library health",
- "health_ok": "Library is healthy. No problems detected.",
- "health_zero_byte": "Zero-byte videos ({{count}})",
- "health_missing": "Missing videos ({{count}})",
- "health_orphan_desc": "Orphan description.html ({{count}})",
+ "health_ok": "Everything's where it should be.",
+ "health_banner_one": "1 file needs your attention",
+ "health_banner_many": "{{count}} files need your attention",
+ "health_banner_part_empty": "{{count}} empty",
+ "health_banner_part_missing": "{{count}} missing",
+ "health_banner_part_orphan": "{{count}} orphan",
+ "health_banner_cta": "Review",
+ "health_banner_aria": "Open library health report",
+ "health_zero_byte": "Empty videos",
+ "health_zero_byte_hint": "These didn't finish downloading. Re-download the course, or delete the empty file and rescan.",
+ "health_missing": "Missing videos",
+ "health_missing_hint": "Tracked in the database but not on disk — usually moved or deleted outside the app. Cleanup only removes entries when the course folder still exists, so unmounted drives are safe.",
+ "health_orphan_desc": "Orphan description.html",
+ "health_orphan_hint": "Folders with description text but no video. Often a scraped \"free preview\" that didn't download, or a text-only lesson the scanner skipped.",
+ "health_checking": "Checking…",
+ "health_recheck": "Re-check",
+ "cleanup_busy": "Cleaning…",
+ "filters": "Filters",
+ "filter_status": "Status",
+ "filter_playlist": "Playlist",
+ "filter_tags": "Tags",
+ "all_courses": "All courses",
+ "manage_playlists": "Manage playlists →",
+ "clear_filters": "clear",
+ "tags_hint": "Click → include · Shift+Click → exclude",
+ "loading_more": "Loading more courses…",
+ "status_all": "All",
+ "status_in_progress": "In progress",
+ "status_not_started": "Not started",
+ "status_completed": "Completed",
+ "view_mode_aria": "View mode",
+ "status_aria": "Status",
"cleanup_btn": "Clean orphan entries",
"cleanup_orphan_delete": "Delete file",
"cleanup_confirm_title": "Clean missing-video entries",
@@ -1661,11 +1689,11 @@
"book_metadata_only": "Metadata only",
"book_borrow_only": "Borrow on archive.org",
"book_borrow_only_hint": "This book is under Controlled Digital Lending. Free download is not available; borrowing requires an archive.org account.",
- "annas_manage_link": "Advanced sources (Anna's Archive)",
- "annas_title": "Anna's Archive — advanced source",
+ "annas_manage_link": "Advanced sources (Alt Library)",
+ "annas_title": "Alt Library — advanced source",
"annas_subtitle": "Shadow-library metasearch. Disabled by default. Jurisdiction-dependent.",
"annas_warning_title": "Legal & safety notice",
- "annas_warning_body1": "Anna's Archive aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
+ "annas_warning_body1": "Alt Library aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
"annas_warning_body2": "The legality of accessing, downloading or distributing that content varies per country. In some jurisdictions (Palau, for example) personal use is permitted; in others it is not. You are solely responsible for checking your own laws.",
"annas_warning_body3": "omniget-study merely provides a programmable HTTP client. Enabling this source downloads content that YOU chose to request. Keep your own compliance.",
"annas_status": "Source status",
@@ -1674,8 +1702,8 @@
"annas_on": "Active",
"annas_enable_btn": "Enable source",
"annas_disable_btn": "Disable",
- "annas_enabled": "Anna's Archive enabled.",
- "annas_disabled": "Anna's Archive disabled.",
+ "annas_enabled": "Alt Library enabled.",
+ "annas_disabled": "Alt Library disabled.",
"annas_log_title": "Log mirrors tried",
"annas_log_hint": "Optional local log of which domains/mirrors each download used. Stored locally only.",
"annas_domains_title": "Mirror domains",
@@ -1685,17 +1713,17 @@
"annas_domains_saved": "Domains saved.",
"annas_reset_title": "Reset everything",
"annas_reset_hint": "Clears acknowledgement, disables source, restores default domains. Does NOT remove already-downloaded files.",
- "annas_reset_btn": "Reset Anna's Archive settings",
- "annas_reset_confirm": "Reset all Anna's Archive settings? Source will be disabled and require re-acknowledgement.",
+ "annas_reset_btn": "Reset Alt Library settings",
+ "annas_reset_confirm": "Reset all Alt Library settings? Source will be disabled and require re-acknowledgement.",
"annas_reset_done": "Settings reset.",
- "annas_warning_modal_title": "Before enabling Anna's Archive",
+ "annas_warning_modal_title": "Before enabling Alt Library",
"annas_warning_modal_line1": "This source scrapes shadow libraries.",
"annas_warning_modal_line2": "Most content there is copyrighted. Downloading it may be legal in your jurisdiction, grey-area, or outright illegal — verify with your local laws.",
"annas_warning_modal_line3": "omniget-study does not host content. All downloads go through mirrors YOU configure and YOU trigger.",
"annas_warning_modal_line4": "Tick the box below if you understand and accept personal responsibility for your usage.",
"annas_warning_ack_label": "I understand. I take full responsibility for my use in my jurisdiction.",
"annas_warning_cancel": "Cancel",
- "annas_warning_confirm": "Enable Anna's Archive"
+ "annas_warning_confirm": "Enable Alt Library"
},
"bulk": {
"select_all": "Select all",
diff --git a/src/lib/i18n/fr.json b/src/lib/i18n/fr.json
index a96b5553..b792777a 100644
--- a/src/lib/i18n/fr.json
+++ b/src/lib/i18n/fr.json
@@ -844,10 +844,38 @@
"empty": "Aucun cours indexé. Lancez une analyse depuis les paramètres.",
"error_loading_notes": "Couldn't load your notes. Try reloading or contact support if it persists.",
"health_title": "Library health",
- "health_ok": "Library is healthy. No problems detected.",
- "health_zero_byte": "Zero-byte videos ({{count}})",
- "health_missing": "Missing videos ({{count}})",
- "health_orphan_desc": "Orphan description.html ({{count}})",
+ "health_ok": "Tout est à sa place.",
+ "health_banner_one": "1 fichier requiert votre attention",
+ "health_banner_many": "{{count}} fichiers requièrent votre attention",
+ "health_banner_part_empty": "{{count}} vides",
+ "health_banner_part_missing": "{{count}} manquants",
+ "health_banner_part_orphan": "{{count}} orphelins",
+ "health_banner_cta": "Examiner",
+ "health_banner_aria": "Ouvrir le rapport de santé de la bibliothèque",
+ "health_zero_byte": "Vidéos vides",
+ "health_zero_byte_hint": "Ces téléchargements n'ont pas abouti. Retéléchargez le cours, ou supprimez le fichier vide et relancez un scan.",
+ "health_missing": "Vidéos manquantes",
+ "health_missing_hint": "Enregistrées en base mais absentes du disque — généralement déplacées ou supprimées hors de l'application. Le nettoyage ne retire les entrées que si le dossier du cours existe encore, donc les disques non montés sont préservés.",
+ "health_orphan_desc": "description.html orphelins",
+ "health_orphan_hint": "Dossiers avec un texte descriptif mais sans vidéo. Souvent un \"free preview\" récupéré qui n'a pas téléchargé, ou une leçon textuelle que le scanner a sautée.",
+ "health_checking": "Vérification…",
+ "health_recheck": "Re-vérifier",
+ "cleanup_busy": "Nettoyage…",
+ "filters": "Filtres",
+ "filter_status": "Statut",
+ "filter_playlist": "Playlist",
+ "filter_tags": "Tags",
+ "all_courses": "Tous les cours",
+ "manage_playlists": "Gérer les playlists →",
+ "clear_filters": "effacer",
+ "tags_hint": "Click → inclure · Shift+Click → exclure",
+ "loading_more": "Chargement de plus de cours…",
+ "status_all": "Tous",
+ "status_in_progress": "En cours",
+ "status_not_started": "Non commencés",
+ "status_completed": "Terminés",
+ "view_mode_aria": "Mode d'affichage",
+ "status_aria": "Statut",
"cleanup_btn": "Clean orphan entries",
"cleanup_orphan_delete": "Delete file",
"cleanup_confirm_title": "Clean missing-video entries",
@@ -881,13 +909,9 @@
"progress_pct": "{{pct}} % terminé",
"favorite_on": "Retirer des favoris",
"favorite_off": "Ajouter aux favoris",
- "filters": "Filters",
"platform": "Platform",
"status": "Status",
"status_new": "New",
- "status_not_started": "Not started",
- "status_in_progress": "In progress",
- "status_completed": "Completed",
"status_empty": "Empty",
"has_gaps": "Has gaps",
"has_notes": "Has notes",
@@ -1660,11 +1684,11 @@
"book_metadata_only": "Metadata only",
"book_borrow_only": "Borrow on archive.org",
"book_borrow_only_hint": "This book is under Controlled Digital Lending. Free download is not available; borrowing requires an archive.org account.",
- "annas_manage_link": "Advanced sources (Anna's Archive)",
- "annas_title": "Anna's Archive — advanced source",
+ "annas_manage_link": "Advanced sources (Alt Library)",
+ "annas_title": "Alt Library — advanced source",
"annas_subtitle": "Shadow-library metasearch. Disabled by default. Jurisdiction-dependent.",
"annas_warning_title": "Legal & safety notice",
- "annas_warning_body1": "Anna's Archive aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
+ "annas_warning_body1": "Alt Library aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
"annas_warning_body2": "The legality of accessing, downloading or distributing that content varies per country. In some jurisdictions (Palau, for example) personal use is permitted; in others it is not. You are solely responsible for checking your own laws.",
"annas_warning_body3": "omniget-study merely provides a programmable HTTP client. Enabling this source downloads content that YOU chose to request. Keep your own compliance.",
"annas_status": "Source status",
@@ -1673,8 +1697,8 @@
"annas_on": "Active",
"annas_enable_btn": "Enable source",
"annas_disable_btn": "Disable",
- "annas_enabled": "Anna's Archive enabled.",
- "annas_disabled": "Anna's Archive disabled.",
+ "annas_enabled": "Alt Library enabled.",
+ "annas_disabled": "Alt Library disabled.",
"annas_log_title": "Log mirrors tried",
"annas_log_hint": "Optional local log of which domains/mirrors each download used. Stored locally only.",
"annas_domains_title": "Mirror domains",
@@ -1684,17 +1708,17 @@
"annas_domains_saved": "Domains saved.",
"annas_reset_title": "Reset everything",
"annas_reset_hint": "Clears acknowledgement, disables source, restores default domains. Does NOT remove already-downloaded files.",
- "annas_reset_btn": "Reset Anna's Archive settings",
- "annas_reset_confirm": "Reset all Anna's Archive settings? Source will be disabled and require re-acknowledgement.",
+ "annas_reset_btn": "Reset Alt Library settings",
+ "annas_reset_confirm": "Reset all Alt Library settings? Source will be disabled and require re-acknowledgement.",
"annas_reset_done": "Settings reset.",
- "annas_warning_modal_title": "Before enabling Anna's Archive",
+ "annas_warning_modal_title": "Before enabling Alt Library",
"annas_warning_modal_line1": "This source scrapes shadow libraries.",
"annas_warning_modal_line2": "Most content there is copyrighted. Downloading it may be legal in your jurisdiction, grey-area, or outright illegal — verify with your local laws.",
"annas_warning_modal_line3": "omniget-study does not host content. All downloads go through mirrors YOU configure and YOU trigger.",
"annas_warning_modal_line4": "Tick the box below if you understand and accept personal responsibility for your usage.",
"annas_warning_ack_label": "I understand. I take full responsibility for my use in my jurisdiction.",
"annas_warning_cancel": "Cancel",
- "annas_warning_confirm": "Enable Anna's Archive"
+ "annas_warning_confirm": "Enable Alt Library"
},
"bulk": {
"select_all": "Select all",
diff --git a/src/lib/i18n/it.json b/src/lib/i18n/it.json
index 05ede7be..9224917d 100644
--- a/src/lib/i18n/it.json
+++ b/src/lib/i18n/it.json
@@ -844,10 +844,38 @@
"empty": "Nessun corso indicizzato. Avvia una scansione dalle impostazioni.",
"error_loading_notes": "Couldn't load your notes. Try reloading or contact support if it persists.",
"health_title": "Library health",
- "health_ok": "Library is healthy. No problems detected.",
- "health_zero_byte": "Zero-byte videos ({{count}})",
- "health_missing": "Missing videos ({{count}})",
- "health_orphan_desc": "Orphan description.html ({{count}})",
+ "health_ok": "Tutto al suo posto.",
+ "health_banner_one": "1 file richiede la tua attenzione",
+ "health_banner_many": "{{count}} file richiedono la tua attenzione",
+ "health_banner_part_empty": "{{count}} vuoti",
+ "health_banner_part_missing": "{{count}} mancanti",
+ "health_banner_part_orphan": "{{count}} orfani",
+ "health_banner_cta": "Rivedi",
+ "health_banner_aria": "Apri il rapporto di salute della libreria",
+ "health_zero_byte": "Video vuoti",
+ "health_zero_byte_hint": "Non hanno completato il download. Riscarica il corso, oppure elimina il file vuoto e rifai la scansione.",
+ "health_missing": "Video mancanti",
+ "health_missing_hint": "Registrati nel database ma non sul disco — di solito spostati o eliminati fuori dall'app. La pulizia rimuove le voci solo se la cartella del corso esiste ancora, quindi i drive smontati sono al sicuro.",
+ "health_orphan_desc": "description.html orfani",
+ "health_orphan_hint": "Cartelle con testo descrittivo ma senza video. Spesso una \"free preview\" raccolta che non ha scaricato, o una lezione di solo testo saltata dallo scanner.",
+ "health_checking": "Verifica in corso…",
+ "health_recheck": "Riverifica",
+ "cleanup_busy": "Pulizia in corso…",
+ "filters": "Filtri",
+ "filter_status": "Stato",
+ "filter_playlist": "Playlist",
+ "filter_tags": "Tag",
+ "all_courses": "Tutti i corsi",
+ "manage_playlists": "Gestisci playlist →",
+ "clear_filters": "azzera",
+ "tags_hint": "Click → includi · Shift+Click → escludi",
+ "loading_more": "Caricamento altri corsi…",
+ "status_all": "Tutti",
+ "status_in_progress": "In corso",
+ "status_not_started": "Non iniziati",
+ "status_completed": "Completati",
+ "view_mode_aria": "Modalità di visualizzazione",
+ "status_aria": "Stato",
"cleanup_btn": "Clean orphan entries",
"cleanup_orphan_delete": "Delete file",
"cleanup_confirm_title": "Clean missing-video entries",
@@ -881,13 +909,9 @@
"progress_pct": "{{pct}}% completato",
"favorite_on": "Rimuovi dai preferiti",
"favorite_off": "Aggiungi ai preferiti",
- "filters": "Filters",
"platform": "Platform",
"status": "Status",
"status_new": "New",
- "status_not_started": "Not started",
- "status_in_progress": "In progress",
- "status_completed": "Completed",
"status_empty": "Empty",
"has_gaps": "Has gaps",
"has_notes": "Has notes",
@@ -1660,11 +1684,11 @@
"book_metadata_only": "Metadata only",
"book_borrow_only": "Borrow on archive.org",
"book_borrow_only_hint": "This book is under Controlled Digital Lending. Free download is not available; borrowing requires an archive.org account.",
- "annas_manage_link": "Advanced sources (Anna's Archive)",
- "annas_title": "Anna's Archive — advanced source",
+ "annas_manage_link": "Advanced sources (Alt Library)",
+ "annas_title": "Alt Library — advanced source",
"annas_subtitle": "Shadow-library metasearch. Disabled by default. Jurisdiction-dependent.",
"annas_warning_title": "Legal & safety notice",
- "annas_warning_body1": "Anna's Archive aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
+ "annas_warning_body1": "Alt Library aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
"annas_warning_body2": "The legality of accessing, downloading or distributing that content varies per country. In some jurisdictions (Palau, for example) personal use is permitted; in others it is not. You are solely responsible for checking your own laws.",
"annas_warning_body3": "omniget-study merely provides a programmable HTTP client. Enabling this source downloads content that YOU chose to request. Keep your own compliance.",
"annas_status": "Source status",
@@ -1673,8 +1697,8 @@
"annas_on": "Active",
"annas_enable_btn": "Enable source",
"annas_disable_btn": "Disable",
- "annas_enabled": "Anna's Archive enabled.",
- "annas_disabled": "Anna's Archive disabled.",
+ "annas_enabled": "Alt Library enabled.",
+ "annas_disabled": "Alt Library disabled.",
"annas_log_title": "Log mirrors tried",
"annas_log_hint": "Optional local log of which domains/mirrors each download used. Stored locally only.",
"annas_domains_title": "Mirror domains",
@@ -1684,17 +1708,17 @@
"annas_domains_saved": "Domains saved.",
"annas_reset_title": "Reset everything",
"annas_reset_hint": "Clears acknowledgement, disables source, restores default domains. Does NOT remove already-downloaded files.",
- "annas_reset_btn": "Reset Anna's Archive settings",
- "annas_reset_confirm": "Reset all Anna's Archive settings? Source will be disabled and require re-acknowledgement.",
+ "annas_reset_btn": "Reset Alt Library settings",
+ "annas_reset_confirm": "Reset all Alt Library settings? Source will be disabled and require re-acknowledgement.",
"annas_reset_done": "Settings reset.",
- "annas_warning_modal_title": "Before enabling Anna's Archive",
+ "annas_warning_modal_title": "Before enabling Alt Library",
"annas_warning_modal_line1": "This source scrapes shadow libraries.",
"annas_warning_modal_line2": "Most content there is copyrighted. Downloading it may be legal in your jurisdiction, grey-area, or outright illegal — verify with your local laws.",
"annas_warning_modal_line3": "omniget-study does not host content. All downloads go through mirrors YOU configure and YOU trigger.",
"annas_warning_modal_line4": "Tick the box below if you understand and accept personal responsibility for your usage.",
"annas_warning_ack_label": "I understand. I take full responsibility for my use in my jurisdiction.",
"annas_warning_cancel": "Cancel",
- "annas_warning_confirm": "Enable Anna's Archive"
+ "annas_warning_confirm": "Enable Alt Library"
},
"bulk": {
"select_all": "Select all",
diff --git a/src/lib/i18n/ja.json b/src/lib/i18n/ja.json
index 17e39fd7..3a522f08 100644
--- a/src/lib/i18n/ja.json
+++ b/src/lib/i18n/ja.json
@@ -844,10 +844,38 @@
"empty": "まだコースがインデックス化されていません。設定からスキャンを実行してください。",
"error_loading_notes": "Couldn't load your notes. Try reloading or contact support if it persists.",
"health_title": "Library health",
- "health_ok": "Library is healthy. No problems detected.",
- "health_zero_byte": "Zero-byte videos ({{count}})",
- "health_missing": "Missing videos ({{count}})",
- "health_orphan_desc": "Orphan description.html ({{count}})",
+ "health_ok": "すべてが正しい場所にあります。",
+ "health_banner_one": "1 件のファイルに注意が必要です",
+ "health_banner_many": "{{count}} 件のファイルに注意が必要です",
+ "health_banner_part_empty": "空 {{count}} 件",
+ "health_banner_part_missing": "欠落 {{count}} 件",
+ "health_banner_part_orphan": "孤立 {{count}} 件",
+ "health_banner_cta": "確認",
+ "health_banner_aria": "ライブラリのヘルスレポートを開く",
+ "health_zero_byte": "空の動画",
+ "health_zero_byte_hint": "ダウンロードが完了していません。コースを再ダウンロードするか、空ファイルを削除して再スキャンしてください。",
+ "health_missing": "欠落した動画",
+ "health_missing_hint": "DB に登録されていますがディスク上にありません — アプリ外で移動または削除された可能性があります。コースフォルダが存在する場合のみクリーンアップで削除されるので、未マウントのドライブは安全です。",
+ "health_orphan_desc": "孤立した description.html",
+ "health_orphan_hint": "説明テキストはあるが動画がないフォルダ。スクレイピングされた「無料プレビュー」がダウンロードされなかった、またはスキャナがスキップしたテキストのみのレッスンの可能性があります。",
+ "health_checking": "確認中…",
+ "health_recheck": "再確認",
+ "cleanup_busy": "クリーンアップ中…",
+ "filters": "フィルタ",
+ "filter_status": "ステータス",
+ "filter_playlist": "プレイリスト",
+ "filter_tags": "タグ",
+ "all_courses": "すべてのコース",
+ "manage_playlists": "プレイリストを管理 →",
+ "clear_filters": "クリア",
+ "tags_hint": "クリック → 含める · Shift+クリック → 除外",
+ "loading_more": "さらにコースを読み込み中…",
+ "status_all": "すべて",
+ "status_in_progress": "進行中",
+ "status_not_started": "未開始",
+ "status_completed": "完了",
+ "view_mode_aria": "表示モード",
+ "status_aria": "ステータス",
"cleanup_btn": "Clean orphan entries",
"cleanup_orphan_delete": "Delete file",
"cleanup_confirm_title": "Clean missing-video entries",
@@ -881,13 +909,9 @@
"progress_pct": "{{pct}}% 完了",
"favorite_on": "お気に入りから削除",
"favorite_off": "お気に入りに追加",
- "filters": "Filters",
"platform": "Platform",
"status": "Status",
"status_new": "New",
- "status_not_started": "Not started",
- "status_in_progress": "In progress",
- "status_completed": "Completed",
"status_empty": "Empty",
"has_gaps": "Has gaps",
"has_notes": "Has notes",
@@ -1660,11 +1684,11 @@
"book_metadata_only": "Metadata only",
"book_borrow_only": "Borrow on archive.org",
"book_borrow_only_hint": "This book is under Controlled Digital Lending. Free download is not available; borrowing requires an archive.org account.",
- "annas_manage_link": "Advanced sources (Anna's Archive)",
- "annas_title": "Anna's Archive — advanced source",
+ "annas_manage_link": "Advanced sources (Alt Library)",
+ "annas_title": "Alt Library — advanced source",
"annas_subtitle": "Shadow-library metasearch. Disabled by default. Jurisdiction-dependent.",
"annas_warning_title": "Legal & safety notice",
- "annas_warning_body1": "Anna's Archive aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
+ "annas_warning_body1": "Alt Library aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
"annas_warning_body2": "The legality of accessing, downloading or distributing that content varies per country. In some jurisdictions (Palau, for example) personal use is permitted; in others it is not. You are solely responsible for checking your own laws.",
"annas_warning_body3": "omniget-study merely provides a programmable HTTP client. Enabling this source downloads content that YOU chose to request. Keep your own compliance.",
"annas_status": "Source status",
@@ -1673,8 +1697,8 @@
"annas_on": "Active",
"annas_enable_btn": "Enable source",
"annas_disable_btn": "Disable",
- "annas_enabled": "Anna's Archive enabled.",
- "annas_disabled": "Anna's Archive disabled.",
+ "annas_enabled": "Alt Library enabled.",
+ "annas_disabled": "Alt Library disabled.",
"annas_log_title": "Log mirrors tried",
"annas_log_hint": "Optional local log of which domains/mirrors each download used. Stored locally only.",
"annas_domains_title": "Mirror domains",
@@ -1684,17 +1708,17 @@
"annas_domains_saved": "Domains saved.",
"annas_reset_title": "Reset everything",
"annas_reset_hint": "Clears acknowledgement, disables source, restores default domains. Does NOT remove already-downloaded files.",
- "annas_reset_btn": "Reset Anna's Archive settings",
- "annas_reset_confirm": "Reset all Anna's Archive settings? Source will be disabled and require re-acknowledgement.",
+ "annas_reset_btn": "Reset Alt Library settings",
+ "annas_reset_confirm": "Reset all Alt Library settings? Source will be disabled and require re-acknowledgement.",
"annas_reset_done": "Settings reset.",
- "annas_warning_modal_title": "Before enabling Anna's Archive",
+ "annas_warning_modal_title": "Before enabling Alt Library",
"annas_warning_modal_line1": "This source scrapes shadow libraries.",
"annas_warning_modal_line2": "Most content there is copyrighted. Downloading it may be legal in your jurisdiction, grey-area, or outright illegal — verify with your local laws.",
"annas_warning_modal_line3": "omniget-study does not host content. All downloads go through mirrors YOU configure and YOU trigger.",
"annas_warning_modal_line4": "Tick the box below if you understand and accept personal responsibility for your usage.",
"annas_warning_ack_label": "I understand. I take full responsibility for my use in my jurisdiction.",
"annas_warning_cancel": "Cancel",
- "annas_warning_confirm": "Enable Anna's Archive"
+ "annas_warning_confirm": "Enable Alt Library"
},
"bulk": {
"select_all": "Select all",
diff --git a/src/lib/i18n/keys.ts b/src/lib/i18n/keys.ts
index e836179f..b2a8bdb2 100644
--- a/src/lib/i18n/keys.ts
+++ b/src/lib/i18n/keys.ts
@@ -791,11 +791,13 @@ export type TranslationKeys =
| 'study.lesson.theater_hint'
| 'study.lesson.theater_off'
| 'study.lesson.theater_on'
+ | 'study.library.all_courses'
| 'study.library.back'
| 'study.library.browse_breadcrumb_root'
| 'study.library.browse_empty'
| 'study.library.browse_empty_roots'
| 'study.library.cleanup_btn'
+ | 'study.library.cleanup_busy'
| 'study.library.cleanup_confirm_message'
| 'study.library.cleanup_confirm_title'
| 'study.library.cleanup_done'
@@ -804,23 +806,39 @@ export type TranslationKeys =
| 'study.library.cleanup_force_confirm_title'
| 'study.library.cleanup_force_hint'
| 'study.library.cleanup_orphan_delete'
+ | 'study.library.clear_filters'
| 'study.library.empty'
| 'study.library.error_loading_notes'
| 'study.library.favorite'
| 'study.library.favorite_off'
| 'study.library.favorite_on'
| 'study.library.favorites_only'
+ | 'study.library.filter_playlist'
+ | 'study.library.filter_status'
+ | 'study.library.filter_tags'
| 'study.library.filters'
| 'study.library.folder'
| 'study.library.gap'
| 'study.library.has_cards'
| 'study.library.has_gaps'
| 'study.library.has_notes'
+ | 'study.library.health_banner_aria'
+ | 'study.library.health_banner_cta'
+ | 'study.library.health_banner_many'
+ | 'study.library.health_banner_one'
+ | 'study.library.health_banner_part_empty'
+ | 'study.library.health_banner_part_missing'
+ | 'study.library.health_banner_part_orphan'
+ | 'study.library.health_checking'
| 'study.library.health_missing'
+ | 'study.library.health_missing_hint'
| 'study.library.health_ok'
| 'study.library.health_orphan_desc'
+ | 'study.library.health_orphan_hint'
+ | 'study.library.health_recheck'
| 'study.library.health_title'
| 'study.library.health_zero_byte'
+ | 'study.library.health_zero_byte_hint'
| 'study.library.history'
| 'study.library.history_empty'
| 'study.library.kind_all'
@@ -829,7 +847,9 @@ export type TranslationKeys =
| 'study.library.kind_media_badge'
| 'study.library.lessons'
| 'study.library.lessons_count'
+ | 'study.library.loading_more'
| 'study.library.loose_lessons'
+ | 'study.library.manage_playlists'
| 'study.library.mode_browse'
| 'study.library.mode_courses'
| 'study.library.mode_telegram'
@@ -872,6 +892,8 @@ export type TranslationKeys =
| 'study.library.sort_recent'
| 'study.library.sort_title'
| 'study.library.status'
+ | 'study.library.status_all'
+ | 'study.library.status_aria'
| 'study.library.status_completed'
| 'study.library.status_empty'
| 'study.library.status_in_progress'
@@ -880,6 +902,7 @@ export type TranslationKeys =
| 'study.library.tag'
| 'study.library.tag_add'
| 'study.library.tags'
+ | 'study.library.tags_hint'
| 'study.library.telegram.album_indicator'
| 'study.library.telegram.album_next'
| 'study.library.telegram.album_prev'
@@ -1069,6 +1092,7 @@ export type TranslationKeys =
| 'study.library.videos_count'
| 'study.library.view_grid'
| 'study.library.view_list'
+ | 'study.library.view_mode_aria'
| 'study.library.watch_back'
| 'study.library.watch_file_missing'
| 'study.library.watch_not_found'
diff --git a/src/lib/i18n/pt.json b/src/lib/i18n/pt.json
index 3ee4e0ff..a0cfa085 100644
--- a/src/lib/i18n/pt.json
+++ b/src/lib/i18n/pt.json
@@ -844,10 +844,38 @@
"empty": "Nenhum curso indexado. Rode uma varredura em Configurações.",
"error_loading_notes": "Não foi possível carregar suas notas. Tente recarregar ou entre em contato com o suporte.",
"health_title": "Saúde da biblioteca",
- "health_ok": "Biblioteca íntegra. Nenhum problema detectado.",
- "health_zero_byte": "Vídeos com 0 bytes ({{count}})",
- "health_missing": "Vídeos ausentes ({{count}})",
- "health_orphan_desc": "description.html órfãs ({{count}})",
+ "health_ok": "Tudo nos seus lugares.",
+ "health_banner_one": "1 arquivo precisa da sua atenção",
+ "health_banner_many": "{{count}} arquivos precisam da sua atenção",
+ "health_banner_part_empty": "{{count}} vazios",
+ "health_banner_part_missing": "{{count}} sumiram",
+ "health_banner_part_orphan": "{{count}} órfãos",
+ "health_banner_cta": "Revisar",
+ "health_banner_aria": "Abrir relatório de saúde da biblioteca",
+ "health_zero_byte": "Vídeos vazios",
+ "health_zero_byte_hint": "Esses não terminaram de baixar. Re-baixe o curso, ou apague o arquivo vazio e faça um rescan.",
+ "health_missing": "Vídeos ausentes",
+ "health_missing_hint": "Estão no banco mas não no disco — provavelmente foram movidos ou apagados por fora do app. A limpeza só remove se a pasta do curso ainda existir, então drives desmontados ficam seguros.",
+ "health_orphan_desc": "description.html órfãs",
+ "health_orphan_hint": "Pastas com texto mas sem vídeo. Costuma ser um \"free preview\" raspado que não baixou, ou uma aula só de texto que o scanner pulou.",
+ "health_checking": "Verificando…",
+ "health_recheck": "Re-verificar",
+ "cleanup_busy": "Limpando…",
+ "filters": "Filtros",
+ "filter_status": "Status",
+ "filter_playlist": "Playlist",
+ "filter_tags": "Tags",
+ "all_courses": "Todos os cursos",
+ "manage_playlists": "Gerenciar playlists →",
+ "clear_filters": "limpar",
+ "tags_hint": "Click → incluir · Shift+Click → excluir",
+ "loading_more": "Carregando mais cursos…",
+ "status_all": "Todos",
+ "status_in_progress": "Em progresso",
+ "status_not_started": "Não iniciados",
+ "status_completed": "Concluídos",
+ "view_mode_aria": "Modo de visualização",
+ "status_aria": "Status",
"cleanup_btn": "Limpar entradas órfãs",
"cleanup_orphan_delete": "Apagar arquivo",
"cleanup_confirm_title": "Limpar entradas de aulas ausentes",
@@ -881,13 +909,9 @@
"progress_pct": "{{pct}}% concluído",
"favorite_on": "Desfavoritar",
"favorite_off": "Favoritar",
- "filters": "Filtros",
"platform": "Plataforma",
"status": "Status",
"status_new": "Novo",
- "status_not_started": "Não iniciado",
- "status_in_progress": "Em andamento",
- "status_completed": "Concluído",
"status_empty": "Vazio",
"has_gaps": "Só com lacunas",
"has_notes": "Só com notas",
@@ -1660,11 +1684,11 @@
"book_metadata_only": "Só metadata",
"book_borrow_only": "Emprestar no archive.org",
"book_borrow_only_hint": "Este livro está em Controlled Digital Lending. Download livre indisponível; empréstimo exige conta do archive.org.",
- "annas_manage_link": "Fontes avançadas (Anna's Archive)",
- "annas_title": "Anna's Archive — fonte avançada",
+ "annas_manage_link": "Fontes avançadas (Alt Library)",
+ "annas_title": "Alt Library — fonte avançada",
"annas_subtitle": "Metasearch de shadow library. Desativada por padrão. Depende da jurisdição.",
"annas_warning_title": "Aviso legal e de uso",
- "annas_warning_body1": "Anna's Archive agrega mirrors do LibGen, Z-Library, Sci-Hub e outras shadow libraries. Material lá pode ter copyright.",
+ "annas_warning_body1": "Alt Library agrega mirrors do LibGen, Z-Library, Sci-Hub e outras shadow libraries. Material lá pode ter copyright.",
"annas_warning_body2": "A legalidade de acessar, baixar ou distribuir esse conteúdo varia por país. Em algumas jurisdições (Palau, por exemplo) o uso pessoal é permitido; em outras não. Você é responsável por verificar as leis do seu país.",
"annas_warning_body3": "omniget-study só fornece um cliente HTTP programável. Ao ativar essa fonte, o que é baixado é o que VOCÊ pediu. Conformidade é sua.",
"annas_status": "Status da fonte",
@@ -1673,8 +1697,8 @@
"annas_on": "Ativa",
"annas_enable_btn": "Ativar fonte",
"annas_disable_btn": "Desativar",
- "annas_enabled": "Anna's Archive ativada.",
- "annas_disabled": "Anna's Archive desativada.",
+ "annas_enabled": "Alt Library ativada.",
+ "annas_disabled": "Alt Library desativada.",
"annas_log_title": "Log de mirrors tentados",
"annas_log_hint": "Log local opcional com os domínios/mirrors usados em cada download. Armazenado só localmente.",
"annas_domains_title": "Domínios mirror",
@@ -1684,17 +1708,17 @@
"annas_domains_saved": "Domínios salvos.",
"annas_reset_title": "Resetar tudo",
"annas_reset_hint": "Limpa aceite, desativa fonte, restaura domínios padrão. NÃO remove arquivos já baixados.",
- "annas_reset_btn": "Resetar configurações do Anna's Archive",
- "annas_reset_confirm": "Resetar todas as configurações do Anna's Archive? A fonte será desativada e exigirá nova aceitação.",
+ "annas_reset_btn": "Resetar configurações do Alt Library",
+ "annas_reset_confirm": "Resetar todas as configurações do Alt Library? A fonte será desativada e exigirá nova aceitação.",
"annas_reset_done": "Configurações resetadas.",
- "annas_warning_modal_title": "Antes de ativar Anna's Archive",
+ "annas_warning_modal_title": "Antes de ativar Alt Library",
"annas_warning_modal_line1": "Essa fonte faz scraping de shadow libraries.",
"annas_warning_modal_line2": "A maior parte do conteúdo tem copyright. Baixar pode ser legal na sua jurisdição, zona cinza, ou ilegal — verifique suas leis locais.",
"annas_warning_modal_line3": "omniget-study não hospeda conteúdo. Todos os downloads passam por mirrors que VOCÊ configura e VOCÊ dispara.",
"annas_warning_modal_line4": "Marque a caixa abaixo se você entende e aceita responsabilidade pessoal pelo seu uso.",
"annas_warning_ack_label": "Entendo. Assumo total responsabilidade pelo meu uso na minha jurisdição.",
"annas_warning_cancel": "Cancelar",
- "annas_warning_confirm": "Ativar Anna's Archive"
+ "annas_warning_confirm": "Ativar Alt Library"
},
"bulk": {
"select_all": "Selecionar tudo",
diff --git a/src/lib/i18n/zh-TW.json b/src/lib/i18n/zh-TW.json
index 7ee74b0d..64610698 100644
--- a/src/lib/i18n/zh-TW.json
+++ b/src/lib/i18n/zh-TW.json
@@ -844,10 +844,38 @@
"empty": "尚未索引任何課程。請從設定中執行掃描。",
"error_loading_notes": "Couldn't load your notes. Try reloading or contact support if it persists.",
"health_title": "Library health",
- "health_ok": "Library is healthy. No problems detected.",
- "health_zero_byte": "Zero-byte videos ({{count}})",
- "health_missing": "Missing videos ({{count}})",
- "health_orphan_desc": "Orphan description.html ({{count}})",
+ "health_ok": "一切都在它該在的地方。",
+ "health_banner_one": "1 個檔案需要您的關注",
+ "health_banner_many": "{{count}} 個檔案需要您的關注",
+ "health_banner_part_empty": "{{count}} 個空檔案",
+ "health_banner_part_missing": "{{count}} 個缺失",
+ "health_banner_part_orphan": "{{count}} 個孤立",
+ "health_banner_cta": "查看",
+ "health_banner_aria": "開啟資料庫健康報告",
+ "health_zero_byte": "空影片",
+ "health_zero_byte_hint": "這些未完成下載。重新下載課程,或刪除空檔案並重新掃描。",
+ "health_missing": "缺失的影片",
+ "health_missing_hint": "資料庫中有記錄但磁碟上沒有 — 通常是在應用程式外被移動或刪除。清理僅在課程資料夾仍存在時移除項目,因此未掛載的磁碟機是安全的。",
+ "health_orphan_desc": "孤立的 description.html",
+ "health_orphan_hint": "有說明文字但無影片的資料夾。通常是已抓取但未下載的\"免費預覽\",或掃描器跳過的純文字課程。",
+ "health_checking": "檢查中…",
+ "health_recheck": "重新檢查",
+ "cleanup_busy": "清理中…",
+ "filters": "篩選",
+ "filter_status": "狀態",
+ "filter_playlist": "播放清單",
+ "filter_tags": "標籤",
+ "all_courses": "所有課程",
+ "manage_playlists": "管理播放清單 →",
+ "clear_filters": "清除",
+ "tags_hint": "點擊 → 包含 · Shift+點擊 → 排除",
+ "loading_more": "載入更多課程…",
+ "status_all": "全部",
+ "status_in_progress": "進行中",
+ "status_not_started": "未開始",
+ "status_completed": "已完成",
+ "view_mode_aria": "檢視模式",
+ "status_aria": "狀態",
"cleanup_btn": "Clean orphan entries",
"cleanup_orphan_delete": "Delete file",
"cleanup_confirm_title": "Clean missing-video entries",
@@ -881,13 +909,9 @@
"progress_pct": "已完成 {{pct}}%",
"favorite_on": "取消收藏",
"favorite_off": "收藏",
- "filters": "Filters",
"platform": "Platform",
"status": "Status",
"status_new": "New",
- "status_not_started": "Not started",
- "status_in_progress": "In progress",
- "status_completed": "Completed",
"status_empty": "Empty",
"has_gaps": "Has gaps",
"has_notes": "Has notes",
@@ -1660,11 +1684,11 @@
"book_metadata_only": "Metadata only",
"book_borrow_only": "Borrow on archive.org",
"book_borrow_only_hint": "This book is under Controlled Digital Lending. Free download is not available; borrowing requires an archive.org account.",
- "annas_manage_link": "Advanced sources (Anna's Archive)",
- "annas_title": "Anna's Archive — advanced source",
+ "annas_manage_link": "Advanced sources (Alt Library)",
+ "annas_title": "Alt Library — advanced source",
"annas_subtitle": "Shadow-library metasearch. Disabled by default. Jurisdiction-dependent.",
"annas_warning_title": "Legal & safety notice",
- "annas_warning_body1": "Anna's Archive aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
+ "annas_warning_body1": "Alt Library aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
"annas_warning_body2": "The legality of accessing, downloading or distributing that content varies per country. In some jurisdictions (Palau, for example) personal use is permitted; in others it is not. You are solely responsible for checking your own laws.",
"annas_warning_body3": "omniget-study merely provides a programmable HTTP client. Enabling this source downloads content that YOU chose to request. Keep your own compliance.",
"annas_status": "Source status",
@@ -1673,8 +1697,8 @@
"annas_on": "Active",
"annas_enable_btn": "Enable source",
"annas_disable_btn": "Disable",
- "annas_enabled": "Anna's Archive enabled.",
- "annas_disabled": "Anna's Archive disabled.",
+ "annas_enabled": "Alt Library enabled.",
+ "annas_disabled": "Alt Library disabled.",
"annas_log_title": "Log mirrors tried",
"annas_log_hint": "Optional local log of which domains/mirrors each download used. Stored locally only.",
"annas_domains_title": "Mirror domains",
@@ -1684,17 +1708,17 @@
"annas_domains_saved": "Domains saved.",
"annas_reset_title": "Reset everything",
"annas_reset_hint": "Clears acknowledgement, disables source, restores default domains. Does NOT remove already-downloaded files.",
- "annas_reset_btn": "Reset Anna's Archive settings",
- "annas_reset_confirm": "Reset all Anna's Archive settings? Source will be disabled and require re-acknowledgement.",
+ "annas_reset_btn": "Reset Alt Library settings",
+ "annas_reset_confirm": "Reset all Alt Library settings? Source will be disabled and require re-acknowledgement.",
"annas_reset_done": "Settings reset.",
- "annas_warning_modal_title": "Before enabling Anna's Archive",
+ "annas_warning_modal_title": "Before enabling Alt Library",
"annas_warning_modal_line1": "This source scrapes shadow libraries.",
"annas_warning_modal_line2": "Most content there is copyrighted. Downloading it may be legal in your jurisdiction, grey-area, or outright illegal — verify with your local laws.",
"annas_warning_modal_line3": "omniget-study does not host content. All downloads go through mirrors YOU configure and YOU trigger.",
"annas_warning_modal_line4": "Tick the box below if you understand and accept personal responsibility for your usage.",
"annas_warning_ack_label": "I understand. I take full responsibility for my use in my jurisdiction.",
"annas_warning_cancel": "Cancel",
- "annas_warning_confirm": "Enable Anna's Archive"
+ "annas_warning_confirm": "Enable Alt Library"
},
"bulk": {
"select_all": "Select all",
diff --git a/src/lib/i18n/zh.json b/src/lib/i18n/zh.json
index d621f393..1d7ad84f 100644
--- a/src/lib/i18n/zh.json
+++ b/src/lib/i18n/zh.json
@@ -844,10 +844,38 @@
"empty": "尚未索引任何课程。请从设置中运行扫描。",
"error_loading_notes": "Couldn't load your notes. Try reloading or contact support if it persists.",
"health_title": "Library health",
- "health_ok": "Library is healthy. No problems detected.",
- "health_zero_byte": "Zero-byte videos ({{count}})",
- "health_missing": "Missing videos ({{count}})",
- "health_orphan_desc": "Orphan description.html ({{count}})",
+ "health_ok": "一切都在它该在的地方。",
+ "health_banner_one": "1 个文件需要您的关注",
+ "health_banner_many": "{{count}} 个文件需要您的关注",
+ "health_banner_part_empty": "{{count}} 个空文件",
+ "health_banner_part_missing": "{{count}} 个缺失",
+ "health_banner_part_orphan": "{{count}} 个孤立",
+ "health_banner_cta": "查看",
+ "health_banner_aria": "打开库健康报告",
+ "health_zero_byte": "空视频",
+ "health_zero_byte_hint": "这些未完成下载。重新下载课程,或删除空文件并重新扫描。",
+ "health_missing": "缺失的视频",
+ "health_missing_hint": "数据库中有记录但磁盘上没有 — 通常是在应用外被移动或删除。清理仅在课程文件夹仍存在时移除条目,因此未挂载的驱动器是安全的。",
+ "health_orphan_desc": "孤立的 description.html",
+ "health_orphan_hint": "有说明文字但无视频的文件夹。通常是已抓取但未下载的\"免费预览\",或扫描器跳过的纯文本课程。",
+ "health_checking": "检查中…",
+ "health_recheck": "重新检查",
+ "cleanup_busy": "清理中…",
+ "filters": "筛选",
+ "filter_status": "状态",
+ "filter_playlist": "播放列表",
+ "filter_tags": "标签",
+ "all_courses": "所有课程",
+ "manage_playlists": "管理播放列表 →",
+ "clear_filters": "清除",
+ "tags_hint": "点击 → 包含 · Shift+点击 → 排除",
+ "loading_more": "加载更多课程…",
+ "status_all": "全部",
+ "status_in_progress": "进行中",
+ "status_not_started": "未开始",
+ "status_completed": "已完成",
+ "view_mode_aria": "视图模式",
+ "status_aria": "状态",
"cleanup_btn": "Clean orphan entries",
"cleanup_orphan_delete": "Delete file",
"cleanup_confirm_title": "Clean missing-video entries",
@@ -881,13 +909,9 @@
"progress_pct": "已完成 {{pct}}%",
"favorite_on": "取消收藏",
"favorite_off": "收藏",
- "filters": "Filters",
"platform": "Platform",
"status": "Status",
"status_new": "New",
- "status_not_started": "Not started",
- "status_in_progress": "In progress",
- "status_completed": "Completed",
"status_empty": "Empty",
"has_gaps": "Has gaps",
"has_notes": "Has notes",
@@ -1660,11 +1684,11 @@
"book_metadata_only": "Metadata only",
"book_borrow_only": "Borrow on archive.org",
"book_borrow_only_hint": "This book is under Controlled Digital Lending. Free download is not available; borrowing requires an archive.org account.",
- "annas_manage_link": "Advanced sources (Anna's Archive)",
- "annas_title": "Anna's Archive — advanced source",
+ "annas_manage_link": "Advanced sources (Alt Library)",
+ "annas_title": "Alt Library — advanced source",
"annas_subtitle": "Shadow-library metasearch. Disabled by default. Jurisdiction-dependent.",
"annas_warning_title": "Legal & safety notice",
- "annas_warning_body1": "Anna's Archive aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
+ "annas_warning_body1": "Alt Library aggregates mirrors of LibGen, Z-Library, Sci-Hub and other shadow libraries. Material there may be copyrighted.",
"annas_warning_body2": "The legality of accessing, downloading or distributing that content varies per country. In some jurisdictions (Palau, for example) personal use is permitted; in others it is not. You are solely responsible for checking your own laws.",
"annas_warning_body3": "omniget-study merely provides a programmable HTTP client. Enabling this source downloads content that YOU chose to request. Keep your own compliance.",
"annas_status": "Source status",
@@ -1673,8 +1697,8 @@
"annas_on": "Active",
"annas_enable_btn": "Enable source",
"annas_disable_btn": "Disable",
- "annas_enabled": "Anna's Archive enabled.",
- "annas_disabled": "Anna's Archive disabled.",
+ "annas_enabled": "Alt Library enabled.",
+ "annas_disabled": "Alt Library disabled.",
"annas_log_title": "Log mirrors tried",
"annas_log_hint": "Optional local log of which domains/mirrors each download used. Stored locally only.",
"annas_domains_title": "Mirror domains",
@@ -1684,17 +1708,17 @@
"annas_domains_saved": "Domains saved.",
"annas_reset_title": "Reset everything",
"annas_reset_hint": "Clears acknowledgement, disables source, restores default domains. Does NOT remove already-downloaded files.",
- "annas_reset_btn": "Reset Anna's Archive settings",
- "annas_reset_confirm": "Reset all Anna's Archive settings? Source will be disabled and require re-acknowledgement.",
+ "annas_reset_btn": "Reset Alt Library settings",
+ "annas_reset_confirm": "Reset all Alt Library settings? Source will be disabled and require re-acknowledgement.",
"annas_reset_done": "Settings reset.",
- "annas_warning_modal_title": "Before enabling Anna's Archive",
+ "annas_warning_modal_title": "Before enabling Alt Library",
"annas_warning_modal_line1": "This source scrapes shadow libraries.",
"annas_warning_modal_line2": "Most content there is copyrighted. Downloading it may be legal in your jurisdiction, grey-area, or outright illegal — verify with your local laws.",
"annas_warning_modal_line3": "omniget-study does not host content. All downloads go through mirrors YOU configure and YOU trigger.",
"annas_warning_modal_line4": "Tick the box below if you understand and accept personal responsibility for your usage.",
"annas_warning_ack_label": "I understand. I take full responsibility for my use in my jurisdiction.",
"annas_warning_cancel": "Cancel",
- "annas_warning_confirm": "Enable Anna's Archive"
+ "annas_warning_confirm": "Enable Alt Library"
},
"bulk": {
"select_all": "Select all",
diff --git a/src/lib/study-components/anki/Sidebar.svelte b/src/lib/study-components/anki/Sidebar.svelte
index 00d8eba2..8fd7dee9 100644
--- a/src/lib/study-components/anki/Sidebar.svelte
+++ b/src/lib/study-components/anki/Sidebar.svelte
@@ -17,6 +17,8 @@
title: "Conteúdo",
items: [
{ href: "/study/anki/notetypes", label: "Modelos", icon: "M4 4h6v6H4z M14 4h6v6h-6z M4 14h6v6H4z M14 14h6v6h-6z" },
+ { href: "/study/anki/tags", label: "Tags", icon: "M20 12L12 20l-9-9V3h8z M7 7h.01" },
+ { href: "/study/anki/media", label: "Mídia", icon: "M21 15V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10 M21 15l-5 6 M14 8a2 2 0 1 0 0-4 2 2 0 0 0 0 4z M3 16l5-5 8 8" },
{ href: "/study/anki/import", label: "Importar", icon: "M12 3v12 M7 10l5 5 5-5 M5 21h14" },
],
},
diff --git a/src/lib/study-components/notes/EmbedView.svelte b/src/lib/study-components/notes/EmbedView.svelte
index 3338f3de..ae2f25a1 100644
--- a/src/lib/study-components/notes/EmbedView.svelte
+++ b/src/lib/study-components/notes/EmbedView.svelte
@@ -87,7 +87,9 @@
{@const data = eState.data}
{#if data.kind === "missing"}
<div class="embed-warning">
- <span class="warning-icon">⚠</span>
+ <svg class="warning-icon" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M12 3l10 18H2z M12 10v5 M12 18v.5" />
+ </svg>
<span>
{data.target.kind === "page"
? `Página "${data.target.name}" não encontrada`
@@ -96,7 +98,9 @@
</div>
{:else if data.kind === "cycle"}
<div class="embed-warning cycle">
- <span class="warning-icon">⚠</span>
+ <svg class="warning-icon" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M12 3l10 18H2z M12 10v5 M12 18v.5" />
+ </svg>
<span>Embed cíclico bloqueado</span>
</div>
{:else if data.kind === "block"}
@@ -113,7 +117,10 @@
class="embed-page-title"
onclick={() => navigateToPage(data.page.name)}
>
- 📄 {data.page.title ?? data.page.name}
+ <svg class="page-icon" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z M14 3v5h5" />
+ </svg>
+ {data.page.title ?? data.page.name}
</button>
<ul class="embed-block-list">
{#each flattenBlocks(data.nodes, 8) as n (n.id)}
@@ -197,7 +204,12 @@
color: var(--error, #e74c3c);
}
.warning-icon {
- font-size: 13px;
+ flex-shrink: 0;
+ }
+ .page-icon {
+ flex-shrink: 0;
+ margin-right: 4px;
+ vertical-align: -2px;
}
.embed-block {
display: flex;
diff --git a/src/lib/study-components/notes/HistoryModal.svelte b/src/lib/study-components/notes/HistoryModal.svelte
index 91119495..99b5118d 100644
--- a/src/lib/study-components/notes/HistoryModal.svelte
+++ b/src/lib/study-components/notes/HistoryModal.svelte
@@ -203,7 +203,9 @@
<div class="modal small" role="dialog" aria-label="Limpar histórico" aria-modal="true">
<h3>Limpar histórico?</h3>
<p class="warn">
- Isso vai apagar {snapshots.length} snapshot(s) deste bloco. Não dá pra desfazer.
+ {snapshots.length === 1
+ ? "Isso apaga o snapshot deste bloco. Não dá pra desfazer."
+ : `Isso apaga ${snapshots.length} snapshots deste bloco. Não dá pra desfazer.`}
</p>
<footer class="foot">
<span class="spacer"></span>
diff --git a/src/lib/study-components/notes/InlineToolbar.svelte b/src/lib/study-components/notes/InlineToolbar.svelte
index fba4cb15..9f6f6d77 100644
--- a/src/lib/study-components/notes/InlineToolbar.svelte
+++ b/src/lib/study-components/notes/InlineToolbar.svelte
@@ -100,7 +100,9 @@
setOrUnsetLink();
}}
>
- 🔗
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M10 13a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1 M14 11a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1" />
+ </svg>
</button>
</div>
diff --git a/src/lib/study-components/notes/MaintenancePanel.svelte b/src/lib/study-components/notes/MaintenancePanel.svelte
index 8e815533..648d8037 100644
--- a/src/lib/study-components/notes/MaintenancePanel.svelte
+++ b/src/lib/study-components/notes/MaintenancePanel.svelte
@@ -137,7 +137,7 @@
disabled={busy !== null}
title="Reindexa FTS5 (notes_v2). Use se a busca estiver retornando resultados desatualizados."
>
- {busy === "search" ? "Reindexando…" : "🔍 Reconstruir busca"}
+ {busy === "search" ? "Reindexando…" : "Reconstruir busca"}
</button>
<button
type="button"
@@ -146,7 +146,7 @@
disabled={busy !== null}
title="Recalcula a tabela de refs/backlinks varrendo todo o conteúdo."
>
- {busy === "refs" ? "Calculando…" : "🔗 Reconstruir backlinks"}
+ {busy === "refs" ? "Calculando…" : "Reconstruir backlinks"}
</button>
<button
type="button"
@@ -155,7 +155,7 @@
disabled={busy !== null}
title="Limpa cache de queries. Inofensivo; queries serão recalculadas."
>
- {busy === "qcache" ? "Limpando…" : "♻️ Limpar cache de queries"}
+ {busy === "qcache" ? "Limpando…" : "Limpar cache de queries"}
</button>
<button
type="button"
@@ -164,7 +164,7 @@
disabled={busy !== null}
title="Baixa o grafo de notes (nodes + edges) como JSON pra inspeção/backup."
>
- {busy === "graph" ? "Exportando…" : "📊 Exportar grafo (JSON)"}
+ {busy === "graph" ? "Exportando…" : "Exportar grafo (JSON)"}
</button>
<button
type="button"
@@ -173,7 +173,7 @@
disabled={busy !== null || importing}
title="Lê um .md do disco e cria uma página com o conteúdo."
>
- 📥 Importar markdown
+ Importar markdown
</button>
<input
type="file"
diff --git a/src/lib/study-components/notes/SidebarTree.svelte b/src/lib/study-components/notes/SidebarTree.svelte
index 1ca2faec..14022522 100644
--- a/src/lib/study-components/notes/SidebarTree.svelte
+++ b/src/lib/study-components/notes/SidebarTree.svelte
@@ -189,19 +189,40 @@
<div class="quick-actions">
<button class="quick" onclick={onJournalToday}>
- <span>📅</span> <span>Journal hoje</span>
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <rect x="3" y="4" width="18" height="18" rx="2" />
+ <path d="M3 10h18 M8 2v4 M16 2v4" />
+ </svg>
+ <span>Journal hoje</span>
</button>
<a class="quick" href="/study/notes/journal">
- <span>📆</span> <span>Histórico de journal</span>
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <rect x="3" y="4" width="18" height="18" rx="2" />
+ <path d="M3 10h18 M8 2v4 M16 2v4 M12 14v3l2 1" />
+ </svg>
+ <span>Histórico de journal</span>
</a>
<a class="quick" href="/study/notes/search">
- <span>🔎</span> <span>Buscar</span>
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <circle cx="11" cy="11" r="7" />
+ <path d="M21 21l-4.3-4.3" />
+ </svg>
+ <span>Buscar</span>
</a>
<a class="quick" href="/study/notes/graph">
- <span>🕸</span> <span>Grafo</span>
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <circle cx="6" cy="6" r="2.5" />
+ <circle cx="18" cy="6" r="2.5" />
+ <circle cx="12" cy="18" r="2.5" />
+ <path d="M8 7l3 9 M16 7l-3 9 M9 6h6" />
+ </svg>
+ <span>Grafo</span>
</a>
<a class="quick" href="/study/notes/templates">
- <span>📄</span> <span>Templates</span>
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z M14 3v5h5" />
+ </svg>
+ <span>Templates</span>
</a>
</div>
@@ -214,7 +235,12 @@
{#if sectionFavorites.length > 0}
<section class="sidebar-section">
- <h3>★ Favoritas</h3>
+ <h3>
+ <svg class="section-icon" viewBox="0 0 24 24" width="13" height="13" fill="currentColor" stroke="none" aria-hidden="true">
+ <path d="M12 2l2.9 6.5 7.1.6-5.4 4.7 1.7 7-6.3-3.8-6.3 3.8 1.7-7L2 9.1l7.1-.6z" />
+ </svg>
+ Favoritas
+ </h3>
<ul class="page-list">
{#each sectionFavorites as p (p.id)}
<li>
@@ -283,7 +309,12 @@
{#if sectionCursos.length > 0}
<section class="sidebar-section">
- <h3>📚 Cursos</h3>
+ <h3>
+ <svg class="section-icon" viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M4 4h6a3 3 0 0 1 3 3v13a2 2 0 0 0-2-2H4z M20 4h-6a3 3 0 0 0-3 3v13a2 2 0 0 1 2-2h7z" />
+ </svg>
+ Cursos
+ </h3>
<ul class="page-list">
{#each sectionCursos as p (p.id)}
<li>
@@ -396,6 +427,19 @@
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--tertiary);
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ }
+ .section-icon {
+ flex-shrink: 0;
+ }
+ .quick svg {
+ flex-shrink: 0;
+ color: var(--tertiary);
+ }
+ .quick:hover svg {
+ color: currentColor;
}
.page-list {
list-style: none;
diff --git a/src/routes/downloads/+page.svelte b/src/routes/downloads/+page.svelte
index e49513b6..13791a36 100644
--- a/src/routes/downloads/+page.svelte
+++ b/src/routes/downloads/+page.svelte
@@ -88,7 +88,7 @@
async function cancelDownload(courseId: number) {
try {
- await pluginInvoke("courses", "cancel_download", { course_id: courseId });
+ await pluginInvoke("courses", "cancel_course_download", { courseId });
} catch (e: any) {
const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
showToast("error", msg);
diff --git a/src/routes/study/anki/browse/+page.svelte b/src/routes/study/anki/browse/+page.svelte
index d4baa8c5..de2108a0 100644
--- a/src/routes/study/anki/browse/+page.svelte
+++ b/src/routes/study/anki/browse/+page.svelte
@@ -89,6 +89,26 @@
let bulkDeckTarget = $state<number | null>(null);
let allDecks = $state<DeckSummary[]>([]);
+ let bulkTagOpen = $state(false);
+ let bulkTagMode = $state<"add" | "remove">("add");
+ let bulkTagInput = $state("");
+
+ let unburyDeckPickerOpen = $state(false);
+ let unburyDeckTarget = $state<number | null>(null);
+
+ let editNoteOpen = $state(false);
+ let editNoteTarget = $state<Note | null>(null);
+ let editNoteFields = $state<string[]>([]);
+ let editNoteTags = $state("");
+ let editNoteBusy = $state(false);
+
+ let confirmDeleteNoteOpen = $state(false);
+ let deleteNoteTarget = $state<number | null>(null);
+ let deleteNoteBusy = $state(false);
+
+ let siblingCards = $state<Card[]>([]);
+ let siblingsLoading = $state(false);
+
let busy = $state(false);
let searchTimer: number | null = null;
@@ -346,6 +366,124 @@
busy = false;
}
}
+
+ function selectedNoteIds(): number[] {
+ const noteIds = new Set<number>();
+ for (const cardId of selected) {
+ const card = items.find((c) => c.id === cardId);
+ if (card) noteIds.add(card.nid);
+ }
+ return [...noteIds];
+ }
+
+ async function bulkApplyTags() {
+ const noteIds = selectedNoteIds();
+ const tags = bulkTagInput
+ .trim()
+ .split(/\s+/)
+ .filter((t) => t.length > 0);
+ if (noteIds.length === 0 || tags.length === 0) return;
+ busy = true;
+ try {
+ const cmd =
+ bulkTagMode === "add"
+ ? "study:anki:tags:add_to_notes"
+ : "study:anki:tags:remove_from_notes";
+ await pluginInvoke<{ updated: number }>("study", cmd, {
+ noteIds,
+ tags,
+ });
+ bulkTagOpen = false;
+ bulkTagInput = "";
+ await runSearch();
+ } catch (e) {
+ error = e instanceof Error ? e.message : String(e);
+ } finally {
+ busy = false;
+ }
+ }
+
+ async function unburyDeckAction() {
+ if (unburyDeckTarget == null) return;
+ busy = true;
+ try {
+ await pluginInvoke("study", "study:anki:cards:unbury_deck", {
+ deckId: unburyDeckTarget,
+ });
+ unburyDeckPickerOpen = false;
+ await runSearch();
+ } catch (e) {
+ error = e instanceof Error ? e.message : String(e);
+ } finally {
+ busy = false;
+ }
+ }
+
+ function startEditNote(note: Note) {
+ editNoteTarget = note;
+ editNoteFields = [...note.fields];
+ editNoteTags = note.tags.join(" ");
+ editNoteOpen = true;
+ }
+
+ async function saveEditedNote() {
+ if (!editNoteTarget) return;
+ editNoteBusy = true;
+ try {
+ const tags = editNoteTags.trim().split(/\s+/).filter((t) => t.length > 0);
+ await pluginInvoke("study", "study:anki:notes:update", {
+ id: editNoteTarget.id,
+ fields: editNoteFields,
+ tags,
+ });
+ editNoteOpen = false;
+ editNoteTarget = null;
+ await runSearch();
+ } catch (e) {
+ error = e instanceof Error ? e.message : String(e);
+ } finally {
+ editNoteBusy = false;
+ }
+ }
+
+ function askDeleteNote(noteId: number) {
+ deleteNoteTarget = noteId;
+ confirmDeleteNoteOpen = true;
+ }
+
+ async function confirmDeleteNote() {
+ if (deleteNoteTarget == null) return;
+ deleteNoteBusy = true;
+ try {
+ await pluginInvoke("study", "study:anki:notes:delete", {
+ id: deleteNoteTarget,
+ });
+ confirmDeleteNoteOpen = false;
+ deleteNoteTarget = null;
+ drawerOpen = false;
+ await runSearch();
+ } catch (e) {
+ error = e instanceof Error ? e.message : String(e);
+ } finally {
+ deleteNoteBusy = false;
+ }
+ }
+
+ async function loadSiblingCards(noteId: number) {
+ siblingsLoading = true;
+ try {
+ const cards = await pluginInvoke<Card[]>(
+ "study",
+ "study:anki:cards:list_by_note",
+ { noteId },
+ );
+ siblingCards = cards ?? [];
+ } catch (e) {
+ siblingCards = [];
+ } finally {
+ siblingsLoading = false;
+ }
+ }
function askDelete() {
if (selected.size === 0) return;
confirmAction = "delete";
@@ -372,6 +510,7 @@
drawerStats = null;
drawerNote = null;
drawerError = "";
+ siblingCards = [];
try {
const stats = await pluginInvoke<CardStats>(
"study",
@@ -385,6 +524,7 @@
id: stats.note_id,
});
}
+ void loadSiblingCards(stats.note_id);
} catch (e) {
drawerError = e instanceof Error ? e.message : String(e);
}
@@ -472,6 +612,22 @@
>
Mover deck
</button>
+ <button
+ type="button"
+ class="bulk-btn"
+ onclick={() => { bulkTagMode = "add"; bulkTagOpen = true; }}
+ disabled={busy}
+ >
+ Adicionar tag
+ </button>
+ <button
+ type="button"
+ class="bulk-btn"
+ onclick={() => { bulkTagMode = "remove"; bulkTagOpen = true; }}
+ disabled={busy}
+ >
+ Remover tag
+ </button>
<button
type="button"
class="bulk-btn danger"
@@ -486,6 +642,18 @@
</div>
{/if}
+ <div class="utility-row">
+ <button
+ type="button"
+ class="util-btn"
+ onclick={() => { unburyDeckTarget = null; unburyDeckPickerOpen = true; }}
+ disabled={busy}
+ title="Reativa cards enterrados de um deck inteiro"
+ >
+ Reativar enterrados…
+ </button>
+ </div>
+
{#if loading}
<p class="muted">Buscando…</p>
{:else if error}
@@ -625,6 +793,142 @@
</div>
{/if}
+{#if bulkTagOpen}
+ <div
+ class="modal-backdrop"
+ role="presentation"
+ onclick={(e) => { if (e.target === e.currentTarget) bulkTagOpen = false; }}
+ >
+ <div class="modal" role="dialog" aria-modal="true">
+ <h3>
+ {bulkTagMode === "add" ? "Adicionar tag" : "Remover tag"}
+ em {selectedNoteIds().length}
+ {selectedNoteIds().length === 1 ? "nota" : "notas"}
+ </h3>
+ <label>
+ <span>Tags (separadas por espaço; use <code>::</code> para hierarquia)</span>
+ <input
+ type="text"
+ bind:value={bulkTagInput}
+ placeholder="exemplo livro::cap1"
+ onkeydown={(e) => { if (e.key === "Enter") bulkApplyTags(); }}
+ />
+ </label>
+ <div class="modal-actions">
+ <button
+ type="button"
+ class="btn-secondary"
+ onclick={() => (bulkTagOpen = false)}
+ disabled={busy}
+ >
+ Cancelar
+ </button>
+ <button
+ type="button"
+ class="btn-primary"
+ onclick={bulkApplyTags}
+ disabled={busy || bulkTagInput.trim() === ""}
+ >
+ {bulkTagMode === "add" ? "Adicionar" : "Remover"}
+ </button>
+ </div>
+ </div>
+ </div>
+{/if}
+
+{#if unburyDeckPickerOpen}
+ <div
+ class="modal-backdrop"
+ role="presentation"
+ onclick={(e) => { if (e.target === e.currentTarget) unburyDeckPickerOpen = false; }}
+ >
+ <div class="modal" role="dialog" aria-modal="true">
+ <h3>Reativar cards enterrados</h3>
+ <p class="modal-hint">
+ Reverte o estado de enterro de cards do deck selecionado, retornando-os
+ às filas normais.
+ </p>
+ <label>
+ <span>Deck</span>
+ <select bind:value={unburyDeckTarget}>
+ <option value={null}>Selecione…</option>
+ {#each allDecks as d (d.id)}
+ <option value={d.id}>{d.name}</option>
+ {/each}
+ </select>
+ </label>
+ <div class="modal-actions">
+ <button
+ type="button"
+ class="btn-secondary"
+ onclick={() => (unburyDeckPickerOpen = false)}
+ >
+ Cancelar
+ </button>
+ <button
+ type="button"
+ class="btn-primary"
+ onclick={unburyDeckAction}
+ disabled={busy || unburyDeckTarget == null}
+ >
+ Reativar
+ </button>
+ </div>
+ </div>
+ </div>
+{/if}
+
+{#if editNoteOpen && editNoteTarget}
+ <div
+ class="modal-backdrop"
+ role="presentation"
+ onclick={(e) => { if (e.target === e.currentTarget) editNoteOpen = false; }}
+ >
+ <div class="modal modal-wide" role="dialog" aria-modal="true">
+ <h3>Editar nota #{editNoteTarget.id}</h3>
+ <div class="edit-fields">
+ {#each editNoteFields as _field, idx (idx)}
+ <label class="edit-field">
+ <span>Campo {idx + 1}</span>
+ <textarea bind:value={editNoteFields[idx]} rows="2"></textarea>
+ </label>
+ {/each}
+ <label class="edit-field">
+ <span>Tags (espaço como separador)</span>
+ <input type="text" bind:value={editNoteTags} />
+ </label>
+ </div>
+ <div class="modal-actions">
+ <button
+ type="button"
+ class="btn-secondary"
+ onclick={() => (editNoteOpen = false)}
+ disabled={editNoteBusy}
+ >
+ Cancelar
+ </button>
+ <button
+ type="button"
+ class="btn-primary"
+ onclick={saveEditedNote}
+ disabled={editNoteBusy}
+ >
+ {editNoteBusy ? "Salvando…" : "Salvar"}
+ </button>
+ </div>
+ </div>
+ </div>
+{/if}
+
+<ConfirmDialog
+ bind:open={confirmDeleteNoteOpen}
+ title="Excluir nota"
+ message="A nota e todos os cards associados serão removidos. Não pode ser desfeito."
+ confirmLabel="Excluir nota"
+ variant="danger"
+ onConfirm={confirmDeleteNote}
+/>
+
{#if drawerOpen}
<aside
class="drawer-backdrop"
@@ -644,7 +948,27 @@
<p class="muted">Carregando…</p>
{:else}
<section class="drawer-section">
- <h4>Conteúdo</h4>
+ <div class="drawer-section-head">
+ <h4>Conteúdo</h4>
+ {#if drawerNote}
+ <div class="drawer-section-actions">
+ <button
+ type="button"
+ class="btn-link"
+ onclick={() => drawerNote && startEditNote(drawerNote)}
+ >
+ Editar
+ </button>
+ <button
+ type="button"
+ class="btn-link danger"
+ onclick={() => drawerNote && askDeleteNote(drawerNote.id)}
+ >
+ Excluir nota
+ </button>
+ </div>
+ {/if}
+ </div>
{#if drawerNote}
<ul class="fields">
{#each drawerNote.fields as field, i (i)}
@@ -664,6 +988,32 @@
{/if}
</section>
+ <section class="drawer-section">
+ <h4>Outras cards desta nota</h4>
+ {#if siblingsLoading}
+ <p class="muted small">Carregando…</p>
+ {:else if siblingCards.length <= 1}
+ <p class="muted small">Esta nota tem só essa card.</p>
+ {:else}
+ <ul class="sibling-list">
+ {#each siblingCards as sib (sib.id)}
+ <li class:current={sib.id === drawerCardId}>
+ <button
+ type="button"
+ class="sibling-link"
+ onclick={() => sib.id !== drawerCardId && openDrawer(sib.id)}
+ disabled={sib.id === drawerCardId}
+ >
+ <span class="sib-ord">ord {sib.ord}</span>
+ <span class="sib-state">{sib.queue}</span>
+ <span class="sib-id mono">#{sib.id}</span>
+ </button>
+ </li>
+ {/each}
+ </ul>
+ {/if}
+ </section>
+
<section class="drawer-section">
<h4>Scheduler</h4>
<dl class="kv">
@@ -1050,6 +1400,144 @@
justify-content: flex-end;
gap: 8px;
}
+ .modal-wide {
+ max-width: 720px;
+ }
+ .modal-hint {
+ margin: 0 0 12px;
+ font-size: 12px;
+ color: var(--tertiary);
+ }
+ .edit-fields {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ margin-bottom: 16px;
+ max-height: 60vh;
+ overflow-y: auto;
+ }
+ .edit-field {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ font-size: 11px;
+ color: var(--tertiary);
+ }
+ .edit-field textarea,
+ .edit-field input {
+ padding: 8px 10px;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ background: var(--bg);
+ color: var(--text);
+ font: inherit;
+ font-size: 13px;
+ resize: vertical;
+ }
+ .edit-field textarea:focus,
+ .edit-field input:focus {
+ outline: none;
+ border-color: var(--accent);
+ }
+
+ .utility-row {
+ display: flex;
+ gap: 8px;
+ padding-top: 4px;
+ }
+ .util-btn {
+ padding: 5px 12px;
+ background: transparent;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ color: var(--tertiary);
+ font: inherit;
+ font-size: 12px;
+ cursor: pointer;
+ }
+ .util-btn:hover:not(:disabled) {
+ color: var(--text);
+ border-color: var(--accent);
+ }
+ .util-btn:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
+
+ .drawer-section-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ }
+ .drawer-section-actions {
+ display: flex;
+ gap: 4px;
+ }
+ .btn-link {
+ padding: 2px 8px;
+ background: transparent;
+ border: 0;
+ color: var(--accent);
+ font: inherit;
+ font-size: 11px;
+ cursor: pointer;
+ border-radius: 4px;
+ }
+ .btn-link:hover {
+ background: color-mix(in oklab, var(--accent) 10%, transparent);
+ }
+ .btn-link.danger {
+ color: var(--error, var(--accent));
+ }
+ .btn-link.danger:hover {
+ background: color-mix(in oklab, var(--error, var(--accent)) 10%, transparent);
+ }
+
+ .sibling-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ }
+ .sibling-list li.current .sibling-link {
+ background: color-mix(in oklab, var(--accent) 10%, transparent);
+ cursor: default;
+ }
+ .sibling-link {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ width: 100%;
+ padding: 6px 10px;
+ border: 0;
+ background: transparent;
+ border-radius: var(--border-radius);
+ color: var(--text);
+ font: inherit;
+ text-align: left;
+ cursor: pointer;
+ }
+ .sibling-link:hover:not(:disabled) {
+ background: color-mix(in oklab, var(--accent) 5%, transparent);
+ }
+ .sib-ord {
+ font-size: 12px;
+ }
+ .sib-state {
+ font-size: 11px;
+ color: var(--tertiary);
+ }
+ .sib-id {
+ margin-left: auto;
+ font-size: 11px;
+ color: var(--tertiary);
+ }
+ .small {
+ font-size: 12px;
+ }
.btn-primary {
padding: 8px 18px;
background: var(--accent);
diff --git a/src/routes/study/anki/decks/+page.svelte b/src/routes/study/anki/decks/+page.svelte
index b4a7f940..a0cc16ab 100644
--- a/src/routes/study/anki/decks/+page.svelte
+++ b/src/routes/study/anki/decks/+page.svelte
@@ -308,6 +308,8 @@
<button type="button" class="btn-primary" onclick={() => openCreate(null)}>
+ Novo deck
</button>
+ <a href="/study/anki/decks/filtered" class="advanced-link">Decks filtrados →</a>
+ <a href="/study/anki/decks/presets" class="advanced-link">Presets →</a>
<span class="hint">
Use <code>::</code> no nome pra criar sub-deck (ex: <code>Idiomas::Espanhol</code>)
</span>
@@ -771,6 +773,17 @@
background: color-mix(in oklab, var(--error) 8%, transparent);
}
+ .advanced-link {
+ color: var(--accent);
+ font-size: 12px;
+ text-decoration: none;
+ padding: 4px 8px;
+ border-radius: var(--border-radius);
+ }
+ .advanced-link:hover {
+ background: color-mix(in oklab, var(--accent) 10%, transparent);
+ }
+
.btn-primary {
display: inline-flex;
align-items: center;
diff --git a/src/routes/study/anki/decks/filtered/+page.svelte b/src/routes/study/anki/decks/filtered/+page.svelte
new file mode 100644
index 00000000..1ba1812d
--- /dev/null
+++ b/src/routes/study/anki/decks/filtered/+page.svelte
@@ -0,0 +1,676 @@
+<script lang="ts">
+ import { onMount } from "svelte";
+ import { pluginInvoke } from "$lib/plugin-invoke";
+ import PageHero from "$lib/study-components/PageHero.svelte";
+ import ConfirmDialog from "$lib/study-components/ConfirmDialog.svelte";
+
+ type DeckSummary = {
+ id: number;
+ name: string;
+ filtered: boolean;
+ new_count: number;
+ learn_count: number;
+ review_count: number;
+ };
+
+ type FilteredSearchTerm = {
+ search: string;
+ limit: number;
+ order: string;
+ };
+
+ let decks = $state<DeckSummary[]>([]);
+ let loading = $state(true);
+ let error = $state("");
+ let toast = $state<{ kind: "ok" | "err"; msg: string } | null>(null);
+
+ let createOpen = $state(false);
+ let newName = $state("");
+ let newSearch = $state("is:due");
+ let newLimit = $state(100);
+ let newOrder = $state("oldest_seen_first");
+ let newReschedule = $state(true);
+ let createBusy = $state(false);
+
+ let rebuilding = $state<number | null>(null);
+ let emptying = $state<number | null>(null);
+
+ let confirmDeleteOpen = $state(false);
+ let deleteTarget = $state<DeckSummary | null>(null);
+ let deleteBusy = $state(false);
+
+ const ORDER_OPTIONS = [
+ { value: "oldest_seen_first", label: "Mais antigo primeiro" },
+ { value: "random", label: "Aleatório" },
+ { value: "interval_descending", label: "Maior intervalo" },
+ { value: "interval_ascending", label: "Menor intervalo" },
+ { value: "lapses_descending", label: "Mais lapsos" },
+ { value: "added_descending", label: "Adicionados recentemente" },
+ { value: "added_ascending", label: "Adicionados há mais tempo" },
+ { value: "due_first", label: "Vencidos primeiro" },
+ ];
+
+ const PRESETS = [
+ { label: "Vencidos hoje", search: "is:due" },
+ { label: "Aprendendo", search: "is:learn" },
+ { label: "Suspensos", search: "is:suspended" },
+ { label: "Marcados (flag)", search: "flag:1 OR flag:2 OR flag:3 OR flag:4" },
+ { label: "Tagged 'difícil'", search: 'tag:difícil' },
+ { label: "Lapsos > 5", search: "prop:lapses>5" },
+ ];
+
+ function showToast(kind: "ok" | "err", msg: string) {
+ toast = { kind, msg };
+ setTimeout(() => (toast = null), 2400);
+ }
+
+ async function load() {
+ loading = true;
+ error = "";
+ try {
+ await pluginInvoke("study", "study:anki:storage:open");
+ const all = await pluginInvoke<DeckSummary[]>(
+ "study",
+ "study:anki:decks:list",
+ );
+ decks = all.filter((d) => d.filtered);
+ } catch (e) {
+ error = e instanceof Error ? e.message : String(e);
+ } finally {
+ loading = false;
+ }
+ }
+
+ async function createFiltered() {
+ const name = newName.trim();
+ if (!name || !newSearch.trim()) return;
+ createBusy = true;
+ try {
+ const term: FilteredSearchTerm = {
+ search: newSearch.trim(),
+ limit: Math.max(1, Math.min(99999, Math.floor(newLimit))),
+ order: newOrder,
+ };
+ await pluginInvoke<{ id: number; cards: number }>(
+ "study",
+ "study:anki:decks:create_filtered",
+ {
+ name,
+ searchTerms: [term],
+ reschedule: newReschedule,
+ },
+ );
+ showToast("ok", `Deck "${name}" criado`);
+ createOpen = false;
+ newName = "";
+ newSearch = "is:due";
+ newLimit = 100;
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ createBusy = false;
+ }
+ }
+
+ async function rebuild(deck: DeckSummary) {
+ rebuilding = deck.id;
+ try {
+ const r = await pluginInvoke<{ cards: number }>(
+ "study",
+ "study:anki:decks:rebuild_filtered",
+ { id: deck.id },
+ );
+ showToast(
+ "ok",
+ r.cards === 1
+ ? "1 card no deck filtrado"
+ : `${r.cards} cards no deck filtrado`,
+ );
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ rebuilding = null;
+ }
+ }
+
+ async function emptyDeck(deck: DeckSummary) {
+ emptying = deck.id;
+ try {
+ const r = await pluginInvoke<{ returned: number }>(
+ "study",
+ "study:anki:decks:empty_filtered",
+ { id: deck.id },
+ );
+ showToast(
+ "ok",
+ r.returned === 0
+ ? "Deck já estava vazio"
+ : r.returned === 1
+ ? "1 card devolvido pro deck original"
+ : `${r.returned} cards devolvidos`,
+ );
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ emptying = null;
+ }
+ }
+
+ function askDelete(deck: DeckSummary) {
+ deleteTarget = deck;
+ confirmDeleteOpen = true;
+ }
+
+ async function confirmDelete() {
+ if (!deleteTarget) return;
+ deleteBusy = true;
+ try {
+ await pluginInvoke("study", "study:anki:decks:delete_filtered", {
+ id: deleteTarget.id,
+ });
+ showToast("ok", "Deck filtrado removido");
+ confirmDeleteOpen = false;
+ deleteTarget = null;
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ deleteBusy = false;
+ }
+ }
+
+ onMount(load);
+</script>
+
+<section class="study-page">
+ <PageHero
+ title="Decks filtrados"
+ subtitle="Cards selecionados por uma query — bom para revisão dirigida"
+ />
+
+ {#if toast}
+ <div class="toast" class:err={toast.kind === "err"} role="status">
+ {toast.msg}
+ </div>
+ {/if}
+
+ <div class="toolbar">
+ <a class="back-link" href="/study/anki/decks">← Voltar pra Decks</a>
+ <button
+ type="button"
+ class="btn primary"
+ onclick={() => (createOpen = true)}
+ >
+ + Novo deck filtrado
+ </button>
+ </div>
+
+ {#if loading}
+ <div class="state">Carregando…</div>
+ {:else if error}
+ <div class="state err">{error}</div>
+ <button class="btn ghost" onclick={load}>Tentar de novo</button>
+ {:else if decks.length === 0}
+ <div class="empty">
+ <p>Nenhum deck filtrado ainda.</p>
+ <p class="hint">
+ Decks filtrados puxam cards de outros decks via query (ex: <code>is:due</code>).
+ Quando você termina, os cards voltam pro deck original.
+ </p>
+ <button
+ type="button"
+ class="btn primary"
+ onclick={() => (createOpen = true)}
+ >
+ Criar primeiro
+ </button>
+ </div>
+ {:else}
+ <ul class="filtered-list">
+ {#each decks as deck (deck.id)}
+ {@const total = deck.new_count + deck.learn_count + deck.review_count}
+ <li class="filtered-row">
+ <div class="filtered-info">
+ <h3>{deck.name}</h3>
+ <p class="meta">
+ <span class="pill new">{deck.new_count} novos</span>
+ <span class="pill learn">{deck.learn_count} aprendendo</span>
+ <span class="pill review">{deck.review_count} revisão</span>
+ </p>
+ </div>
+ <div class="filtered-actions">
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={() => rebuild(deck)}
+ disabled={rebuilding === deck.id || emptying === deck.id}
+ title="Refaz a query e popula o deck"
+ >
+ {rebuilding === deck.id ? "Reconstruindo…" : "Reconstruir"}
+ </button>
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={() => emptyDeck(deck)}
+ disabled={rebuilding === deck.id || emptying === deck.id || total === 0}
+ title="Devolve os cards ao deck original sem apagar o filtrado"
+ >
+ {emptying === deck.id ? "Esvaziando…" : "Esvaziar"}
+ </button>
+ <button
+ type="button"
+ class="btn ghost sm danger"
+ onclick={() => askDelete(deck)}
+ disabled={rebuilding === deck.id || emptying === deck.id}
+ >
+ Apagar
+ </button>
+ </div>
+ </li>
+ {/each}
+ </ul>
+ {/if}
+</section>
+
+{#if createOpen}
+ <div
+ class="modal-backdrop"
+ role="presentation"
+ onclick={(e) => { if (e.target === e.currentTarget) createOpen = false; }}
+ >
+ <div class="modal" role="dialog" aria-modal="true">
+ <h3>Criar deck filtrado</h3>
+ <p class="modal-hint">
+ O deck puxa cards que casam com a query. Use sintaxe Anki:
+ <code>is:due</code>, <code>tag:foo</code>, <code>deck:Bar</code>.
+ </p>
+
+ <label class="field">
+ <span>Nome</span>
+ <input
+ type="text"
+ bind:value={newName}
+ placeholder="Ex: Revisão hoje"
+ />
+ </label>
+
+ <label class="field">
+ <span>Query</span>
+ <input
+ type="text"
+ bind:value={newSearch}
+ placeholder="is:due"
+ />
+ </label>
+
+ <details class="presets">
+ <summary>Presets</summary>
+ <div class="preset-grid">
+ {#each PRESETS as p (p.label)}
+ <button
+ type="button"
+ class="preset-btn"
+ onclick={() => (newSearch = p.search)}
+ >
+ <span class="preset-label">{p.label}</span>
+ <span class="preset-q">{p.search}</span>
+ </button>
+ {/each}
+ </div>
+ </details>
+
+ <div class="row">
+ <label class="field">
+ <span>Limite</span>
+ <input
+ type="number"
+ min="1"
+ max="9999"
+ bind:value={newLimit}
+ />
+ </label>
+
+ <label class="field">
+ <span>Ordem</span>
+ <select bind:value={newOrder}>
+ {#each ORDER_OPTIONS as opt (opt.value)}
+ <option value={opt.value}>{opt.label}</option>
+ {/each}
+ </select>
+ </label>
+ </div>
+
+ <label class="check">
+ <input type="checkbox" bind:checked={newReschedule} />
+ <span>Re-agendar cards (Anki recomenda manter ligado)</span>
+ </label>
+
+ <div class="modal-foot">
+ <button
+ type="button"
+ class="btn ghost"
+ onclick={() => (createOpen = false)}
+ disabled={createBusy}
+ >
+ Cancelar
+ </button>
+ <button
+ type="button"
+ class="btn primary"
+ onclick={createFiltered}
+ disabled={createBusy || !newName.trim() || !newSearch.trim()}
+ >
+ {createBusy ? "Criando…" : "Criar"}
+ </button>
+ </div>
+ </div>
+ </div>
+{/if}
+
+<ConfirmDialog
+ bind:open={confirmDeleteOpen}
+ title="Apagar deck filtrado"
+ message={deleteTarget
+ ? `O deck "${deleteTarget.name}" será removido. Os cards voltam pro deck original — nada é perdido.`
+ : ""}
+ confirmLabel="Apagar"
+ variant="danger"
+ onConfirm={confirmDelete}
+/>
+
+<style>
+ .study-page {
+ display: flex;
+ flex-direction: column;
+ gap: calc(var(--padding) * 1.25);
+ width: 100%;
+ max-width: 820px;
+ margin-inline: auto;
+ }
+
+ .toolbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ }
+
+ .back-link {
+ color: var(--accent);
+ font-size: 13px;
+ text-decoration: none;
+ }
+ .back-link:hover {
+ text-decoration: underline;
+ }
+
+ .state {
+ padding: 24px;
+ text-align: center;
+ color: var(--secondary);
+ font-size: 13px;
+ }
+ .state.err {
+ color: var(--error, var(--accent));
+ }
+
+ .empty {
+ padding: 48px 24px;
+ text-align: center;
+ color: var(--secondary);
+ font-size: 13px;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 12px;
+ }
+ .empty .hint {
+ margin: 0;
+ color: var(--tertiary);
+ font-size: 12px;
+ max-width: 420px;
+ line-height: 1.55;
+ }
+
+ .filtered-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ }
+ .filtered-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ padding: 14px 16px;
+ border: 1px solid color-mix(in oklab, var(--input-border) 60%, transparent);
+ border-radius: var(--border-radius);
+ background: var(--surface);
+ }
+ .filtered-info {
+ flex: 1;
+ min-width: 0;
+ }
+ .filtered-info h3 {
+ margin: 0 0 6px;
+ font-size: 14px;
+ font-weight: 600;
+ }
+ .meta {
+ display: flex;
+ gap: 6px;
+ margin: 0;
+ }
+ .pill {
+ padding: 1px 8px;
+ border-radius: 999px;
+ font-size: 11px;
+ font-family: var(--font-mono, ui-monospace, monospace);
+ }
+ .pill.new {
+ background: color-mix(in oklab, var(--blue, var(--accent)) 14%, transparent);
+ color: var(--blue, var(--accent));
+ }
+ .pill.learn {
+ background: color-mix(in oklab, var(--orange, var(--accent)) 14%, transparent);
+ color: var(--orange, var(--accent));
+ }
+ .pill.review {
+ background: color-mix(in oklab, var(--green, var(--accent)) 14%, transparent);
+ color: var(--green, var(--accent));
+ }
+
+ .filtered-actions {
+ display: flex;
+ gap: 6px;
+ flex-shrink: 0;
+ }
+
+ .btn {
+ padding: 7px 14px;
+ border-radius: var(--border-radius);
+ border: 1px solid transparent;
+ font: inherit;
+ font-size: 13px;
+ font-weight: 500;
+ cursor: pointer;
+ transition: background 120ms ease, border-color 120ms ease;
+ }
+ .btn:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
+ .btn.primary {
+ background: var(--accent);
+ color: var(--on-accent, var(--on-cta, white));
+ }
+ .btn.primary:hover:not(:disabled) {
+ background: var(--accent-hover, var(--accent));
+ }
+ .btn.ghost {
+ background: transparent;
+ border-color: var(--input-border);
+ color: var(--text);
+ }
+ .btn.ghost:hover:not(:disabled) {
+ background: color-mix(in oklab, var(--accent) 8%, transparent);
+ }
+ .btn.ghost.danger {
+ color: var(--error, var(--accent));
+ border-color: color-mix(in oklab, var(--error, var(--accent)) 35%, var(--input-border));
+ }
+ .btn.ghost.danger:hover:not(:disabled) {
+ background: color-mix(in oklab, var(--error, var(--accent)) 10%, transparent);
+ }
+ .btn.sm {
+ padding: 5px 10px;
+ font-size: 12px;
+ }
+
+ .toast {
+ position: fixed;
+ bottom: 20px;
+ right: 20px;
+ padding: 10px 16px;
+ border-radius: var(--border-radius);
+ background: color-mix(in oklab, var(--accent) 16%, var(--surface));
+ color: var(--text);
+ font-size: 13px;
+ box-shadow: 0 8px 24px color-mix(in oklab, black 20%, transparent);
+ z-index: 100;
+ }
+ .toast.err {
+ background: color-mix(in oklab, var(--error, var(--accent)) 18%, var(--surface));
+ }
+
+ .modal-backdrop {
+ position: fixed;
+ inset: 0;
+ background: var(--dialog-backdrop, rgba(0, 0, 0, 0.55));
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 200;
+ padding: 16px;
+ }
+ .modal {
+ background: var(--popup-bg, var(--surface));
+ border: 1px solid color-mix(in oklab, var(--input-border) 60%, transparent);
+ border-radius: var(--border-radius);
+ padding: 20px;
+ max-width: 540px;
+ width: 100%;
+ box-shadow: 0 20px 50px color-mix(in oklab, black 30%, transparent);
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ }
+ .modal h3 {
+ margin: 0;
+ font-size: 15px;
+ font-weight: 600;
+ }
+ .modal-hint {
+ margin: 0;
+ color: var(--tertiary);
+ font-size: 12px;
+ line-height: 1.55;
+ }
+
+ .field {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ font-size: 11px;
+ color: var(--tertiary);
+ }
+ .field input,
+ .field select {
+ padding: 8px 10px;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ background: var(--bg);
+ color: var(--text);
+ font: inherit;
+ font-size: 13px;
+ }
+ .field input:focus,
+ .field select:focus {
+ outline: none;
+ border-color: var(--accent);
+ }
+ .row {
+ display: grid;
+ grid-template-columns: 1fr 2fr;
+ gap: 8px;
+ }
+ .check {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ color: var(--secondary);
+ font-size: 12px;
+ cursor: pointer;
+ }
+ .check input {
+ accent-color: var(--accent);
+ }
+
+ .presets summary {
+ cursor: pointer;
+ color: var(--accent);
+ font-size: 12px;
+ }
+ .preset-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 6px;
+ margin-top: 8px;
+ }
+ .preset-btn {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ padding: 6px 10px;
+ background: var(--bg);
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ text-align: left;
+ cursor: pointer;
+ }
+ .preset-btn:hover {
+ background: color-mix(in oklab, var(--accent) 6%, transparent);
+ border-color: var(--accent);
+ }
+ .preset-label {
+ font-size: 12px;
+ color: var(--text);
+ }
+ .preset-q {
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 10px;
+ color: var(--tertiary);
+ }
+
+ .modal-foot {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+ border-top: 1px solid color-mix(in oklab, var(--input-border) 40%, transparent);
+ padding-top: 12px;
+ }
+
+ code {
+ padding: 1px 6px;
+ background: color-mix(in oklab, var(--accent) 8%, transparent);
+ border-radius: 4px;
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 11px;
+ }
+</style>
diff --git a/src/routes/study/anki/decks/presets/+page.svelte b/src/routes/study/anki/decks/presets/+page.svelte
new file mode 100644
index 00000000..2cb4dfda
--- /dev/null
+++ b/src/routes/study/anki/decks/presets/+page.svelte
@@ -0,0 +1,636 @@
+<script lang="ts">
+ import { onMount } from "svelte";
+ import { pluginInvoke } from "$lib/plugin-invoke";
+ import PageHero from "$lib/study-components/PageHero.svelte";
+ import ConfirmDialog from "$lib/study-components/ConfirmDialog.svelte";
+
+ type DeckConfigSummary = {
+ id: number;
+ name: string;
+ mtime_secs: number;
+ use_count: number;
+ };
+
+ type DeckConfigData = {
+ learn_steps: number[];
+ relearn_steps: number[];
+ fsrs_params_5: number[];
+ new_per_day: number;
+ reviews_per_day: number;
+ initial_ease: number;
+ easy_multiplier: number;
+ hard_multiplier: number;
+ lapse_multiplier: number;
+ interval_multiplier: number;
+ maximum_review_interval: number;
+ minimum_lapse_interval: number;
+ graduating_interval_good: number;
+ graduating_interval_easy: number;
+ leech_threshold: number;
+ cap_answer_time_to_secs: number;
+ show_timer: boolean;
+ stop_timer_on_answer: boolean;
+ bury_new: boolean;
+ bury_reviews: boolean;
+ bury_interday_learning: boolean;
+ disable_autoplay: boolean;
+ desired_retention: number;
+ historical_retention: number;
+ ignore_revlogs_before_date: string;
+ new_card_insert_order: string;
+ new_card_gather_priority: string;
+ new_card_sort_order: string;
+ new_mix: string;
+ review_order: string;
+ interday_learning_mix: string;
+ leech_action: string;
+ };
+
+ type DeckConfig = {
+ id: number;
+ name: string;
+ mtime_secs: number;
+ usn: number;
+ config: DeckConfigData;
+ };
+
+ const DEFAULT_PRESET_ID = 1;
+
+ let summaries = $state<DeckConfigSummary[]>([]);
+ let loading = $state(true);
+ let error = $state("");
+ let toast = $state<{ kind: "ok" | "err"; msg: string } | null>(null);
+
+ let createName = $state("");
+ let creating = $state(false);
+
+ let editing = $state<DeckConfig | null>(null);
+ let editForm = $state<DeckConfigData | null>(null);
+ let editLearnRaw = $state("");
+ let editRelearnRaw = $state("");
+ let editBusy = $state(false);
+
+ let confirmDeleteOpen = $state(false);
+ let deleteTarget = $state<DeckConfigSummary | null>(null);
+ let deleteBusy = $state(false);
+
+ function showToast(kind: "ok" | "err", msg: string) {
+ toast = { kind, msg };
+ setTimeout(() => (toast = null), 2400);
+ }
+
+ async function load() {
+ loading = true;
+ error = "";
+ try {
+ await pluginInvoke("study", "study:anki:storage:open");
+ summaries = await pluginInvoke<DeckConfigSummary[]>(
+ "study",
+ "study:anki:deckconfig:list",
+ );
+ } catch (e) {
+ error = e instanceof Error ? e.message : String(e);
+ } finally {
+ loading = false;
+ }
+ }
+
+ async function create() {
+ const name = createName.trim();
+ if (!name) return;
+ creating = true;
+ try {
+ await pluginInvoke<{ id: number }>(
+ "study",
+ "study:anki:deckconfig:create",
+ { name },
+ );
+ showToast("ok", `Preset "${name}" criado`);
+ createName = "";
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ creating = false;
+ }
+ }
+
+ async function startEdit(summary: DeckConfigSummary) {
+ try {
+ const full = await pluginInvoke<DeckConfig>(
+ "study",
+ "study:anki:deckconfig:get",
+ { id: summary.id },
+ );
+ editing = full;
+ editForm = { ...full.config };
+ editLearnRaw = full.config.learn_steps.join(" ");
+ editRelearnRaw = full.config.relearn_steps.join(" ");
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ }
+ }
+
+ function parseSteps(raw: string): number[] {
+ return raw
+ .trim()
+ .split(/\s+/)
+ .map((s) => Number(s))
+ .filter((n) => Number.isFinite(n) && n > 0);
+ }
+
+ async function saveEdit() {
+ if (!editing || !editForm) return;
+ editBusy = true;
+ try {
+ const updated: DeckConfig = {
+ ...editing,
+ config: {
+ ...editForm,
+ learn_steps: parseSteps(editLearnRaw),
+ relearn_steps: parseSteps(editRelearnRaw),
+ },
+ };
+ await pluginInvoke("study", "study:anki:deckconfig:update", {
+ config: updated,
+ });
+ showToast("ok", "Preset atualizado");
+ editing = null;
+ editForm = null;
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ editBusy = false;
+ }
+ }
+
+ function askDelete(summary: DeckConfigSummary) {
+ if (summary.id === DEFAULT_PRESET_ID) return;
+ deleteTarget = summary;
+ confirmDeleteOpen = true;
+ }
+
+ async function confirmDelete() {
+ if (!deleteTarget) return;
+ deleteBusy = true;
+ try {
+ await pluginInvoke("study", "study:anki:deckconfig:delete", {
+ id: deleteTarget.id,
+ });
+ showToast("ok", `Preset "${deleteTarget.name}" removido`);
+ confirmDeleteOpen = false;
+ deleteTarget = null;
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ deleteBusy = false;
+ }
+ }
+
+ function fmtTime(secs: number): string {
+ if (!secs || secs <= 0) return "—";
+ return new Date(secs * 1000).toLocaleDateString();
+ }
+
+ onMount(load);
+</script>
+
+<section class="study-page">
+ <PageHero
+ title="Presets de deck"
+ subtitle="Configurações reutilizáveis (limites, FSRS, learning steps)"
+ />
+
+ {#if toast}
+ <div class="toast" class:err={toast.kind === "err"} role="status">
+ {toast.msg}
+ </div>
+ {/if}
+
+ <div class="toolbar">
+ <a class="back-link" href="/study/anki/decks">← Voltar pra Decks</a>
+ </div>
+
+ <div class="create-row">
+ <input
+ type="text"
+ class="name-input"
+ placeholder="Nome do novo preset…"
+ bind:value={createName}
+ onkeydown={(e) => { if (e.key === "Enter") create(); }}
+ />
+ <button
+ type="button"
+ class="btn primary"
+ onclick={create}
+ disabled={creating || !createName.trim()}
+ >
+ {creating ? "Criando…" : "Criar preset"}
+ </button>
+ </div>
+
+ {#if loading}
+ <div class="state">Carregando…</div>
+ {:else if error}
+ <div class="state err">{error}</div>
+ {:else if summaries.length === 0}
+ <div class="empty">
+ <p>Nenhum preset ainda.</p>
+ </div>
+ {:else}
+ <ul class="preset-list">
+ {#each summaries as p (p.id)}
+ <li class="preset-row">
+ <div class="preset-info">
+ <div class="preset-name">
+ {p.name}
+ {#if p.id === DEFAULT_PRESET_ID}
+ <span class="badge">padrão</span>
+ {/if}
+ </div>
+ <div class="preset-meta">
+ {p.use_count === 1 ? "1 deck usa" : `${p.use_count} decks usam`}
+ · atualizado {fmtTime(p.mtime_secs)}
+ </div>
+ </div>
+ <div class="preset-actions">
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={() => startEdit(p)}
+ >
+ Editar
+ </button>
+ <button
+ type="button"
+ class="btn ghost sm danger"
+ onclick={() => askDelete(p)}
+ disabled={p.id === DEFAULT_PRESET_ID || p.use_count > 0}
+ title={p.id === DEFAULT_PRESET_ID
+ ? "Preset padrão não pode ser apagado"
+ : p.use_count > 0
+ ? "Mover decks pra outro preset antes de apagar"
+ : ""}
+ >
+ Apagar
+ </button>
+ </div>
+ </li>
+ {/each}
+ </ul>
+ {/if}
+</section>
+
+{#if editing && editForm}
+ <div
+ class="modal-backdrop"
+ role="presentation"
+ onclick={(e) => { if (e.target === e.currentTarget) editing = null; }}
+ >
+ <div class="modal modal-wide" role="dialog" aria-modal="true">
+ <h3>Editar preset · {editing.name}</h3>
+
+ <div class="form-grid">
+ <label class="field">
+ <span>Novos cards / dia</span>
+ <input
+ type="number"
+ min="0"
+ bind:value={editForm.new_per_day}
+ />
+ </label>
+ <label class="field">
+ <span>Reviews / dia</span>
+ <input
+ type="number"
+ min="0"
+ bind:value={editForm.reviews_per_day}
+ />
+ </label>
+ <label class="field">
+ <span>Retenção desejada (FSRS)</span>
+ <input
+ type="number"
+ step="0.01"
+ min="0.7"
+ max="0.99"
+ bind:value={editForm.desired_retention}
+ />
+ </label>
+ <label class="field">
+ <span>Limite de leech</span>
+ <input
+ type="number"
+ min="1"
+ bind:value={editForm.leech_threshold}
+ />
+ </label>
+ <label class="field">
+ <span>Learning steps (min)</span>
+ <input
+ type="text"
+ bind:value={editLearnRaw}
+ placeholder="1 10"
+ />
+ </label>
+ <label class="field">
+ <span>Relearning steps (min)</span>
+ <input
+ type="text"
+ bind:value={editRelearnRaw}
+ placeholder="10"
+ />
+ </label>
+ </div>
+
+ <fieldset class="check-group">
+ <legend>Comportamento</legend>
+ <label class="check">
+ <input type="checkbox" bind:checked={editForm.bury_new} />
+ <span>Enterrar novos cards relacionados</span>
+ </label>
+ <label class="check">
+ <input type="checkbox" bind:checked={editForm.bury_reviews} />
+ <span>Enterrar reviews relacionados</span>
+ </label>
+ <label class="check">
+ <input type="checkbox" bind:checked={editForm.disable_autoplay} />
+ <span>Desativar autoplay de mídia</span>
+ </label>
+ <label class="check">
+ <input type="checkbox" bind:checked={editForm.show_timer} />
+ <span>Mostrar timer durante estudo</span>
+ </label>
+ </fieldset>
+
+ <div class="modal-foot">
+ <button
+ type="button"
+ class="btn ghost"
+ onclick={() => { editing = null; editForm = null; }}
+ disabled={editBusy}
+ >
+ Cancelar
+ </button>
+ <button
+ type="button"
+ class="btn primary"
+ onclick={saveEdit}
+ disabled={editBusy}
+ >
+ {editBusy ? "Salvando…" : "Salvar"}
+ </button>
+ </div>
+ </div>
+ </div>
+{/if}
+
+<ConfirmDialog
+ bind:open={confirmDeleteOpen}
+ title="Apagar preset"
+ message={deleteTarget
+ ? `Apagar o preset "${deleteTarget.name}"? Decks que usam vão pro preset padrão.`
+ : ""}
+ confirmLabel="Apagar"
+ variant="danger"
+ onConfirm={confirmDelete}
+/>
+
+<style>
+ .study-page {
+ display: flex;
+ flex-direction: column;
+ gap: calc(var(--padding) * 1.25);
+ width: 100%;
+ max-width: 820px;
+ margin-inline: auto;
+ }
+
+ .toolbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ }
+ .back-link {
+ color: var(--accent);
+ font-size: 13px;
+ text-decoration: none;
+ }
+ .back-link:hover {
+ text-decoration: underline;
+ }
+
+ .create-row {
+ display: flex;
+ gap: 8px;
+ }
+ .name-input {
+ flex: 1;
+ padding: 8px 12px;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ background: var(--bg);
+ color: var(--text);
+ font: inherit;
+ font-size: 13px;
+ }
+ .name-input:focus {
+ outline: none;
+ border-color: var(--accent);
+ }
+
+ .state {
+ padding: 24px;
+ text-align: center;
+ color: var(--secondary);
+ font-size: 13px;
+ }
+ .state.err { color: var(--error, var(--accent)); }
+
+ .empty {
+ padding: 48px 16px;
+ text-align: center;
+ color: var(--tertiary);
+ font-size: 13px;
+ }
+
+ .preset-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ }
+ .preset-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 12px 16px;
+ border: 1px solid color-mix(in oklab, var(--input-border) 60%, transparent);
+ border-radius: var(--border-radius);
+ background: var(--surface);
+ }
+ .preset-info {
+ flex: 1;
+ min-width: 0;
+ }
+ .preset-name {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ font-size: 14px;
+ font-weight: 500;
+ color: var(--text);
+ }
+ .badge {
+ padding: 1px 8px;
+ border-radius: 999px;
+ background: color-mix(in oklab, var(--accent) 14%, transparent);
+ color: var(--accent);
+ font-size: 10px;
+ font-weight: 500;
+ }
+ .preset-meta {
+ color: var(--tertiary);
+ font-size: 12px;
+ margin-top: 2px;
+ }
+ .preset-actions {
+ display: flex;
+ gap: 6px;
+ flex-shrink: 0;
+ }
+
+ .btn {
+ padding: 7px 14px;
+ border-radius: var(--border-radius);
+ border: 1px solid transparent;
+ font: inherit;
+ font-size: 13px;
+ font-weight: 500;
+ cursor: pointer;
+ transition: background 120ms ease;
+ }
+ .btn:disabled { opacity: 0.5; cursor: not-allowed; }
+ .btn.primary {
+ background: var(--accent);
+ color: var(--on-accent, var(--on-cta, white));
+ }
+ .btn.ghost {
+ background: transparent;
+ border-color: var(--input-border);
+ color: var(--text);
+ }
+ .btn.ghost:hover:not(:disabled) {
+ background: color-mix(in oklab, var(--accent) 8%, transparent);
+ }
+ .btn.ghost.danger {
+ color: var(--error, var(--accent));
+ border-color: color-mix(in oklab, var(--error, var(--accent)) 35%, var(--input-border));
+ }
+ .btn.ghost.danger:hover:not(:disabled) {
+ background: color-mix(in oklab, var(--error, var(--accent)) 10%, transparent);
+ }
+ .btn.sm { padding: 5px 10px; font-size: 12px; }
+
+ .toast {
+ position: fixed;
+ bottom: 20px;
+ right: 20px;
+ padding: 10px 16px;
+ border-radius: var(--border-radius);
+ background: color-mix(in oklab, var(--accent) 16%, var(--surface));
+ color: var(--text);
+ font-size: 13px;
+ z-index: 100;
+ }
+ .toast.err {
+ background: color-mix(in oklab, var(--error, var(--accent)) 18%, var(--surface));
+ }
+
+ .modal-backdrop {
+ position: fixed;
+ inset: 0;
+ background: var(--dialog-backdrop, rgba(0, 0, 0, 0.55));
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 200;
+ padding: 16px;
+ }
+ .modal {
+ background: var(--popup-bg, var(--surface));
+ border: 1px solid color-mix(in oklab, var(--input-border) 60%, transparent);
+ border-radius: var(--border-radius);
+ padding: 20px;
+ max-width: 540px;
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ gap: 14px;
+ }
+ .modal-wide { max-width: 720px; }
+ .modal h3 { margin: 0; font-size: 15px; font-weight: 600; }
+
+ .form-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 10px;
+ }
+ .field {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ font-size: 11px;
+ color: var(--tertiary);
+ }
+ .field input {
+ padding: 7px 10px;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ background: var(--bg);
+ color: var(--text);
+ font: inherit;
+ font-size: 13px;
+ font-family: var(--font-mono, ui-monospace, monospace);
+ }
+ .field input:focus { outline: none; border-color: var(--accent); }
+
+ .check-group {
+ border: 1px solid color-mix(in oklab, var(--input-border) 50%, transparent);
+ border-radius: var(--border-radius);
+ padding: 10px 14px 12px;
+ margin: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ }
+ .check-group legend {
+ padding: 0 6px;
+ font-size: 11px;
+ color: var(--tertiary);
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ }
+ .check {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ color: var(--secondary);
+ font-size: 13px;
+ cursor: pointer;
+ }
+ .check input { accent-color: var(--accent); }
+
+ .modal-foot {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+ border-top: 1px solid color-mix(in oklab, var(--input-border) 40%, transparent);
+ padding-top: 12px;
+ }
+</style>
diff --git a/src/routes/study/anki/import/+page.svelte b/src/routes/study/anki/import/+page.svelte
index 1eb365fd..0cc7192e 100644
--- a/src/routes/study/anki/import/+page.svelte
+++ b/src/routes/study/anki/import/+page.svelte
@@ -60,6 +60,17 @@
let result = $state<Result | null>(null);
let lastSourcePath = $state("");
+ type ExportKind = "apkg" | "colpkg" | "json" | "csv";
+ let exporting = $state<ExportKind | null>(null);
+ let exportNotetypeId = $state<number | null>(null);
+ let exportDelimiter = $state<"" | "\t" | "," | ";">("");
+ let exportToast = $state<{ kind: "ok" | "err"; msg: string } | null>(null);
+
+ function showExportToast(kind: "ok" | "err", msg: string) {
+ exportToast = { kind, msg };
+ setTimeout(() => (exportToast = null), 3000);
+ }
+
async function refreshLookups() {
try {
const [nts, ds] = await Promise.all([
@@ -71,6 +82,9 @@
if (csvNotetypeId === null && notetypes.length > 0) {
csvNotetypeId = notetypes[0].id;
}
+ if (exportNotetypeId === null && notetypes.length > 0) {
+ exportNotetypeId = notetypes[0].id;
+ }
if (csvDeckId === null) {
const def = decks.find((d) => d.id === 1) ?? decks[0];
if (def) csvDeckId = def.id;
@@ -89,9 +103,10 @@
await refreshLookups();
});
- function detectKind(path: string): "apkg" | "json" | "csv" | null {
+ function detectKind(path: string): "apkg" | "colpkg" | "json" | "csv" | null {
const lower = path.toLowerCase();
- if (lower.endsWith(".apkg") || lower.endsWith(".colpkg")) return "apkg";
+ if (lower.endsWith(".colpkg")) return "colpkg";
+ if (lower.endsWith(".apkg")) return "apkg";
if (lower.endsWith(".json")) return "json";
if (lower.endsWith(".csv") || lower.endsWith(".tsv") || lower.endsWith(".txt"))
return "csv";
@@ -127,6 +142,13 @@
{ sourcePath: picked },
);
result = { kind: "apkg", data };
+ } else if (kind === "colpkg") {
+ const data = await pluginInvoke<ApkgSummary>(
+ "study",
+ "study:anki:import:colpkg",
+ { sourcePath: picked },
+ );
+ result = { kind: "apkg", data };
} else if (kind === "json") {
const data = await pluginInvoke<JsonSummary>(
"study",
@@ -161,6 +183,51 @@
}
}
+ async function pickAndExport(kind: ExportKind) {
+ if (exporting) return;
+ exporting = kind;
+ try {
+ const dialog = await import("@tauri-apps/plugin-dialog");
+ const ext =
+ kind === "apkg" ? "apkg"
+ : kind === "colpkg" ? "colpkg"
+ : kind === "json" ? "json"
+ : "csv";
+ const defaultName = `omniget-${kind}-${new Date().toISOString().slice(0, 10)}.${ext}`;
+ const target = await dialog.save({
+ defaultPath: defaultName,
+ filters: [{ name: ext.toUpperCase(), extensions: [ext] }],
+ });
+ if (typeof target !== "string" || !target) {
+ exporting = null;
+ return;
+ }
+ if (kind === "apkg") {
+ await pluginInvoke("study", "study:anki:export:apkg", { targetPath: target });
+ } else if (kind === "colpkg") {
+ await pluginInvoke("study", "study:anki:export:colpkg", { targetPath: target });
+ } else if (kind === "json") {
+ await pluginInvoke("study", "study:anki:export:json", { targetPath: target });
+ } else {
+ if (exportNotetypeId == null) {
+ showExportToast("err", "Selecione um modelo para exportar CSV");
+ return;
+ }
+ const delim = exportDelimiter === "" ? null : exportDelimiter;
+ await pluginInvoke("study", "study:anki:export:csv_notes", {
+ notetypeId: exportNotetypeId,
+ targetPath: target,
+ delimiter: delim,
+ });
+ }
+ showExportToast("ok", `Exportado · ${target.split(/[\\/]/).pop()}`);
+ } catch (e) {
+ showExportToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ exporting = null;
+ }
+ }
+
function summaryRows(r: Result): { label: string; value: number | string }[] {
if (r.kind === "apkg") {
return [
@@ -192,7 +259,7 @@
</script>
<section class="study-page">
- <PageHero title="Importar" subtitle="Carregue uma coleção do Anki ou um arquivo de notas" />
+ <PageHero title="Importar / Exportar" subtitle="Mover dados entre o omniget e outros clientes Anki" />
<div class="format-grid">
<article class="format-card">
@@ -254,6 +321,93 @@
<p class="error">{error}</p>
{/if}
+ <section class="export-section">
+ <h2 class="section-heading">Exportar</h2>
+ <p class="section-lede">
+ Salve a coleção em um arquivo. Útil pra backup externo, migração ou
+ compartilhamento.
+ </p>
+
+ {#if exportToast}
+ <div class="toast" class:err={exportToast.kind === "err"} role="status">
+ {exportToast.msg}
+ </div>
+ {/if}
+
+ <div class="export-grid">
+ <article class="export-card">
+ <h3>.apkg</h3>
+ <p>Compatível com Anki desktop. Inclui notes, cards, decks, modelos e mídia.</p>
+ <button
+ type="button"
+ class="btn-secondary"
+ onclick={() => pickAndExport("apkg")}
+ disabled={exporting !== null || busy}
+ >
+ {exporting === "apkg" ? "Exportando…" : "Exportar .apkg"}
+ </button>
+ </article>
+
+ <article class="export-card">
+ <h3>.colpkg</h3>
+ <p>Coleção completa (formato preferido pelo Anki para backup full).</p>
+ <button
+ type="button"
+ class="btn-secondary"
+ onclick={() => pickAndExport("colpkg")}
+ disabled={exporting !== null || busy}
+ >
+ {exporting === "colpkg" ? "Exportando…" : "Exportar .colpkg"}
+ </button>
+ </article>
+
+ <article class="export-card">
+ <h3>.json</h3>
+ <p>Snapshot interno. Importável de volta no omniget com round-trip completo.</p>
+ <button
+ type="button"
+ class="btn-secondary"
+ onclick={() => pickAndExport("json")}
+ disabled={exporting !== null || busy}
+ >
+ {exporting === "json" ? "Exportando…" : "Exportar .json"}
+ </button>
+ </article>
+
+ <article class="export-card csv-card">
+ <h3>.csv (notes)</h3>
+ <p>Planilha de notes para um modelo específico. Útil pra editar em Excel/Sheets.</p>
+ <div class="export-options">
+ <label>
+ <span>Modelo</span>
+ <select bind:value={exportNotetypeId} disabled={exporting !== null}>
+ {#each notetypes as nt (nt.id)}
+ <option value={nt.id}>{nt.name}</option>
+ {/each}
+ </select>
+ </label>
+ <label>
+ <span>Delimitador</span>
+ <select bind:value={exportDelimiter} disabled={exporting !== null}>
+ <option value="">Auto</option>
+ <option value={"\t"}>Tab</option>
+ <option value=",">Vírgula</option>
+ <option value=";">Ponto-e-vírgula</option>
+ </select>
+ </label>
+ </div>
+ <button
+ type="button"
+ class="btn-secondary"
+ onclick={() => pickAndExport("csv")}
+ disabled={exporting !== null || busy || exportNotetypeId == null}
+ >
+ {exporting === "csv" ? "Exportando…" : "Exportar .csv"}
+ </button>
+ </article>
+ </div>
+ </section>
+
{#if result}
<section class="card result-card">
<header class="card-head">
@@ -510,8 +664,115 @@
outline-offset: 2px;
}
+ .export-section {
+ display: flex;
+ flex-direction: column;
+ gap: var(--padding);
+ padding-top: calc(var(--padding) * 1.5);
+ border-top: 1px solid color-mix(in oklab, var(--input-border) 50%, transparent);
+ }
+ .section-heading {
+ margin: 0;
+ font-size: 14px;
+ font-weight: 600;
+ color: var(--secondary);
+ }
+ .section-lede {
+ margin: 0;
+ color: var(--tertiary);
+ font-size: 13px;
+ line-height: 1.5;
+ }
+
+ .export-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
+ gap: var(--padding);
+ }
+ .export-card {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ padding: calc(var(--padding) * 1.25);
+ background: var(--button-elevated);
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ }
+ .export-card h3 {
+ margin: 0;
+ font-size: 13px;
+ font-weight: 500;
+ color: var(--secondary);
+ font-family: var(--font-mono, monospace);
+ }
+ .export-card p {
+ margin: 0;
+ flex: 1;
+ font-size: 12px;
+ color: var(--text);
+ line-height: 1.5;
+ }
+ .export-card.csv-card {
+ grid-column: 1 / -1;
+ }
+ .export-options {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
+ gap: 8px;
+ }
+ .export-options label {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ font-size: 11px;
+ color: var(--tertiary);
+ }
+ .export-options select {
+ background: var(--input-bg);
+ border: 1px solid var(--input-border);
+ color: var(--secondary);
+ padding: 6px 8px;
+ border-radius: var(--border-radius);
+ font-size: 13px;
+ }
+
+ .btn-secondary {
+ align-self: flex-start;
+ padding: 7px 14px;
+ background: transparent;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ color: var(--text);
+ font-family: inherit;
+ font-size: 12px;
+ cursor: pointer;
+ transition: background 120ms ease, border-color 120ms ease;
+ }
+ .btn-secondary:hover:not(:disabled) {
+ background: color-mix(in oklab, var(--accent) 8%, transparent);
+ border-color: var(--accent);
+ }
+ .btn-secondary:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
+
+ .toast {
+ padding: 8px 12px;
+ border-radius: var(--border-radius);
+ background: color-mix(in oklab, var(--accent) 14%, var(--surface));
+ color: var(--text);
+ font-size: 12px;
+ border: 1px solid color-mix(in oklab, var(--accent) 30%, transparent);
+ }
+ .toast.err {
+ background: color-mix(in oklab, var(--error, var(--accent)) 14%, var(--surface));
+ border-color: color-mix(in oklab, var(--error, var(--accent)) 30%, transparent);
+ }
+
@media (prefers-reduced-motion: reduce) {
.btn-primary,
+ .btn-secondary,
.back-link {
transition: none;
}
diff --git a/src/routes/study/anki/media/+page.svelte b/src/routes/study/anki/media/+page.svelte
new file mode 100644
index 00000000..d5e0fdca
--- /dev/null
+++ b/src/routes/study/anki/media/+page.svelte
@@ -0,0 +1,915 @@
+<script lang="ts">
+ import { onMount } from "svelte";
+ import { pluginInvoke } from "$lib/plugin-invoke";
+ import PageHero from "$lib/study-components/PageHero.svelte";
+
+ type MediaEntry = {
+ fname: string;
+ csum: string | null;
+ mtime: number;
+ dirty: boolean;
+ };
+
+ type CheckReport = {
+ total: number;
+ used: number;
+ unused: string[];
+ missing: string[];
+ };
+
+ type TrashGroup = {
+ id: number;
+ fnames: string[];
+ timestamp: number;
+ };
+
+ let entries = $state<MediaEntry[]>([]);
+ let report = $state<CheckReport | null>(null);
+ let recentTrash = $state<TrashGroup[]>([]);
+
+ let loading = $state(true);
+ let checking = $state(false);
+ let trashing = $state(false);
+ let restoring = $state<number | null>(null);
+ let emptying = $state(false);
+ let adding = $state(false);
+ let confirmEmpty = $state(false);
+
+ let error = $state("");
+ let toast = $state<{ kind: "ok" | "err"; msg: string } | null>(null);
+
+ let filter = $state("");
+ let view = $state<"all" | "unused" | "missing">("all");
+ let selected = $state<Set<string>>(new Set());
+
+ let visible = $derived.by(() => {
+ const q = filter.trim().toLowerCase();
+ let pool: string[] = [];
+ if (view === "all") {
+ pool = entries.map((e) => e.fname);
+ } else if (view === "unused") {
+ pool = report?.unused ?? [];
+ } else {
+ pool = report?.missing ?? [];
+ }
+ if (q) pool = pool.filter((f) => f.toLowerCase().includes(q));
+ return pool;
+ });
+
+ function showToast(kind: "ok" | "err", msg: string) {
+ toast = { kind, msg };
+ setTimeout(() => (toast = null), 2400);
+ }
+
+ async function load() {
+ loading = true;
+ error = "";
+ try {
+ await pluginInvoke("study", "study:anki:storage:open");
+ const list = await pluginInvoke<MediaEntry[]>(
+ "study",
+ "study:anki:media:list",
+ );
+ entries = list ?? [];
+ } catch (e) {
+ error = e instanceof Error ? e.message : String(e);
+ } finally {
+ loading = false;
+ }
+ }
+
+ async function runCheck() {
+ checking = true;
+ try {
+ const r = await pluginInvoke<CheckReport>(
+ "study",
+ "study:anki:media:check",
+ );
+ report = r;
+ showToast("ok", "Verificação concluída");
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ checking = false;
+ }
+ }
+
+ async function pickAndAdd() {
+ if (adding) return;
+ adding = true;
+ try {
+ const dialog = await import("@tauri-apps/plugin-dialog");
+ const picked = await dialog.open({
+ multiple: false,
+ filters: [
+ {
+ name: "Mídia",
+ extensions: [
+ "png", "jpg", "jpeg", "gif", "webp", "svg", "bmp",
+ "mp3", "wav", "ogg", "m4a", "flac",
+ "mp4", "webm", "mov",
+ ],
+ },
+ ],
+ });
+ if (typeof picked !== "string" || !picked) return;
+ const r = await pluginInvoke<{ fname: string }>(
+ "study",
+ "study:anki:media:add",
+ { sourcePath: picked },
+ );
+ showToast("ok", `Adicionado: ${r.fname}`);
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ adding = false;
+ }
+ }
+
+ function toggleSelect(fname: string) {
+ if (selected.has(fname)) {
+ selected.delete(fname);
+ } else {
+ selected.add(fname);
+ }
+ selected = new Set(selected);
+ }
+
+ function selectAllVisible() {
+ selected = new Set([...selected, ...visible]);
+ }
+
+ function clearSelection() {
+ selected = new Set();
+ }
+
+ async function trashSelected() {
+ if (selected.size === 0 || trashing) return;
+ const fnames = [...selected];
+ trashing = true;
+ try {
+ const r = await pluginInvoke<{ moved: number }>(
+ "study",
+ "study:anki:media:trash",
+ { fnames },
+ );
+ showToast(
+ "ok",
+ r.moved === 1 ? "1 arquivo movido pro lixo" : `${r.moved} arquivos movidos pro lixo`,
+ );
+ if (r.moved > 0) {
+ recentTrash = [
+ { id: Date.now(), fnames, timestamp: Date.now() },
+ ...recentTrash,
+ ];
+ }
+ clearSelection();
+ await load();
+ if (report) await runCheck();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ trashing = false;
+ }
+ }
+
+ async function trashUnused() {
+ if (!report || report.unused.length === 0) return;
+ const fnames = [...report.unused];
+ trashing = true;
+ try {
+ const r = await pluginInvoke<{ moved: number }>(
+ "study",
+ "study:anki:media:trash",
+ { fnames },
+ );
+ showToast(
+ "ok",
+ r.moved === 1 ? "1 arquivo não usado movido pro lixo" : `${r.moved} arquivos não usados movidos pro lixo`,
+ );
+ if (r.moved > 0) {
+ recentTrash = [
+ { id: Date.now(), fnames, timestamp: Date.now() },
+ ...recentTrash,
+ ];
+ }
+ await load();
+ await runCheck();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ trashing = false;
+ }
+ }
+
+ async function restoreGroup(group: TrashGroup) {
+ if (restoring !== null) return;
+ restoring = group.id;
+ try {
+ const r = await pluginInvoke<{ restored: number }>(
+ "study",
+ "study:anki:media:restore",
+ { fnames: group.fnames },
+ );
+ showToast(
+ "ok",
+ r.restored === 1 ? "1 arquivo restaurado" : `${r.restored} arquivos restaurados`,
+ );
+ recentTrash = recentTrash.filter((g) => g.id !== group.id);
+ await load();
+ if (report) await runCheck();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ restoring = null;
+ }
+ }
+
+ async function emptyTrash() {
+ confirmEmpty = false;
+ emptying = true;
+ try {
+ const r = await pluginInvoke<{ removed: number }>(
+ "study",
+ "study:anki:media:empty_trash",
+ );
+ showToast(
+ "ok",
+ r.removed === 0 ? "Lixeira já estava vazia" :
+ r.removed === 1 ? "1 arquivo apagado pra sempre" :
+ `${r.removed} arquivos apagados pra sempre`,
+ );
+ recentTrash = [];
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ emptying = false;
+ }
+ }
+
+ function formatBytes(bytes: number): string {
+ if (!Number.isFinite(bytes) || bytes <= 0) return "—";
+ const units = ["B", "KB", "MB", "GB"];
+ let n = bytes;
+ let i = 0;
+ while (n >= 1024 && i < units.length - 1) {
+ n /= 1024;
+ i++;
+ }
+ return `${n < 10 ? n.toFixed(1) : Math.round(n)} ${units[i]}`;
+ }
+
+ function fmtTime(secs: number): string {
+ if (!secs || secs <= 0) return "—";
+ return new Date(secs * 1000).toLocaleDateString();
+ }
+
+ function fmtRelative(ms: number): string {
+ const diff = Date.now() - ms;
+ const min = Math.floor(diff / 60000);
+ if (min < 1) return "agora";
+ if (min < 60) return `${min}m atrás`;
+ const h = Math.floor(min / 60);
+ if (h < 24) return `${h}h atrás`;
+ return new Date(ms).toLocaleDateString();
+ }
+
+ onMount(load);
+</script>
+
+<section class="study-page">
+ <PageHero
+ title="Mídia"
+ subtitle={loading
+ ? "Carregando…"
+ : entries.length === 0
+ ? "Imagens, áudio e vídeo da coleção"
+ : entries.length === 1
+ ? "1 arquivo"
+ : `${entries.length} arquivos`}
+ />
+
+ {#if toast}
+ <div class="toast" class:err={toast.kind === "err"} role="status">
+ {toast.msg}
+ </div>
+ {/if}
+
+ <div class="toolbar">
+ <div class="tabs" role="tablist" aria-label="Filtro de mídia">
+ <button
+ type="button"
+ class="tab"
+ class:active={view === "all"}
+ role="tab"
+ aria-selected={view === "all"}
+ onclick={() => (view = "all")}
+ >
+ Tudo
+ <span class="count">{entries.length}</span>
+ </button>
+ <button
+ type="button"
+ class="tab"
+ class:active={view === "unused"}
+ class:disabled={!report}
+ role="tab"
+ aria-selected={view === "unused"}
+ onclick={() => (view = "unused")}
+ disabled={!report}
+ title={report ? "" : "Rode \"Verificar\" primeiro"}
+ >
+ Não usados
+ <span class="count">{report?.unused.length ?? "—"}</span>
+ </button>
+ <button
+ type="button"
+ class="tab"
+ class:active={view === "missing"}
+ class:disabled={!report}
+ role="tab"
+ aria-selected={view === "missing"}
+ onclick={() => (view = "missing")}
+ disabled={!report}
+ title={report ? "" : "Rode \"Verificar\" primeiro"}
+ >
+ Faltando
+ <span class="count">{report?.missing.length ?? "—"}</span>
+ </button>
+ </div>
+
+ <div class="actions">
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={runCheck}
+ disabled={checking}
+ >
+ {checking ? "Verificando…" : "Verificar"}
+ </button>
+ <button
+ type="button"
+ class="btn primary sm"
+ onclick={pickAndAdd}
+ disabled={adding}
+ >
+ {adding ? "Adicionando…" : "Adicionar arquivo"}
+ </button>
+ </div>
+ </div>
+
+ {#if report && view === "unused" && report.unused.length > 0}
+ <div class="unused-banner">
+ <span>{report.unused.length} {report.unused.length === 1 ? "arquivo não está" : "arquivos não estão"} sendo usado</span>
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={trashUnused}
+ disabled={trashing}
+ >
+ {trashing ? "Movendo…" : "Mover todos pro lixo"}
+ </button>
+ </div>
+ {/if}
+
+ {#if view !== "missing"}
+ <div class="search-row">
+ <input
+ type="search"
+ class="search"
+ placeholder="Filtrar arquivos…"
+ bind:value={filter}
+ />
+ {#if selected.size > 0}
+ <span class="sel-count">
+ {selected.size} {selected.size === 1 ? "selecionado" : "selecionados"}
+ </span>
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={clearSelection}
+ >
+ Limpar
+ </button>
+ <button
+ type="button"
+ class="btn ghost sm danger"
+ onclick={trashSelected}
+ disabled={trashing}
+ >
+ {trashing ? "Movendo…" : "Mover pro lixo"}
+ </button>
+ {:else if visible.length > 0}
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={selectAllVisible}
+ >
+ Selecionar visíveis
+ </button>
+ {/if}
+ </div>
+ {/if}
+
+ {#if loading}
+ <div class="state">Carregando arquivos…</div>
+ {:else if error}
+ <div class="state err">{error}</div>
+ <button class="btn ghost" onclick={load}>Tentar de novo</button>
+ {:else if visible.length === 0}
+ <div class="empty">
+ {#if view === "missing"}
+ <p>Nenhum arquivo faltando.</p>
+ {#if !report}
+ <p class="hint">Rode "Verificar" pra começar.</p>
+ {/if}
+ {:else if view === "unused"}
+ {#if !report}
+ <p>Verificação ainda não rodada.</p>
+ <p class="hint">Clique em "Verificar" pra encontrar arquivos não usados.</p>
+ {:else}
+ <p>Nada não usado — coleção limpa.</p>
+ {/if}
+ {:else}
+ <p>Nenhum arquivo de mídia ainda.</p>
+ <p class="hint">Adicione arquivos com o botão acima ou via importação.</p>
+ {/if}
+ </div>
+ {:else if view === "missing"}
+ <ul class="file-list">
+ {#each visible as fname (fname)}
+ <li class="file-row missing-row">
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M12 3l10 18H2z M12 10v5 M12 18v.5" />
+ </svg>
+ <span class="fname">{fname}</span>
+ <span class="muted">no DB mas não no disco</span>
+ </li>
+ {/each}
+ </ul>
+ {:else}
+ <ul class="file-list">
+ {#each visible as fname (fname)}
+ {@const entry = entries.find((e) => e.fname === fname)}
+ <li class="file-row">
+ <input
+ type="checkbox"
+ class="row-check"
+ checked={selected.has(fname)}
+ onchange={() => toggleSelect(fname)}
+ aria-label="Selecionar {fname}"
+ />
+ <span class="fname">{fname}</span>
+ {#if entry}
+ <span class="muted">{fmtTime(entry.mtime)}</span>
+ {#if entry.csum}
+ <span class="csum">{entry.csum.slice(0, 8)}</span>
+ {/if}
+ {/if}
+ </li>
+ {/each}
+ </ul>
+ {/if}
+
+ {#if recentTrash.length > 0}
+ <section class="trash-section">
+ <header class="trash-head">
+ <h3>Lixeira (sessão atual)</h3>
+ <button
+ type="button"
+ class="btn ghost sm danger"
+ onclick={() => (confirmEmpty = true)}
+ disabled={emptying}
+ >
+ {emptying ? "Esvaziando…" : "Esvaziar lixeira"}
+ </button>
+ </header>
+ <p class="trash-lede">
+ Restaurar move o arquivo de volta. Esvaziar apaga permanentemente.
+ </p>
+ <ul class="trash-list">
+ {#each recentTrash as group (group.id)}
+ <li class="trash-row">
+ <div class="trash-info">
+ <span class="trash-count">
+ {group.fnames.length === 1
+ ? "1 arquivo"
+ : `${group.fnames.length} arquivos`}
+ </span>
+ <span class="trash-when">{fmtRelative(group.timestamp)}</span>
+ <details class="trash-detail">
+ <summary>Ver lista</summary>
+ <ul class="trash-fnames">
+ {#each group.fnames.slice(0, 20) as f (f)}
+ <li>{f}</li>
+ {/each}
+ {#if group.fnames.length > 20}
+ <li class="muted">… mais {group.fnames.length - 20}</li>
+ {/if}
+ </ul>
+ </details>
+ </div>
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={() => restoreGroup(group)}
+ disabled={restoring !== null}
+ >
+ {restoring === group.id ? "Restaurando…" : "Restaurar"}
+ </button>
+ </li>
+ {/each}
+ </ul>
+ </section>
+ {/if}
+</section>
+
+{#if confirmEmpty}
+ <div
+ class="modal-backdrop"
+ role="presentation"
+ onclick={() => (confirmEmpty = false)}
+ onkeydown={(e) => { if (e.key === "Escape") confirmEmpty = false; }}
+ >
+ <div
+ class="modal"
+ role="dialog"
+ aria-modal="true"
+ aria-labelledby="empty-title"
+ tabindex="-1"
+ onclick={(e) => e.stopPropagation()}
+ onkeydown={(e) => { if (e.key === "Escape") { e.stopPropagation(); confirmEmpty = false; } }}
+ >
+ <h3 id="empty-title">Esvaziar lixeira?</h3>
+ <p class="modal-body">
+ Os arquivos serão apagados do disco permanentemente. Não dá pra desfazer.
+ </p>
+ <footer class="modal-foot">
+ <button
+ type="button"
+ class="btn ghost"
+ onclick={() => (confirmEmpty = false)}
+ >
+ Cancelar
+ </button>
+ <button
+ type="button"
+ class="btn primary danger"
+ onclick={emptyTrash}
+ >
+ Esvaziar
+ </button>
+ </footer>
+ </div>
+ </div>
+{/if}
+
+<style>
+ .study-page {
+ display: flex;
+ flex-direction: column;
+ gap: calc(var(--padding) * 1.25);
+ width: 100%;
+ max-width: 900px;
+ margin-inline: auto;
+ }
+
+ .toolbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ flex-wrap: wrap;
+ }
+ .tabs {
+ display: flex;
+ gap: 2px;
+ padding: 2px;
+ background: var(--button-elevated);
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ }
+ .tab {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ padding: 6px 12px;
+ border: 0;
+ background: transparent;
+ border-radius: calc(var(--border-radius) - 2px);
+ color: var(--secondary);
+ font: inherit;
+ font-size: 12px;
+ cursor: pointer;
+ transition: background 100ms ease;
+ }
+ .tab.active {
+ background: var(--surface);
+ color: var(--text);
+ }
+ .tab:hover:not(.active):not(.disabled) {
+ background: color-mix(in oklab, var(--accent) 8%, transparent);
+ }
+ .tab.disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
+ .tab .count {
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 11px;
+ color: var(--tertiary);
+ }
+ .tab.active .count {
+ color: var(--accent);
+ }
+
+ .actions {
+ display: flex;
+ gap: 8px;
+ }
+
+ .unused-banner {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 10px 14px;
+ background: color-mix(in oklab, var(--warning, var(--accent)) 8%, transparent);
+ border: 1px solid color-mix(in oklab, var(--warning, var(--accent)) 30%, transparent);
+ border-radius: var(--border-radius);
+ color: var(--secondary);
+ font-size: 13px;
+ }
+
+ .search-row {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+ .search {
+ flex: 1;
+ padding: 7px 12px;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ background: var(--bg);
+ color: var(--text);
+ font: inherit;
+ font-size: 13px;
+ }
+ .search:focus {
+ outline: none;
+ border-color: var(--accent);
+ }
+ .sel-count {
+ color: var(--accent);
+ font-size: 12px;
+ font-weight: 500;
+ }
+
+ .state {
+ padding: 24px;
+ text-align: center;
+ color: var(--secondary);
+ font-size: 13px;
+ }
+ .state.err {
+ color: var(--error, var(--accent));
+ }
+
+ .empty {
+ padding: 48px 16px;
+ text-align: center;
+ color: var(--secondary);
+ font-size: 13px;
+ }
+ .empty .hint {
+ margin: 4px 0 0;
+ color: var(--tertiary);
+ font-size: 12px;
+ }
+
+ .file-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 1px;
+ }
+ .file-row {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding: 8px 12px;
+ border-radius: var(--border-radius);
+ }
+ .file-row:hover {
+ background: color-mix(in oklab, var(--accent) 5%, transparent);
+ }
+ .row-check {
+ flex-shrink: 0;
+ accent-color: var(--accent);
+ }
+ .fname {
+ flex: 1;
+ min-width: 0;
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 12px;
+ color: var(--text);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ .muted {
+ color: var(--tertiary);
+ font-size: 11px;
+ flex-shrink: 0;
+ }
+ .csum {
+ color: var(--tertiary);
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 10px;
+ flex-shrink: 0;
+ }
+
+ .missing-row {
+ color: var(--error, var(--accent));
+ }
+
+ .trash-section {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ padding-top: calc(var(--padding) * 1.25);
+ border-top: 1px solid color-mix(in oklab, var(--input-border) 50%, transparent);
+ }
+ .trash-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ }
+ .trash-head h3 {
+ margin: 0;
+ font-size: 13px;
+ font-weight: 600;
+ color: var(--secondary);
+ }
+ .trash-lede {
+ margin: 0;
+ color: var(--tertiary);
+ font-size: 12px;
+ }
+ .trash-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ }
+ .trash-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 10px 12px;
+ border: 1px solid color-mix(in oklab, var(--input-border) 50%, transparent);
+ border-radius: var(--border-radius);
+ }
+ .trash-info {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ font-size: 12px;
+ }
+ .trash-count {
+ color: var(--text);
+ font-weight: 500;
+ }
+ .trash-when {
+ color: var(--tertiary);
+ font-size: 11px;
+ }
+ .trash-detail summary {
+ cursor: pointer;
+ color: var(--accent);
+ font-size: 11px;
+ margin-top: 4px;
+ }
+ .trash-fnames {
+ list-style: none;
+ margin: 6px 0 0;
+ padding: 6px 10px;
+ background: var(--bg);
+ border-radius: var(--border-radius);
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 11px;
+ color: var(--secondary);
+ max-height: 200px;
+ overflow-y: auto;
+ }
+ .trash-fnames li {
+ padding: 1px 0;
+ }
+
+ .btn {
+ padding: 6px 12px;
+ border-radius: var(--border-radius);
+ border: 1px solid transparent;
+ font: inherit;
+ font-size: 13px;
+ font-weight: 500;
+ cursor: pointer;
+ transition: background 120ms ease, border-color 120ms ease;
+ }
+ .btn:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
+ .btn.primary {
+ background: var(--accent);
+ color: var(--on-accent, var(--on-cta, white));
+ }
+ .btn.primary:hover:not(:disabled) {
+ background: var(--accent-hover, var(--accent));
+ }
+ .btn.primary.danger {
+ background: var(--error, var(--accent));
+ color: var(--on-error, var(--on-cta, white));
+ }
+ .btn.ghost {
+ background: transparent;
+ border-color: var(--input-border);
+ color: var(--text);
+ }
+ .btn.ghost:hover:not(:disabled) {
+ background: color-mix(in oklab, var(--accent) 8%, transparent);
+ }
+ .btn.ghost.danger {
+ color: var(--error, var(--accent));
+ border-color: color-mix(in oklab, var(--error, var(--accent)) 35%, var(--input-border));
+ }
+ .btn.ghost.danger:hover:not(:disabled) {
+ background: color-mix(in oklab, var(--error, var(--accent)) 10%, transparent);
+ }
+ .btn.sm {
+ padding: 5px 10px;
+ font-size: 12px;
+ }
+
+ .toast {
+ position: fixed;
+ bottom: 20px;
+ right: 20px;
+ padding: 10px 16px;
+ border-radius: var(--border-radius);
+ background: color-mix(in oklab, var(--accent) 16%, var(--surface));
+ color: var(--text);
+ font-size: 13px;
+ box-shadow: 0 8px 24px color-mix(in oklab, black 20%, transparent);
+ z-index: 100;
+ }
+ .toast.err {
+ background: color-mix(in oklab, var(--error, var(--accent)) 18%, var(--surface));
+ }
+
+ .modal-backdrop {
+ position: fixed;
+ inset: 0;
+ background: var(--dialog-backdrop, rgba(0, 0, 0, 0.55));
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 200;
+ padding: 16px;
+ }
+ .modal {
+ background: var(--popup-bg, var(--surface));
+ border: 1px solid color-mix(in oklab, var(--input-border) 60%, transparent);
+ border-radius: var(--border-radius);
+ padding: 20px;
+ max-width: 420px;
+ width: 100%;
+ box-shadow: 0 20px 50px color-mix(in oklab, black 30%, transparent);
+ }
+ .modal h3 {
+ margin: 0 0 12px;
+ font-size: 15px;
+ font-weight: 600;
+ }
+ .modal-body {
+ margin: 0 0 16px;
+ color: var(--secondary);
+ font-size: 13px;
+ line-height: 1.55;
+ }
+ .modal-foot {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+ border-top: 1px solid color-mix(in oklab, var(--input-border) 40%, transparent);
+ padding-top: 12px;
+ }
+</style>
diff --git a/src/routes/study/anki/notetypes/+page.svelte b/src/routes/study/anki/notetypes/+page.svelte
index f5cfe937..18791ea7 100644
--- a/src/routes/study/anki/notetypes/+page.svelte
+++ b/src/routes/study/anki/notetypes/+page.svelte
@@ -571,25 +571,25 @@
<div class="info-banner ok">
Salvo:
{#if saveSummary.fields_added}
- +{saveSummary.fields_added} field(s)
+ +{saveSummary.fields_added} {saveSummary.fields_added === 1 ? "field" : "fields"}
{/if}
{#if saveSummary.fields_removed}
- · −{saveSummary.fields_removed} field(s)
+ · −{saveSummary.fields_removed} {saveSummary.fields_removed === 1 ? "field" : "fields"}
{/if}
{#if saveSummary.templates_added}
- · +{saveSummary.templates_added} template(s)
+ · +{saveSummary.templates_added} {saveSummary.templates_added === 1 ? "template" : "templates"}
{/if}
{#if saveSummary.templates_removed}
- · −{saveSummary.templates_removed} template(s)
+ · −{saveSummary.templates_removed} {saveSummary.templates_removed === 1 ? "template" : "templates"}
{/if}
{#if saveSummary.cards_added}
- · +{saveSummary.cards_added} card(s)
+ · +{saveSummary.cards_added} {saveSummary.cards_added === 1 ? "card" : "cards"}
{/if}
{#if saveSummary.cards_removed}
- · −{saveSummary.cards_removed} card(s)
+ · −{saveSummary.cards_removed} {saveSummary.cards_removed === 1 ? "card" : "cards"}
{/if}
{#if saveSummary.notes_rewritten}
- · {saveSummary.notes_rewritten} nota(s) ajustadas
+ · {saveSummary.notes_rewritten} {saveSummary.notes_rewritten === 1 ? "nota ajustada" : "notas ajustadas"}
{/if}
</div>
{/if}
diff --git a/src/routes/study/anki/settings/+page.svelte b/src/routes/study/anki/settings/+page.svelte
index 743a40be..75e100b0 100644
--- a/src/routes/study/anki/settings/+page.svelte
+++ b/src/routes/study/anki/settings/+page.svelte
@@ -55,6 +55,20 @@
type GlobalConf = Record<string, unknown>;
+ type BackupEntry = {
+ filename: string;
+ path: string;
+ bytes: number;
+ modified_secs: number;
+ };
+
+ type VerifyReport = {
+ ok: boolean;
+ message: string;
+ schema_version: number | null;
+ bytes: number;
+ };
+
let loading = $state(true);
let saving = $state<string | null>(null);
let error = $state("");
@@ -64,6 +78,20 @@
let deckConfigs = $state<DeckConfigSummary[]>([]);
let defaultDeckCfg = $state<DeckConfig | null>(null);
+ let backups = $state<BackupEntry[]>([]);
+ let backupsLoading = $state(false);
+ let verifyCache = $state<Record<string, VerifyReport>>({});
+ let verifyingPath = $state<string | null>(null);
+ let restoreTargetPath = $state<string | null>(null);
+ let restoring = $state(false);
+ let cleanupKeep = $state(5);
+ let cleanupBusy = $state(false);
+
+ let rawKey = $state("");
+ let rawValue = $state<string | null>(null);
+ let rawBusy = $state(false);
+ let confirmDeleteKeyOpen = $state(false);
+
let schedulerVer = $state("v3");
let nextNewCardPos = $state(1);
let lastUnburied = $state(0);
@@ -243,14 +271,30 @@
}
}
+ async function loadBackups() {
+ backupsLoading = true;
+ try {
+ const list = await pluginInvoke<BackupEntry[]>(
+ "study",
+ "study:anki:backup:list",
+ );
+ backups = list ?? [];
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ backupsLoading = false;
+ }
+ }
+
async function runBackup() {
saving = "backup";
try {
- const r = await pluginInvoke<{ path: string }>(
+ const r = await pluginInvoke<{ path: string; bytes: number }>(
"study",
"study:anki:backup:create",
);
- showToast("ok", `Backup criado em ${r.path}`);
+ showToast("ok", `Backup criado · ${formatBytes(r.bytes)}`);
+ await loadBackups();
} catch (e) {
showToast("err", e instanceof Error ? e.message : String(e));
} finally {
@@ -258,8 +302,129 @@
}
}
+ async function verifyBackup(path: string) {
+ verifyingPath = path;
+ try {
+ const report = await pluginInvoke<VerifyReport>(
+ "study",
+ "study:anki:backup:verify",
+ { sourcePath: path },
+ );
+ verifyCache = { ...verifyCache, [path]: report };
+ showToast(report.ok ? "ok" : "err", report.ok ? "Backup íntegro" : "Backup com problemas");
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ verifyingPath = null;
+ }
+ }
+
+ function askRestore(path: string) {
+ restoreTargetPath = path;
+ }
+
+ async function confirmRestore() {
+ if (!restoreTargetPath) return;
+ restoring = true;
+ try {
+ await pluginInvoke<{ source: string; target: string; backup_before: string | null }>(
+ "study",
+ "study:anki:backup:restore",
+ { sourcePath: restoreTargetPath },
+ );
+ showToast("ok", "Coleção restaurada");
+ restoreTargetPath = null;
+ await loadBackups();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ restoring = false;
+ }
+ }
+
+ async function runCleanup() {
+ const keep = Math.max(0, Math.floor(cleanupKeep));
+ cleanupBusy = true;
+ try {
+ const r = await pluginInvoke<{ removed: number }>(
+ "study",
+ "study:anki:backup:cleanup",
+ { keep },
+ );
+ if (r.removed === 0) {
+ showToast("ok", "Nenhum backup antigo pra remover");
+ } else {
+ showToast(
+ "ok",
+ r.removed === 1 ? "1 backup removido" : `${r.removed} backups removidos`,
+ );
+ await loadBackups();
+ }
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ cleanupBusy = false;
+ }
+ }
+
+ function formatBytes(bytes: number): string {
+ if (!Number.isFinite(bytes) || bytes <= 0) return "—";
+ const units = ["B", "KB", "MB", "GB"];
+ let n = bytes;
+ let i = 0;
+ while (n >= 1024 && i < units.length - 1) {
+ n /= 1024;
+ i++;
+ }
+ return `${n < 10 ? n.toFixed(1) : Math.round(n)} ${units[i]}`;
+ }
+
+ function formatDate(secs: number): string {
+ if (!secs || secs <= 0) return "—";
+ return new Date(secs * 1000).toLocaleString();
+ }
+
+ async function getRawKey() {
+ const key = rawKey.trim();
+ if (!key) return;
+ rawBusy = true;
+ try {
+ const v = await pluginInvoke<unknown>(
+ "study",
+ "study:anki:config:get_global",
+ { key },
+ );
+ rawValue = v == null ? "(não encontrado)" : JSON.stringify(v, null, 2);
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ rawValue = null;
+ } finally {
+ rawBusy = false;
+ }
+ }
+
+ async function deleteRawKey() {
+ const key = rawKey.trim();
+ if (!key) return;
+ confirmDeleteKeyOpen = false;
+ rawBusy = true;
+ try {
+ await pluginInvoke("study", "study:anki:config:delete_global", { key });
+ showToast("ok", `Chave "${key}" removida`);
+ rawValue = null;
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ rawBusy = false;
+ }
+ }
+
function toggleSection(key: string) {
openSection = openSection === key ? "" : key;
+ if (openSection === "backup" && backups.length === 0 && !backupsLoading) {
+ void loadBackups();
+ }
}
onMount(load);
@@ -544,19 +709,24 @@
>
<div class="head-left">
<h3>Backup</h3>
- <span class="head-sub">Snapshot manual da coleção</span>
+ <span class="head-sub">
+ {backups.length === 0
+ ? "Snapshots manuais da coleção"
+ : backups.length === 1
+ ? "1 backup salvo"
+ : `${backups.length} backups salvos`}
+ </span>
</div>
<span class="chev" aria-hidden="true">›</span>
</button>
{#if openSection === "backup"}
<div class="card-body">
- <p class="lede">
- Cria uma cópia compactada da coleção atual em
- <code>plugin_data_dir/backups/</code>. Use antes de migrações
- maiores ou imports de .apkg.
- </p>
- <div class="actions">
+ <div class="backup-head">
+ <p class="lede">
+ Backups ficam em <code>plugin_data_dir/backups/</code>. Restaurar
+ substitui a coleção atual — uma cópia de segurança é feita antes.
+ </p>
<button
class="btn primary"
onclick={runBackup}
@@ -565,6 +735,81 @@
{saving === "backup" ? "Criando…" : "Criar backup agora"}
</button>
</div>
+
+ {#if backupsLoading}
+ <p class="muted small">Carregando…</p>
+ {:else if backups.length === 0}
+ <div class="empty-backup">
+ <p>Nenhum backup ainda.</p>
+ <p class="hint">
+ Crie o primeiro antes de imports grandes ou mudanças de schema.
+ </p>
+ </div>
+ {:else}
+ <ul class="backup-list">
+ {#each backups as b (b.path)}
+ {@const v = verifyCache[b.path]}
+ <li class="backup-row">
+ <div class="backup-info">
+ <div class="backup-name">
+ <span class="backup-filename">{b.filename}</span>
+ {#if v}
+ <span
+ class="verify-badge"
+ class:ok={v.ok}
+ class:err={!v.ok}
+ title={v.message}
+ >
+ {v.ok ? "íntegro" : "com problema"}
+ </span>
+ {/if}
+ </div>
+ <div class="backup-meta">
+ {formatDate(b.modified_secs)} · {formatBytes(b.bytes)}
+ </div>
+ </div>
+ <div class="backup-actions">
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={() => verifyBackup(b.path)}
+ disabled={verifyingPath === b.path}
+ >
+ {verifyingPath === b.path ? "Verificando…" : "Verificar"}
+ </button>
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={() => askRestore(b.path)}
+ >
+ Restaurar
+ </button>
+ </div>
+ </li>
+ {/each}
+ </ul>
+
+ <div class="cleanup-row">
+ <label class="cleanup-label">
+ Manter os
+ <input
+ type="number"
+ min="0"
+ max="999"
+ class="cleanup-keep"
+ bind:value={cleanupKeep}
+ />
+ mais recentes
+ </label>
+ <button
+ class="btn ghost sm"
+ onclick={runCleanup}
+ disabled={cleanupBusy || backups.length <= cleanupKeep}
+ >
+ {cleanupBusy ? "Limpando…" : "Limpar antigos"}
+ </button>
+ </div>
+ {/if}
</div>
{/if}
</section>
@@ -607,6 +852,40 @@
<summary>Configuração global bruta (col.conf)</summary>
<pre>{JSON.stringify(globalConf, null, 2)}</pre>
</details>
+
+ <h4 class="subhead">Inspecionar chave</h4>
+ <p class="lede">
+ Lê ou apaga uma chave específica de <code>col.conf</code>. Use só
+ se souber o que está fazendo.
+ </p>
+ <div class="raw-row">
+ <input
+ type="text"
+ class="raw-input"
+ placeholder="ex: schedVer"
+ bind:value={rawKey}
+ onkeydown={(e) => { if (e.key === "Enter") getRawKey(); }}
+ />
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={getRawKey}
+ disabled={rawBusy || !rawKey.trim()}
+ >
+ Ler
+ </button>
+ <button
+ type="button"
+ class="btn ghost sm danger"
+ onclick={() => (confirmDeleteKeyOpen = true)}
+ disabled={rawBusy || !rawKey.trim()}
+ >
+ Apagar
+ </button>
+ </div>
+ {#if rawValue !== null}
+ <pre class="raw-output">{rawValue}</pre>
+ {/if}
</div>
{/if}
</section>
@@ -614,6 +893,89 @@
{/if}
</section>
+{#if confirmDeleteKeyOpen}
+ <div
+ class="modal-backdrop"
+ role="presentation"
+ onclick={() => (confirmDeleteKeyOpen = false)}
+ onkeydown={(e) => { if (e.key === "Escape") confirmDeleteKeyOpen = false; }}
+ >
+ <div
+ class="modal"
+ role="dialog"
+ aria-modal="true"
+ tabindex="-1"
+ onclick={(e) => e.stopPropagation()}
+ onkeydown={(e) => { if (e.key === "Escape") { e.stopPropagation(); confirmDeleteKeyOpen = false; } }}
+ >
+ <h3>Apagar chave?</h3>
+ <p class="modal-body">
+ Vai apagar <code>{rawKey}</code> de <code>col.conf</code>. Não dá pra desfazer.
+ </p>
+ <footer class="modal-foot">
+ <button
+ type="button"
+ class="btn ghost"
+ onclick={() => (confirmDeleteKeyOpen = false)}
+ >
+ Cancelar
+ </button>
+ <button
+ type="button"
+ class="btn primary danger"
+ onclick={deleteRawKey}
+ >
+ Apagar
+ </button>
+ </footer>
+ </div>
+ </div>
+{/if}
+
+{#if restoreTargetPath}
+ <div
+ class="modal-backdrop"
+ role="presentation"
+ onclick={() => (restoreTargetPath = null)}
+ onkeydown={(e) => { if (e.key === "Escape") restoreTargetPath = null; }}
+ >
+ <div
+ class="modal"
+ role="dialog"
+ aria-modal="true"
+ aria-labelledby="restore-title"
+ tabindex="-1"
+ onclick={(e) => e.stopPropagation()}
+ onkeydown={(e) => { if (e.key === "Escape") { e.stopPropagation(); restoreTargetPath = null; } }}
+ >
+ <h3 id="restore-title">Restaurar este backup?</h3>
+ <p class="modal-body">
+ A coleção atual vai ser substituída pelo conteúdo de
+ <code>{restoreTargetPath?.split(/[\\/]/).pop()}</code>.
+ Uma cópia de segurança é criada automaticamente antes.
+ </p>
+ <footer class="modal-foot">
+ <button
+ type="button"
+ class="btn ghost"
+ onclick={() => (restoreTargetPath = null)}
+ disabled={restoring}
+ >
+ Cancelar
+ </button>
+ <button
+ type="button"
+ class="btn primary"
+ onclick={confirmRestore}
+ disabled={restoring}
+ >
+ {restoring ? "Restaurando…" : "Restaurar"}
+ </button>
+ </footer>
+ </div>
+ </div>
+{/if}
+
<style>
.study-page {
display: flex;
@@ -931,6 +1293,222 @@
color: var(--text);
}
+ .backup-head {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 16px;
+ }
+ .backup-head .lede {
+ flex: 1;
+ margin: 0;
+ }
+ .backup-head .btn {
+ flex-shrink: 0;
+ }
+
+ .empty-backup {
+ text-align: center;
+ padding: 24px 16px;
+ color: var(--secondary);
+ font-size: 13px;
+ }
+ .empty-backup .hint {
+ margin: 4px 0 0;
+ color: var(--tertiary);
+ font-size: 12px;
+ }
+
+ .backup-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ }
+ .backup-row {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding: 10px 12px;
+ border: 1px solid color-mix(in oklab, var(--input-border) 50%, transparent);
+ border-radius: var(--border-radius);
+ background: color-mix(in oklab, var(--surface) 60%, transparent);
+ }
+ .backup-info {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ }
+ .backup-name {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+ .backup-filename {
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 12px;
+ color: var(--text);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ .verify-badge {
+ flex-shrink: 0;
+ padding: 1px 8px;
+ border-radius: 999px;
+ font-size: 10px;
+ font-weight: 500;
+ }
+ .verify-badge.ok {
+ background: color-mix(in oklab, var(--success, var(--accent)) 14%, transparent);
+ color: var(--success, var(--accent));
+ }
+ .verify-badge.err {
+ background: color-mix(in oklab, var(--error, var(--accent)) 14%, transparent);
+ color: var(--error, var(--accent));
+ }
+ .backup-meta {
+ color: var(--tertiary);
+ font-size: 11px;
+ }
+ .backup-actions {
+ display: flex;
+ gap: 6px;
+ flex-shrink: 0;
+ }
+
+ .btn.sm {
+ padding: 5px 10px;
+ font-size: 12px;
+ }
+
+ .cleanup-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ padding-top: 8px;
+ border-top: 1px solid color-mix(in oklab, var(--input-border) 40%, transparent);
+ }
+ .cleanup-label {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ color: var(--secondary);
+ font-size: 13px;
+ }
+ .cleanup-keep {
+ width: 56px;
+ padding: 4px 8px;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ background: var(--bg);
+ color: var(--text);
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 13px;
+ text-align: center;
+ }
+ .cleanup-keep:focus {
+ outline: none;
+ border-color: var(--accent);
+ }
+
+ .muted {
+ color: var(--tertiary);
+ }
+ .small {
+ font-size: 12px;
+ }
+
+ .modal-backdrop {
+ position: fixed;
+ inset: 0;
+ background: var(--dialog-backdrop, rgba(0, 0, 0, 0.55));
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 200;
+ padding: 16px;
+ }
+ .modal {
+ background: var(--popup-bg, var(--surface));
+ border: 1px solid color-mix(in oklab, var(--input-border) 60%, transparent);
+ border-radius: var(--border-radius);
+ padding: 20px;
+ max-width: 460px;
+ width: 100%;
+ box-shadow: 0 20px 50px color-mix(in oklab, black 30%, transparent);
+ }
+ .modal h3 {
+ margin: 0 0 12px;
+ font-size: 15px;
+ font-weight: 600;
+ }
+ .modal-body {
+ margin: 0 0 16px;
+ color: var(--secondary);
+ font-size: 13px;
+ line-height: 1.55;
+ }
+ .modal-body code {
+ word-break: break-all;
+ }
+ .modal-foot {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+ border-top: 1px solid color-mix(in oklab, var(--input-border) 40%, transparent);
+ padding-top: 12px;
+ }
+
+ .raw-row {
+ display: flex;
+ gap: 6px;
+ align-items: center;
+ }
+ .raw-input {
+ flex: 1;
+ padding: 7px 10px;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ background: var(--bg);
+ color: var(--text);
+ font: inherit;
+ font-size: 12px;
+ font-family: var(--font-mono, ui-monospace, monospace);
+ }
+ .raw-input:focus {
+ outline: none;
+ border-color: var(--accent);
+ }
+ .raw-output {
+ margin: 8px 0 0;
+ padding: 10px 12px;
+ background: var(--bg);
+ border: 1px solid color-mix(in oklab, var(--input-border) 50%, transparent);
+ border-radius: var(--border-radius);
+ font-size: 11px;
+ color: var(--secondary);
+ overflow-x: auto;
+ max-height: 200px;
+ overflow-y: auto;
+ }
+ .btn.ghost.danger {
+ color: var(--error, var(--accent));
+ border-color: color-mix(in oklab, var(--error, var(--accent)) 35%, var(--input-border));
+ }
+ .btn.ghost.danger:hover:not(:disabled) {
+ background: color-mix(in oklab, var(--error, var(--accent)) 10%, transparent);
+ }
+ .btn.primary.danger {
+ background: var(--error, var(--accent));
+ color: var(--on-error, var(--on-cta, white));
+ }
+
@media (prefers-reduced-motion: reduce) {
.card,
.card-head,
diff --git a/src/routes/study/anki/stats/+page.svelte b/src/routes/study/anki/stats/+page.svelte
index 9930eefd..58461d9e 100644
--- a/src/routes/study/anki/stats/+page.svelte
+++ b/src/routes/study/anki/stats/+page.svelte
@@ -139,6 +139,7 @@
bind:value={period}
ariaLabel="Período"
/>
+ <a href="/study/anki/stats/revlog" class="advanced-link">Revlog detalhado →</a>
</div>
{#if loading}
@@ -370,7 +371,19 @@
.period-row {
display: flex;
- justify-content: flex-start;
+ justify-content: space-between;
+ align-items: center;
+ gap: 12px;
+ }
+ .advanced-link {
+ color: var(--accent);
+ font-size: 12px;
+ text-decoration: none;
+ padding: 4px 10px;
+ border-radius: var(--border-radius);
+ }
+ .advanced-link:hover {
+ background: color-mix(in oklab, var(--accent) 10%, transparent);
}
.kpi-grid {
diff --git a/src/routes/study/anki/stats/revlog/+page.svelte b/src/routes/study/anki/stats/revlog/+page.svelte
new file mode 100644
index 00000000..284ab517
--- /dev/null
+++ b/src/routes/study/anki/stats/revlog/+page.svelte
@@ -0,0 +1,560 @@
+<script lang="ts">
+ import { onMount } from "svelte";
+ import { pluginInvoke } from "$lib/plugin-invoke";
+ import PageHero from "$lib/study-components/PageHero.svelte";
+
+ type RevlogEntry = {
+ id: number;
+ cid: number;
+ ease: number;
+ ivl: number;
+ last_ivl: number;
+ factor: number;
+ time_ms: number;
+ kind: string;
+ };
+
+ type DeckSummary = { id: number; name: string };
+ type NotetypeSummary = { id: number; name: string };
+ type TagSummary = { tag: string };
+
+ type Mode = "card" | "deck" | "notetype" | "tag" | "range";
+
+ let mode = $state<Mode>("range");
+ let entries = $state<RevlogEntry[]>([]);
+ let loading = $state(false);
+ let error = $state("");
+
+ let cardId = $state<number | "">("");
+ let deckId = $state<number | null>(null);
+ let notetypeId = $state<number | null>(null);
+ let tag = $state("");
+ let rangeDays = $state(7);
+
+ let decks = $state<DeckSummary[]>([]);
+ let notetypes = $state<NotetypeSummary[]>([]);
+ let tags = $state<TagSummary[]>([]);
+
+ let limit = $state(200);
+ let offset = $state(0);
+
+ async function loadLookups() {
+ try {
+ await pluginInvoke("study", "study:anki:storage:open");
+ const [d, n, t] = await Promise.all([
+ pluginInvoke<DeckSummary[]>("study", "study:anki:decks:list"),
+ pluginInvoke<NotetypeSummary[]>("study", "study:anki:notetypes:list"),
+ pluginInvoke<TagSummary[]>("study", "study:anki:tags:list"),
+ ]);
+ decks = d ?? [];
+ notetypes = n ?? [];
+ tags = t ?? [];
+ if (deckId == null && decks.length > 0) deckId = decks[0].id;
+ if (notetypeId == null && notetypes.length > 0) notetypeId = notetypes[0].id;
+ } catch (e) {
+ console.error(e);
+ }
+ }
+
+ async function run() {
+ error = "";
+ loading = true;
+ try {
+ let res: RevlogEntry[] = [];
+ if (mode === "card") {
+ if (cardId === "" || !Number.isFinite(Number(cardId))) {
+ error = "Informe um cardId numérico";
+ entries = [];
+ return;
+ }
+ res = await pluginInvoke<RevlogEntry[]>(
+ "study",
+ "study:anki:revlog:list_by_card",
+ { cardId: Number(cardId) },
+ );
+ } else if (mode === "deck") {
+ if (deckId == null) return;
+ res = await pluginInvoke<RevlogEntry[]>(
+ "study",
+ "study:anki:revlog:list_by_deck",
+ { deckId, limit, offset },
+ );
+ } else if (mode === "notetype") {
+ if (notetypeId == null) return;
+ res = await pluginInvoke<RevlogEntry[]>(
+ "study",
+ "study:anki:revlog:list_by_notetype",
+ { notetypeId, limit, offset },
+ );
+ } else if (mode === "tag") {
+ if (!tag.trim()) {
+ error = "Informe uma tag";
+ entries = [];
+ return;
+ }
+ res = await pluginInvoke<RevlogEntry[]>(
+ "study",
+ "study:anki:revlog:list_by_tag",
+ { tag: tag.trim(), limit, offset },
+ );
+ } else {
+ const endSecs = Math.floor(Date.now() / 1000);
+ const startSecs = endSecs - Math.max(1, Math.floor(rangeDays)) * 86400;
+ res = await pluginInvoke<RevlogEntry[]>(
+ "study",
+ "study:anki:revlog:list_in_range",
+ { startSecs, endSecs, limit, offset },
+ );
+ }
+ entries = res ?? [];
+ } catch (e) {
+ error = e instanceof Error ? e.message : String(e);
+ entries = [];
+ } finally {
+ loading = false;
+ }
+ }
+
+ function fmtDate(ms: number): string {
+ return new Date(ms).toLocaleString();
+ }
+
+ function fmtIvl(days: number): string {
+ if (days === 0) return "—";
+ if (days < 30) return `${days}d`;
+ if (days < 365) return `${Math.round(days / 30)}m`;
+ return `${(days / 365).toFixed(1)}a`;
+ }
+
+ function easeLabel(ease: number): string {
+ return ["?", "Errei", "Difícil", "Bom", "Fácil"][ease] ?? `?${ease}`;
+ }
+
+ function easeClass(ease: number): string {
+ return ["", "ease-1", "ease-2", "ease-3", "ease-4"][ease] ?? "";
+ }
+
+ let summary = $derived.by(() => {
+ if (entries.length === 0) return null;
+ const counts = [0, 0, 0, 0, 0];
+ let totalMs = 0;
+ for (const e of entries) {
+ if (e.ease >= 0 && e.ease <= 4) counts[e.ease]++;
+ totalMs += e.time_ms;
+ }
+ return {
+ total: entries.length,
+ counts,
+ avgSec: (totalMs / entries.length / 1000).toFixed(1),
+ };
+ });
+
+ onMount(async () => {
+ await loadLookups();
+ await run();
+ });
+</script>
+
+<section class="study-page">
+ <PageHero
+ title="Revlog"
+ subtitle="Histórico bruto de respostas para análise"
+ />
+
+ <div class="toolbar">
+ <a href="/study/anki/stats" class="back-link">← Estatísticas</a>
+ </div>
+
+ <div class="filter-card">
+ <div class="mode-tabs" role="tablist" aria-label="Filtro">
+ <button
+ type="button"
+ class="mode-tab"
+ class:active={mode === "range"}
+ role="tab"
+ onclick={() => (mode = "range")}
+ >Período</button>
+ <button
+ type="button"
+ class="mode-tab"
+ class:active={mode === "deck"}
+ role="tab"
+ onclick={() => (mode = "deck")}
+ >Deck</button>
+ <button
+ type="button"
+ class="mode-tab"
+ class:active={mode === "notetype"}
+ role="tab"
+ onclick={() => (mode = "notetype")}
+ >Modelo</button>
+ <button
+ type="button"
+ class="mode-tab"
+ class:active={mode === "tag"}
+ role="tab"
+ onclick={() => (mode = "tag")}
+ >Tag</button>
+ <button
+ type="button"
+ class="mode-tab"
+ class:active={mode === "card"}
+ role="tab"
+ onclick={() => (mode = "card")}
+ >Card específico</button>
+ </div>
+
+ <div class="filter-body">
+ {#if mode === "range"}
+ <label class="field">
+ <span>Últimos N dias</span>
+ <input
+ type="number"
+ min="1"
+ max="3650"
+ bind:value={rangeDays}
+ />
+ </label>
+ {:else if mode === "deck"}
+ <label class="field">
+ <span>Deck</span>
+ <select bind:value={deckId}>
+ {#each decks as d (d.id)}
+ <option value={d.id}>{d.name}</option>
+ {/each}
+ </select>
+ </label>
+ {:else if mode === "notetype"}
+ <label class="field">
+ <span>Modelo</span>
+ <select bind:value={notetypeId}>
+ {#each notetypes as n (n.id)}
+ <option value={n.id}>{n.name}</option>
+ {/each}
+ </select>
+ </label>
+ {:else if mode === "tag"}
+ <label class="field">
+ <span>Tag</span>
+ <input
+ type="text"
+ bind:value={tag}
+ placeholder="exemplo::tag"
+ list="tag-list"
+ />
+ <datalist id="tag-list">
+ {#each tags as t (t.tag)}
+ <option value={t.tag}></option>
+ {/each}
+ </datalist>
+ </label>
+ {:else}
+ <label class="field">
+ <span>Card ID</span>
+ <input
+ type="number"
+ bind:value={cardId}
+ placeholder="123456789"
+ />
+ </label>
+ {/if}
+
+ {#if mode !== "card"}
+ <label class="field">
+ <span>Limite</span>
+ <input type="number" min="1" max="5000" bind:value={limit} />
+ </label>
+ {/if}
+
+ <button
+ type="button"
+ class="btn primary"
+ onclick={run}
+ disabled={loading}
+ >
+ {loading ? "Buscando…" : "Buscar"}
+ </button>
+ </div>
+ </div>
+
+ {#if error}
+ <p class="error">{error}</p>
+ {/if}
+
+ {#if summary}
+ <div class="summary-row">
+ <div class="sum-stat">
+ <span class="sum-num">{summary.total}</span>
+ <span class="sum-label">{summary.total === 1 ? "review" : "reviews"}</span>
+ </div>
+ <div class="sum-stat ease-1">
+ <span class="sum-num">{summary.counts[1]}</span>
+ <span class="sum-label">errei</span>
+ </div>
+ <div class="sum-stat ease-2">
+ <span class="sum-num">{summary.counts[2]}</span>
+ <span class="sum-label">difícil</span>
+ </div>
+ <div class="sum-stat ease-3">
+ <span class="sum-num">{summary.counts[3]}</span>
+ <span class="sum-label">bom</span>
+ </div>
+ <div class="sum-stat ease-4">
+ <span class="sum-num">{summary.counts[4]}</span>
+ <span class="sum-label">fácil</span>
+ </div>
+ <div class="sum-stat">
+ <span class="sum-num">{summary.avgSec}s</span>
+ <span class="sum-label">médio</span>
+ </div>
+ </div>
+ {/if}
+
+ {#if loading}
+ <p class="muted">Carregando…</p>
+ {:else if entries.length === 0 && !error}
+ <p class="muted center">Nenhuma entrada nesse filtro.</p>
+ {:else if entries.length > 0}
+ <div class="table-wrap">
+ <table class="revlog-table">
+ <thead>
+ <tr>
+ <th class="when">Quando</th>
+ <th class="card-col">Card</th>
+ <th class="ease-col">Resp.</th>
+ <th class="num">Ivl</th>
+ <th class="num">→ Ivl</th>
+ <th class="num">Tempo</th>
+ <th class="kind-col">Tipo</th>
+ </tr>
+ </thead>
+ <tbody>
+ {#each entries as e (e.id)}
+ <tr>
+ <td class="mono">{fmtDate(e.id)}</td>
+ <td class="mono">#{e.cid}</td>
+ <td>
+ <span class="ease {easeClass(e.ease)}">
+ {easeLabel(e.ease)}
+ </span>
+ </td>
+ <td class="num mono">{fmtIvl(e.last_ivl)}</td>
+ <td class="num mono">{fmtIvl(e.ivl)}</td>
+ <td class="num mono">{(e.time_ms / 1000).toFixed(1)}s</td>
+ <td class="kind">{e.kind}</td>
+ </tr>
+ {/each}
+ </tbody>
+ </table>
+ </div>
+ {/if}
+</section>
+
+<style>
+ .study-page {
+ display: flex;
+ flex-direction: column;
+ gap: calc(var(--padding) * 1.25);
+ width: 100%;
+ max-width: 980px;
+ margin-inline: auto;
+ }
+
+ .toolbar { display: flex; }
+ .back-link {
+ color: var(--accent);
+ font-size: 13px;
+ text-decoration: none;
+ }
+ .back-link:hover { text-decoration: underline; }
+
+ .filter-card {
+ background: var(--surface);
+ border: 1px solid color-mix(in oklab, var(--input-border) 60%, transparent);
+ border-radius: var(--border-radius);
+ padding: 4px;
+ }
+ .mode-tabs {
+ display: flex;
+ gap: 2px;
+ padding: 2px;
+ overflow-x: auto;
+ }
+ .mode-tab {
+ padding: 6px 12px;
+ border: 0;
+ background: transparent;
+ border-radius: calc(var(--border-radius) - 2px);
+ color: var(--secondary);
+ font: inherit;
+ font-size: 12px;
+ white-space: nowrap;
+ cursor: pointer;
+ }
+ .mode-tab.active {
+ background: color-mix(in oklab, var(--accent) 16%, transparent);
+ color: var(--accent);
+ }
+ .mode-tab:hover:not(.active) {
+ background: color-mix(in oklab, var(--accent) 6%, transparent);
+ }
+
+ .filter-body {
+ display: flex;
+ align-items: flex-end;
+ gap: 12px;
+ padding: 12px 16px;
+ flex-wrap: wrap;
+ border-top: 1px solid color-mix(in oklab, var(--input-border) 50%, transparent);
+ }
+
+ .field {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ font-size: 11px;
+ color: var(--tertiary);
+ flex: 1;
+ min-width: 140px;
+ }
+ .field input,
+ .field select {
+ padding: 7px 10px;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ background: var(--bg);
+ color: var(--text);
+ font: inherit;
+ font-size: 13px;
+ }
+ .field input:focus,
+ .field select:focus {
+ outline: none;
+ border-color: var(--accent);
+ }
+
+ .btn {
+ padding: 7px 16px;
+ border-radius: var(--border-radius);
+ border: 0;
+ font: inherit;
+ font-size: 13px;
+ font-weight: 500;
+ cursor: pointer;
+ }
+ .btn:disabled { opacity: 0.5; cursor: not-allowed; }
+ .btn.primary {
+ background: var(--accent);
+ color: var(--on-accent, var(--on-cta, white));
+ }
+ .btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
+
+ .summary-row {
+ display: flex;
+ gap: 12px;
+ flex-wrap: wrap;
+ }
+ .sum-stat {
+ flex: 1;
+ min-width: 90px;
+ padding: 10px 14px;
+ background: var(--surface);
+ border: 1px solid color-mix(in oklab, var(--input-border) 50%, transparent);
+ border-radius: var(--border-radius);
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ }
+ .sum-num {
+ font-size: 18px;
+ font-weight: 600;
+ color: var(--text);
+ font-variant-numeric: tabular-nums;
+ }
+ .sum-label {
+ font-size: 11px;
+ color: var(--tertiary);
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ }
+ .sum-stat.ease-1 .sum-num { color: var(--error, var(--accent)); }
+ .sum-stat.ease-2 .sum-num { color: var(--orange, var(--accent)); }
+ .sum-stat.ease-3 .sum-num { color: var(--green, var(--accent)); }
+ .sum-stat.ease-4 .sum-num { color: var(--accent); }
+
+ .error {
+ color: var(--error, var(--accent));
+ font-size: 13px;
+ padding: 8px 12px;
+ background: color-mix(in oklab, var(--error, var(--accent)) 8%, transparent);
+ border: 1px solid color-mix(in oklab, var(--error, var(--accent)) 25%, var(--input-border));
+ border-radius: var(--border-radius);
+ }
+
+ .muted { color: var(--tertiary); font-size: 13px; }
+ .center { text-align: center; padding: 24px; }
+
+ .table-wrap {
+ overflow-x: auto;
+ border: 1px solid color-mix(in oklab, var(--input-border) 50%, transparent);
+ border-radius: var(--border-radius);
+ }
+ .revlog-table {
+ width: 100%;
+ border-collapse: collapse;
+ font-size: 12px;
+ }
+ .revlog-table th {
+ text-align: left;
+ padding: 8px 10px;
+ background: var(--surface);
+ color: var(--tertiary);
+ font-weight: 500;
+ font-size: 11px;
+ text-transform: uppercase;
+ letter-spacing: 0.03em;
+ border-bottom: 1px solid color-mix(in oklab, var(--input-border) 50%, transparent);
+ }
+ .revlog-table td {
+ padding: 6px 10px;
+ border-bottom: 1px solid color-mix(in oklab, var(--input-border) 25%, transparent);
+ color: var(--text);
+ }
+ .revlog-table tr:last-child td {
+ border-bottom: 0;
+ }
+ .revlog-table .num { text-align: right; }
+ .revlog-table .mono {
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 11px;
+ }
+ .revlog-table .when { white-space: nowrap; }
+
+ .ease {
+ display: inline-block;
+ padding: 1px 8px;
+ border-radius: 999px;
+ font-size: 11px;
+ font-weight: 500;
+ }
+ .ease.ease-1 {
+ background: color-mix(in oklab, var(--error, var(--accent)) 14%, transparent);
+ color: var(--error, var(--accent));
+ }
+ .ease.ease-2 {
+ background: color-mix(in oklab, var(--orange, var(--accent)) 14%, transparent);
+ color: var(--orange, var(--accent));
+ }
+ .ease.ease-3 {
+ background: color-mix(in oklab, var(--green, var(--accent)) 14%, transparent);
+ color: var(--green, var(--accent));
+ }
+ .ease.ease-4 {
+ background: color-mix(in oklab, var(--accent) 14%, transparent);
+ color: var(--accent);
+ }
+ .kind {
+ color: var(--tertiary);
+ font-size: 11px;
+ }
+</style>
diff --git a/src/routes/study/anki/tags/+page.svelte b/src/routes/study/anki/tags/+page.svelte
new file mode 100644
index 00000000..08c7cfa7
--- /dev/null
+++ b/src/routes/study/anki/tags/+page.svelte
@@ -0,0 +1,665 @@
+<script lang="ts">
+ import { onMount } from "svelte";
+ import { pluginInvoke } from "$lib/plugin-invoke";
+ import PageHero from "$lib/study-components/PageHero.svelte";
+
+ type TagTreeNode = {
+ name: string;
+ full_name: string;
+ level: number;
+ collapsed: boolean;
+ used_count: number;
+ children: TagTreeNode[];
+ };
+
+ let tree = $state<TagTreeNode[]>([]);
+ let loading = $state(true);
+ let error = $state("");
+ let toast = $state<{ kind: "ok" | "err"; msg: string } | null>(null);
+
+ let filter = $state("");
+ let totalTags = $state(0);
+ let unusedCount = $derived.by(() => {
+ let count = 0;
+ function walk(nodes: TagTreeNode[]) {
+ for (const n of nodes) {
+ if (n.used_count === 0) count++;
+ walk(n.children);
+ }
+ }
+ walk(tree);
+ return count;
+ });
+
+ let renameTarget = $state<TagTreeNode | null>(null);
+ let renameNewValue = $state("");
+ let renameBusy = $state(false);
+
+ let reparentTarget = $state<TagTreeNode | null>(null);
+ let reparentNewParent = $state("");
+ let reparentBusy = $state(false);
+
+ let cleanupBusy = $state(false);
+
+ function showToast(kind: "ok" | "err", msg: string) {
+ toast = { kind, msg };
+ setTimeout(() => (toast = null), 2400);
+ }
+
+ async function load() {
+ loading = true;
+ error = "";
+ try {
+ await pluginInvoke("study", "study:anki:storage:open");
+ const nodes = await pluginInvoke<TagTreeNode[]>(
+ "study",
+ "study:anki:tags:tree",
+ );
+ tree = nodes ?? [];
+ totalTags = countAll(tree);
+ } catch (e) {
+ error = e instanceof Error ? e.message : String(e);
+ } finally {
+ loading = false;
+ }
+ }
+
+ function countAll(nodes: TagTreeNode[]): number {
+ let n = 0;
+ for (const node of nodes) {
+ n += 1 + countAll(node.children);
+ }
+ return n;
+ }
+
+ async function toggleCollapse(node: TagTreeNode) {
+ const next = !node.collapsed;
+ try {
+ await pluginInvoke("study", "study:anki:tags:set_collapsed", {
+ tag: node.full_name,
+ collapsed: next,
+ });
+ node.collapsed = next;
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ }
+ }
+
+ function askRename(node: TagTreeNode) {
+ renameTarget = node;
+ renameNewValue = node.full_name;
+ }
+
+ async function confirmRename() {
+ if (!renameTarget) return;
+ const newName = renameNewValue.trim();
+ if (!newName || newName === renameTarget.full_name) {
+ renameTarget = null;
+ return;
+ }
+ renameBusy = true;
+ try {
+ const r = await pluginInvoke<{ updated: number }>(
+ "study",
+ "study:anki:tags:rename",
+ { old: renameTarget.full_name, new: newName },
+ );
+ showToast(
+ "ok",
+ r.updated === 0
+ ? "Tag renomeada"
+ : r.updated === 1
+ ? "Tag renomeada · 1 nota atualizada"
+ : `Tag renomeada · ${r.updated} notas atualizadas`,
+ );
+ renameTarget = null;
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ renameBusy = false;
+ }
+ }
+
+ function askReparent(node: TagTreeNode) {
+ reparentTarget = node;
+ const sep = node.full_name.lastIndexOf("::");
+ reparentNewParent = sep === -1 ? "" : node.full_name.slice(0, sep);
+ }
+
+ async function confirmReparent() {
+ if (!reparentTarget) return;
+ reparentBusy = true;
+ try {
+ const newParent = reparentNewParent.trim();
+ const r = await pluginInvoke<{ updated: number }>(
+ "study",
+ "study:anki:tags:reparent",
+ {
+ tag: reparentTarget.full_name,
+ newParent: newParent === "" ? null : newParent,
+ },
+ );
+ showToast(
+ "ok",
+ r.updated === 0
+ ? "Tag movida"
+ : r.updated === 1
+ ? "Tag movida · 1 nota atualizada"
+ : `Tag movida · ${r.updated} notas atualizadas`,
+ );
+ reparentTarget = null;
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ reparentBusy = false;
+ }
+ }
+
+ async function clearUnused() {
+ cleanupBusy = true;
+ try {
+ const r = await pluginInvoke<{ removed: number }>(
+ "study",
+ "study:anki:tags:clear_unused",
+ );
+ showToast(
+ "ok",
+ r.removed === 0
+ ? "Nenhuma tag não usada"
+ : r.removed === 1
+ ? "1 tag removida"
+ : `${r.removed} tags removidas`,
+ );
+ if (r.removed > 0) await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ cleanupBusy = false;
+ }
+ }
+
+ function matchesFilter(node: TagTreeNode, q: string): boolean {
+ if (!q) return true;
+ if (node.full_name.toLowerCase().includes(q)) return true;
+ return node.children.some((c) => matchesFilter(c, q));
+ }
+
+ let visibleTree = $derived.by(() => {
+ const q = filter.trim().toLowerCase();
+ if (!q) return tree;
+ function prune(nodes: TagTreeNode[]): TagTreeNode[] {
+ const out: TagTreeNode[] = [];
+ for (const n of nodes) {
+ if (matchesFilter(n, q)) {
+ out.push({ ...n, children: prune(n.children) });
+ }
+ }
+ return out;
+ }
+ return prune(tree);
+ });
+
+ onMount(load);
+</script>
+
+<section class="study-page">
+ <PageHero
+ title="Tags"
+ subtitle={totalTags === 0
+ ? "Gerencie as tags da coleção"
+ : totalTags === 1
+ ? "1 tag · " + (unusedCount === 1 ? "1 sem uso" : `${unusedCount} sem uso`)
+ : `${totalTags} tags · ${unusedCount === 1 ? "1 sem uso" : `${unusedCount} sem uso`}`}
+ />
+
+ {#if toast}
+ <div class="toast" class:err={toast.kind === "err"} role="status">
+ {toast.msg}
+ </div>
+ {/if}
+
+ <div class="toolbar">
+ <input
+ class="filter"
+ type="search"
+ placeholder="Filtrar tags…"
+ bind:value={filter}
+ />
+ <button
+ class="btn ghost sm"
+ onclick={clearUnused}
+ disabled={cleanupBusy || unusedCount === 0}
+ >
+ {cleanupBusy ? "Limpando…" : "Limpar não usadas"}
+ </button>
+ </div>
+
+ {#if loading}
+ <div class="state">Carregando tags…</div>
+ {:else if error}
+ <div class="state err">{error}</div>
+ <button class="btn ghost" onclick={load}>Tentar de novo</button>
+ {:else if tree.length === 0}
+ <div class="empty">
+ <p>Nenhuma tag ainda.</p>
+ <p class="hint">Tags são criadas quando você adiciona uma a uma nota.</p>
+ </div>
+ {:else if visibleTree.length === 0}
+ <div class="empty">
+ <p>Nenhuma tag combina com "{filter}".</p>
+ </div>
+ {:else}
+ <ul class="tree">
+ {#each visibleTree as node (node.full_name)}
+ {@render renderNode(node)}
+ {/each}
+ </ul>
+ {/if}
+</section>
+
+{#snippet renderNode(node: TagTreeNode)}
+ <li class="tag-row" style:--depth={node.level}>
+ <div class="tag-line">
+ {#if node.children.length > 0}
+ <button
+ type="button"
+ class="caret"
+ aria-expanded={!node.collapsed}
+ aria-label={node.collapsed ? "Expandir" : "Recolher"}
+ onclick={() => toggleCollapse(node)}
+ >
+ <svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d={node.collapsed ? "M9 6l6 6-6 6" : "M6 9l6 6 6-6"} />
+ </svg>
+ </button>
+ {:else}
+ <span class="caret-spacer" aria-hidden="true"></span>
+ {/if}
+
+ <span class="tag-name" class:unused={node.used_count === 0}>
+ {node.name}
+ </span>
+
+ <span class="tag-count" class:unused={node.used_count === 0}>
+ {node.used_count}
+ </span>
+
+ <div class="tag-actions">
+ <button
+ type="button"
+ class="btn ghost xs"
+ onclick={() => askRename(node)}
+ >
+ Renomear
+ </button>
+ <button
+ type="button"
+ class="btn ghost xs"
+ onclick={() => askReparent(node)}
+ >
+ Mover
+ </button>
+ </div>
+ </div>
+
+ {#if node.children.length > 0 && !node.collapsed}
+ <ul class="tree">
+ {#each node.children as child (child.full_name)}
+ {@render renderNode(child)}
+ {/each}
+ </ul>
+ {/if}
+ </li>
+{/snippet}
+
+{#if renameTarget}
+ <div
+ class="modal-backdrop"
+ role="presentation"
+ onclick={() => (renameTarget = null)}
+ onkeydown={(e) => { if (e.key === "Escape") renameTarget = null; }}
+ >
+ <div
+ class="modal"
+ role="dialog"
+ aria-modal="true"
+ aria-labelledby="rename-title"
+ tabindex="-1"
+ onclick={(e) => e.stopPropagation()}
+ onkeydown={(e) => { if (e.key === "Escape") { e.stopPropagation(); renameTarget = null; } }}
+ >
+ <h3 id="rename-title">Renomear tag</h3>
+ <p class="modal-hint">
+ Use <code>::</code> para hierarquia (ex: <code>livro::cap1</code>).
+ </p>
+ <input
+ class="modal-input"
+ type="text"
+ bind:value={renameNewValue}
+ placeholder={renameTarget.full_name}
+ onkeydown={(e) => { if (e.key === "Enter") confirmRename(); }}
+ />
+ <footer class="modal-foot">
+ <button
+ type="button"
+ class="btn ghost"
+ onclick={() => (renameTarget = null)}
+ disabled={renameBusy}
+ >
+ Cancelar
+ </button>
+ <button
+ type="button"
+ class="btn primary"
+ onclick={confirmRename}
+ disabled={renameBusy || !renameNewValue.trim() || renameNewValue.trim() === renameTarget.full_name}
+ >
+ {renameBusy ? "Renomeando…" : "Renomear"}
+ </button>
+ </footer>
+ </div>
+ </div>
+{/if}
+
+{#if reparentTarget}
+ <div
+ class="modal-backdrop"
+ role="presentation"
+ onclick={() => (reparentTarget = null)}
+ onkeydown={(e) => { if (e.key === "Escape") reparentTarget = null; }}
+ >
+ <div
+ class="modal"
+ role="dialog"
+ aria-modal="true"
+ aria-labelledby="reparent-title"
+ tabindex="-1"
+ onclick={(e) => e.stopPropagation()}
+ onkeydown={(e) => { if (e.key === "Escape") { e.stopPropagation(); reparentTarget = null; } }}
+ >
+ <h3 id="reparent-title">Mover <code>{reparentTarget.full_name}</code></h3>
+ <p class="modal-hint">
+ Novo parent (deixe vazio para mover pra raiz). Use <code>::</code> para
+ encadear níveis.
+ </p>
+ <input
+ class="modal-input"
+ type="text"
+ bind:value={reparentNewParent}
+ placeholder="(raiz)"
+ onkeydown={(e) => { if (e.key === "Enter") confirmReparent(); }}
+ />
+ <footer class="modal-foot">
+ <button
+ type="button"
+ class="btn ghost"
+ onclick={() => (reparentTarget = null)}
+ disabled={reparentBusy}
+ >
+ Cancelar
+ </button>
+ <button
+ type="button"
+ class="btn primary"
+ onclick={confirmReparent}
+ disabled={reparentBusy}
+ >
+ {reparentBusy ? "Movendo…" : "Mover"}
+ </button>
+ </footer>
+ </div>
+ </div>
+{/if}
+
+<style>
+ .study-page {
+ display: flex;
+ flex-direction: column;
+ gap: calc(var(--padding) * 1.25);
+ width: 100%;
+ max-width: 820px;
+ margin-inline: auto;
+ }
+
+ .toolbar {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+ .filter {
+ flex: 1;
+ padding: 8px 12px;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ background: var(--bg);
+ color: var(--text);
+ font: inherit;
+ font-size: 13px;
+ }
+ .filter:focus {
+ outline: none;
+ border-color: var(--accent);
+ }
+
+ .state {
+ padding: calc(var(--padding) * 2);
+ text-align: center;
+ color: var(--secondary);
+ font-size: 14px;
+ }
+ .state.err {
+ color: var(--error, var(--accent));
+ }
+
+ .empty {
+ padding: 32px 16px;
+ text-align: center;
+ color: var(--secondary);
+ font-size: 13px;
+ }
+ .empty .hint {
+ margin: 4px 0 0;
+ color: var(--tertiary);
+ font-size: 12px;
+ }
+
+ .tree {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 1px;
+ }
+
+ .tag-row {
+ --indent: calc(var(--depth, 0) * 18px);
+ display: flex;
+ flex-direction: column;
+ }
+ .tag-line {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 6px 8px 6px calc(8px + var(--indent));
+ border-radius: var(--border-radius);
+ transition: background 100ms ease;
+ }
+ .tag-line:hover {
+ background: color-mix(in oklab, var(--accent) 5%, transparent);
+ }
+ .tag-line:hover .tag-actions {
+ opacity: 1;
+ }
+
+ .caret,
+ .caret-spacer {
+ width: 18px;
+ height: 18px;
+ flex-shrink: 0;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ }
+ .caret {
+ border: 0;
+ background: transparent;
+ color: var(--tertiary);
+ cursor: pointer;
+ border-radius: 4px;
+ }
+ .caret:hover {
+ color: var(--text);
+ background: color-mix(in oklab, var(--accent) 10%, transparent);
+ }
+
+ .tag-name {
+ flex: 1;
+ min-width: 0;
+ color: var(--text);
+ font-size: 13px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ .tag-name.unused {
+ color: var(--tertiary);
+ }
+
+ .tag-count {
+ flex-shrink: 0;
+ padding: 0 8px;
+ color: var(--tertiary);
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 11px;
+ }
+ .tag-count.unused {
+ opacity: 0.5;
+ }
+
+ .tag-actions {
+ display: flex;
+ gap: 4px;
+ flex-shrink: 0;
+ opacity: 0;
+ transition: opacity 100ms ease;
+ }
+
+ .btn {
+ padding: 6px 12px;
+ border-radius: var(--border-radius);
+ border: 1px solid transparent;
+ font: inherit;
+ font-size: 13px;
+ font-weight: 500;
+ cursor: pointer;
+ transition: background 120ms ease, border-color 120ms ease;
+ }
+ .btn:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
+ .btn.primary {
+ background: var(--accent);
+ color: var(--on-accent, var(--on-cta, white));
+ }
+ .btn.primary:hover:not(:disabled) {
+ background: var(--accent-hover, var(--accent));
+ }
+ .btn.ghost {
+ background: transparent;
+ border-color: var(--input-border);
+ color: var(--text);
+ }
+ .btn.ghost:hover:not(:disabled) {
+ background: color-mix(in oklab, var(--accent) 8%, transparent);
+ }
+ .btn.sm {
+ padding: 5px 10px;
+ font-size: 12px;
+ }
+ .btn.xs {
+ padding: 3px 8px;
+ font-size: 11px;
+ }
+
+ .toast {
+ position: fixed;
+ bottom: 20px;
+ right: 20px;
+ padding: 10px 16px;
+ border-radius: var(--border-radius);
+ background: color-mix(in oklab, var(--accent) 16%, var(--surface));
+ color: var(--text);
+ font-size: 13px;
+ box-shadow: 0 8px 24px color-mix(in oklab, black 20%, transparent);
+ z-index: 100;
+ }
+ .toast.err {
+ background: color-mix(in oklab, var(--error, var(--accent)) 18%, var(--surface));
+ }
+
+ .modal-backdrop {
+ position: fixed;
+ inset: 0;
+ background: var(--dialog-backdrop, rgba(0, 0, 0, 0.55));
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 200;
+ padding: 16px;
+ }
+ .modal {
+ background: var(--popup-bg, var(--surface));
+ border: 1px solid color-mix(in oklab, var(--input-border) 60%, transparent);
+ border-radius: var(--border-radius);
+ padding: 20px;
+ max-width: 460px;
+ width: 100%;
+ box-shadow: 0 20px 50px color-mix(in oklab, black 30%, transparent);
+ }
+ .modal h3 {
+ margin: 0 0 8px;
+ font-size: 15px;
+ font-weight: 600;
+ }
+ .modal-hint {
+ margin: 0 0 12px;
+ color: var(--tertiary);
+ font-size: 12px;
+ }
+ .modal-input {
+ width: 100%;
+ padding: 8px 12px;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ background: var(--bg);
+ color: var(--text);
+ font: inherit;
+ font-size: 13px;
+ font-family: var(--font-mono, ui-monospace, monospace);
+ margin-bottom: 16px;
+ }
+ .modal-input:focus {
+ outline: none;
+ border-color: var(--accent);
+ }
+ .modal-foot {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+ border-top: 1px solid color-mix(in oklab, var(--input-border) 40%, transparent);
+ padding-top: 12px;
+ }
+
+ code {
+ padding: 1px 6px;
+ background: color-mix(in oklab, var(--accent) 8%, transparent);
+ border-radius: 4px;
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 12px;
+ color: var(--text);
+ }
+</style>
diff --git a/src/routes/study/course/[id]/+page.svelte b/src/routes/study/course/[id]/+page.svelte
index c1673740..1b3ed9af 100644
--- a/src/routes/study/course/[id]/+page.svelte
+++ b/src/routes/study/course/[id]/+page.svelte
@@ -220,7 +220,12 @@
}>("study", "study:courses:probe_durations", { courseId });
probeReport = r;
if (r.probed > 0) {
- showToast("ok", `${r.probed} duração(ões) detectada(s)`);
+ showToast(
+ "ok",
+ r.probed === 1
+ ? "1 duração detectada"
+ : `${r.probed} durações detectadas`,
+ );
await load();
} else if (r.failed > 0 && r.probed === 0) {
showToast("err", "ffprobe falhou — verifique se está instalado");
@@ -349,9 +354,12 @@
loose_lessons: detail.loose_lessons.map(update),
};
}
+ const status = completed ? "completas" : "incompletas";
showToast(
"ok",
- `${ids.length} aula(s) marcada(s) como ${completed ? "completas" : "incompletas"}`,
+ ids.length === 1
+ ? `1 aula marcada como ${completed ? "completa" : "incompleta"}`
+ : `${ids.length} aulas marcadas como ${status}`,
);
clearSelection();
} catch (e) {
@@ -686,7 +694,8 @@
{#if selectedLessons.size > 0}
<div class="selection-bar" role="toolbar" aria-label="Ações em massa">
<span class="sel-count">
- <strong>{selectedLessons.size}</strong> selecionada(s)
+ <strong>{selectedLessons.size}</strong>
+ {selectedLessons.size === 1 ? "selecionada" : "selecionadas"}
</span>
<button class="sel-btn" onclick={selectAllVisible}>
Selecionar todas
diff --git a/src/routes/study/library/+page.svelte b/src/routes/study/library/+page.svelte
index 5de4343f..4c05fdae 100644
--- a/src/routes/study/library/+page.svelte
+++ b/src/routes/study/library/+page.svelte
@@ -707,7 +707,7 @@
onChange={onSearchChange}
placeholder={$t("study.library.search_placeholder")}
/>
- <div class="view-toggle" role="tablist" aria-label="Modo de visualização">
+ <div class="view-toggle" role="tablist" aria-label={$t("study.library.view_mode_aria")}>
<button
type="button"
class="view-btn"
@@ -745,29 +745,35 @@
</header>
{#if healthReport && healthReport.total_issues > 0}
+ {@const parts = [
+ healthReport.zero_byte_videos.length > 0
+ ? $t("study.library.health_banner_part_empty", { count: healthReport.zero_byte_videos.length })
+ : null,
+ healthReport.missing_videos.length > 0
+ ? $t("study.library.health_banner_part_missing", { count: healthReport.missing_videos.length })
+ : null,
+ healthReport.orphan_descriptions.length > 0
+ ? $t("study.library.health_banner_part_orphan", { count: healthReport.orphan_descriptions.length })
+ : null,
+ ].filter(Boolean)}
<button
class="health-banner"
type="button"
onclick={openHealth}
- aria-label="Abrir relatório de saúde da biblioteca"
+ aria-label={$t("study.library.health_banner_aria")}
>
- <span class="health-icon">⚠️</span>
+ <span class="health-dot" aria-hidden="true"></span>
<span class="health-text">
- <strong>{healthReport.total_issues}</strong>
- problema{healthReport.total_issues === 1 ? "" : "s"} na biblioteca:
- {#if healthReport.zero_byte_videos.length > 0}
- {healthReport.zero_byte_videos.length} vídeo(s) com 0 bytes
- {/if}
- {#if healthReport.missing_videos.length > 0}
- {healthReport.zero_byte_videos.length > 0 ? " · " : ""}
- {healthReport.missing_videos.length} vídeo(s) ausente(s)
- {/if}
- {#if healthReport.orphan_descriptions.length > 0}
- {healthReport.zero_byte_videos.length + healthReport.missing_videos.length > 0 ? " · " : ""}
- {healthReport.orphan_descriptions.length} description.html órfã(s)
+ <strong>
+ {healthReport.total_issues === 1
+ ? $t("study.library.health_banner_one")
+ : $t("study.library.health_banner_many", { count: healthReport.total_issues })}
+ </strong>
+ {#if parts.length > 0}
+ <span class="health-parts">{parts.join(" · ")}</span>
{/if}
</span>
- <span class="health-cta">Ver detalhes →</span>
+ <span class="health-cta">{$t("study.library.health_banner_cta")}</span>
</button>
{/if}
@@ -782,12 +788,12 @@
<SegmentedControl
bind:value={statusFilter}
options={[
- { value: "all", label: "Todos" },
- { value: "in_progress", label: "Em progresso" },
- { value: "not_started", label: "Não iniciados" },
- { value: "completed", label: "Concluídos" },
+ { value: "all", label: $t("study.library.status_all") },
+ { value: "in_progress", label: $t("study.library.status_in_progress") },
+ { value: "not_started", label: $t("study.library.status_not_started") },
+ { value: "completed", label: $t("study.library.status_completed") },
]}
- ariaLabel="Status"
+ ariaLabel={$t("study.library.status_aria")}
/>
<span class="result-count-inline">
{visibleCourses.length} de {courses.length}
@@ -800,7 +806,7 @@
class="filters-toggle"
onclick={() => (filtersOpen = !filtersOpen)}
>
- <span>Filtros</span>
+ <span>{$t("study.library.filters")}</span>
<span class="count" aria-hidden="true">
{includeTags.size + excludeTags.size +
(statusFilter !== "all" ? 1 : 0) +
@@ -810,13 +816,13 @@
{#if filtersOpen}
<section class="filter-section">
- <h3>Status</h3>
+ <h3>{$t("study.library.filter_status")}</h3>
<div class="status-buttons">
{#each [
- { v: "all", label: "Todos" },
- { v: "not_started", label: "Não iniciados" },
- { v: "in_progress", label: "Em progresso" },
- { v: "completed", label: "Completos" },
+ { v: "all", label: $t("study.library.status_all") },
+ { v: "not_started", label: $t("study.library.status_not_started") },
+ { v: "in_progress", label: $t("study.library.status_in_progress") },
+ { v: "completed", label: $t("study.library.status_completed") },
] as opt (opt.v)}
<button
type="button"
@@ -832,7 +838,7 @@
{#if playlists.length > 0}
<section class="filter-section">
- <h3>Playlist</h3>
+ <h3>{$t("study.library.filter_playlist")}</h3>
<div class="playlist-list">
<button
type="button"
@@ -840,7 +846,7 @@
class:active={playlistFilter == null}
onclick={() => selectPlaylist(null)}
>
- <span>Todos os cursos</span>
+ <span>{$t("study.library.all_courses")}</span>
<span class="pl-count">{courses.length}</span>
</button>
{#each playlists as p (p.id)}
@@ -857,7 +863,7 @@
</button>
{/each}
</div>
- <a href="/study/library/playlists" class="manage">Gerenciar playlists →</a>
+ <a href="/study/library/playlists" class="manage">{$t("study.library.manage_playlists")}</a>
</section>
{:else}
<section class="filter-section">
@@ -871,16 +877,16 @@
{#if allTags.length > 0}
<section class="filter-section">
<header class="tags-head">
- <h3>Tags</h3>
+ <h3>{$t("study.library.filter_tags")}</h3>
{#if includeTags.size + excludeTags.size > 0}
<button
type="button"
class="clear-link"
onclick={clearTagFilters}
- >limpar</button>
+ >{$t("study.library.clear_filters")}</button>
{/if}
</header>
- <p class="hint">Click → incluir · Shift+Click → excluir</p>
+ <p class="hint">{$t("study.library.tags_hint")}</p>
<div class="tag-grid">
{#each allTags.slice(0, 40) as t (t.tag)}
{@const inc = includeTags.has(t.tag)}
@@ -964,7 +970,7 @@
</div>
{#if gridPageSize < visibleCourses.length}
<div class="grid-sentinel" bind:this={gridSentinel} aria-hidden="true">
- <span class="muted">Carregando mais cursos…</span>
+ <span class="muted">{$t("study.library.loading_more")}</span>
</div>
{/if}
{/if}
@@ -1124,23 +1130,26 @@
}}
disabled={healthLoading}
>
- {healthLoading ? "Verificando…" : "Re-verificar"}
+ {healthLoading ? $t("study.library.health_checking") : $t("study.library.health_recheck")}
</button>
- <button class="close-btn" onclick={() => (healthOpen = false)} aria-label="Fechar">×</button>
+ <button class="close-btn" onclick={() => (healthOpen = false)} aria-label={$t("study.common.close")}>×</button>
</header>
{#if !healthReport}
- <p class="muted small">Carregando…</p>
+ <p class="muted small">{$t("study.common.loading")}</p>
{:else if healthReport.total_issues === 0}
- <p class="health-ok">✅ {$t("study.library.health_ok")}</p>
+ <p class="health-ok">
+ <span class="health-ok-dot" aria-hidden="true"></span>
+ {$t("study.library.health_ok")}
+ </p>
{:else}
{#if healthReport.zero_byte_videos.length > 0}
<section class="health-section">
- <h3>{$t("study.library.health_zero_byte", { count: healthReport.zero_byte_videos.length })}</h3>
- <p class="muted small">
- Download interrompido. Re-baixe o curso ou apague o arquivo
- vazio + faça rescan.
- </p>
+ <h3>
+ {$t("study.library.health_zero_byte")}
+ <span class="health-count">{healthReport.zero_byte_videos.length}</span>
+ </h3>
+ <p class="muted small">{$t("study.library.health_zero_byte_hint")}</p>
<ul class="health-list">
{#each healthReport.zero_byte_videos as v (v.lesson_id)}
<li>
@@ -1154,12 +1163,11 @@
{#if healthReport.missing_videos.length > 0}
<section class="health-section">
- <h3>{$t("study.library.health_missing", { count: healthReport.missing_videos.length })}</h3>
- <p class="muted small">
- Arquivo registrado no DB mas inexistente no disco. Provavelmente
- foi movido/apagado fora do app. Limpeza só remove se a pasta do
- curso ainda existir (drives desmontados são preservados).
- </p>
+ <h3>
+ {$t("study.library.health_missing")}
+ <span class="health-count">{healthReport.missing_videos.length}</span>
+ </h3>
+ <p class="muted small">{$t("study.library.health_missing_hint")}</p>
<div class="health-actions">
<button
type="button"
@@ -1167,7 +1175,7 @@
disabled={cleanupBusy}
onclick={() => (cleanupConfirmOpen = true)}
>
- {cleanupBusy ? "Limpando…" : $t("study.library.cleanup_btn")}
+ {cleanupBusy ? $t("study.library.cleanup_busy") : $t("study.library.cleanup_btn")}
</button>
<button
type="button"
@@ -1195,12 +1203,11 @@
{#if healthReport.orphan_descriptions.length > 0}
<section class="health-section">
- <h3>{$t("study.library.health_orphan_desc", { count: healthReport.orphan_descriptions.length })}</h3>
- <p class="muted small">
- Pastas com texto descritivo mas sem vídeo. Pode ser aula
- "free preview" do scraper que não baixou o conteúdo, ou aula
- não-vídeo (texto puro) que o scanner pulou.
- </p>
+ <h3>
+ {$t("study.library.health_orphan_desc")}
+ <span class="health-count">{healthReport.orphan_descriptions.length}</span>
+ </h3>
+ <p class="muted small">{$t("study.library.health_orphan_hint")}</p>
<ul class="health-list">
{#each healthReport.orphan_descriptions as o, i (i)}
<li>
@@ -2123,32 +2130,60 @@
width: 100%;
display: flex;
align-items: center;
- gap: 10px;
+ gap: 12px;
padding: 10px 14px;
- border: 1px solid color-mix(in oklab, var(--warning, var(--accent)) 50%, transparent);
- background: color-mix(in oklab, var(--warning, var(--accent)) 8%, transparent);
+ border: 1px solid color-mix(in oklab, var(--input-border) 40%, transparent);
+ background: color-mix(in oklab, var(--surface, var(--primary)) 60%, transparent);
border-radius: var(--border-radius);
- color: var(--text);
+ color: var(--secondary);
cursor: pointer;
font: inherit;
font-size: 13px;
text-align: left;
- transition: background 120ms ease;
+ transition: background 120ms ease, border-color 120ms ease;
}
.health-banner:hover {
- background: color-mix(in oklab, var(--warning, var(--accent)) 14%, transparent);
+ background: color-mix(in oklab, var(--surface, var(--primary)) 90%, transparent);
+ border-color: color-mix(in oklab, var(--input-border) 70%, transparent);
}
- .health-icon {
- font-size: 16px;
+ .health-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: var(--warning, var(--accent));
+ flex-shrink: 0;
}
.health-text {
flex: 1;
+ display: flex;
+ align-items: baseline;
+ gap: 8px;
+ flex-wrap: wrap;
+ }
+ .health-text strong {
+ font-weight: 500;
+ }
+ .health-parts {
+ color: var(--tertiary);
+ font-size: 12px;
}
.health-cta {
color: var(--accent);
font-size: 12px;
+ font-weight: 500;
white-space: nowrap;
}
+ .health-count {
+ display: inline-block;
+ margin-left: 8px;
+ padding: 1px 8px;
+ border-radius: 999px;
+ background: color-mix(in oklab, var(--input-border) 50%, transparent);
+ color: var(--secondary);
+ font-size: 11px;
+ font-weight: 500;
+ vertical-align: middle;
+ }
.health-drawer {
width: min(720px, 90vw);
@@ -2186,12 +2221,21 @@
color: var(--text);
}
.health-ok {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
margin: 0;
padding: 12px;
- text-align: center;
- color: var(--success, var(--accent));
+ color: var(--secondary);
font-size: 14px;
}
+ .health-ok-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: var(--success, var(--accent));
+ }
.health-section {
display: flex;
flex-direction: column;
diff --git a/src/routes/study/notes/+page.svelte b/src/routes/study/notes/+page.svelte
index eeee7856..d1cab074 100644
--- a/src/routes/study/notes/+page.svelte
+++ b/src/routes/study/notes/+page.svelte
@@ -191,9 +191,11 @@
await openPage(currentPage.id);
showToast(
"ok",
- r.blocks_updated > 0
- ? `Renomeada e ${r.blocks_updated} bloco(s) atualizado(s)`
- : "Renomeada",
+ r.blocks_updated === 0
+ ? "Renomeada"
+ : r.blocks_updated === 1
+ ? "Renomeada e 1 bloco atualizado"
+ : `Renomeada e ${r.blocks_updated} blocos atualizados`,
);
} catch (e) {
showToast("err", e instanceof Error ? e.message : String(e));
diff --git a/src/routes/study/read/+page.svelte b/src/routes/study/read/+page.svelte
index c43dfd09..97c2aa91 100644
--- a/src/routes/study/read/+page.svelte
+++ b/src/routes/study/read/+page.svelte
@@ -755,6 +755,19 @@
</svg>
<span>{$t("study.read.book_discover_nav")}</span>
</a>
+ <a href="/study/read/search" class="ghost-btn">
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <circle cx="11" cy="11" r="7"></circle>
+ <path d="M21 21l-4.35-4.35"></path>
+ </svg>
+ <span>Buscar anotações</span>
+ </a>
+ <a href="/study/read/downloads" class="ghost-btn">
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M12 3v12 M7 10l5 5 5-5 M5 21h14"></path>
+ </svg>
+ <span>Downloads</span>
+ </a>
<button
type="button"
class="ghost-btn"
diff --git a/src/routes/study/read/books/annas-settings/+page.svelte b/src/routes/study/read/books/annas-settings/+page.svelte
index 627ceddc..de2bc194 100644
--- a/src/routes/study/read/books/annas-settings/+page.svelte
+++ b/src/routes/study/read/books/annas-settings/+page.svelte
@@ -126,12 +126,72 @@
}
}
+ let clearingCache = $state(false);
+ async function clearCache() {
+ clearingCache = true;
+ try {
+ const r = await pluginInvoke<{ removed: number }>(
+ "study",
+ "study:read:annas:clear_cache",
+ );
+ okMsg =
+ r.removed === 0
+ ? "Cache já estava vazio"
+ : r.removed === 1
+ ? "1 entrada de cache removida"
+ : `${r.removed} entradas de cache removidas`;
+ setTimeout(() => (okMsg = ""), 3000);
+ } catch (e) {
+ errorMsg = e instanceof Error ? e.message : String(e);
+ } finally {
+ clearingCache = false;
+ }
+ }
+
+ type BrowserStatus = {
+ available: boolean;
+ enabled: boolean;
+ detected_at?: string | null;
+ };
+ let browserStatus = $state<BrowserStatus | null>(null);
+ let browserBusy = $state(false);
+ async function loadBrowserStatus() {
+ try {
+ browserStatus = await pluginInvoke<BrowserStatus>(
+ "study",
+ "study:read:browser:status",
+ );
+ } catch (e) {
+ browserStatus = null;
+ }
+ }
+ async function toggleBrowser(next: boolean) {
+ browserBusy = true;
+ try {
+ await pluginInvoke("study", "study:read:browser:set_enabled", {
+ enabled: next,
+ });
+ await loadBrowserStatus();
+ okMsg = next
+ ? "Browser auxiliar habilitado"
+ : "Browser auxiliar desabilitado";
+ setTimeout(() => (okMsg = ""), 3000);
+ } catch (e) {
+ errorMsg = e instanceof Error ? e.message : String(e);
+ } finally {
+ browserBusy = false;
+ }
+ }
+
function fmtDate(ts: number | null): string {
if (!ts) return "—";
return new Date(ts * 1000).toLocaleString();
}
- onMount(load);
+ onMount(async () => {
+ await load();
+ await loadBrowserStatus();
+ });
</script>
<section class="page">
@@ -232,6 +292,58 @@
</div>
</section>
+ <section class="block">
+ <h3>Cache de busca</h3>
+ <p class="muted small">
+ Resultados são guardados em memória pra não bombardear os mirrors.
+ Limpe se você está vendo dados desatualizados.
+ </p>
+ <button
+ type="button"
+ class="ghost-btn"
+ onclick={clearCache}
+ disabled={clearingCache}
+ >
+ {clearingCache ? "Limpando…" : "Limpar cache"}
+ </button>
+ </section>
+
+ <section class="block">
+ <h3>Browser auxiliar</h3>
+ <p class="muted small">
+ Alguns mirrors exigem JavaScript pra retornar HTML. Habilite o browser
+ embutido pra esses casos. Pode ficar mais lento.
+ </p>
+ {#if browserStatus}
+ <div class="browser-status">
+ <span
+ class="dot"
+ class:on={browserStatus.enabled}
+ class:off={!browserStatus.enabled}
+ aria-hidden="true"
+ ></span>
+ <span>
+ {browserStatus.enabled ? "Habilitado" : "Desabilitado"}
+ {#if browserStatus.available === false}
+ · não detectado no sistema
+ {/if}
+ </span>
+ </div>
+ {/if}
+ <button
+ type="button"
+ class="ghost-btn"
+ onclick={() => toggleBrowser(!(browserStatus?.enabled ?? false))}
+ disabled={browserBusy}
+ >
+ {browserBusy
+ ? "Aplicando…"
+ : browserStatus?.enabled
+ ? "Desabilitar"
+ : "Habilitar"}
+ </button>
+ </section>
+
<section class="block danger">
<h3>{$t("study.read.annas_reset_title")}</h3>
<p class="muted small">{$t("study.read.annas_reset_hint")}</p>
@@ -463,6 +575,22 @@
background: color-mix(in oklab, var(--error) 15%, transparent);
}
+ .browser-status {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 6px 0;
+ color: var(--secondary);
+ font-size: 12px;
+ }
+ .dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ }
+ .dot.on { background: var(--success, var(--accent)); }
+ .dot.off { background: var(--tertiary); }
+
.modal-overlay {
position: fixed;
inset: 0;
diff --git a/src/routes/study/read/downloads/+page.svelte b/src/routes/study/read/downloads/+page.svelte
new file mode 100644
index 00000000..cb7200e1
--- /dev/null
+++ b/src/routes/study/read/downloads/+page.svelte
@@ -0,0 +1,715 @@
+<script lang="ts">
+ import { onMount, onDestroy } from "svelte";
+ import { pluginInvoke } from "$lib/plugin-invoke";
+ import PageHero from "$lib/study-components/PageHero.svelte";
+ import ConfirmDialog from "$lib/study-components/ConfirmDialog.svelte";
+
+ type DownloadStatus =
+ | "queued"
+ | "downloading"
+ | "complete"
+ | "error"
+ | "cancelled";
+
+ type Download = {
+ id: number;
+ source_id: string;
+ book_ref: string;
+ title: string | null;
+ author: string | null;
+ status: DownloadStatus;
+ progress: number;
+ bytes_downloaded: number;
+ total_bytes: number | null;
+ error: string | null;
+ created_secs: number;
+ updated_secs: number;
+ };
+
+ type TorrentMirror = {
+ name: string;
+ magnet: string;
+ size_label: string | null;
+ seeders: number | null;
+ };
+
+ let downloads = $state<Download[]>([]);
+ let loading = $state(true);
+ let error = $state("");
+ let toast = $state<{ kind: "ok" | "err"; msg: string } | null>(null);
+
+ let filter = $state<"all" | "active" | "finished" | "errored">("all");
+ let acting = $state<number | null>(null);
+ let clearingFinished = $state(false);
+ let confirmClearOpen = $state(false);
+
+ let torrentsTarget = $state<{ sourceId: string; bookRef: string; title: string } | null>(null);
+ let torrentsLoading = $state(false);
+ let torrents = $state<TorrentMirror[]>([]);
+
+ let pollTimer: ReturnType<typeof setInterval> | null = null;
+
+ function showToast(kind: "ok" | "err", msg: string) {
+ toast = { kind, msg };
+ setTimeout(() => (toast = null), 2400);
+ }
+
+ async function load() {
+ try {
+ const filters: Record<string, unknown> = {};
+ if (filter === "active") filters.status = ["queued", "downloading"];
+ else if (filter === "finished") filters.status = ["complete"];
+ else if (filter === "errored") filters.status = ["error", "cancelled"];
+
+ const list = await pluginInvoke<Download[]>(
+ "study",
+ "study:read:downloads:list",
+ { filters: Object.keys(filters).length > 0 ? filters : null },
+ );
+ downloads = list ?? [];
+ } catch (e) {
+ error = e instanceof Error ? e.message : String(e);
+ } finally {
+ loading = false;
+ }
+ }
+
+ function startPolling() {
+ stopPolling();
+ pollTimer = setInterval(() => {
+ const hasActive = downloads.some(
+ (d) => d.status === "queued" || d.status === "downloading",
+ );
+ if (hasActive) void load();
+ }, 2000);
+ }
+
+ function stopPolling() {
+ if (pollTimer) {
+ clearInterval(pollTimer);
+ pollTimer = null;
+ }
+ }
+
+ async function retry(d: Download) {
+ acting = d.id;
+ try {
+ await pluginInvoke("study", "study:read:downloads:retry", { id: d.id });
+ showToast("ok", "Retry agendado");
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ acting = null;
+ }
+ }
+
+ async function cancel(d: Download) {
+ acting = d.id;
+ try {
+ await pluginInvoke("study", "study:read:downloads:cancel", { id: d.id });
+ showToast("ok", "Cancelado");
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ acting = null;
+ }
+ }
+
+ async function clearFinished() {
+ confirmClearOpen = false;
+ clearingFinished = true;
+ try {
+ const r = await pluginInvoke<{ removed: number }>(
+ "study",
+ "study:read:downloads:clear_finished",
+ );
+ showToast(
+ "ok",
+ r.removed === 0
+ ? "Nada pra limpar"
+ : r.removed === 1
+ ? "1 entrada removida"
+ : `${r.removed} entradas removidas`,
+ );
+ await load();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ clearingFinished = false;
+ }
+ }
+
+ async function showTorrents(d: Download) {
+ torrentsTarget = {
+ sourceId: d.source_id,
+ bookRef: d.book_ref,
+ title: d.title ?? d.book_ref,
+ };
+ torrents = [];
+ torrentsLoading = true;
+ try {
+ const list = await pluginInvoke<TorrentMirror[]>(
+ "study",
+ "study:read:downloads:list_torrents",
+ { sourceId: d.source_id, bookRef: d.book_ref },
+ );
+ torrents = list ?? [];
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ torrentsLoading = false;
+ }
+ }
+
+ function copyMagnet(m: TorrentMirror) {
+ if (navigator.clipboard) {
+ navigator.clipboard.writeText(m.magnet);
+ showToast("ok", "Magnet copiado");
+ }
+ }
+
+ function fmtBytes(n: number | null): string {
+ if (!n || n <= 0) return "—";
+ const units = ["B", "KB", "MB", "GB"];
+ let v = n;
+ let i = 0;
+ while (v >= 1024 && i < units.length - 1) {
+ v /= 1024;
+ i++;
+ }
+ return `${v < 10 ? v.toFixed(1) : Math.round(v)} ${units[i]}`;
+ }
+
+ function fmtPct(n: number): string {
+ return `${Math.max(0, Math.min(100, Math.round(n))).toString()}%`;
+ }
+
+ function statusLabel(s: DownloadStatus): string {
+ return {
+ queued: "fila",
+ downloading: "baixando",
+ complete: "ok",
+ error: "erro",
+ cancelled: "cancelado",
+ }[s];
+ }
+
+ let counts = $derived.by(() => {
+ let active = 0,
+ finished = 0,
+ errored = 0;
+ for (const d of downloads) {
+ if (d.status === "queued" || d.status === "downloading") active++;
+ else if (d.status === "complete") finished++;
+ else errored++;
+ }
+ return { active, finished, errored, total: downloads.length };
+ });
+
+ $effect(() => {
+ void filter;
+ void load();
+ });
+
+ onMount(() => {
+ void load();
+ startPolling();
+ });
+ onDestroy(stopPolling);
+</script>
+
+<section class="study-page">
+ <PageHero
+ title="Downloads de livros"
+ subtitle={loading
+ ? "Carregando…"
+ : counts.active > 0
+ ? counts.active === 1
+ ? "1 ativo"
+ : `${counts.active} ativos`
+ : "Nenhum download ativo"}
+ />
+
+ {#if toast}
+ <div class="toast" class:err={toast.kind === "err"} role="status">
+ {toast.msg}
+ </div>
+ {/if}
+
+ <div class="toolbar">
+ <div class="tabs" role="tablist">
+ <button
+ type="button"
+ class="tab"
+ class:active={filter === "all"}
+ onclick={() => (filter = "all")}
+ >
+ Todos <span class="count">{counts.total}</span>
+ </button>
+ <button
+ type="button"
+ class="tab"
+ class:active={filter === "active"}
+ onclick={() => (filter = "active")}
+ >
+ Ativos <span class="count">{counts.active}</span>
+ </button>
+ <button
+ type="button"
+ class="tab"
+ class:active={filter === "finished"}
+ onclick={() => (filter = "finished")}
+ >
+ Concluídos <span class="count">{counts.finished}</span>
+ </button>
+ <button
+ type="button"
+ class="tab"
+ class:active={filter === "errored"}
+ onclick={() => (filter = "errored")}
+ >
+ Falhas <span class="count">{counts.errored}</span>
+ </button>
+ </div>
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={() => (confirmClearOpen = true)}
+ disabled={clearingFinished || (counts.finished === 0 && counts.errored === 0)}
+ >
+ {clearingFinished ? "Limpando…" : "Limpar concluídos"}
+ </button>
+ </div>
+
+ {#if error}
+ <div class="state err">{error}</div>
+ {:else if loading}
+ <div class="state">Carregando…</div>
+ {:else if downloads.length === 0}
+ <div class="empty">
+ <p>Nenhum download {filter !== "all" ? "neste filtro" : "ainda"}.</p>
+ {#if filter === "all"}
+ <p class="hint">
+ Use <a href="/study/read/discover">Descobrir</a> pra encontrar livros.
+ </p>
+ {/if}
+ </div>
+ {:else}
+ <ul class="dl-list">
+ {#each downloads as d (d.id)}
+ <li class="dl-row" data-status={d.status}>
+ <div class="dl-info">
+ <div class="dl-title">
+ {d.title ?? d.book_ref}
+ <span class="dl-status status-{d.status}">{statusLabel(d.status)}</span>
+ </div>
+ {#if d.author}
+ <div class="dl-author">{d.author}</div>
+ {/if}
+ <div class="dl-meta">
+ {d.source_id}
+ {#if d.total_bytes != null}
+ · {fmtBytes(d.bytes_downloaded)} / {fmtBytes(d.total_bytes)}
+ {:else if d.bytes_downloaded > 0}
+ · {fmtBytes(d.bytes_downloaded)}
+ {/if}
+ </div>
+ {#if d.status === "downloading" || d.status === "queued"}
+ <div class="progress">
+ <div class="progress-bar" style:width={fmtPct(d.progress * 100)}></div>
+ <span class="progress-text">{fmtPct(d.progress * 100)}</span>
+ </div>
+ {/if}
+ {#if d.error}
+ <div class="dl-error" title={d.error}>{d.error}</div>
+ {/if}
+ </div>
+ <div class="dl-actions">
+ {#if d.status === "error" || d.status === "cancelled"}
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={() => retry(d)}
+ disabled={acting === d.id}
+ >
+ {acting === d.id ? "…" : "Retry"}
+ </button>
+ {/if}
+ {#if d.status === "queued" || d.status === "downloading"}
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={() => cancel(d)}
+ disabled={acting === d.id}
+ >
+ {acting === d.id ? "…" : "Cancelar"}
+ </button>
+ {/if}
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={() => showTorrents(d)}
+ title="Listar mirrors torrent disponíveis"
+ >
+ Mirrors…
+ </button>
+ </div>
+ </li>
+ {/each}
+ </ul>
+ {/if}
+</section>
+
+{#if torrentsTarget}
+ <div
+ class="modal-backdrop"
+ role="presentation"
+ onclick={(e) => { if (e.target === e.currentTarget) torrentsTarget = null; }}
+ >
+ <div class="modal modal-wide" role="dialog" aria-modal="true">
+ <h3>Mirrors torrent</h3>
+ <p class="modal-hint">{torrentsTarget.title}</p>
+ {#if torrentsLoading}
+ <p class="muted small">Buscando mirrors…</p>
+ {:else if torrents.length === 0}
+ <p class="muted small">Nenhum mirror torrent encontrado.</p>
+ {:else}
+ <ul class="torrent-list">
+ {#each torrents as t (t.magnet)}
+ <li class="torrent-row">
+ <div class="torrent-info">
+ <span class="torrent-name">{t.name}</span>
+ <span class="torrent-meta">
+ {t.size_label ?? "—"}
+ {#if t.seeders != null}
+ · {t.seeders} seeders
+ {/if}
+ </span>
+ </div>
+ <button
+ type="button"
+ class="btn ghost sm"
+ onclick={() => copyMagnet(t)}
+ >
+ Copiar magnet
+ </button>
+ </li>
+ {/each}
+ </ul>
+ {/if}
+ <div class="modal-foot">
+ <button
+ type="button"
+ class="btn primary"
+ onclick={() => (torrentsTarget = null)}
+ >
+ Fechar
+ </button>
+ </div>
+ </div>
+ </div>
+{/if}
+
+<ConfirmDialog
+ bind:open={confirmClearOpen}
+ title="Limpar concluídos"
+ message="Vai remover entradas de downloads concluídos e cancelados. Os arquivos baixados continuam intactos."
+ confirmLabel="Limpar"
+ variant="danger"
+ onConfirm={clearFinished}
+/>
+
+<style>
+ .study-page {
+ display: flex;
+ flex-direction: column;
+ gap: calc(var(--padding) * 1.25);
+ width: 100%;
+ max-width: 900px;
+ margin-inline: auto;
+ }
+
+ .toolbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ flex-wrap: wrap;
+ }
+ .tabs {
+ display: flex;
+ gap: 2px;
+ padding: 2px;
+ background: var(--button-elevated);
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ }
+ .tab {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ padding: 6px 12px;
+ border: 0;
+ background: transparent;
+ border-radius: calc(var(--border-radius) - 2px);
+ color: var(--secondary);
+ font: inherit;
+ font-size: 12px;
+ cursor: pointer;
+ transition: background 100ms ease;
+ }
+ .tab.active {
+ background: var(--surface);
+ color: var(--text);
+ }
+ .tab:hover:not(.active) {
+ background: color-mix(in oklab, var(--accent) 6%, transparent);
+ }
+ .tab .count {
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 11px;
+ color: var(--tertiary);
+ }
+ .tab.active .count {
+ color: var(--accent);
+ }
+
+ .state, .empty {
+ padding: 32px 16px;
+ text-align: center;
+ color: var(--secondary);
+ font-size: 13px;
+ }
+ .empty .hint {
+ margin: 8px 0 0;
+ color: var(--tertiary);
+ font-size: 12px;
+ }
+ .empty a {
+ color: var(--accent);
+ }
+ .state.err { color: var(--error, var(--accent)); }
+
+ .dl-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ }
+ .dl-row {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 12px 16px;
+ border: 1px solid color-mix(in oklab, var(--input-border) 60%, transparent);
+ border-radius: var(--border-radius);
+ background: var(--surface);
+ }
+ .dl-info {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ }
+ .dl-title {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ color: var(--text);
+ font-size: 14px;
+ font-weight: 500;
+ }
+ .dl-status {
+ padding: 1px 8px;
+ border-radius: 999px;
+ font-size: 10px;
+ font-weight: 500;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ }
+ .status-queued, .status-downloading {
+ background: color-mix(in oklab, var(--accent) 14%, transparent);
+ color: var(--accent);
+ }
+ .status-complete {
+ background: color-mix(in oklab, var(--success, var(--accent)) 14%, transparent);
+ color: var(--success, var(--accent));
+ }
+ .status-error, .status-cancelled {
+ background: color-mix(in oklab, var(--error, var(--accent)) 14%, transparent);
+ color: var(--error, var(--accent));
+ }
+
+ .dl-author {
+ font-size: 12px;
+ color: var(--secondary);
+ }
+ .dl-meta {
+ color: var(--tertiary);
+ font-size: 11px;
+ font-family: var(--font-mono, ui-monospace, monospace);
+ }
+ .dl-error {
+ margin-top: 4px;
+ padding: 4px 8px;
+ background: color-mix(in oklab, var(--error, var(--accent)) 8%, transparent);
+ border-left: 2px solid var(--error, var(--accent));
+ color: var(--error, var(--accent));
+ font-size: 11px;
+ border-radius: 3px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ max-width: 480px;
+ }
+
+ .progress {
+ position: relative;
+ margin-top: 4px;
+ height: 4px;
+ background: var(--bg);
+ border-radius: 2px;
+ overflow: hidden;
+ }
+ .progress-bar {
+ height: 100%;
+ background: var(--accent);
+ transition: width 200ms ease;
+ }
+ .progress-text {
+ position: absolute;
+ right: 0;
+ top: -16px;
+ font-size: 10px;
+ color: var(--tertiary);
+ font-family: var(--font-mono, ui-monospace, monospace);
+ }
+
+ .dl-actions {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ flex-shrink: 0;
+ }
+
+ .btn {
+ padding: 6px 12px;
+ border-radius: var(--border-radius);
+ border: 1px solid transparent;
+ font: inherit;
+ font-size: 12px;
+ cursor: pointer;
+ }
+ .btn:disabled { opacity: 0.5; cursor: not-allowed; }
+ .btn.primary {
+ background: var(--accent);
+ color: var(--on-accent, var(--on-cta, white));
+ }
+ .btn.ghost {
+ background: transparent;
+ border-color: var(--input-border);
+ color: var(--text);
+ }
+ .btn.ghost:hover:not(:disabled) {
+ background: color-mix(in oklab, var(--accent) 8%, transparent);
+ }
+ .btn.sm { padding: 4px 10px; }
+
+ .toast {
+ position: fixed;
+ bottom: 20px;
+ right: 20px;
+ padding: 10px 16px;
+ border-radius: var(--border-radius);
+ background: color-mix(in oklab, var(--accent) 16%, var(--surface));
+ color: var(--text);
+ font-size: 13px;
+ z-index: 100;
+ }
+ .toast.err {
+ background: color-mix(in oklab, var(--error, var(--accent)) 18%, var(--surface));
+ }
+
+ .modal-backdrop {
+ position: fixed;
+ inset: 0;
+ background: var(--dialog-backdrop, rgba(0, 0, 0, 0.55));
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 200;
+ padding: 16px;
+ }
+ .modal {
+ background: var(--popup-bg, var(--surface));
+ border: 1px solid color-mix(in oklab, var(--input-border) 60%, transparent);
+ border-radius: var(--border-radius);
+ padding: 20px;
+ max-width: 480px;
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ }
+ .modal-wide { max-width: 640px; }
+ .modal h3 { margin: 0; font-size: 15px; font-weight: 600; }
+ .modal-hint {
+ margin: 0;
+ color: var(--tertiary);
+ font-size: 12px;
+ }
+ .modal-foot {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+ border-top: 1px solid color-mix(in oklab, var(--input-border) 40%, transparent);
+ padding-top: 12px;
+ }
+
+ .torrent-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ max-height: 50vh;
+ overflow-y: auto;
+ }
+ .torrent-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 8px 12px;
+ border: 1px solid color-mix(in oklab, var(--input-border) 50%, transparent);
+ border-radius: var(--border-radius);
+ }
+ .torrent-info {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ }
+ .torrent-name {
+ font-size: 13px;
+ color: var(--text);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+ .torrent-meta {
+ color: var(--tertiary);
+ font-size: 11px;
+ font-family: var(--font-mono, ui-monospace, monospace);
+ }
+
+ .muted { color: var(--tertiary); }
+ .small { font-size: 12px; }
+</style>
diff --git a/src/routes/study/read/search/+page.svelte b/src/routes/study/read/search/+page.svelte
new file mode 100644
index 00000000..b8fecc7f
--- /dev/null
+++ b/src/routes/study/read/search/+page.svelte
@@ -0,0 +1,368 @@
+<script lang="ts">
+ import { goto } from "$app/navigation";
+ import { pluginInvoke } from "$lib/plugin-invoke";
+ import PageHero from "$lib/study-components/PageHero.svelte";
+
+ type SearchResult = {
+ annotation_id: number;
+ book_id: number;
+ book_title: string | null;
+ page_index: number | null;
+ snippet: string;
+ color: string | null;
+ note: string | null;
+ created_secs: number;
+ };
+
+ let query = $state("");
+ let results = $state<SearchResult[]>([]);
+ let searching = $state(false);
+ let rebuilding = $state(false);
+ let error = $state("");
+ let searched = $state(false);
+ let toast = $state<{ kind: "ok" | "err"; msg: string } | null>(null);
+ let timer: ReturnType<typeof setTimeout> | null = null;
+
+ function showToast(kind: "ok" | "err", msg: string) {
+ toast = { kind, msg };
+ setTimeout(() => (toast = null), 2400);
+ }
+
+ async function runSearch() {
+ const q = query.trim();
+ if (!q) {
+ results = [];
+ searched = false;
+ return;
+ }
+ searching = true;
+ error = "";
+ try {
+ const list = await pluginInvoke<SearchResult[]>(
+ "study",
+ "study:read:search:global",
+ { query: q, limit: 100 },
+ );
+ results = list ?? [];
+ searched = true;
+ } catch (e) {
+ error = e instanceof Error ? e.message : String(e);
+ results = [];
+ } finally {
+ searching = false;
+ }
+ }
+
+ function debouncedSearch() {
+ if (timer) clearTimeout(timer);
+ timer = setTimeout(runSearch, 300);
+ }
+
+ async function rebuildIndex() {
+ rebuilding = true;
+ try {
+ await pluginInvoke<{ indexed: number }>(
+ "study",
+ "study:read:search:rebuild",
+ );
+ showToast("ok", "Índice reconstruído");
+ if (query.trim()) await runSearch();
+ } catch (e) {
+ showToast("err", e instanceof Error ? e.message : String(e));
+ } finally {
+ rebuilding = false;
+ }
+ }
+
+ function openAnnotation(r: SearchResult) {
+ const params = new URLSearchParams();
+ if (r.page_index != null) params.set("page", String(r.page_index));
+ params.set("annotation", String(r.annotation_id));
+ goto(`/study/read/${r.book_id}?${params.toString()}`);
+ }
+
+ function highlight(text: string, q: string): string {
+ if (!q.trim()) return text;
+ const safeQ = q.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+ const re = new RegExp(`(${safeQ})`, "gi");
+ return text.replace(re, "<mark>$1</mark>");
+ }
+
+ function fmtDate(secs: number): string {
+ if (!secs) return "";
+ return new Date(secs * 1000).toLocaleDateString();
+ }
+
+ $effect(() => {
+ void query;
+ debouncedSearch();
+ });
+</script>
+
+<section class="study-page">
+ <PageHero
+ title="Buscar nas anotações"
+ subtitle="Encontre highlights, notas e marcações em todos os livros"
+ />
+
+ {#if toast}
+ <div class="toast" class:err={toast.kind === "err"} role="status">
+ {toast.msg}
+ </div>
+ {/if}
+
+ <div class="search-box">
+ <input
+ type="search"
+ class="search-input"
+ placeholder="Texto, palavra-chave ou frase…"
+ bind:value={query}
+ autofocus
+ />
+ <button
+ type="button"
+ class="btn ghost"
+ onclick={rebuildIndex}
+ disabled={rebuilding}
+ title="Reconstruir índice se busca estiver retornando resultados desatualizados"
+ >
+ {rebuilding ? "Reindexando…" : "Reindexar"}
+ </button>
+ </div>
+
+ {#if error}
+ <div class="state err">{error}</div>
+ {:else if searching}
+ <div class="state">Buscando…</div>
+ {:else if !searched}
+ <div class="empty">
+ <p>Digite uma palavra ou frase pra buscar.</p>
+ <p class="hint">
+ A busca cobre highlights, notas e o texto dos livros indexados.
+ </p>
+ </div>
+ {:else if results.length === 0}
+ <div class="empty">
+ <p>Nada encontrado pra "{query}".</p>
+ <p class="hint">
+ Se você tem certeza que o texto existe, tente
+ <button type="button" class="btn-link" onclick={rebuildIndex}>
+ reindexar
+ </button>.
+ </p>
+ </div>
+ {:else}
+ <p class="result-count">
+ {results.length === 1 ? "1 resultado" : `${results.length} resultados`}
+ </p>
+ <ul class="result-list">
+ {#each results as r (r.annotation_id)}
+ <li class="result-row">
+ <button
+ type="button"
+ class="result-link"
+ onclick={() => openAnnotation(r)}
+ >
+ <div class="result-head">
+ <span class="result-book">
+ {r.book_title ?? "(sem título)"}
+ </span>
+ {#if r.page_index != null}
+ <span class="result-page">p. {r.page_index + 1}</span>
+ {/if}
+ {#if r.color}
+ <span
+ class="result-color"
+ style:background={r.color}
+ aria-label="Cor: {r.color}"
+ ></span>
+ {/if}
+ </div>
+ <div class="result-snippet">
+ {@html highlight(r.snippet, query)}
+ </div>
+ {#if r.note}
+ <div class="result-note">{@html highlight(r.note, query)}</div>
+ {/if}
+ <div class="result-meta">{fmtDate(r.created_secs)}</div>
+ </button>
+ </li>
+ {/each}
+ </ul>
+ {/if}
+</section>
+
+<style>
+ .study-page {
+ display: flex;
+ flex-direction: column;
+ gap: calc(var(--padding) * 1.25);
+ width: 100%;
+ max-width: 820px;
+ margin-inline: auto;
+ }
+
+ .search-box {
+ display: flex;
+ gap: 8px;
+ }
+ .search-input {
+ flex: 1;
+ padding: 10px 14px;
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ background: var(--bg);
+ color: var(--text);
+ font: inherit;
+ font-size: 14px;
+ }
+ .search-input:focus {
+ outline: none;
+ border-color: var(--accent);
+ }
+
+ .state, .empty {
+ padding: 32px 16px;
+ text-align: center;
+ color: var(--secondary);
+ font-size: 13px;
+ }
+ .empty .hint {
+ margin: 8px 0 0;
+ color: var(--tertiary);
+ font-size: 12px;
+ }
+ .state.err { color: var(--error, var(--accent)); }
+
+ .result-count {
+ margin: 0;
+ color: var(--tertiary);
+ font-size: 12px;
+ }
+
+ .result-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ }
+ .result-row {
+ display: flex;
+ }
+ .result-link {
+ flex: 1;
+ text-align: left;
+ border: 1px solid color-mix(in oklab, var(--input-border) 50%, transparent);
+ border-radius: var(--border-radius);
+ background: var(--surface);
+ padding: 12px 14px;
+ cursor: pointer;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ font: inherit;
+ color: inherit;
+ transition: border-color 100ms ease, background 100ms ease;
+ }
+ .result-link:hover {
+ border-color: var(--accent);
+ background: color-mix(in oklab, var(--accent) 5%, var(--surface));
+ }
+
+ .result-head {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+ .result-book {
+ color: var(--secondary);
+ font-size: 12px;
+ font-weight: 500;
+ }
+ .result-page {
+ color: var(--tertiary);
+ font-size: 11px;
+ font-family: var(--font-mono, ui-monospace, monospace);
+ }
+ .result-color {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ border: 1px solid color-mix(in oklab, currentColor 20%, transparent);
+ }
+ .result-snippet {
+ color: var(--text);
+ font-size: 13px;
+ line-height: 1.5;
+ }
+ .result-snippet :global(mark) {
+ background: color-mix(in oklab, var(--accent) 30%, transparent);
+ color: var(--text);
+ padding: 0 2px;
+ border-radius: 2px;
+ }
+ .result-note {
+ margin-top: 4px;
+ padding: 4px 8px;
+ border-left: 2px solid var(--accent);
+ background: color-mix(in oklab, var(--accent) 5%, transparent);
+ color: var(--secondary);
+ font-size: 12px;
+ line-height: 1.5;
+ }
+ .result-note :global(mark) {
+ background: color-mix(in oklab, var(--accent) 30%, transparent);
+ padding: 0 2px;
+ border-radius: 2px;
+ }
+ .result-meta {
+ color: var(--tertiary);
+ font-size: 11px;
+ }
+
+ .btn {
+ padding: 8px 14px;
+ border-radius: var(--border-radius);
+ border: 1px solid transparent;
+ font: inherit;
+ font-size: 13px;
+ font-weight: 500;
+ cursor: pointer;
+ }
+ .btn:disabled { opacity: 0.5; cursor: not-allowed; }
+ .btn.ghost {
+ background: transparent;
+ border-color: var(--input-border);
+ color: var(--text);
+ }
+ .btn.ghost:hover:not(:disabled) {
+ background: color-mix(in oklab, var(--accent) 8%, transparent);
+ }
+ .btn-link {
+ border: 0;
+ background: transparent;
+ color: var(--accent);
+ font: inherit;
+ font-size: 12px;
+ cursor: pointer;
+ padding: 0;
+ text-decoration: underline;
+ }
+
+ .toast {
+ position: fixed;
+ bottom: 20px;
+ right: 20px;
+ padding: 10px 16px;
+ border-radius: var(--border-radius);
+ background: color-mix(in oklab, var(--accent) 16%, var(--surface));
+ color: var(--text);
+ font-size: 13px;
+ z-index: 100;
+ }
+ .toast.err {
+ background: color-mix(in oklab, var(--error, var(--accent)) 18%, var(--surface));
+ }
+</style>