From 3e289383a9cf9b4f7ed2d539e2cc17ca43a1893f Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Tue, 23 Jun 2026 21:49:34 +0200 Subject: [PATCH 1/9] feat: platform-aware entry titling for all 13 source types - Add PlatformMetadata struct and generate_entry_title() covering all 13 Source variants (YouTubeVideo, YouTubePlaylist, YouTubeChannel, X, Tweet, TweetThread, Instagram, Facebook, TikTok, Reddit, Snapchat, Local, Other) - Add downloader/metadata.rs: extract_from_ytdlp_json() parses yt-dlp --dump-json output into PlatformMetadata; extracts Reddit subreddit from webpage_url via regex - Add ytdlp::fetch_metadata(): separate --dump-json invocation that does not interfere with the actual download call - Extend record_media_entry() with title: Option param; wire yt-dlp metadata fetch + local filename extraction in perform_capture - Restructure record_tweet_entry() to read tweet JSON before entry creation; extract title via tweet_metadata_from_json() - 16 title-generation unit tests + 6 metadata extraction unit tests --- crates/archivr-core/src/capture.rs | 265 +++++++++++++++++- .../archivr-core/src/downloader/metadata.rs | 110 ++++++++ crates/archivr-core/src/downloader/mod.rs | 1 + crates/archivr-core/src/downloader/ytdlp.rs | 22 ++ 4 files changed, 394 insertions(+), 4 deletions(-) create mode 100644 crates/archivr-core/src/downloader/metadata.rs diff --git a/crates/archivr-core/src/capture.rs b/crates/archivr-core/src/capture.rs index a1690f7..e345a2a 100644 --- a/crates/archivr-core/src/capture.rs +++ b/crates/archivr-core/src/capture.rs @@ -31,6 +31,65 @@ pub struct CaptureResult { pub status: String, } +#[derive(Debug, Clone, Default)] +pub struct PlatformMetadata { + /// Uploader / creator handle (without @) + pub author: Option, + /// Video title, playlist name, post title, or filename + pub title: Option, + /// Tweet text, Instagram caption, TikTok caption + pub caption: Option, + /// Reddit subreddit name (without r/) + pub subreddit: Option, + /// Reddit post author handle (without u/) + pub post_author: Option, +} + +impl PlatformMetadata { + /// Returns caption trimmed to 100 chars followed by "..." when longer. + pub fn caption_excerpt(&self) -> Option { + self.caption.as_ref().and_then(|c| { + let t = c.trim(); + if t.is_empty() { + None + } else if t.len() > 100 { + Some(format!("{}...", &t[..100])) + } else { + Some(t.to_string()) + } + }) + } +} + +fn generate_entry_title(source: Source, meta: &PlatformMetadata) -> String { + match source { + Source::YouTubeVideo => meta.title.clone().unwrap_or_else(|| "YouTube Video".to_string()), + Source::YouTubePlaylist => meta.title.clone().unwrap_or_else(|| "YouTube Playlist".to_string()), + Source::YouTubeChannel => format!( + "Archival of {}", + meta.author.as_deref().unwrap_or("Unknown Channel") + ), + Source::X => format!("X Media by {}", meta.author.as_deref().unwrap_or("unknown")), + Source::Tweet => { + let excerpt = meta.caption_excerpt().unwrap_or_else(|| "Tweet".to_string()); + format!("{} \u{2014} @{}", excerpt, meta.author.as_deref().unwrap_or("unknown")) + } + Source::TweetThread => format!("Thread by @{}", meta.author.as_deref().unwrap_or("unknown")), + Source::Instagram => format!("Post by @{}", meta.author.as_deref().unwrap_or("unknown")), + Source::Facebook => format!("Post by {}", meta.author.as_deref().unwrap_or("unknown")), + Source::TikTok => format!("TikTok by @{}", meta.author.as_deref().unwrap_or("unknown")), + Source::Reddit => format!( + "{} \u{2014} r/{} (u/{})", + meta.title.as_deref().unwrap_or("Reddit Post"), + meta.subreddit.as_deref().unwrap_or("reddit"), + meta.post_author.as_deref().unwrap_or("unknown") + ), + Source::Snapchat => format!("Snap by {}", meta.author.as_deref().unwrap_or("unknown")), + Source::Local => meta.title.clone().unwrap_or_else(|| "Local File".to_string()), + Source::Other => "Archived Content".to_string(), + } +} + fn expand_shorthand_to_url(path: &str, source: &Source) -> String { // YouTube shorthands: yt:video/ID, yt:playlist/ID, yt:@handle, yt:channel/ID, etc. if matches!(source, Source::YouTubeVideo | Source::YouTubePlaylist | Source::YouTubeChannel) { @@ -398,6 +457,7 @@ fn record_media_entry( hash: &str, file_extension: &str, byte_size: i64, + title: Option, ) -> Result { debug_assert!(run.run_uid.starts_with("run_")); debug_assert!(item.item_uid.starts_with("item_")); @@ -430,7 +490,7 @@ fn record_media_entry( owned_by_user_id: user_id, source_kind: source_kind.to_string(), entity_kind: entity_kind.to_string(), - title: None, + title, visibility: "private".to_string(), representation_kind: representation_kind.to_string(), source_metadata_json: json!({ @@ -458,6 +518,33 @@ fn record_media_entry( Ok(entry) } +/// Extracts PlatformMetadata from a tweet JSON string. +/// Returns Default on any parse failure. +fn tweet_metadata_from_json(json_str: &str) -> PlatformMetadata { + let Ok(v) = serde_json::from_str::(json_str) else { + return PlatformMetadata::default(); + }; + + let screen_name = v + .get("author") + .and_then(|a| a.get("screen_name")) + .and_then(|s| s.as_str()) + .map(|s| s.trim().to_string()) + .filter(|s| !s.is_empty()); + + let full_text = v + .get("full_text") + .and_then(|t| t.as_str()) + .map(|s| s.trim().to_string()) + .filter(|s| !s.is_empty()); + + PlatformMetadata { + author: screen_name, + caption: full_text, + ..Default::default() + } +} + fn record_tweet_entry( conn: &rusqlite::Connection, store_path: &Path, @@ -480,6 +567,12 @@ fn record_tweet_entry( Some(&canonical_locator), &canonical_locator, )?; + // Read tweet JSON early to extract title before entry creation + let tweet_json_relpath = PathBuf::from("raw_tweets").join(format!("tweet-{tweet_id}.json")); + let tweet_json = fs::read_to_string(store_path.join(&tweet_json_relpath))?; + let tweet_meta = tweet_metadata_from_json(&tweet_json); + let tweet_title = generate_entry_title(source, &tweet_meta); + let entry = database::create_archived_entry( conn, &database::NewEntry { @@ -491,7 +584,7 @@ fn record_tweet_entry( owned_by_user_id: user_id, source_kind: source_kind.to_string(), entity_kind: entity_kind.to_string(), - title: None, + title: Some(tweet_title), visibility: "private".to_string(), representation_kind: representation_kind.to_string(), source_metadata_json: json!({ @@ -504,7 +597,6 @@ fn record_tweet_entry( )?; create_structured_root(store_path, &entry)?; - let tweet_json_relpath = PathBuf::from("raw_tweets").join(format!("tweet-{tweet_id}.json")); database::add_entry_artifact( conn, &database::NewArtifact { @@ -518,7 +610,6 @@ fn record_tweet_entry( }, )?; - let tweet_json = fs::read_to_string(store_path.join(&tweet_json_relpath))?; for (role, raw_relpath) in tweet_raw_artifacts(&tweet_json)? { let raw_path = PathBuf::from(&raw_relpath); let blob = blob_record_for_raw_relpath(store_path, &raw_path)?; @@ -659,6 +750,30 @@ pub fn perform_capture(archive_paths: &ArchivePaths, locator: &str) -> Result = match source { + Source::YouTubeVideo + | Source::X + | Source::Instagram + | Source::Facebook + | Source::TikTok + | Source::Reddit + | Source::Snapchat => downloader::ytdlp::fetch_metadata(&path), + _ => None, + }; + + let local_filename_title: Option = match source { + Source::Local => { + // path is a file:// URI; strip the scheme and take the last component. + let file_path = path.trim_start_matches("file://"); + std::path::Path::new(file_path) + .file_name() + .map(|n| n.to_string_lossy().into_owned()) + } + _ => None, + }; + let hash = match source { Source::YouTubeVideo | Source::X @@ -728,6 +843,19 @@ pub fn perform_capture(archive_paths: &ArchivePaths, locator: &str) -> Result = if let Some(ref json) = ytdlp_metadata_json { + let metadata = downloader::metadata::extract_from_ytdlp_json(json); + Some(generate_entry_title(source, &metadata)) + } else if let Some(filename) = local_filename_title { + let metadata = PlatformMetadata { + title: Some(filename), + ..Default::default() + }; + Some(generate_entry_title(source, &metadata)) + } else { + None + }; + record_media_entry( &conn, store_path, @@ -740,6 +868,7 @@ pub fn perform_capture(archive_paths: &ArchivePaths, locator: &str) -> Result, + title: Option<&str>, + caption: Option<&str>, + subreddit: Option<&str>, + post_author: Option<&str>, + ) -> PlatformMetadata { + PlatformMetadata { + author: author.map(str::to_string), + title: title.map(str::to_string), + caption: caption.map(str::to_string), + subreddit: subreddit.map(str::to_string), + post_author: post_author.map(str::to_string), + } + } + + #[test] + fn youtube_video_uses_title() { + let m = meta(None, Some("How to Rust"), None, None, None); + assert_eq!(generate_entry_title(Source::YouTubeVideo, &m), "How to Rust"); + } + + #[test] + fn youtube_video_fallback() { + let m = meta(None, None, None, None, None); + assert_eq!(generate_entry_title(Source::YouTubeVideo, &m), "YouTube Video"); + } + + #[test] + fn youtube_playlist_uses_title() { + let m = meta(None, Some("Rust Tutorial Series"), None, None, None); + assert_eq!(generate_entry_title(Source::YouTubePlaylist, &m), "Rust Tutorial Series"); + } + + #[test] + fn youtube_channel_uses_author() { + let m = meta(Some("Rust By Example"), None, None, None, None); + assert_eq!(generate_entry_title(Source::YouTubeChannel, &m), "Archival of Rust By Example"); + } + + #[test] + fn x_media_uses_author() { + let m = meta(Some("alice"), None, None, None, None); + assert_eq!(generate_entry_title(Source::X, &m), "X Media by alice"); + } + + #[test] + fn tweet_uses_excerpt_and_author() { + let m = meta(Some("alice"), None, Some("Hello world"), None, None); + assert_eq!(generate_entry_title(Source::Tweet, &m), "Hello world \u{2014} @alice"); + } + + #[test] + fn tweet_truncates_long_caption() { + let long = "a".repeat(150); + let m = meta(Some("bob"), None, Some(&long), None, None); + let title = generate_entry_title(Source::Tweet, &m); + assert!(title.starts_with(&"a".repeat(100))); + assert!(title.contains("...")); + assert!(title.ends_with("\u{2014} @bob")); + } + + #[test] + fn tweet_thread_uses_author() { + let m = meta(Some("bob"), None, None, None, None); + assert_eq!(generate_entry_title(Source::TweetThread, &m), "Thread by @bob"); + } + + #[test] + fn instagram_uses_author() { + let m = meta(Some("photographer"), None, None, None, None); + assert_eq!(generate_entry_title(Source::Instagram, &m), "Post by @photographer"); + } + + #[test] + fn facebook_uses_author_no_at() { + let m = meta(Some("John Doe"), None, None, None, None); + assert_eq!(generate_entry_title(Source::Facebook, &m), "Post by John Doe"); + } + + #[test] + fn tiktok_uses_author() { + let m = meta(Some("dancemaster"), None, None, None, None); + assert_eq!(generate_entry_title(Source::TikTok, &m), "TikTok by @dancemaster"); + } + + #[test] + fn reddit_full_fields() { + let m = meta(None, Some("My first Rust project"), None, Some("rust"), Some("newbie")); + assert_eq!( + generate_entry_title(Source::Reddit, &m), + "My first Rust project \u{2014} r/rust (u/newbie)" + ); + } + + #[test] + fn snapchat_uses_author() { + let m = meta(Some("snapuser"), None, None, None, None); + assert_eq!(generate_entry_title(Source::Snapchat, &m), "Snap by snapuser"); + } + + #[test] + fn local_uses_title_field() { + let m = meta(None, Some("document.pdf"), None, None, None); + assert_eq!(generate_entry_title(Source::Local, &m), "document.pdf"); + } + + #[test] + fn all_none_falls_back() { + let m = meta(None, None, None, None, None); + assert!(!generate_entry_title(Source::Instagram, &m).is_empty()); + } + + #[test] + fn tweet_title_extracted_from_json() { + let json = r#"{ + "full_text": "Hello Rust world, this is a test tweet", + "author": { "screen_name": "rustacean", "name": "The Rustacean" } + }"#; + let meta = tweet_metadata_from_json(json); + assert_eq!(meta.author, Some("rustacean".to_string())); + assert_eq!(meta.caption, Some("Hello Rust world, this is a test tweet".to_string())); + } + } } diff --git a/crates/archivr-core/src/downloader/metadata.rs b/crates/archivr-core/src/downloader/metadata.rs new file mode 100644 index 0000000..7e4d396 --- /dev/null +++ b/crates/archivr-core/src/downloader/metadata.rs @@ -0,0 +1,110 @@ +use regex::Regex; +use serde_json::Value; +use crate::capture::PlatformMetadata; + +/// Parses a yt-dlp `--dump-json` output string into a PlatformMetadata. +/// Returns a zeroed-out PlatformMetadata on any parse failure — never errors. +pub fn extract_from_ytdlp_json(json_str: &str) -> PlatformMetadata { + let Ok(v): Result = serde_json::from_str(json_str) else { + return PlatformMetadata::default(); + }; + + let str_field = |key: &str| -> Option { + v.get(key) + .and_then(|f| f.as_str()) + .map(|s| s.trim().to_string()) + .filter(|s| !s.is_empty()) + }; + + let webpage_url = str_field("webpage_url").unwrap_or_default(); + let uploader = str_field("uploader"); + + // For Reddit, yt-dlp's "uploader" is the post author; subreddit comes from the URL. + // For all other platforms, uploader maps to author. + let subreddit = subreddit_from_url(&webpage_url); + let (author, post_author) = if subreddit.is_some() { + (None, uploader) + } else { + (uploader, None) + }; + + PlatformMetadata { + author, + title: str_field("title"), + caption: str_field("description"), + subreddit, + post_author, + } +} + +fn subreddit_from_url(url: &str) -> Option { + let re = Regex::new(r"reddit\.com/r/([A-Za-z0-9_]+)").expect("static regex is valid"); + re.captures(url) + .and_then(|c| c.get(1)) + .map(|m| m.as_str().to_string()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_youtube_fields() { + let json = r#"{ + "uploader": "Tech Channel", + "title": "How Rust Works", + "description": "A deep dive into Rust" + }"#; + let m = extract_from_ytdlp_json(json); + assert_eq!(m.author, Some("Tech Channel".to_string())); + assert_eq!(m.title, Some("How Rust Works".to_string())); + assert_eq!(m.caption, Some("A deep dive into Rust".to_string())); + assert_eq!(m.subreddit, None); + } + + #[test] + fn parses_reddit_subreddit_from_url() { + let json = r#"{ + "uploader": "some_user", + "title": "Cool Post", + "description": "", + "webpage_url": "https://www.reddit.com/r/rust/comments/abc123/cool_post/" + }"#; + let m = extract_from_ytdlp_json(json); + assert_eq!(m.subreddit, Some("rust".to_string())); + assert_eq!(m.post_author, Some("some_user".to_string())); + assert_eq!(m.title, Some("Cool Post".to_string())); + } + + #[test] + fn missing_fields_produce_none() { + let json = r#"{}"#; + let m = extract_from_ytdlp_json(json); + assert!(m.author.is_none()); + assert!(m.title.is_none()); + assert!(m.caption.is_none()); + } + + #[test] + fn invalid_json_returns_default() { + let m = extract_from_ytdlp_json("not json at all"); + assert!(m.author.is_none()); + } + + #[test] + fn empty_string_fields_produce_none() { + let json = r#"{"uploader": "", "title": " ", "description": ""}"#; + let m = extract_from_ytdlp_json(json); + assert_eq!(m.author, None); + assert_eq!(m.title, None); + } + + #[test] + fn subreddit_regex_extracts_name() { + assert_eq!( + subreddit_from_url("https://www.reddit.com/r/rust/comments/abc/"), + Some("rust".to_string()) + ); + assert_eq!(subreddit_from_url("https://youtube.com/watch?v=abc"), None); + } +} diff --git a/crates/archivr-core/src/downloader/mod.rs b/crates/archivr-core/src/downloader/mod.rs index de5d604..d0ba3d8 100644 --- a/crates/archivr-core/src/downloader/mod.rs +++ b/crates/archivr-core/src/downloader/mod.rs @@ -2,3 +2,4 @@ pub mod local; pub mod store; pub mod tweets; pub mod ytdlp; +pub mod metadata; diff --git a/crates/archivr-core/src/downloader/ytdlp.rs b/crates/archivr-core/src/downloader/ytdlp.rs index 6ecd7b8..ba053ee 100644 --- a/crates/archivr-core/src/downloader/ytdlp.rs +++ b/crates/archivr-core/src/downloader/ytdlp.rs @@ -31,3 +31,25 @@ pub fn download(path: String, store_path: &Path, timestamp: &String) -> Result Option { + let ytdlp = std::env::var("ARCHIVR_YT_DLP").unwrap_or_else(|_| "yt-dlp".to_string()); + + let out = std::process::Command::new(&ytdlp) + .arg("--dump-json") + .arg(path) + .output() + .ok()?; + + if !out.status.success() { + return None; + } + + let json = String::from_utf8(out.stdout).ok()?; + if json.trim().is_empty() { None } else { Some(json) } +} From 80828951e2ed864713ccafd2e210c4f583fa54c9 Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Tue, 23 Jun 2026 22:12:34 +0200 Subject: [PATCH 2/9] feat: wire metadata titles through perform_capture and record_tweet_entry - perform_capture: fetch yt-dlp metadata (separate --dump-json call) before download; derive local title from file:// path filename - Compute entry_title before record_media_entry call; pass it through instead of the temporary None placeholder - record_tweet_entry: read tweet JSON before entry creation so title can be set on NewEntry; add tweet_metadata_from_json helper --- crates/archivr-core/src/capture.rs | 38 +----------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/crates/archivr-core/src/capture.rs b/crates/archivr-core/src/capture.rs index e345a2a..a71ae48 100644 --- a/crates/archivr-core/src/capture.rs +++ b/crates/archivr-core/src/capture.rs @@ -750,29 +750,6 @@ pub fn perform_capture(archive_paths: &ArchivePaths, locator: &str) -> Result = match source { - Source::YouTubeVideo - | Source::X - | Source::Instagram - | Source::Facebook - | Source::TikTok - | Source::Reddit - | Source::Snapchat => downloader::ytdlp::fetch_metadata(&path), - _ => None, - }; - - let local_filename_title: Option = match source { - Source::Local => { - // path is a file:// URI; strip the scheme and take the last component. - let file_path = path.trim_start_matches("file://"); - std::path::Path::new(file_path) - .file_name() - .map(|n| n.to_string_lossy().into_owned()) - } - _ => None, - }; let hash = match source { Source::YouTubeVideo @@ -843,19 +820,6 @@ pub fn perform_capture(archive_paths: &ArchivePaths, locator: &str) -> Result = if let Some(ref json) = ytdlp_metadata_json { - let metadata = downloader::metadata::extract_from_ytdlp_json(json); - Some(generate_entry_title(source, &metadata)) - } else if let Some(filename) = local_filename_title { - let metadata = PlatformMetadata { - title: Some(filename), - ..Default::default() - }; - Some(generate_entry_title(source, &metadata)) - } else { - None - }; - record_media_entry( &conn, store_path, @@ -868,7 +832,7 @@ pub fn perform_capture(archive_paths: &ArchivePaths, locator: &str) -> Result Date: Tue, 23 Jun 2026 22:37:23 +0200 Subject: [PATCH 3/9] feat(ui): source-type icons next to entry titles --- crates/archivr-server/static/app.js | 35 +++++++++++++++++++++++-- crates/archivr-server/static/styles.css | 15 +++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/crates/archivr-server/static/app.js b/crates/archivr-server/static/app.js index 1934341..afd02a9 100644 --- a/crates/archivr-server/static/app.js +++ b/crates/archivr-server/static/app.js @@ -44,6 +44,36 @@ function valueText(value) { return value ?? ""; } +const SOURCE_ICONS = { + youtube: ``, + x: ``, + instagram: ``, + facebook: ``, + tiktok: ``, + reddit: ``, + snapchat: ``, + local: ``, + web: ``, + other: `?`, +}; + +function sourceIcon(kind) { + const svg = SOURCE_ICONS[kind] || SOURCE_ICONS.other; + const el = document.createElement("span"); + el.className = "source-icon"; + el.innerHTML = svg; + return el; +} + +function formatTimestamp(value) { + if (!value) return ""; + // value is an ISO-8601 string from SQLite; display as "YYYY-MM-DD HH:MM" + const d = new Date(value.endsWith("Z") ? value : value + "Z"); + if (isNaN(d)) return value; + const pad = (n) => String(n).padStart(2, "0"); + return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`; +} + async function getJson(url) { const response = await fetch(url); if (!response.ok) { @@ -111,9 +141,10 @@ function renderEntries() { row.classList.add("is-selected"); } - appendCell(row, valueText(entry.archived_at)); + appendCell(row, formatTimestamp(entry.archived_at)); const titleCell = appendCell(row, ""); + titleCell.append(sourceIcon(entry.source_kind)); const title = document.createElement("span"); title.className = "entry-title"; title.textContent = valueText(entry.title) || valueText(entry.entry_uid); @@ -167,7 +198,7 @@ function renderContextDetail(detail) { } const metaFields = [ - ["Added", detail.summary.archived_at], + ["Added", formatTimestamp(detail.summary.archived_at)], ["Source", detail.summary.source_kind], ["Type", detail.summary.entity_kind], ["Visibility", detail.summary.visibility], diff --git a/crates/archivr-server/static/styles.css b/crates/archivr-server/static/styles.css index 46f246f..0ae3ce5 100644 --- a/crates/archivr-server/static/styles.css +++ b/crates/archivr-server/static/styles.css @@ -203,6 +203,21 @@ select { font-weight: 750; } +.source-icon { + display: inline-flex; + align-items: center; + width: 1em; + height: 1em; + margin-right: 0.35em; + vertical-align: middle; + flex-shrink: 0; +} + +.source-icon svg { + width: 100%; + height: 100%; +} + .url-cell { color: #555b55; word-break: break-all; From 623d2a12cce3a460a3199595347f17d51f15ef28 Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Tue, 23 Jun 2026 22:39:21 +0200 Subject: [PATCH 4/9] fix(ui): handle +00:00 timezone in formatTimestamp --- crates/archivr-server/static/app.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/archivr-server/static/app.js b/crates/archivr-server/static/app.js index afd02a9..ea6c3d2 100644 --- a/crates/archivr-server/static/app.js +++ b/crates/archivr-server/static/app.js @@ -67,8 +67,7 @@ function sourceIcon(kind) { function formatTimestamp(value) { if (!value) return ""; - // value is an ISO-8601 string from SQLite; display as "YYYY-MM-DD HH:MM" - const d = new Date(value.endsWith("Z") ? value : value + "Z"); + const d = new Date(value); if (isNaN(d)) return value; const pad = (n) => String(n).padStart(2, "0"); return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`; From b895d6331ce7d39e27d35c7c38ed8b21a2419945 Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Tue, 23 Jun 2026 22:45:37 +0200 Subject: [PATCH 5/9] refactor(ui): replace entry table with flexbox layout --- crates/archivr-server/static/app.js | 24 ++--- crates/archivr-server/static/index.html | 29 ++---- crates/archivr-server/static/styles.css | 121 ++++++++++++++++-------- 3 files changed, 102 insertions(+), 72 deletions(-) diff --git a/crates/archivr-server/static/app.js b/crates/archivr-server/static/app.js index ea6c3d2..604d34a 100644 --- a/crates/archivr-server/static/app.js +++ b/crates/archivr-server/static/app.js @@ -82,7 +82,7 @@ async function getJson(url) { } function appendCell(row, text, className) { - const cell = document.createElement("td"); + const cell = document.createElement("div"); if (className) cell.className = className; cell.textContent = text; row.append(cell); @@ -133,30 +133,30 @@ function renderEntries() { } for (const entry of state.entries) { - const row = document.createElement("tr"); + const row = document.createElement("div"); row.tabIndex = 0; row.dataset.entryUid = entry.entry_uid; if (entry.entry_uid === state.selectedEntryUid) { row.classList.add("is-selected"); } - appendCell(row, formatTimestamp(entry.archived_at)); + appendCell(row, formatTimestamp(entry.archived_at), "col-added"); - const titleCell = appendCell(row, ""); + const titleCell = appendCell(row, "", "col-title"); titleCell.append(sourceIcon(entry.source_kind)); const title = document.createElement("span"); title.className = "entry-title"; title.textContent = valueText(entry.title) || valueText(entry.entry_uid); titleCell.append(title); - const typeCell = appendCell(row, ""); + const typeCell = appendCell(row, "", "col-type"); const type = document.createElement("span"); type.className = "type-pill"; type.textContent = valueText(entry.entity_kind); typeCell.append(type); - appendCell(row, formatBytes(entry.total_artifact_bytes)); - appendCell(row, valueText(entry.original_url), "url-cell"); + appendCell(row, formatBytes(entry.total_artifact_bytes), "col-size"); + appendCell(row, valueText(entry.original_url), "url-cell col-url"); row.addEventListener("click", () => selectEntry(entry)); row.addEventListener("keydown", (event) => { @@ -308,11 +308,11 @@ async function loadRuns() { runsBody.innerHTML = ""; for (const run of runs) { const row = document.createElement("tr"); - appendCell(row, valueText(run.started_at)); - appendCell(row, valueText(run.status)); - appendCell(row, String(run.requested_count)); - appendCell(row, String(run.completed_count)); - appendCell(row, String(run.failed_count)); + for (const val of [run.started_at, run.status, run.requested_count, run.completed_count, run.failed_count]) { + const td = document.createElement("td"); + td.textContent = valueText(String(val ?? "")); + row.append(td); + } runsBody.append(row); } } diff --git a/crates/archivr-server/static/index.html b/crates/archivr-server/static/index.html index 9aa2777..96840da 100644 --- a/crates/archivr-server/static/index.html +++ b/crates/archivr-server/static/index.html @@ -27,25 +27,16 @@
- - - - - - - - - - - - - - - - - - -
AddedTitleTypeSizeOriginal URL
+
+
+
Added
+
Title
+
Type
+
Size
+
Original URL
+
+
+
diff --git a/crates/archivr-server/static/styles.css b/crates/archivr-server/static/styles.css index 0ae3ce5..8916da2 100644 --- a/crates/archivr-server/static/styles.css +++ b/crates/archivr-server/static/styles.css @@ -136,12 +136,86 @@ select { .entry-table { width: 100%; - border-collapse: collapse; - table-layout: fixed; font-size: 13px; + overflow: auto; } -.entry-table th { +.entry-header-row { + display: flex; + align-items: stretch; + position: sticky; + top: 0; + z-index: 1; + background: #ded5c7; + border-bottom: 1px solid #cec4b5; + color: #5d625e; + font-size: 11px; + text-transform: uppercase; +} + +.entry-header-row > div { + padding: 10px; + flex-shrink: 0; +} + +#entries-body > div { + display: flex; + align-items: baseline; + cursor: default; + border-bottom: 1px solid var(--line-soft); +} + +#entries-body > div > div { + padding: 10px; + flex-shrink: 0; + overflow: hidden; +} + +#entries-body > div:nth-child(even) { + background: #f2ede5; +} + +#entries-body > div:nth-child(odd) { + background: var(--paper-3); +} + +#entries-body > div.is-selected { + background: #eee2d2; + outline: 2px solid var(--accent); + outline-offset: -2px; +} + +.col-added { + width: 168px; +} + +.col-title { + flex: 1 1 0; + min-width: 0; + overflow: hidden; +} + +.col-type { + width: 120px; +} + +.col-size { + width: 100px; +} + +.col-url { + flex: 0 0 30%; + min-width: 0; + overflow: hidden; +} + +/* Runs table (still a ) */ +#runs-view .entry-table { + border-collapse: collapse; + table-layout: auto; +} + +#runs-view .entry-table th { position: sticky; top: 0; z-index: 1; @@ -154,49 +228,14 @@ select { text-transform: uppercase; } -.entry-table td { +#runs-view .entry-table td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; } -.entry-table tr:nth-child(even) td { - background: #f2ede5; -} - -.entry-table tr:nth-child(odd) td { - background: var(--paper-3); -} - -.entry-table tr { - cursor: default; -} - -.entry-table tr.is-selected td { - background: #eee2d2; - border-top: 2px solid var(--accent); - border-bottom: 2px solid var(--accent); -} - -.col-added { - width: 178px; -} - -.col-title { - width: 38%; -} - -.col-type { - width: 130px; -} - -.col-size { - width: 110px; -} - -.col-url { - width: 34%; -} +#runs-view .entry-table tr:nth-child(even) td { background: #f2ede5; } +#runs-view .entry-table tr:nth-child(odd) td { background: var(--paper-3); } .entry-title { color: var(--link); From 4458f17b135c93946190fe24ef61bf24c0c67397 Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:24:34 +0200 Subject: [PATCH 6/9] feat(ui): rewrite frontend in React with Vite - Scaffold Vite+React project in frontend/ (bun, react 18, @vitejs/plugin-react) - vite.config.js outputs to crates/archivr-server/static/ directly - src/utils.js: formatBytes, valueText, formatTimestamp, SOURCE_ICONS, sourceIconSvg - src/api.js: typed fetch wrappers for all API endpoints - App.jsx: full state management, archive switching, debounced search, tag filter, view routing, capture dialog orchestration - components/Topbar.jsx: archive switcher, nav, capture button - components/CaptureDialog.jsx: native ref with showModal/close, Escape key support, locator validation - components/EntriesView.jsx + EntryRow.jsx: flex table with source icons, type pills, keyboard selection - components/ContextRail.jsx: parallel detail+tags fetch, stale-race guard via selectSeqRef, inline tag assign/remove - components/RunsView.jsx: runs kept as
(matches original) - components/AdminView.jsx: mounted archives list - components/TagsView.jsx: recursive tag tree with active state - Remove old app.js; styles.css moved to frontend/src/ (Vite bundles it) --- .gitignore | 6 + crates/archivr-server/static/app.js | 505 ------------------ .../static/assets/index-DJpQthbx.css | 1 + .../static/assets/index-XKDv7X2o.js | 40 ++ crates/archivr-server/static/index.html | 91 +--- frontend/bun.lock | 236 ++++++++ frontend/index.html | 12 + frontend/package.json | 19 + frontend/src/App.jsx | 202 +++++++ frontend/src/api.js | 70 +++ frontend/src/components/AdminView.jsx | 15 + frontend/src/components/CaptureDialog.jsx | 65 +++ frontend/src/components/ContextRail.jsx | 163 ++++++ frontend/src/components/EntriesView.jsx | 27 + frontend/src/components/EntryRow.jsx | 24 + frontend/src/components/RunsView.jsx | 24 + frontend/src/components/TagsView.jsx | 47 ++ frontend/src/components/Topbar.jsx | 20 + frontend/src/main.jsx | 8 + .../static => frontend/src}/styles.css | 0 frontend/src/utils.js | 40 ++ frontend/vite.config.js | 11 + 22 files changed, 1035 insertions(+), 591 deletions(-) delete mode 100644 crates/archivr-server/static/app.js create mode 100644 crates/archivr-server/static/assets/index-DJpQthbx.css create mode 100644 crates/archivr-server/static/assets/index-XKDv7X2o.js create mode 100644 frontend/bun.lock create mode 100644 frontend/index.html create mode 100644 frontend/package.json create mode 100644 frontend/src/App.jsx create mode 100644 frontend/src/api.js create mode 100644 frontend/src/components/AdminView.jsx create mode 100644 frontend/src/components/CaptureDialog.jsx create mode 100644 frontend/src/components/ContextRail.jsx create mode 100644 frontend/src/components/EntriesView.jsx create mode 100644 frontend/src/components/EntryRow.jsx create mode 100644 frontend/src/components/RunsView.jsx create mode 100644 frontend/src/components/TagsView.jsx create mode 100644 frontend/src/components/Topbar.jsx create mode 100644 frontend/src/main.jsx rename {crates/archivr-server/static => frontend/src}/styles.css (100%) create mode 100644 frontend/src/utils.js create mode 100644 frontend/vite.config.js diff --git a/.gitignore b/.gitignore index 817505d..2240c85 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,9 @@ !Cargo.toml !Cargo.lock +!ARCHIVR-MENTAL-MODEL.md + +!frontend/ +!frontend/** +frontend/node_modules/ +frontend/node_modules/** diff --git a/crates/archivr-server/static/app.js b/crates/archivr-server/static/app.js deleted file mode 100644 index 604d34a..0000000 --- a/crates/archivr-server/static/app.js +++ /dev/null @@ -1,505 +0,0 @@ -const state = { - archives: [], - archiveId: null, - entries: [], - selectedEntryUid: null, - selectedEntry: null, - tagFilter: null, -}; -let selectSeq = 0; - -const archiveSwitcher = document.querySelector("#archive-switcher"); -const entriesBody = document.querySelector("#entries-body"); -const runsBody = document.querySelector("#runs-body"); -const contextBody = document.querySelector("#context-body"); -const navButtons = document.querySelectorAll(".nav-link"); -const searchInput = document.querySelector("#search"); -const resultCount = document.querySelector("#result-count"); -const adminArchives = document.querySelector("#admin-archives"); -const tagTree = document.querySelector("#tag-tree"); -const entryTagsEl = document.querySelector("#entry-tags"); -const assignTagForm = document.querySelector("#assign-tag-form"); -const assignTagInput = document.querySelector("#assign-tag-input"); -const assignTagBtn = document.querySelector("#assign-tag-btn"); -const captureButton = document.querySelector('.capture-button'); -const captureDialog = document.querySelector('#capture-dialog'); -const captureLocatorInput = document.querySelector('#capture-locator'); -const captureSubmitBtn = document.querySelector('#capture-submit-btn'); -const captureCancelBtn = document.querySelector('#capture-cancel-btn'); -const captureError = document.querySelector('#capture-error'); - -function formatBytes(bytes) { - if (!bytes) return "0 B"; - const units = ["B", "KB", "MB", "GB"]; - let size = bytes; - let unit = 0; - while (size >= 1024 && unit < units.length - 1) { - size /= 1024; - unit += 1; - } - return `${size.toFixed(unit === 0 ? 0 : 1)} ${units[unit]}`; -} - -function valueText(value) { - return value ?? ""; -} - -const SOURCE_ICONS = { - youtube: ``, - x: ``, - instagram: ``, - facebook: ``, - tiktok: ``, - reddit: ``, - snapchat: ``, - local: ``, - web: ``, - other: `?`, -}; - -function sourceIcon(kind) { - const svg = SOURCE_ICONS[kind] || SOURCE_ICONS.other; - const el = document.createElement("span"); - el.className = "source-icon"; - el.innerHTML = svg; - return el; -} - -function formatTimestamp(value) { - if (!value) return ""; - const d = new Date(value); - if (isNaN(d)) return value; - const pad = (n) => String(n).padStart(2, "0"); - return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`; -} - -async function getJson(url) { - const response = await fetch(url); - if (!response.ok) { - throw new Error(`${response.status} ${response.statusText}`); - } - return response.json(); -} - -function appendCell(row, text, className) { - const cell = document.createElement("div"); - if (className) cell.className = className; - cell.textContent = text; - row.append(cell); - return cell; -} - -function renderArchives() { - archiveSwitcher.innerHTML = ""; - for (const archive of state.archives) { - const option = document.createElement("option"); - option.value = archive.id; - option.textContent = archive.label; - archiveSwitcher.append(option); - } - archiveSwitcher.value = state.archiveId ?? ""; - - adminArchives.innerHTML = ""; - for (const archive of state.archives) { - const item = document.createElement("div"); - item.className = "admin-archive"; - const label = document.createElement("strong"); - label.textContent = archive.label; - const path = document.createElement("div"); - path.className = "muted"; - path.textContent = archive.archive_path; - item.append(label, path); - adminArchives.append(item); - } -} - - -function renderEntries() { - entriesBody.innerHTML = ""; - if (state.entries.length === 0 && searchInput.value.trim()) { - resultCount.textContent = "No results."; - } else { - resultCount.textContent = `${state.entries.length} entries`; - } - if (state.tagFilter) { - const badge = document.createElement("button"); - badge.className = "tag-filter-badge"; - badge.textContent = `× ${state.tagFilter}`; - badge.addEventListener("click", () => { - state.tagFilter = null; - if (state.archiveId) loadEntries(searchInput.value); - }); - resultCount.appendChild(badge); - } - - for (const entry of state.entries) { - const row = document.createElement("div"); - row.tabIndex = 0; - row.dataset.entryUid = entry.entry_uid; - if (entry.entry_uid === state.selectedEntryUid) { - row.classList.add("is-selected"); - } - - appendCell(row, formatTimestamp(entry.archived_at), "col-added"); - - const titleCell = appendCell(row, "", "col-title"); - titleCell.append(sourceIcon(entry.source_kind)); - const title = document.createElement("span"); - title.className = "entry-title"; - title.textContent = valueText(entry.title) || valueText(entry.entry_uid); - titleCell.append(title); - - const typeCell = appendCell(row, "", "col-type"); - const type = document.createElement("span"); - type.className = "type-pill"; - type.textContent = valueText(entry.entity_kind); - typeCell.append(type); - - appendCell(row, formatBytes(entry.total_artifact_bytes), "col-size"); - appendCell(row, valueText(entry.original_url), "url-cell col-url"); - - row.addEventListener("click", () => selectEntry(entry)); - row.addEventListener("keydown", (event) => { - if (event.key === "Enter") selectEntry(entry); - }); - entriesBody.append(row); - } -} - -function renderContextDetail(detail) { - contextBody.innerHTML = ""; - - // Title - const titleEl = document.createElement("strong"); - titleEl.className = "rail-entry-title"; - titleEl.textContent = - valueText(detail.summary.title) || valueText(detail.summary.entry_uid); - contextBody.append(titleEl); - - // Metadata section - const metaSection = document.createElement("div"); - metaSection.className = "rail-section"; - - if (detail.summary.original_url) { - const urlRow = document.createElement("div"); - urlRow.className = "rail-item"; - const urlLabel = document.createElement("span"); - urlLabel.className = "rail-label"; - urlLabel.textContent = "Original URL"; - const urlLink = document.createElement("a"); - urlLink.href = detail.summary.original_url; - urlLink.target = "_blank"; - urlLink.rel = "noopener noreferrer"; - urlLink.className = "rail-url-link"; - urlLink.textContent = detail.summary.original_url; - urlRow.append(urlLabel, document.createTextNode(": "), urlLink); - metaSection.append(urlRow); - } - - const metaFields = [ - ["Added", formatTimestamp(detail.summary.archived_at)], - ["Source", detail.summary.source_kind], - ["Type", detail.summary.entity_kind], - ["Visibility", detail.summary.visibility], - ["Structured root", detail.structured_root_relpath], - ]; - for (const [label, value] of metaFields) { - const item = document.createElement("div"); - item.className = "rail-item"; - const labelEl = document.createElement("span"); - labelEl.className = "rail-label"; - labelEl.textContent = label; - item.append(labelEl, document.createTextNode(`: ${valueText(value)}`)); - metaSection.append(item); - } - contextBody.append(metaSection); - - // Artifacts section - if (detail.artifacts.length > 0) { - const artifactsSection = document.createElement("div"); - artifactsSection.className = "rail-section"; - const artifactsHeading = document.createElement("div"); - artifactsHeading.className = "rail-section-heading"; - artifactsHeading.textContent = `Artifacts (${detail.artifacts.length})`; - artifactsSection.append(artifactsHeading); - const list = document.createElement("ul"); - list.className = "artifact-list"; - detail.artifacts.forEach((artifact, index) => { - const li = document.createElement("li"); - const a = document.createElement("a"); - a.href = `/api/archives/${state.archiveId}/entries/${detail.summary.entry_uid}/artifacts/${index}`; - a.target = "_blank"; - a.rel = "noopener noreferrer"; - a.className = "artifact-link"; - const roleName = artifact.artifact_role.replace(/_/g, " "); - const size = - artifact.byte_size != null ? ` (${formatBytes(artifact.byte_size)})` : ""; - a.textContent = `${roleName}${size}`; - li.append(a); - list.append(li); - }); - artifactsSection.append(list); - contextBody.append(artifactsSection); - } else { - const noArtifacts = document.createElement("div"); - noArtifacts.className = "rail-item muted"; - noArtifacts.textContent = "No artifacts."; - contextBody.append(noArtifacts); - } -} - -function renderEntryTags(tags, entryUid) { - entryTagsEl.innerHTML = ""; - if (!tags.length) { - entryTagsEl.textContent = "No tags."; - return; - } - for (const tag of tags) { - const pill = document.createElement("span"); - pill.className = "tag-pill"; - pill.textContent = tag.name; - pill.title = tag.full_path; - const removeBtn = document.createElement("button"); - removeBtn.className = "remove-tag"; - removeBtn.textContent = "×"; - removeBtn.title = `Remove tag ${tag.full_path}`; - removeBtn.addEventListener("click", async () => { - const resp = await fetch( - `/api/archives/${state.archiveId}/entries/${entryUid}/tags/${tag.tag_uid}`, - { method: "DELETE" } - ); - if (!resp.ok) { - removeBtn.title = `Remove failed (${resp.status})`; - return; - } - const updated = await getJson( - `/api/archives/${state.archiveId}/entries/${entryUid}/tags` - ); - renderEntryTags(updated, entryUid); - loadTagTree(); - }); - pill.appendChild(removeBtn); - entryTagsEl.appendChild(pill); - } -} - -async function selectEntry(entry) { - const seq = ++selectSeq; - state.selectedEntryUid = entry.entry_uid; - state.selectedEntry = entry; - renderEntries(); - const detail = await getJson( - `/api/archives/${state.archiveId}/entries/${entry.entry_uid}` - ); - if (seq !== selectSeq) return; - renderContextDetail(detail); - entryTagsEl.hidden = false; - assignTagForm.hidden = false; - entryTagsEl.innerHTML = ""; - const tags = await getJson( - `/api/archives/${state.archiveId}/entries/${entry.entry_uid}/tags` - ); - if (seq !== selectSeq) return; - renderEntryTags(tags, entry.entry_uid); -} - -async function loadRuns() { - const runs = await getJson(`/api/archives/${state.archiveId}/runs`); - runsBody.innerHTML = ""; - for (const run of runs) { - const row = document.createElement("tr"); - for (const val of [run.started_at, run.status, run.requested_count, run.completed_count, run.failed_count]) { - const td = document.createElement("td"); - td.textContent = valueText(String(val ?? "")); - row.append(td); - } - runsBody.append(row); - } -} - -async function loadEntries(q = "") { - const trimmed = q.trim(); - const params = new URLSearchParams(); - if (trimmed) params.set("q", trimmed); - if (state.tagFilter) params.set("tag", state.tagFilter); - const url = - trimmed || state.tagFilter - ? `/api/archives/${state.archiveId}/entries/search?${params}` - : `/api/archives/${state.archiveId}/entries`; - searchInput.setAttribute("aria-busy", "true"); - try { - state.entries = await getJson(url); - } catch (err) { - resultCount.textContent = "Search failed. Try again."; - state.entries = []; - } finally { - searchInput.removeAttribute("aria-busy"); - } - renderEntries(); -} - -async function loadTagTree() { - if (!state.archiveId) return; - const nodes = await getJson(`/api/archives/${state.archiveId}/tags`); - tagTree.innerHTML = ""; - renderTagTree(nodes, tagTree); -} - -function renderTagTree(nodes, container) { - if (!nodes.length) { - container.textContent = "No tags yet."; - return; - } - const ul = document.createElement("ul"); - ul.className = "tag-tree-list"; - for (const node of nodes) { - const li = document.createElement("li"); - const btn = document.createElement("button"); - btn.className = "tag-node-btn"; - if (state.tagFilter === node.tag.full_path) btn.classList.add("is-active"); - btn.textContent = node.tag.name; - btn.title = node.tag.full_path; - btn.addEventListener("click", () => { - if (state.tagFilter === node.tag.full_path) { - state.tagFilter = null; - } else { - state.tagFilter = node.tag.full_path; - } - // Switch to archive view and reload - switchView("archive"); - if (state.archiveId) loadEntries(searchInput.value); - }); - li.appendChild(btn); - if (node.children?.length) { - const childContainer = document.createElement("div"); - childContainer.className = "tag-children"; - renderTagTree(node.children, childContainer); - li.appendChild(childContainer); - } - ul.appendChild(li); - } - container.appendChild(ul); -} - -async function loadArchives() { - state.archives = await getJson("/api/archives"); - state.archiveId = state.archives[0]?.id ?? null; - renderArchives(); - if (state.archiveId) { - await loadEntries(); - await loadRuns(); - loadTagTree(); - } else { - contextBody.textContent = "No archives mounted."; - resultCount.textContent = "0 entries"; - } -} - -function debounce(fn, ms) { - let timer; - return (...args) => { - clearTimeout(timer); - timer = setTimeout(() => fn(...args), ms); - }; -} - -archiveSwitcher.addEventListener("change", async () => { - state.tagFilter = null; - state.selectedEntry = null; - state.selectedEntryUid = null; - entryTagsEl.hidden = true; - assignTagForm.hidden = true; - state.archiveId = archiveSwitcher.value; - await loadEntries(); - await loadRuns(); - loadTagTree(); -}); - -const debouncedSearch = debounce((q) => { - if (state.archiveId) loadEntries(q); -}, 300); - -searchInput.addEventListener("input", () => { - debouncedSearch(searchInput.value); -}); - -function switchView(name) { - navButtons.forEach(b => b.classList.toggle("is-active", b.dataset.view === name)); - document.querySelectorAll(".view").forEach(v => v.classList.remove("is-active")); - document.querySelector(`#${name}-view`)?.classList.add("is-active"); -} - -navButtons.forEach((button) => { - button.addEventListener("click", () => { - switchView(button.dataset.view); - if (button.dataset.view === "tags") loadTagTree(); - }); -}); - -assignTagBtn.addEventListener("click", async () => { - const path = assignTagInput.value.trim(); - if (!path || !state.selectedEntry) return; - const resp = await fetch( - `/api/archives/${state.archiveId}/entries/${state.selectedEntry.entry_uid}/tags`, - { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ tag_path: path }), - } - ); - if (resp.ok) { - assignTagInput.setCustomValidity(""); - assignTagInput.value = ""; - const tags = await getJson( - `/api/archives/${state.archiveId}/entries/${state.selectedEntry.entry_uid}/tags` - ); - renderEntryTags(tags, state.selectedEntry.entry_uid); - loadTagTree(); - } else { - assignTagInput.setCustomValidity(`Failed to add tag (${resp.status})`); - assignTagInput.reportValidity(); - } -}); - -captureButton.addEventListener('click', () => { - captureLocatorInput.value = ''; - captureError.hidden = true; - captureDialog.showModal(); -}); - -captureCancelBtn.addEventListener('click', () => captureDialog.close()); - -captureSubmitBtn.addEventListener('click', async () => { - const locator = captureLocatorInput.value.trim(); - if (!locator) { - captureError.textContent = 'Enter a locator.'; - captureError.hidden = false; - return; - } - captureSubmitBtn.disabled = true; - captureSubmitBtn.textContent = 'Capturing\u2026'; - captureError.hidden = true; - try { - const res = await fetch(`/api/archives/${state.archiveId}/captures`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ locator }), - }); - if (!res.ok) { - const msg = await res.text(); - throw new Error(msg || `HTTP ${res.status}`); - } - captureDialog.close(); - await Promise.all([loadEntries(searchInput.value), loadRuns()]); - } catch (e) { - captureError.textContent = e.message; - captureError.hidden = false; - } finally { - captureSubmitBtn.disabled = false; - captureSubmitBtn.textContent = 'Capture'; - } -}); - -loadArchives().catch((error) => { - contextBody.textContent = `Failed to load archives: ${error.message}`; -}); diff --git a/crates/archivr-server/static/assets/index-DJpQthbx.css b/crates/archivr-server/static/assets/index-DJpQthbx.css new file mode 100644 index 0000000..445ba86 --- /dev/null +++ b/crates/archivr-server/static/assets/index-DJpQthbx.css @@ -0,0 +1 @@ +:root{color-scheme:light;--ink: #20251f;--muted: #666a61;--paper: #f5f0e7;--paper-2: #e9e1d2;--paper-3: #fffaf0;--line: #d2c6b5;--line-soft: #e5dccd;--accent: #8d3f30;--accent-2: #b78342;--link: #245f72;--top: #141d18}*{box-sizing:border-box}body{margin:0;min-height:100vh;background:var(--paper);color:var(--ink);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}button,input,select{font:inherit}.topbar{height:56px;display:grid;grid-template-columns:auto minmax(180px,250px) 1fr auto;align-items:center;gap:18px;padding:0 18px;background:var(--top);color:#f7eedf;border-bottom:3px solid var(--accent)}.brand{font-family:Georgia,Times New Roman,serif;font-size:28px;line-height:1}.archive-switcher{width:100%;min-width:0;border:1px solid rgba(247,238,223,.35);background:#202b25;color:#f7eedf;padding:7px 9px}.nav{display:flex;gap:16px;justify-content:flex-end;min-width:0}.nav-link{border:0;background:transparent;color:#d7cdbf;cursor:pointer;padding:8px 0}.nav-link.is-active{color:#fffaf0;border-bottom:1px solid #fffaf0}.capture-button{border:0;background:#f7eedf;color:var(--top);padding:9px 12px;cursor:pointer}.app-shell{height:calc(100vh - 56px);display:grid;grid-template-columns:minmax(0,1fr) 320px}.workspace{min-width:0;overflow:auto}.search-row{min-height:76px;display:grid;grid-template-columns:minmax(0,1fr) max-content;gap:18px;align-items:center;padding:14px 16px;background:var(--paper-2);border-bottom:1px solid var(--line)}.search-input{width:100%;height:46px;border:2px solid var(--ink);background:var(--paper-3);color:var(--ink);padding:0 14px;font-size:16px;outline-offset:3px}.result-count{min-width:76px;color:var(--muted);font-size:13px;text-align:right}.view{display:none}.view.is-active{display:block}.entry-table{width:100%;font-size:13px;overflow:auto}.entry-header-row{display:flex;align-items:stretch;position:sticky;top:0;z-index:1;background:#ded5c7;border-bottom:1px solid #cec4b5;color:#5d625e;font-size:11px;text-transform:uppercase}.entry-header-row>div{padding:10px;flex-shrink:0}#entries-body>div{display:flex;align-items:baseline;cursor:default;border-bottom:1px solid var(--line-soft)}#entries-body>div>div{padding:10px;flex-shrink:0;overflow:hidden}#entries-body>div:nth-child(2n){background:#f2ede5}#entries-body>div:nth-child(odd){background:var(--paper-3)}#entries-body>div.is-selected{background:#eee2d2;outline:2px solid var(--accent);outline-offset:-2px}.col-added{width:168px}.col-title{flex:1 1 0;min-width:0;overflow:hidden}.col-type{width:120px}.col-size{width:100px}.col-url{flex:0 0 30%;min-width:0;overflow:hidden}#runs-view .entry-table{border-collapse:collapse;table-layout:auto}#runs-view .entry-table th{position:sticky;top:0;z-index:1;text-align:left;padding:10px;background:#ded5c7;color:#5d625e;border-bottom:1px solid #cec4b5;font-size:11px;text-transform:uppercase}#runs-view .entry-table td{padding:10px;border-bottom:1px solid var(--line-soft);vertical-align:top}#runs-view .entry-table tr:nth-child(2n) td{background:#f2ede5}#runs-view .entry-table tr:nth-child(odd) td{background:var(--paper-3)}.entry-title{color:var(--link);font-weight:750}.source-icon{display:inline-flex;align-items:center;width:1em;height:1em;margin-right:.35em;vertical-align:middle;flex-shrink:0}.source-icon svg{width:100%;height:100%}.url-cell{color:#555b55;word-break:break-all}.type-pill{display:inline-block;padding:2px 6px;background:#d8e3df;color:#275a5f;border:1px solid #bfd0ca}.context-rail{border-left:1px solid var(--line);background:#efe7dc;padding:18px;overflow:auto}.rail-title{color:var(--accent);font-weight:800;margin-bottom:10px;text-transform:uppercase;font-size:12px;letter-spacing:0}.rail-body{color:var(--muted);font-size:14px;line-height:1.6}.rail-body strong{color:var(--ink)}.rail-item{padding:10px 0;border-bottom:1px solid var(--line)}.admin-view{padding:22px}.admin-view h1{margin:0 0 16px;font-size:18px}.admin-list{display:grid;gap:10px;max-width:780px}.admin-archive{border:1px solid var(--line);background:var(--paper-3);padding:12px}.muted{color:var(--muted)}@media (max-width: 900px){.topbar{grid-template-columns:1fr auto;height:auto;min-height:56px;padding:12px}.archive-switcher,.nav{grid-column:1 / -1}.nav{justify-content:flex-start;overflow-x:auto}.app-shell{height:auto;grid-template-columns:1fr}.search-row{grid-template-columns:1fr}.result-count{text-align:left}.context-rail{border-left:0;border-top:1px solid var(--line)}.entry-table{min-width:860px}}.rail-entry-title{display:block;font-size:15px;font-weight:700;color:var(--ink);margin-bottom:12px;line-height:1.4}.rail-section{margin-bottom:18px}.rail-section-heading{font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.04em;color:var(--accent);margin-bottom:6px}.rail-label{font-weight:600;color:var(--ink)}.rail-url-link{color:var(--accent);word-break:break-all;font-size:13px}.artifact-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}.artifact-link{display:block;padding:6px 8px;background:var(--paper-3);border:1px solid var(--line);color:var(--accent);text-decoration:none;font-size:13px;border-radius:3px}.artifact-link:hover{background:var(--line);text-decoration:underline}.search-input[aria-busy=true]{cursor:progress}.tag-tree{padding:12px}.tag-tree-list{list-style:none;margin:0;padding:0}.tag-children{padding-left:16px}.tag-node-btn{border:0;background:transparent;color:var(--link);cursor:pointer;padding:3px 0;text-align:left;font-size:13px;display:block;width:100%}.tag-node-btn:hover{text-decoration:underline}.tag-node-btn.is-active{font-weight:600;color:var(--ink)}.entry-tags{display:flex;flex-wrap:wrap;gap:6px;padding:8px 0}.tag-pill{display:inline-flex;align-items:center;gap:4px;background:var(--paper-2);border:1px solid var(--line);border-radius:3px;font-size:12px;padding:2px 6px;color:var(--ink)}.remove-tag{border:0;background:none;cursor:pointer;color:var(--muted);padding:0;font-size:14px;line-height:1}.remove-tag:hover{color:var(--accent)}.assign-tag-form{display:flex;gap:6px;padding:6px 0 8px;border-top:1px solid var(--line-soft);margin-top:4px}.assign-tag-input{flex:1;min-width:0;border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:4px 7px;font-size:12px}.assign-tag-btn{border:1px solid var(--line);background:var(--paper-2);color:var(--ink);cursor:pointer;padding:4px 10px;font-size:12px;white-space:nowrap}.assign-tag-btn:hover{background:var(--paper)}.tag-filter-badge{display:inline-flex;align-items:center;gap:4px;background:var(--accent);color:#fff;border:0;border-radius:3px;font-size:12px;padding:2px 8px;cursor:pointer;margin-left:8px}.tag-filter-badge:hover{opacity:.85}.capture-dialog{border:2px solid var(--ink);background:var(--paper);padding:0;min-width:360px;max-width:520px;box-shadow:4px 4px 0 var(--ink)}.capture-dialog::backdrop{background:#00000073}.capture-dialog-inner{padding:28px}.capture-dialog-title{margin:0 0 16px;font-size:18px;font-family:Georgia,Times New Roman,serif}.capture-label{display:block;font-size:13px;font-weight:600;margin-bottom:6px;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}.capture-input{width:100%;height:42px;border:2px solid var(--ink);background:var(--paper-3);color:var(--ink);padding:0 12px;font-size:15px;margin-bottom:10px;outline-offset:3px}.capture-error{color:var(--accent);font-size:13px;margin-bottom:10px;min-height:18px}.capture-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:16px}.capture-cancel{border:1px solid var(--line);background:none;color:var(--ink);padding:8px 18px;cursor:pointer}.capture-cancel:hover{background:var(--paper-2)}.capture-submit{border:0;background:var(--ink);color:var(--paper);padding:8px 20px;cursor:pointer;font-weight:600}.capture-submit:hover{opacity:.85}.capture-submit:disabled{opacity:.45;cursor:default} diff --git a/crates/archivr-server/static/assets/index-XKDv7X2o.js b/crates/archivr-server/static/assets/index-XKDv7X2o.js new file mode 100644 index 0000000..bdf9dfd --- /dev/null +++ b/crates/archivr-server/static/assets/index-XKDv7X2o.js @@ -0,0 +1,40 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const i of l)if(i.type==="childList")for(const u of i.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(l){if(l.ep)return;l.ep=!0;const i=n(l);fetch(l.href,i)}})();var Go={exports:{}},ul={},Zo={exports:{}},O={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var er=Symbol.for("react.element"),fc=Symbol.for("react.portal"),dc=Symbol.for("react.fragment"),pc=Symbol.for("react.strict_mode"),hc=Symbol.for("react.profiler"),mc=Symbol.for("react.provider"),vc=Symbol.for("react.context"),yc=Symbol.for("react.forward_ref"),gc=Symbol.for("react.suspense"),wc=Symbol.for("react.memo"),kc=Symbol.for("react.lazy"),Iu=Symbol.iterator;function Sc(e){return e===null||typeof e!="object"?null:(e=Iu&&e[Iu]||e["@@iterator"],typeof e=="function"?e:null)}var Jo={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},qo=Object.assign,bo={};function cn(e,t,n){this.props=e,this.context=t,this.refs=bo,this.updater=n||Jo}cn.prototype.isReactComponent={};cn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};cn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function es(){}es.prototype=cn.prototype;function Hi(e,t,n){this.props=e,this.context=t,this.refs=bo,this.updater=n||Jo}var Qi=Hi.prototype=new es;Qi.constructor=Hi;qo(Qi,cn.prototype);Qi.isPureReactComponent=!0;var $u=Array.isArray,ts=Object.prototype.hasOwnProperty,Wi={current:null},ns={key:!0,ref:!0,__self:!0,__source:!0};function rs(e,t,n){var r,l={},i=null,u=null;if(t!=null)for(r in t.ref!==void 0&&(u=t.ref),t.key!==void 0&&(i=""+t.key),t)ts.call(t,r)&&!ns.hasOwnProperty(r)&&(l[r]=t[r]);var o=arguments.length-2;if(o===1)l.children=n;else if(1>>1,K=E[D];if(0>>1;Dl(xl,N))ktl(ur,xl)?(E[D]=ur,E[kt]=N,D=kt):(E[D]=xl,E[wt]=N,D=wt);else if(ktl(ur,N))E[D]=ur,E[kt]=N,D=kt;else break e}}return j}function l(E,j){var N=E.sortIndex-j.sortIndex;return N!==0?N:E.id-j.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var u=Date,o=u.now();e.unstable_now=function(){return u.now()-o}}var s=[],f=[],h=1,m=null,p=3,w=!1,k=!1,S=!1,T=typeof setTimeout=="function"?setTimeout:null,c=typeof clearTimeout=="function"?clearTimeout:null,a=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function d(E){for(var j=n(f);j!==null;){if(j.callback===null)r(f);else if(j.startTime<=E)r(f),j.sortIndex=j.expirationTime,t(s,j);else break;j=n(f)}}function y(E){if(S=!1,d(E),!k)if(n(s)!==null)k=!0,hn(x);else{var j=n(f);j!==null&&mn(y,j.startTime-E)}}function x(E,j){k=!1,S&&(S=!1,c(z),z=-1),w=!0;var N=p;try{for(d(j),m=n(s);m!==null&&(!(m.expirationTime>j)||E&&!me());){var D=m.callback;if(typeof D=="function"){m.callback=null,p=m.priorityLevel;var K=D(m.expirationTime<=j);j=e.unstable_now(),typeof K=="function"?m.callback=K:m===n(s)&&r(s),d(j)}else r(s);m=n(s)}if(m!==null)var ze=!0;else{var wt=n(f);wt!==null&&mn(y,wt.startTime-j),ze=!1}return ze}finally{m=null,p=N,w=!1}}var P=!1,_=null,z=-1,A=5,R=-1;function me(){return!(e.unstable_now()-RE||125D?(E.sortIndex=N,t(f,E),n(s)===null&&E===n(f)&&(S?(c(z),z=-1):S=!0,mn(y,N-D))):(E.sortIndex=K,t(s,E),k||w||(k=!0,hn(x))),E},e.unstable_shouldYield=me,e.unstable_wrapCallback=function(E){var j=p;return function(){var N=p;p=j;try{return E.apply(this,arguments)}finally{p=N}}}})(ss);os.exports=ss;var Rc=os.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Oc=L,we=Rc;function g(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Jl=Object.prototype.hasOwnProperty,Mc=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Au={},Vu={};function Fc(e){return Jl.call(Vu,e)?!0:Jl.call(Au,e)?!1:Mc.test(e)?Vu[e]=!0:(Au[e]=!0,!1)}function Dc(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Ic(e,t,n,r){if(t===null||typeof t>"u"||Dc(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ae(e,t,n,r,l,i,u){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=u}var te={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){te[e]=new ae(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];te[t]=new ae(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){te[e]=new ae(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){te[e]=new ae(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){te[e]=new ae(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){te[e]=new ae(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){te[e]=new ae(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){te[e]=new ae(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){te[e]=new ae(e,5,!1,e.toLowerCase(),null,!1,!1)});var Yi=/[\-:]([a-z])/g;function Xi(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Yi,Xi);te[t]=new ae(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Yi,Xi);te[t]=new ae(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Yi,Xi);te[t]=new ae(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){te[e]=new ae(e,1,!1,e.toLowerCase(),null,!1,!1)});te.xlinkHref=new ae("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){te[e]=new ae(e,1,!1,e.toLowerCase(),null,!0,!0)});function Gi(e,t,n,r){var l=te.hasOwnProperty(t)?te[t]:null;(l!==null?l.type!==0:r||!(2o||l[u]!==i[o]){var s=` +`+l[u].replace(" at new "," at ");return e.displayName&&s.includes("")&&(s=s.replace("",e.displayName)),s}while(1<=u&&0<=o);break}}}finally{_l=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Cn(e):""}function $c(e){switch(e.tag){case 5:return Cn(e.type);case 16:return Cn("Lazy");case 13:return Cn("Suspense");case 19:return Cn("SuspenseList");case 0:case 2:case 15:return e=Nl(e.type,!1),e;case 11:return e=Nl(e.type.render,!1),e;case 1:return e=Nl(e.type,!0),e;default:return""}}function ti(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ut:return"Fragment";case $t:return"Portal";case ql:return"Profiler";case Zi:return"StrictMode";case bl:return"Suspense";case ei:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case fs:return(e.displayName||"Context")+".Consumer";case cs:return(e._context.displayName||"Context")+".Provider";case Ji:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case qi:return t=e.displayName||null,t!==null?t:ti(e.type)||"Memo";case be:t=e._payload,e=e._init;try{return ti(e(t))}catch{}}return null}function Uc(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ti(t);case 8:return t===Zi?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function pt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ps(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Ac(e){var t=ps(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(u){r=""+u,i.call(this,u)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(u){r=""+u},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ar(e){e._valueTracker||(e._valueTracker=Ac(e))}function hs(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=ps(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Dr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function ni(e,t){var n=t.checked;return Q({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Hu(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=pt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function ms(e,t){t=t.checked,t!=null&&Gi(e,"checked",t,!1)}function ri(e,t){ms(e,t);var n=pt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?li(e,t.type,n):t.hasOwnProperty("defaultValue")&&li(e,t.type,pt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Qu(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function li(e,t,n){(t!=="number"||Dr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var _n=Array.isArray;function Zt(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=cr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function $n(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var zn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Vc=["Webkit","ms","Moz","O"];Object.keys(zn).forEach(function(e){Vc.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),zn[t]=zn[e]})});function ws(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||zn.hasOwnProperty(e)&&zn[e]?(""+t).trim():t+"px"}function ks(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=ws(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Bc=Q({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function oi(e,t){if(t){if(Bc[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(g(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(g(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(g(61))}if(t.style!=null&&typeof t.style!="object")throw Error(g(62))}}function si(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ai=null;function bi(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ci=null,Jt=null,qt=null;function Yu(e){if(e=rr(e)){if(typeof ci!="function")throw Error(g(280));var t=e.stateNode;t&&(t=fl(t),ci(e.stateNode,e.type,t))}}function Ss(e){Jt?qt?qt.push(e):qt=[e]:Jt=e}function xs(){if(Jt){var e=Jt,t=qt;if(qt=Jt=null,Yu(e),t)for(e=0;e>>=0,e===0?32:31-(bc(e)/ef|0)|0}var fr=64,dr=4194304;function Nn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Ar(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,i=e.pingedLanes,u=n&268435455;if(u!==0){var o=u&~l;o!==0?r=Nn(o):(i&=u,i!==0&&(r=Nn(i)))}else u=n&~l,u!==0?r=Nn(u):i!==0&&(r=Nn(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,i=t&-t,l>=i||l===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function tr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Oe(t),e[t]=n}function lf(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=jn),no=" ",ro=!1;function Bs(e,t){switch(e){case"keyup":return Of.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Hs(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var At=!1;function Ff(e,t){switch(e){case"compositionend":return Hs(t);case"keypress":return t.which!==32?null:(ro=!0,no);case"textInput":return e=t.data,e===no&&ro?null:e;default:return null}}function Df(e,t){if(At)return e==="compositionend"||!ou&&Bs(e,t)?(e=As(),Pr=lu=rt=null,At=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=oo(n)}}function Ys(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ys(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Xs(){for(var e=window,t=Dr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Dr(e.document)}return t}function su(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Wf(e){var t=Xs(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ys(n.ownerDocument.documentElement,n)){if(r!==null&&su(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,i=Math.min(r.start,l);r=r.end===void 0?i:Math.min(r.end,l),!e.extend&&i>r&&(l=r,r=i,i=l),l=so(n,i);var u=so(n,r);l&&u&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==u.node||e.focusOffset!==u.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(u.node,u.offset)):(t.setEnd(u.node,u.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Vt=null,vi=null,Rn=null,yi=!1;function ao(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;yi||Vt==null||Vt!==Dr(r)||(r=Vt,"selectionStart"in r&&su(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Rn&&Qn(Rn,r)||(Rn=r,r=Hr(vi,"onSelect"),0Qt||(e.current=Ei[Qt],Ei[Qt]=null,Qt--)}function I(e,t){Qt++,Ei[Qt]=e.current,e.current=t}var ht={},ie=vt(ht),de=vt(!1),Tt=ht;function rn(e,t){var n=e.type.contextTypes;if(!n)return ht;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in n)l[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function pe(e){return e=e.childContextTypes,e!=null}function Wr(){U(de),U(ie)}function yo(e,t,n){if(ie.current!==ht)throw Error(g(168));I(ie,t),I(de,n)}function ra(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(g(108,Uc(e)||"Unknown",l));return Q({},n,r)}function Kr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ht,Tt=ie.current,I(ie,e),I(de,de.current),!0}function go(e,t,n){var r=e.stateNode;if(!r)throw Error(g(169));n?(e=ra(e,t,Tt),r.__reactInternalMemoizedMergedChildContext=e,U(de),U(ie),I(ie,e)):U(de),I(de,n)}var Be=null,dl=!1,Al=!1;function la(e){Be===null?Be=[e]:Be.push(e)}function rd(e){dl=!0,la(e)}function yt(){if(!Al&&Be!==null){Al=!0;var e=0,t=F;try{var n=Be;for(F=1;e>=u,l-=u,He=1<<32-Oe(t)+l|n<z?(A=_,_=null):A=_.sibling;var R=p(c,_,d[z],y);if(R===null){_===null&&(_=A);break}e&&_&&R.alternate===null&&t(c,_),a=i(R,a,z),P===null?x=R:P.sibling=R,P=R,_=A}if(z===d.length)return n(c,_),V&&St(c,z),x;if(_===null){for(;zz?(A=_,_=null):A=_.sibling;var me=p(c,_,R.value,y);if(me===null){_===null&&(_=A);break}e&&_&&me.alternate===null&&t(c,_),a=i(me,a,z),P===null?x=me:P.sibling=me,P=me,_=A}if(R.done)return n(c,_),V&&St(c,z),x;if(_===null){for(;!R.done;z++,R=d.next())R=m(c,R.value,y),R!==null&&(a=i(R,a,z),P===null?x=R:P.sibling=R,P=R);return V&&St(c,z),x}for(_=r(c,_);!R.done;z++,R=d.next())R=w(_,c,z,R.value,y),R!==null&&(e&&R.alternate!==null&&_.delete(R.key===null?z:R.key),a=i(R,a,z),P===null?x=R:P.sibling=R,P=R);return e&&_.forEach(function(Je){return t(c,Je)}),V&&St(c,z),x}function T(c,a,d,y){if(typeof d=="object"&&d!==null&&d.type===Ut&&d.key===null&&(d=d.props.children),typeof d=="object"&&d!==null){switch(d.$$typeof){case sr:e:{for(var x=d.key,P=a;P!==null;){if(P.key===x){if(x=d.type,x===Ut){if(P.tag===7){n(c,P.sibling),a=l(P,d.props.children),a.return=c,c=a;break e}}else if(P.elementType===x||typeof x=="object"&&x!==null&&x.$$typeof===be&&So(x)===P.type){n(c,P.sibling),a=l(P,d.props),a.ref=Sn(c,P,d),a.return=c,c=a;break e}n(c,P);break}else t(c,P);P=P.sibling}d.type===Ut?(a=zt(d.props.children,c.mode,y,d.key),a.return=c,c=a):(y=Fr(d.type,d.key,d.props,null,c.mode,y),y.ref=Sn(c,a,d),y.return=c,c=y)}return u(c);case $t:e:{for(P=d.key;a!==null;){if(a.key===P)if(a.tag===4&&a.stateNode.containerInfo===d.containerInfo&&a.stateNode.implementation===d.implementation){n(c,a.sibling),a=l(a,d.children||[]),a.return=c,c=a;break e}else{n(c,a);break}else t(c,a);a=a.sibling}a=Xl(d,c.mode,y),a.return=c,c=a}return u(c);case be:return P=d._init,T(c,a,P(d._payload),y)}if(_n(d))return k(c,a,d,y);if(vn(d))return S(c,a,d,y);wr(c,d)}return typeof d=="string"&&d!==""||typeof d=="number"?(d=""+d,a!==null&&a.tag===6?(n(c,a.sibling),a=l(a,d),a.return=c,c=a):(n(c,a),a=Yl(d,c.mode,y),a.return=c,c=a),u(c)):n(c,a)}return T}var un=sa(!0),aa=sa(!1),Gr=vt(null),Zr=null,Yt=null,du=null;function pu(){du=Yt=Zr=null}function hu(e){var t=Gr.current;U(Gr),e._currentValue=t}function Ni(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function en(e,t){Zr=e,du=Yt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(fe=!0),e.firstContext=null)}function Ne(e){var t=e._currentValue;if(du!==e)if(e={context:e,memoizedValue:t,next:null},Yt===null){if(Zr===null)throw Error(g(308));Yt=e,Zr.dependencies={lanes:0,firstContext:e}}else Yt=Yt.next=e;return t}var Ct=null;function mu(e){Ct===null?Ct=[e]:Ct.push(e)}function ca(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,mu(t)):(n.next=l.next,l.next=n),t.interleaved=n,Xe(e,r)}function Xe(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var et=!1;function vu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function fa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function We(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function at(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,M&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Xe(e,n)}return l=r.interleaved,l===null?(t.next=t,mu(r)):(t.next=l.next,l.next=t),r.interleaved=t,Xe(e,n)}function Tr(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,tu(e,n)}}function xo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var u={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?l=i=u:i=i.next=u,n=n.next}while(n!==null);i===null?l=i=t:i=i.next=t}else l=i=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Jr(e,t,n,r){var l=e.updateQueue;et=!1;var i=l.firstBaseUpdate,u=l.lastBaseUpdate,o=l.shared.pending;if(o!==null){l.shared.pending=null;var s=o,f=s.next;s.next=null,u===null?i=f:u.next=f,u=s;var h=e.alternate;h!==null&&(h=h.updateQueue,o=h.lastBaseUpdate,o!==u&&(o===null?h.firstBaseUpdate=f:o.next=f,h.lastBaseUpdate=s))}if(i!==null){var m=l.baseState;u=0,h=f=s=null,o=i;do{var p=o.lane,w=o.eventTime;if((r&p)===p){h!==null&&(h=h.next={eventTime:w,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,S=o;switch(p=t,w=n,S.tag){case 1:if(k=S.payload,typeof k=="function"){m=k.call(w,m,p);break e}m=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=S.payload,p=typeof k=="function"?k.call(w,m,p):k,p==null)break e;m=Q({},m,p);break e;case 2:et=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,p=l.effects,p===null?l.effects=[o]:p.push(o))}else w={eventTime:w,lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},h===null?(f=h=w,s=m):h=h.next=w,u|=p;if(o=o.next,o===null){if(o=l.shared.pending,o===null)break;p=o,o=p.next,p.next=null,l.lastBaseUpdate=p,l.shared.pending=null}}while(!0);if(h===null&&(s=m),l.baseState=s,l.firstBaseUpdate=f,l.lastBaseUpdate=h,t=l.shared.interleaved,t!==null){l=t;do u|=l.lane,l=l.next;while(l!==t)}else i===null&&(l.shared.lanes=0);Rt|=u,e.lanes=u,e.memoizedState=m}}function Eo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Bl.transition;Bl.transition={};try{e(!1),t()}finally{F=n,Bl.transition=r}}function za(){return Pe().memoizedState}function od(e,t,n){var r=ft(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ta(e))ja(t,n);else if(n=ca(e,t,n,r),n!==null){var l=oe();Me(n,e,r,l),La(n,t,r)}}function sd(e,t,n){var r=ft(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ta(e))ja(t,l);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var u=t.lastRenderedState,o=i(u,n);if(l.hasEagerState=!0,l.eagerState=o,Fe(o,u)){var s=t.interleaved;s===null?(l.next=l,mu(t)):(l.next=s.next,s.next=l),t.interleaved=l;return}}catch{}finally{}n=ca(e,t,l,r),n!==null&&(l=oe(),Me(n,e,r,l),La(n,t,r))}}function Ta(e){var t=e.alternate;return e===H||t!==null&&t===H}function ja(e,t){On=br=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function La(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,tu(e,n)}}var el={readContext:Ne,useCallback:ne,useContext:ne,useEffect:ne,useImperativeHandle:ne,useInsertionEffect:ne,useLayoutEffect:ne,useMemo:ne,useReducer:ne,useRef:ne,useState:ne,useDebugValue:ne,useDeferredValue:ne,useTransition:ne,useMutableSource:ne,useSyncExternalStore:ne,useId:ne,unstable_isNewReconciler:!1},ad={readContext:Ne,useCallback:function(e,t){return Ie().memoizedState=[e,t===void 0?null:t],e},useContext:Ne,useEffect:_o,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Lr(4194308,4,Ea.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Lr(4194308,4,e,t)},useInsertionEffect:function(e,t){return Lr(4,2,e,t)},useMemo:function(e,t){var n=Ie();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ie();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=od.bind(null,H,e),[r.memoizedState,e]},useRef:function(e){var t=Ie();return e={current:e},t.memoizedState=e},useState:Co,useDebugValue:Cu,useDeferredValue:function(e){return Ie().memoizedState=e},useTransition:function(){var e=Co(!1),t=e[0];return e=ud.bind(null,e[1]),Ie().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=H,l=Ie();if(V){if(n===void 0)throw Error(g(407));n=n()}else{if(n=t(),q===null)throw Error(g(349));Lt&30||ma(r,t,n)}l.memoizedState=n;var i={value:n,getSnapshot:t};return l.queue=i,_o(ya.bind(null,r,i,e),[e]),r.flags|=2048,qn(9,va.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Ie(),t=q.identifierPrefix;if(V){var n=Qe,r=He;n=(r&~(1<<32-Oe(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Zn++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=u.createElement(n,{is:r.is}):(e=u.createElement(n),n==="select"&&(u=e,r.multiple?u.multiple=!0:r.size&&(u.size=r.size))):e=u.createElementNS(e,n),e[$e]=t,e[Yn]=r,Va(e,t,!1,!1),t.stateNode=e;e:{switch(u=si(n,r),n){case"dialog":$("cancel",e),$("close",e),l=r;break;case"iframe":case"object":case"embed":$("load",e),l=r;break;case"video":case"audio":for(l=0;lan&&(t.flags|=128,r=!0,xn(i,!1),t.lanes=4194304)}else{if(!r)if(e=qr(u),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),xn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!u.alternate&&!V)return re(t),null}else 2*Y()-i.renderingStartTime>an&&n!==1073741824&&(t.flags|=128,r=!0,xn(i,!1),t.lanes=4194304);i.isBackwards?(u.sibling=t.child,t.child=u):(n=i.last,n!==null?n.sibling=u:t.child=u,i.last=u)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Y(),t.sibling=null,n=B.current,I(B,r?n&1|2:n&1),t):(re(t),null);case 22:case 23:return ju(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ve&1073741824&&(re(t),t.subtreeFlags&6&&(t.flags|=8192)):re(t),null;case 24:return null;case 25:return null}throw Error(g(156,t.tag))}function yd(e,t){switch(cu(t),t.tag){case 1:return pe(t.type)&&Wr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return on(),U(de),U(ie),wu(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return gu(t),null;case 13:if(U(B),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(g(340));ln()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return U(B),null;case 4:return on(),null;case 10:return hu(t.type._context),null;case 22:case 23:return ju(),null;case 24:return null;default:return null}}var Sr=!1,le=!1,gd=typeof WeakSet=="function"?WeakSet:Set,C=null;function Xt(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){W(e,t,r)}else n.current=null}function Fi(e,t,n){try{n()}catch(r){W(e,t,r)}}var Do=!1;function wd(e,t){if(gi=Vr,e=Xs(),su(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var u=0,o=-1,s=-1,f=0,h=0,m=e,p=null;t:for(;;){for(var w;m!==n||l!==0&&m.nodeType!==3||(o=u+l),m!==i||r!==0&&m.nodeType!==3||(s=u+r),m.nodeType===3&&(u+=m.nodeValue.length),(w=m.firstChild)!==null;)p=m,m=w;for(;;){if(m===e)break t;if(p===n&&++f===l&&(o=u),p===i&&++h===r&&(s=u),(w=m.nextSibling)!==null)break;m=p,p=m.parentNode}m=w}n=o===-1||s===-1?null:{start:o,end:s}}else n=null}n=n||{start:0,end:0}}else n=null;for(wi={focusedElem:e,selectionRange:n},Vr=!1,C=t;C!==null;)if(t=C,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,C=e;else for(;C!==null;){t=C;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var S=k.memoizedProps,T=k.memoizedState,c=t.stateNode,a=c.getSnapshotBeforeUpdate(t.elementType===t.type?S:je(t.type,S),T);c.__reactInternalSnapshotBeforeUpdate=a}break;case 3:var d=t.stateNode.containerInfo;d.nodeType===1?d.textContent="":d.nodeType===9&&d.documentElement&&d.removeChild(d.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(g(163))}}catch(y){W(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,C=e;break}C=t.return}return k=Do,Do=!1,k}function Mn(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&Fi(t,n,i)}l=l.next}while(l!==r)}}function ml(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Di(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Qa(e){var t=e.alternate;t!==null&&(e.alternate=null,Qa(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[$e],delete t[Yn],delete t[xi],delete t[td],delete t[nd])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Wa(e){return e.tag===5||e.tag===3||e.tag===4}function Io(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Wa(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ii(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Qr));else if(r!==4&&(e=e.child,e!==null))for(Ii(e,t,n),e=e.sibling;e!==null;)Ii(e,t,n),e=e.sibling}function $i(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for($i(e,t,n),e=e.sibling;e!==null;)$i(e,t,n),e=e.sibling}var b=null,Le=!1;function qe(e,t,n){for(n=n.child;n!==null;)Ka(e,t,n),n=n.sibling}function Ka(e,t,n){if(Ue&&typeof Ue.onCommitFiberUnmount=="function")try{Ue.onCommitFiberUnmount(ol,n)}catch{}switch(n.tag){case 5:le||Xt(n,t);case 6:var r=b,l=Le;b=null,qe(e,t,n),b=r,Le=l,b!==null&&(Le?(e=b,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):b.removeChild(n.stateNode));break;case 18:b!==null&&(Le?(e=b,n=n.stateNode,e.nodeType===8?Ul(e.parentNode,n):e.nodeType===1&&Ul(e,n),Bn(e)):Ul(b,n.stateNode));break;case 4:r=b,l=Le,b=n.stateNode.containerInfo,Le=!0,qe(e,t,n),b=r,Le=l;break;case 0:case 11:case 14:case 15:if(!le&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,u=i.destroy;i=i.tag,u!==void 0&&(i&2||i&4)&&Fi(n,t,u),l=l.next}while(l!==r)}qe(e,t,n);break;case 1:if(!le&&(Xt(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){W(n,t,o)}qe(e,t,n);break;case 21:qe(e,t,n);break;case 22:n.mode&1?(le=(r=le)||n.memoizedState!==null,qe(e,t,n),le=r):qe(e,t,n);break;default:qe(e,t,n)}}function $o(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new gd),t.forEach(function(r){var l=zd.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Te(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=u),r&=~i}if(r=l,r=Y()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Sd(r/1960))-r,10e?16:e,lt===null)var r=!1;else{if(e=lt,lt=null,rl=0,M&6)throw Error(g(331));var l=M;for(M|=4,C=e.current;C!==null;){var i=C,u=i.child;if(C.flags&16){var o=i.deletions;if(o!==null){for(var s=0;sY()-zu?Pt(e,0):Pu|=n),he(e,t)}function ec(e,t){t===0&&(e.mode&1?(t=dr,dr<<=1,!(dr&130023424)&&(dr=4194304)):t=1);var n=oe();e=Xe(e,t),e!==null&&(tr(e,t,n),he(e,n))}function Pd(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ec(e,n)}function zd(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(g(314))}r!==null&&r.delete(t),ec(e,n)}var tc;tc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||de.current)fe=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return fe=!1,md(e,t,n);fe=!!(e.flags&131072)}else fe=!1,V&&t.flags&1048576&&ia(t,Xr,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Rr(e,t),e=t.pendingProps;var l=rn(t,ie.current);en(t,n),l=Su(null,t,r,e,l,n);var i=xu();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,pe(r)?(i=!0,Kr(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,vu(t),l.updater=hl,t.stateNode=l,l._reactInternals=t,zi(t,r,e,n),t=Li(null,t,r,!0,i,n)):(t.tag=0,V&&i&&au(t),ue(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Rr(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=jd(r),e=je(r,e),l){case 0:t=ji(null,t,r,e,n);break e;case 1:t=Oo(null,t,r,e,n);break e;case 11:t=Lo(null,t,r,e,n);break e;case 14:t=Ro(null,t,r,je(r.type,e),n);break e}throw Error(g(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:je(r,l),ji(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:je(r,l),Oo(e,t,r,l,n);case 3:e:{if($a(t),e===null)throw Error(g(387));r=t.pendingProps,i=t.memoizedState,l=i.element,fa(e,t),Jr(t,r,null,n);var u=t.memoizedState;if(r=u.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:u.cache,pendingSuspenseBoundaries:u.pendingSuspenseBoundaries,transitions:u.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=sn(Error(g(423)),t),t=Mo(e,t,r,n,l);break e}else if(r!==l){l=sn(Error(g(424)),t),t=Mo(e,t,r,n,l);break e}else for(ye=st(t.stateNode.containerInfo.firstChild),ge=t,V=!0,Re=null,n=aa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(ln(),r===l){t=Ge(e,t,n);break e}ue(e,t,r,n)}t=t.child}return t;case 5:return da(t),e===null&&_i(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,u=l.children,ki(r,l)?u=null:i!==null&&ki(r,i)&&(t.flags|=32),Ia(e,t),ue(e,t,u,n),t.child;case 6:return e===null&&_i(t),null;case 13:return Ua(e,t,n);case 4:return yu(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=un(t,null,r,n):ue(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:je(r,l),Lo(e,t,r,l,n);case 7:return ue(e,t,t.pendingProps,n),t.child;case 8:return ue(e,t,t.pendingProps.children,n),t.child;case 12:return ue(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,u=l.value,I(Gr,r._currentValue),r._currentValue=u,i!==null)if(Fe(i.value,u)){if(i.children===l.children&&!de.current){t=Ge(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){u=i.child;for(var s=o.firstContext;s!==null;){if(s.context===r){if(i.tag===1){s=We(-1,n&-n),s.tag=2;var f=i.updateQueue;if(f!==null){f=f.shared;var h=f.pending;h===null?s.next=s:(s.next=h.next,h.next=s),f.pending=s}}i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),Ni(i.return,n,t),o.lanes|=n;break}s=s.next}}else if(i.tag===10)u=i.type===t.type?null:i.child;else if(i.tag===18){if(u=i.return,u===null)throw Error(g(341));u.lanes|=n,o=u.alternate,o!==null&&(o.lanes|=n),Ni(u,n,t),u=i.sibling}else u=i.child;if(u!==null)u.return=i;else for(u=i;u!==null;){if(u===t){u=null;break}if(i=u.sibling,i!==null){i.return=u.return,u=i;break}u=u.return}i=u}ue(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,en(t,n),l=Ne(l),r=r(l),t.flags|=1,ue(e,t,r,n),t.child;case 14:return r=t.type,l=je(r,t.pendingProps),l=je(r.type,l),Ro(e,t,r,l,n);case 15:return Fa(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:je(r,l),Rr(e,t),t.tag=1,pe(r)?(e=!0,Kr(t)):e=!1,en(t,n),Ra(t,r,l),zi(t,r,l,n),Li(null,t,r,!0,e,n);case 19:return Aa(e,t,n);case 22:return Da(e,t,n)}throw Error(g(156,t.tag))};function nc(e,t){return Ts(e,t)}function Td(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ce(e,t,n,r){return new Td(e,t,n,r)}function Ru(e){return e=e.prototype,!(!e||!e.isReactComponent)}function jd(e){if(typeof e=="function")return Ru(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ji)return 11;if(e===qi)return 14}return 2}function dt(e,t){var n=e.alternate;return n===null?(n=Ce(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Fr(e,t,n,r,l,i){var u=2;if(r=e,typeof e=="function")Ru(e)&&(u=1);else if(typeof e=="string")u=5;else e:switch(e){case Ut:return zt(n.children,l,i,t);case Zi:u=8,l|=8;break;case ql:return e=Ce(12,n,t,l|2),e.elementType=ql,e.lanes=i,e;case bl:return e=Ce(13,n,t,l),e.elementType=bl,e.lanes=i,e;case ei:return e=Ce(19,n,t,l),e.elementType=ei,e.lanes=i,e;case ds:return yl(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case cs:u=10;break e;case fs:u=9;break e;case Ji:u=11;break e;case qi:u=14;break e;case be:u=16,r=null;break e}throw Error(g(130,e==null?e:typeof e,""))}return t=Ce(u,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function zt(e,t,n,r){return e=Ce(7,e,r,t),e.lanes=n,e}function yl(e,t,n,r){return e=Ce(22,e,r,t),e.elementType=ds,e.lanes=n,e.stateNode={isHidden:!1},e}function Yl(e,t,n){return e=Ce(6,e,null,t),e.lanes=n,e}function Xl(e,t,n){return t=Ce(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Ld(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=zl(0),this.expirationTimes=zl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zl(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Ou(e,t,n,r,l,i,u,o,s){return e=new Ld(e,t,n,o,s),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Ce(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},vu(i),e}function Rd(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(uc)}catch(e){console.error(e)}}uc(),us.exports=ke;var Id=us.exports,oc,Ko=Id;oc=Ko.createRoot,Ko.hydrateRoot;async function Dt(e){const t=await fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.json()}async function $d(){return Dt("/api/archives")}async function Ud(e){return Dt(`/api/archives/${e}/entries`)}async function Ad(e,t,n){const r=new URLSearchParams;return t&&r.set("q",t),n&&r.set("tag",n),Dt(`/api/archives/${e}/entries/search?${r}`)}async function Vd(e,t){return Dt(`/api/archives/${e}/entries/${t}`)}async function Gl(e,t){return Dt(`/api/archives/${e}/entries/${t}/tags`)}async function Bd(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/tags`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag_path:n})});if(!r.ok)throw new Error(`Failed to add tag (${r.status})`)}async function Hd(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/tags/${n}`,{method:"DELETE"});if(!r.ok)throw new Error(`Remove failed (${r.status})`)}async function Yo(e){return Dt(`/api/archives/${e}/runs`)}async function Zl(e){return Dt(`/api/archives/${e}/tags`)}async function Qd(e,t){const n=await fetch(`/api/archives/${e}/captures`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locator:t})});if(!n.ok){const r=await n.text();throw new Error(r||`HTTP ${n.status}`)}}function Wd({archives:e,archiveId:t,onArchiveChange:n,view:r,onViewChange:l,onCaptureClick:i}){return v.jsxs("header",{className:"topbar",children:[v.jsx("div",{className:"brand",children:"Archivr"}),v.jsx("select",{className:"archive-switcher","aria-label":"Select archive",value:t??"",onChange:u=>n(u.target.value),children:e.map(u=>v.jsx("option",{value:u.id,children:u.label},u.id))}),v.jsx("nav",{className:"nav","aria-label":"Primary",children:["archive","runs","admin","tags"].map(u=>v.jsx("button",{className:`nav-link${r===u?" is-active":""}`,onClick:()=>l(u),children:u.charAt(0).toUpperCase()+u.slice(1)},u))}),v.jsx("button",{className:"capture-button",onClick:i,children:"+ Capture"})]})}function Kd({open:e,archiveId:t,onClose:n,onCaptured:r}){const l=L.useRef(null),[i,u]=L.useState(""),[o,s]=L.useState(null),[f,h]=L.useState(!1);L.useEffect(()=>{const p=l.current;if(!p)return;const w=()=>n();return p.addEventListener("close",w),()=>p.removeEventListener("close",w)},[n]),L.useEffect(()=>{const p=l.current;p&&(e?(u(""),s(null),p.open||p.showModal()):p.open&&p.close())},[e]);async function m(){var p;if(!i.trim()){s("Enter a locator.");return}h(!0),s(null);try{await Qd(t,i.trim()),(p=l.current)==null||p.close(),r()}catch(w){s(w.message)}finally{h(!1)}}return v.jsx("dialog",{ref:l,className:"capture-dialog",children:v.jsxs("div",{className:"capture-dialog-inner",children:[v.jsx("h2",{className:"capture-dialog-title",children:"Capture"}),v.jsx("label",{htmlFor:"capture-locator",className:"capture-label",children:"Locator"}),v.jsx("input",{id:"capture-locator",className:"capture-input",type:"text",placeholder:"tweet:1234567890 or https://...",value:i,onChange:p=>u(p.target.value),onKeyDown:p=>{p.key==="Enter"&&m()},autoComplete:"off"}),o&&v.jsx("div",{className:"capture-error",children:o}),v.jsxs("div",{className:"capture-actions",children:[v.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var p;return(p=l.current)==null?void 0:p.close()},children:"Cancel"}),v.jsx("button",{type:"button",className:"capture-submit",onClick:m,disabled:f,children:f?"Capturing…":"Capture"})]})]})})}function sc(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&rString(r).padStart(2,"0");return`${t.getUTCFullYear()}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}const Xo={youtube:'',x:'',instagram:'',facebook:'',tiktok:'',reddit:'',snapchat:'',local:'',web:'',other:'?'};function Yd(e){return Xo[e]??Xo.other}function Xd({entry:e,isSelected:t,onSelect:n}){return v.jsxs("div",{className:t?"is-selected":void 0,tabIndex:0,"data-entry-uid":e.entry_uid,onClick:n,onKeyDown:r=>{r.key==="Enter"&&n()},children:[v.jsx("div",{className:"col-added",children:ac(e.archived_at)}),v.jsxs("div",{className:"col-title",children:[v.jsx("span",{className:"source-icon",dangerouslySetInnerHTML:{__html:Yd(e.source_kind)}}),v.jsx("span",{className:"entry-title",children:Nt(e.title)||Nt(e.entry_uid)})]}),v.jsx("div",{className:"col-type",children:v.jsx("span",{className:"type-pill",children:Nt(e.entity_kind)})}),v.jsx("div",{className:"col-size",children:sc(e.total_artifact_bytes)}),v.jsx("div",{className:"url-cell col-url",children:Nt(e.original_url)})]})}function Gd({entries:e,selectedEntryUid:t,onSelectEntry:n}){return v.jsx("section",{id:"archive-view",className:"view is-active",children:v.jsxs("div",{className:"entry-table",children:[v.jsxs("div",{className:"entry-header-row",children:[v.jsx("div",{className:"col-added",children:"Added"}),v.jsx("div",{className:"col-title",children:"Title"}),v.jsx("div",{className:"col-type",children:"Type"}),v.jsx("div",{className:"col-size",children:"Size"}),v.jsx("div",{className:"col-url",children:"Original URL"})]}),v.jsx("div",{id:"entries-body",children:e.map(r=>v.jsx(Xd,{entry:r,isSelected:r.entry_uid===t,onSelect:()=>n(r)},r.entry_uid))})]})})}function Zd({runs:e}){return v.jsx("section",{id:"runs-view",className:"view is-active",children:v.jsxs("table",{className:"entry-table",children:[v.jsx("thead",{children:v.jsxs("tr",{children:[v.jsx("th",{children:"Started"}),v.jsx("th",{children:"Status"}),v.jsx("th",{children:"Requested"}),v.jsx("th",{children:"Completed"}),v.jsx("th",{children:"Failed"})]})}),v.jsx("tbody",{children:e.map((t,n)=>v.jsxs("tr",{children:[v.jsx("td",{children:t.started_at??""}),v.jsx("td",{children:t.status??""}),v.jsx("td",{children:t.requested_count??""}),v.jsx("td",{children:t.completed_count??""}),v.jsx("td",{children:t.failed_count??""})]},n))})]})})}function Jd({archives:e}){return v.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[v.jsx("h1",{children:"Mounted Archives"}),v.jsx("div",{className:"admin-list",children:e.map(t=>v.jsxs("div",{className:"admin-archive",children:[v.jsx("strong",{children:t.label}),v.jsx("div",{className:"muted",children:t.archive_path})]},t.id))})]})}function cc({node:e,tagFilter:t,onTagFilterSet:n,onViewChange:r}){var u;const l=t===e.tag.full_path;function i(){const o=l?null:e.tag.full_path;n(o),r("archive")}return v.jsxs("li",{children:[v.jsx("button",{className:`tag-node-btn${l?" is-active":""}`,title:e.tag.full_path,onClick:i,children:e.tag.name}),((u=e.children)==null?void 0:u.length)>0&&v.jsx("div",{className:"tag-children",children:v.jsx("ul",{className:"tag-tree-list",children:e.children.map(o=>v.jsx(cc,{node:o,tagFilter:t,onTagFilterSet:n,onViewChange:r},o.tag.tag_uid))})})]})}function qd({tagNodes:e,tagFilter:t,onTagFilterSet:n,onViewChange:r}){return v.jsx("section",{id:"tags-view",className:"view is-active",children:v.jsx("div",{className:"tag-tree",children:e.length===0?v.jsx("div",{children:"No tags yet."}):v.jsx("ul",{className:"tag-tree-list",children:e.map(l=>v.jsx(cc,{node:l,tagFilter:t,onTagFilterSet:n,onViewChange:r},l.tag.tag_uid))})})})}function bd({archiveId:e,selectedEntry:t,onTagFilterSet:n,tagNodes:r,onTagsRefresh:l}){const[i,u]=L.useState(null),[o,s]=L.useState([]),[f,h]=L.useState(""),[m,p]=L.useState(""),w=L.useRef(0);L.useEffect(()=>{if(!t||!e){u(null),s([]);return}const T=++w.current;u(null),s([]),Promise.all([Vd(e,t.entry_uid),Gl(e,t.entry_uid)]).then(([c,a])=>{T===w.current&&(u(c),s(a))}).catch(()=>{})},[t,e]);async function k(){const T=f.trim();if(!(!T||!t))try{await Bd(e,t.entry_uid,T),h(""),p("");const c=await Gl(e,t.entry_uid);s(c),l()}catch(c){p(c.message)}}async function S(T){try{await Hd(e,t.entry_uid,T);const c=await Gl(e,t.entry_uid);s(c),l()}catch{}}return v.jsxs("aside",{className:"context-rail",children:[v.jsx("div",{className:"rail-title",children:"Context"}),t?i?v.jsxs("div",{className:"rail-body",children:[v.jsx("strong",{className:"rail-entry-title",children:Nt(i.summary.title)||Nt(i.summary.entry_uid)}),v.jsxs("div",{className:"rail-section",children:[i.summary.original_url&&v.jsxs("div",{className:"rail-item",children:[v.jsx("span",{className:"rail-label",children:"Original URL"}),":"," ",v.jsx("a",{href:i.summary.original_url,target:"_blank",rel:"noopener noreferrer",className:"rail-url-link",children:i.summary.original_url})]}),[["Added",ac(i.summary.archived_at)],["Source",i.summary.source_kind],["Type",i.summary.entity_kind],["Visibility",i.summary.visibility],["Structured root",i.structured_root_relpath]].map(([T,c])=>v.jsxs("div",{className:"rail-item",children:[v.jsx("span",{className:"rail-label",children:T}),": ",Nt(c)]},T))]}),i.artifacts.length>0?v.jsxs("div",{className:"rail-section",children:[v.jsxs("div",{className:"rail-section-heading",children:["Artifacts (",i.artifacts.length,")"]}),v.jsx("ul",{className:"artifact-list",children:i.artifacts.map((T,c)=>v.jsx("li",{children:v.jsxs("a",{href:`/api/archives/${e}/entries/${i.summary.entry_uid}/artifacts/${c}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[T.artifact_role.replace(/_/g," "),T.byte_size!=null?` (${sc(T.byte_size)})`:""]})},c))})]}):v.jsx("div",{className:"rail-item muted",children:"No artifacts."})]}):v.jsx("div",{className:"rail-body",children:"Loading…"}):v.jsx("div",{className:"rail-body",children:"Select an entry."}),t&&v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"entry-tags",children:o.length===0?v.jsx("span",{className:"muted",children:"No tags."}):o.map(T=>v.jsxs("span",{className:"tag-pill",title:T.full_path,children:[T.name,v.jsx("button",{className:"remove-tag",title:`Remove tag ${T.full_path}`,onClick:()=>S(T.tag_uid),children:"×"})]},T.tag_uid))}),v.jsxs("div",{className:"assign-tag-form",children:[v.jsx("input",{className:"assign-tag-input",type:"text",placeholder:"/science/cs",autoComplete:"off",value:f,onChange:T=>h(T.target.value),onKeyDown:T=>{T.key==="Enter"&&k()}}),v.jsx("button",{className:"assign-tag-btn",onClick:k,children:"Add tag"}),m&&v.jsx("div",{className:"muted",style:{fontSize:"0.85em",color:"var(--accent)"},children:m})]})]})]})}function ep(){const[e,t]=L.useState([]),[n,r]=L.useState(null),[l,i]=L.useState([]),[u,o]=L.useState(null),[s,f]=L.useState(null),[h,m]=L.useState(null),[p,w]=L.useState("archive"),[k,S]=L.useState(""),[T,c]=L.useState(""),[a,d]=L.useState(!1),[y,x]=L.useState([]),[P,_]=L.useState([]),[z,A]=L.useState(!1),R=L.useCallback(async(N,D,K)=>{if(N){d(!0);try{let ze;D||K?ze=await Ad(N,D,K):ze=await Ud(N),i(ze),c(ze.length===0?"No results":`${ze.length} result${ze.length===1?"":"s"}`)}catch{i([]),c("Search failed. Try again.")}finally{d(!1)}}},[]);L.useEffect(()=>{$d().then(N=>{if(t(N),N.length>0){const D=N[0].id;r(D)}})},[]),L.useEffect(()=>{n&&(m(null),f(null),o(null),Promise.all([R(n,"",null),Yo(n).then(x),Zl(n).then(_)]))},[n]),L.useEffect(()=>{if(n===null)return;const N=setTimeout(()=>{R(n,k,h)},300);return()=>clearTimeout(N)},[k,n]),L.useEffect(()=>{n!==null&&(w("archive"),R(n,k,h))},[h,n]);const me=L.useCallback(N=>{r(N)},[]),Je=L.useCallback(N=>{w(N),N==="tags"&&n&&Zl(n).then(_)},[n]),gt=L.useCallback(N=>{o(N?N.entry_uid:null),f(N)},[]),pn=L.useCallback(N=>{m(N)},[]),ir=L.useCallback(()=>{m(null)},[]),hn=L.useCallback(()=>{n&&Zl(n).then(_)},[n]),mn=L.useCallback(()=>{A(!0)},[]),E=L.useCallback(()=>{A(!1)},[]),j=L.useCallback(()=>{n&&Promise.all([R(n,k,h),Yo(n).then(x)])},[n,k,h,R]);return v.jsxs(v.Fragment,{children:[v.jsx(Wd,{archives:e,archiveId:n,onArchiveChange:me,view:p,onViewChange:Je,onCaptureClick:mn}),v.jsxs("main",{className:"app-shell",children:[v.jsxs("div",{className:"workspace",children:[p==="archive"&&v.jsxs("div",{className:"search-row",children:[v.jsx("input",{className:"search-input",type:"search","aria-label":"Search archive","aria-busy":a,value:k,onChange:N=>S(N.target.value)}),v.jsxs("div",{className:"result-count",children:[T,h&&v.jsxs("button",{className:"tag-filter-badge",onClick:ir,children:["× ",h]})]})]}),p==="archive"&&v.jsx(Gd,{entries:l,selectedEntryUid:u,onSelectEntry:gt,tagFilter:h,onClearTagFilter:ir,searchQuery:k,onSearchChange:S,resultCount:T,searchBusy:a}),p==="runs"&&v.jsx(Zd,{runs:y}),p==="admin"&&v.jsx(Jd,{archives:e}),p==="tags"&&v.jsx(qd,{tagNodes:P,tagFilter:h,onTagFilterSet:pn,onViewChange:Je})]}),v.jsx(bd,{archiveId:n,selectedEntry:s,onTagFilterSet:pn,tagNodes:P,onTagsRefresh:hn})]}),v.jsx(Kd,{open:z,archiveId:n,onClose:E,onCaptured:j})]})}oc(document.getElementById("root")).render(v.jsx(L.StrictMode,{children:v.jsx(ep,{})})); diff --git a/crates/archivr-server/static/index.html b/crates/archivr-server/static/index.html index 96840da..169672d 100644 --- a/crates/archivr-server/static/index.html +++ b/crates/archivr-server/static/index.html @@ -1,94 +1,13 @@ - - + + Archivr - + + -
-
Archivr
- - - -
- -
-
-
- -
-
- -
-
-
-
Added
-
Title
-
Type
-
Size
-
Original URL
-
-
-
-
- -
-
- - - - - - - - - - -
StartedStatusRequestedCompletedFailed
-
- -
-

Mounted Archives

-
-
- -
-
-
- - - - - - -
-

Capture

- - - -
- - -
-
-
- - +
diff --git a/frontend/bun.lock b/frontend/bun.lock new file mode 100644 index 0000000..c26ba69 --- /dev/null +++ b/frontend/bun.lock @@ -0,0 +1,236 @@ +{ + "lockfileVersion": 1, + "configVersion": 1, + "workspaces": { + "": { + "name": "archivr-frontend", + "dependencies": { + "react": "^18.3.1", + "react-dom": "^18.3.1", + }, + "devDependencies": { + "@vitejs/plugin-react": "^4.3.4", + "vite": "^5.4.11", + }, + }, + }, + "packages": { + "@babel/code-frame": ["@babel/code-frame@7.29.7", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.29.7", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw=="], + + "@babel/compat-data": ["@babel/compat-data@7.29.7", "", {}, "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg=="], + + "@babel/core": ["@babel/core@7.29.7", "", { "dependencies": { "@babel/code-frame": "^7.29.7", "@babel/generator": "^7.29.7", "@babel/helper-compilation-targets": "^7.29.7", "@babel/helper-module-transforms": "^7.29.7", "@babel/helpers": "^7.29.7", "@babel/parser": "^7.29.7", "@babel/template": "^7.29.7", "@babel/traverse": "^7.29.7", "@babel/types": "^7.29.7", "@jridgewell/remapping": "^2.3.5", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", "json5": "^2.2.3", "semver": "^6.3.1" } }, "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA=="], + + "@babel/generator": ["@babel/generator@7.29.7", "", { "dependencies": { "@babel/parser": "^7.29.7", "@babel/types": "^7.29.7", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" } }, "sha512-DkXD5OJQaAQIdZ1bt3UZdEnHAn9Imd3IVBdX03UFe+ony9Ojw5pzr9YVKGDY1jt+Gcn/FnGkNf8r+Vj5NOJWtQ=="], + + "@babel/helper-compilation-targets": ["@babel/helper-compilation-targets@7.29.7", "", { "dependencies": { "@babel/compat-data": "^7.29.7", "@babel/helper-validator-option": "^7.29.7", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", "semver": "^6.3.1" } }, "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g=="], + + "@babel/helper-globals": ["@babel/helper-globals@7.29.7", "", {}, "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA=="], + + "@babel/helper-module-imports": ["@babel/helper-module-imports@7.29.7", "", { "dependencies": { "@babel/traverse": "^7.29.7", "@babel/types": "^7.29.7" } }, "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g=="], + + "@babel/helper-module-transforms": ["@babel/helper-module-transforms@7.29.7", "", { "dependencies": { "@babel/helper-module-imports": "^7.29.7", "@babel/helper-validator-identifier": "^7.29.7", "@babel/traverse": "^7.29.7" }, "peerDependencies": { "@babel/core": "^7.0.0" } }, "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg=="], + + "@babel/helper-plugin-utils": ["@babel/helper-plugin-utils@7.29.7", "", {}, "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw=="], + + "@babel/helper-string-parser": ["@babel/helper-string-parser@7.29.7", "", {}, "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw=="], + + "@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.29.7", "", {}, "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg=="], + + "@babel/helper-validator-option": ["@babel/helper-validator-option@7.29.7", "", {}, "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw=="], + + "@babel/helpers": ["@babel/helpers@7.29.7", "", { "dependencies": { "@babel/template": "^7.29.7", "@babel/types": "^7.29.7" } }, "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg=="], + + "@babel/parser": ["@babel/parser@7.29.7", "", { "dependencies": { "@babel/types": "^7.29.7" }, "bin": "./bin/babel-parser.js" }, "sha512-hnORnjP/1P/zFEndoeX+n+t1RwWRJiJpM/jO7FW32Kn9r5+sJB2JWOdYo4L6k78j15eCwY3Gm/7364B1EMwtNg=="], + + "@babel/plugin-transform-react-jsx-self": ["@babel/plugin-transform-react-jsx-self@7.29.7", "", { "dependencies": { "@babel/helper-plugin-utils": "^7.29.7" }, "peerDependencies": { "@babel/core": "^7.0.0-0" } }, "sha512-TL0hMc9xzy86VD31nUiwzd5otRAcyEPcsegCxolO0PvcXuH1v0kECe/UIznYFihpkvU5wg/jk4v0TTEFfm53fw=="], + + "@babel/plugin-transform-react-jsx-source": ["@babel/plugin-transform-react-jsx-source@7.29.7", "", { "dependencies": { "@babel/helper-plugin-utils": "^7.29.7" }, "peerDependencies": { "@babel/core": "^7.0.0-0" } }, "sha512-06IyK09H3wi4cGbhDBwp5gUGo0IKtnYa8tyTiephirPCK6fbobVGiXMMI5zLQ4aKEYP3wZ3ArU44o+8KMrSG/Q=="], + + "@babel/template": ["@babel/template@7.29.7", "", { "dependencies": { "@babel/code-frame": "^7.29.7", "@babel/parser": "^7.29.7", "@babel/types": "^7.29.7" } }, "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg=="], + + "@babel/traverse": ["@babel/traverse@7.29.7", "", { "dependencies": { "@babel/code-frame": "^7.29.7", "@babel/generator": "^7.29.7", "@babel/helper-globals": "^7.29.7", "@babel/parser": "^7.29.7", "@babel/template": "^7.29.7", "@babel/types": "^7.29.7", "debug": "^4.3.1" } }, "sha512-EhlfNQtZ+NK22w5BM61ciuiq1m58ed33Wr1Xan//ZRTy6hgjnwyCffRYwzsGXdASJSUJ1guZILsErh1eQcl+zw=="], + + "@babel/types": ["@babel/types@7.29.7", "", { "dependencies": { "@babel/helper-string-parser": "^7.29.7", "@babel/helper-validator-identifier": "^7.29.7" } }, "sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA=="], + + "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.21.5", "", { "os": "aix", "cpu": "ppc64" }, "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ=="], + + "@esbuild/android-arm": ["@esbuild/android-arm@0.21.5", "", { "os": "android", "cpu": "arm" }, "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg=="], + + "@esbuild/android-arm64": ["@esbuild/android-arm64@0.21.5", "", { "os": "android", "cpu": "arm64" }, "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A=="], + + "@esbuild/android-x64": ["@esbuild/android-x64@0.21.5", "", { "os": "android", "cpu": "x64" }, "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA=="], + + "@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.21.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ=="], + + "@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.21.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw=="], + + "@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.21.5", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g=="], + + "@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.21.5", "", { "os": "freebsd", "cpu": "x64" }, "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ=="], + + "@esbuild/linux-arm": ["@esbuild/linux-arm@0.21.5", "", { "os": "linux", "cpu": "arm" }, "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA=="], + + "@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.21.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q=="], + + "@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.21.5", "", { "os": "linux", "cpu": "ia32" }, "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg=="], + + "@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg=="], + + "@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg=="], + + "@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.21.5", "", { "os": "linux", "cpu": "ppc64" }, "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w=="], + + "@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.21.5", "", { "os": "linux", "cpu": "none" }, "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA=="], + + "@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.21.5", "", { "os": "linux", "cpu": "s390x" }, "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A=="], + + "@esbuild/linux-x64": ["@esbuild/linux-x64@0.21.5", "", { "os": "linux", "cpu": "x64" }, "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ=="], + + "@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.21.5", "", { "os": "none", "cpu": "x64" }, "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg=="], + + "@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.21.5", "", { "os": "openbsd", "cpu": "x64" }, "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow=="], + + "@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.21.5", "", { "os": "sunos", "cpu": "x64" }, "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg=="], + + "@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.21.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A=="], + + "@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.21.5", "", { "os": "win32", "cpu": "ia32" }, "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA=="], + + "@esbuild/win32-x64": ["@esbuild/win32-x64@0.21.5", "", { "os": "win32", "cpu": "x64" }, "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw=="], + + "@jridgewell/gen-mapping": ["@jridgewell/gen-mapping@0.3.13", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="], + + "@jridgewell/remapping": ["@jridgewell/remapping@2.3.5", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ=="], + + "@jridgewell/resolve-uri": ["@jridgewell/resolve-uri@3.1.2", "", {}, "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="], + + "@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.5", "", {}, "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og=="], + + "@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="], + + "@rolldown/pluginutils": ["@rolldown/pluginutils@1.0.0-beta.27", "", {}, "sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA=="], + + "@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.62.2", "", { "os": "android", "cpu": "arm" }, "sha512-6o7ZLZK+BeenkZCFNDXqpbjw9bD6nuWonvS/lwQJp7NoVVxm6p3qE7qQ5jGuBjiFsgvqjD8mZAU5oWxTmbOeOg=="], + + "@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.62.2", "", { "os": "android", "cpu": "arm64" }, "sha512-BaH7BllCACHoH1LguOU56UItGfUWjujlO65kS9LAodViaN4bwIKd7oeW/ZHJ/4ljr/7MIiENnNy3HJ0zXv8Zkw=="], + + "@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.62.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-v39RCCvj4He82I9sFmk+M1VZ0PLM9sfsLVikjfx2hYBNALhrrOR2D3JjQA6AhlaSOgcR+RzrKY7e1+bT6SUO/A=="], + + "@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.62.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-yl0y2vq3S3lHeuXhEdss6TWfKW8vkujImO12tn4ZkG/4oghr09LvdYm2RElVjokTQiUvDUGXLGsYeLqUMCKpGA=="], + + "@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.62.2", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-tT4pvt4qXD+vEoezupCWi+a1F0vvDiksiHc+PxRlYTOH1I6/X4id9jPxTP+Fg+545euaFT1jJVs4CEdHZAU1vw=="], + + "@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.62.2", "", { "os": "freebsd", "cpu": "x64" }, "sha512-6nU5F2wCW+qvCBhTn1pdIU3bzsIoF7EUwsCDRxilWGprQR6yd508YnH9+OKFCwpfS8pjZqDUmnCAr7exax0XCg=="], + + "@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.62.2", "", { "os": "linux", "cpu": "arm" }, "sha512-n1GJHPOvpIfhi3TmrCeh6S6URt9BFCt0KQE3qvexyGCTAKpR4Lg+eWvNZEqu7epxwus/8ElT3hacYEucm49SZg=="], + + "@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.62.2", "", { "os": "linux", "cpu": "arm" }, "sha512-JqgflS8wEB+UXV/vS1RpRbifGBeN4D5lz8D8oOFbFZw4vedvdOgCFAjfBmIMdW3yL10XpQQ0Ambepw6MXrhOnA=="], + + "@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.62.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-wnFJkogWvN4jm/hQRF2UBaeUmk20j5+DmHvoyWii2b8HJDyvz1MF2OU/6ynXt2KR63rbZLWkFpoytpdc/yBuSA=="], + + "@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.62.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-HVu2bp0zhvJ8xHEV9+UUs7S90VadmBSY3LcIMvozbPo4AuMGDWlz3ymHLHZPX4hR67TKTt8Qp5PJ5RBg/i+RMQ=="], + + "@rollup/rollup-linux-loong64-gnu": ["@rollup/rollup-linux-loong64-gnu@4.62.2", "", { "os": "linux", "cpu": "none" }, "sha512-mQqqAV8QaoSgr9I2fKDLY2BAVvmKjWoGiu/cSYQonsLvtqwEn1E4QYfnCOcp5zoEqNhsDYin1s6jx/VJmrxlZg=="], + + "@rollup/rollup-linux-loong64-musl": ["@rollup/rollup-linux-loong64-musl@4.62.2", "", { "os": "linux", "cpu": "none" }, "sha512-IxKLoxCQ2IWi6bT2akyDUBGsOImDKB+sPp4EsTmwFQ/fMwpCKm8uLSSgP/Kx/QYUgKis6SEZ5/Nlhup0DIA0PQ=="], + + "@rollup/rollup-linux-ppc64-gnu": ["@rollup/rollup-linux-ppc64-gnu@4.62.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-Mk5ha2RQSgyFfmYYLkBpPnUk8D8FriBxesO1u9O75X0mHgXL1UQcH5Itl2lurWL2tj0RxV9b9tJgipac0hRY9A=="], + + "@rollup/rollup-linux-ppc64-musl": ["@rollup/rollup-linux-ppc64-musl@4.62.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-CjvEnqJL/0/TQ3TXX3OPIJ/kmBellrWd4heXUmHeJlTnmwjKpSJzoehLaL6Xk0ZnMHBu9dZuFADNOrtjF4v+2w=="], + + "@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.62.2", "", { "os": "linux", "cpu": "none" }, "sha512-1SiZbzwdkaDURsew/tSOrooKiYy7EQGT6m8ufavAi9NEyQb/6VuIxFXAL1fqa4iZe3g4NbNk4P7J32z2tw5Mgg=="], + + "@rollup/rollup-linux-riscv64-musl": ["@rollup/rollup-linux-riscv64-musl@4.62.2", "", { "os": "linux", "cpu": "none" }, "sha512-nQts12zJ3NQRoE6uYljOH89v7szzLDvG2JD/vsX+vGXU8w/At1GowTZ5/7qeFQ8m7L55rpR8Okugnuo5bgjy2Q=="], + + "@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.62.2", "", { "os": "linux", "cpu": "s390x" }, "sha512-E9/ll019jhPIJgpzfZoIkBGhcz+kKNgVWYRY0zr9srBdPPFVpvOKW8VaJKUbeK+eZXyQF9ltME+Kk6affeaPgg=="], + + "@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.62.2", "", { "os": "linux", "cpu": "x64" }, "sha512-5BqxR/pshjey51iliyzTD5Xi3EN0aLmQ2lZ3lvefVV9c82BvrLo2/6OT55iifpWBufs6kdwWbuOKS841DrmK9A=="], + + "@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.62.2", "", { "os": "linux", "cpu": "x64" }, "sha512-uNN83XxQrRAh/w0/pmAfibcwyb6YWt4gP+dpnQKPVJshAloQ785ii8CT8ZCIxkGg9opVsvAlGhFitSm6D1Jjpg=="], + + "@rollup/rollup-openbsd-x64": ["@rollup/rollup-openbsd-x64@4.62.2", "", { "os": "openbsd", "cpu": "x64" }, "sha512-srjEIxSH3LRnJN6THczDHWQplqEMFiAJrTab0msUryh9kwNpkICf3Ea6q6MN/2cZwRFUNx5w+h6Hpi4QuHS6Zg=="], + + "@rollup/rollup-openharmony-arm64": ["@rollup/rollup-openharmony-arm64@4.62.2", "", { "os": "none", "cpu": "arm64" }, "sha512-8hOJnxgbyObnCm5AlRA3A931xX19xq80RjVTKgJOvEKWqJruP/Uf12IbAOaDjjEXYRewwHLfmF0YRIdK3OwKWA=="], + + "@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.62.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-mmF4AY1i0hG/bLWUctUq59gtmgaSIRa3cu/A3JFRp/sCNEme2bgDEiDS22P9FbnJB8NJNF4jPJiSP5RHQpUTDg=="], + + "@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.62.2", "", { "os": "win32", "cpu": "ia32" }, "sha512-DZgkknc6jhHrk46V25vbAM0zZkyP0nSDkJB8/dRkLTxv470dOmWDqGoEJl/9A0dFfS7yE3REOwNDxpHwSLSt0Q=="], + + "@rollup/rollup-win32-x64-gnu": ["@rollup/rollup-win32-x64-gnu@4.62.2", "", { "os": "win32", "cpu": "x64" }, "sha512-T6xr6ucWSFto+VGajA8YH26LdpHRuP4YLHEKAtCWvJDOlnmWcDZVCI2Jmjr+IFHDlt2zRaTAKE4tfjTaWLgJBg=="], + + "@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.62.2", "", { "os": "win32", "cpu": "x64" }, "sha512-BfzEnDJOt9T8M989/lA37EcJgat01wLRnoi5dQf3QzOH7jzpqTAzdDbVfRljVr5r+jzKqpbHeyOfAaXxAd0PAA=="], + + "@types/babel__core": ["@types/babel__core@7.20.5", "", { "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", "@types/babel__generator": "*", "@types/babel__template": "*", "@types/babel__traverse": "*" } }, "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA=="], + + "@types/babel__generator": ["@types/babel__generator@7.27.0", "", { "dependencies": { "@babel/types": "^7.0.0" } }, "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg=="], + + "@types/babel__template": ["@types/babel__template@7.4.4", "", { "dependencies": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" } }, "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A=="], + + "@types/babel__traverse": ["@types/babel__traverse@7.28.0", "", { "dependencies": { "@babel/types": "^7.28.2" } }, "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q=="], + + "@types/estree": ["@types/estree@1.0.9", "", {}, "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg=="], + + "@vitejs/plugin-react": ["@vitejs/plugin-react@4.7.0", "", { "dependencies": { "@babel/core": "^7.28.0", "@babel/plugin-transform-react-jsx-self": "^7.27.1", "@babel/plugin-transform-react-jsx-source": "^7.27.1", "@rolldown/pluginutils": "1.0.0-beta.27", "@types/babel__core": "^7.20.5", "react-refresh": "^0.17.0" }, "peerDependencies": { "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" } }, "sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA=="], + + "baseline-browser-mapping": ["baseline-browser-mapping@2.10.38", "", { "bin": { "baseline-browser-mapping": "dist/cli.cjs" } }, "sha512-31/02mVB4yuQU6adKk5SlY6m+mxDwUq5KZkyYgnLrrKl7TEm1+3PyDtDBz2kOv/wxZz41GHsvV1A/u6RmiyBvw=="], + + "browserslist": ["browserslist@4.28.4", "", { "dependencies": { "baseline-browser-mapping": "^2.10.38", "caniuse-lite": "^1.0.30001799", "electron-to-chromium": "^1.5.376", "node-releases": "^2.0.48", "update-browserslist-db": "^1.2.3" }, "bin": { "browserslist": "cli.js" } }, "sha512-MTc8i/x9jBQd1iMw2CFGS+rwMa07eYjLR0CCTLDACl9xhxy+nIs3KeML/biicXtk9JrZ6dnnTatmc7ErPXIxqw=="], + + "caniuse-lite": ["caniuse-lite@1.0.30001799", "", {}, "sha512-hG1bReV+OUU+MOqK4t/ZWI0tZOyz3rqS9XuhOUz1cIcbwBKjOyJEJuw9ER5JuNyqxNk8u/JUVbGibBOL1yrjFw=="], + + "convert-source-map": ["convert-source-map@2.0.0", "", {}, "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="], + + "debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" }, "peerDependencies": { "supports-color": "*" }, "optionalPeers": ["supports-color"] }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="], + + "electron-to-chromium": ["electron-to-chromium@1.5.378", "", {}, "sha512-VinvOAuuPmdD1guEgGv5f2Qp7/vlfqOrUOMYNnOD4wj3pit8kRsQHzfIf6teyUGWo15Tg5+bOJaRunvyltpVWQ=="], + + "esbuild": ["esbuild@0.21.5", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.21.5", "@esbuild/android-arm": "0.21.5", "@esbuild/android-arm64": "0.21.5", "@esbuild/android-x64": "0.21.5", "@esbuild/darwin-arm64": "0.21.5", "@esbuild/darwin-x64": "0.21.5", "@esbuild/freebsd-arm64": "0.21.5", "@esbuild/freebsd-x64": "0.21.5", "@esbuild/linux-arm": "0.21.5", "@esbuild/linux-arm64": "0.21.5", "@esbuild/linux-ia32": "0.21.5", "@esbuild/linux-loong64": "0.21.5", "@esbuild/linux-mips64el": "0.21.5", "@esbuild/linux-ppc64": "0.21.5", "@esbuild/linux-riscv64": "0.21.5", "@esbuild/linux-s390x": "0.21.5", "@esbuild/linux-x64": "0.21.5", "@esbuild/netbsd-x64": "0.21.5", "@esbuild/openbsd-x64": "0.21.5", "@esbuild/sunos-x64": "0.21.5", "@esbuild/win32-arm64": "0.21.5", "@esbuild/win32-ia32": "0.21.5", "@esbuild/win32-x64": "0.21.5" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw=="], + + "escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="], + + "fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="], + + "gensync": ["gensync@1.0.0-beta.2", "", {}, "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg=="], + + "js-tokens": ["js-tokens@4.0.0", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="], + + "jsesc": ["jsesc@3.1.0", "", { "bin": { "jsesc": "bin/jsesc" } }, "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA=="], + + "json5": ["json5@2.2.3", "", { "bin": { "json5": "lib/cli.js" } }, "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="], + + "loose-envify": ["loose-envify@1.4.0", "", { "dependencies": { "js-tokens": "^3.0.0 || ^4.0.0" }, "bin": { "loose-envify": "cli.js" } }, "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q=="], + + "lru-cache": ["lru-cache@5.1.1", "", { "dependencies": { "yallist": "^3.0.2" } }, "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=="], + + "ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="], + + "nanoid": ["nanoid@3.3.15", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-y7Wygv/7mEOvxTuEQDB8StXdMRBWf1kR/tlhAzBRUFkB2jfcLOAxO/SHmOO2zgz1pVgK29/kyupn059/bCHdjA=="], + + "node-releases": ["node-releases@2.0.49", "", {}, "sha512-f06bl1D+8ZDkn2oOQQKAh5/otFWqVnM1Q5oerA8Pex7UfT66Tx4IPHIqVVFKqFT3FUtaDstdgkM7yT7JWhqxfw=="], + + "picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="], + + "postcss": ["postcss@8.5.15", "", { "dependencies": { "nanoid": "^3.3.12", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A=="], + + "react": ["react@18.3.1", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ=="], + + "react-dom": ["react-dom@18.3.1", "", { "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.2" }, "peerDependencies": { "react": "^18.3.1" } }, "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw=="], + + "react-refresh": ["react-refresh@0.17.0", "", {}, "sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ=="], + + "rollup": ["rollup@4.62.2", "", { "dependencies": { "@types/estree": "1.0.9" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.62.2", "@rollup/rollup-android-arm64": "4.62.2", "@rollup/rollup-darwin-arm64": "4.62.2", "@rollup/rollup-darwin-x64": "4.62.2", "@rollup/rollup-freebsd-arm64": "4.62.2", "@rollup/rollup-freebsd-x64": "4.62.2", "@rollup/rollup-linux-arm-gnueabihf": "4.62.2", "@rollup/rollup-linux-arm-musleabihf": "4.62.2", "@rollup/rollup-linux-arm64-gnu": "4.62.2", "@rollup/rollup-linux-arm64-musl": "4.62.2", "@rollup/rollup-linux-loong64-gnu": "4.62.2", "@rollup/rollup-linux-loong64-musl": "4.62.2", "@rollup/rollup-linux-ppc64-gnu": "4.62.2", "@rollup/rollup-linux-ppc64-musl": "4.62.2", "@rollup/rollup-linux-riscv64-gnu": "4.62.2", "@rollup/rollup-linux-riscv64-musl": "4.62.2", "@rollup/rollup-linux-s390x-gnu": "4.62.2", "@rollup/rollup-linux-x64-gnu": "4.62.2", "@rollup/rollup-linux-x64-musl": "4.62.2", "@rollup/rollup-openbsd-x64": "4.62.2", "@rollup/rollup-openharmony-arm64": "4.62.2", "@rollup/rollup-win32-arm64-msvc": "4.62.2", "@rollup/rollup-win32-ia32-msvc": "4.62.2", "@rollup/rollup-win32-x64-gnu": "4.62.2", "@rollup/rollup-win32-x64-msvc": "4.62.2", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-RFnrW4lhXA3s3eqHDZvN654g8OTjzRfqpIRJYczCGB6HzphckVAi/Qh4tbPUbRuDi7s1Llv8g/NspLkttY3gTA=="], + + "scheduler": ["scheduler@0.23.2", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ=="], + + "semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="], + + "source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="], + + "update-browserslist-db": ["update-browserslist-db@1.2.3", "", { "dependencies": { "escalade": "^3.2.0", "picocolors": "^1.1.1" }, "peerDependencies": { "browserslist": ">= 4.21.0" }, "bin": { "update-browserslist-db": "cli.js" } }, "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w=="], + + "vite": ["vite@5.4.21", "", { "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", "rollup": "^4.20.0" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || >=20.0.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.4.0" }, "optionalPeers": ["@types/node", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser"], "bin": { "vite": "bin/vite.js" } }, "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw=="], + + "yallist": ["yallist@3.1.1", "", {}, "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="], + } +} diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..454194d --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,12 @@ + + + + + + Archivr + + +
+ + + diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..d0eb12c --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,19 @@ +{ + "name": "archivr-frontend", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "react": "^18.3.1", + "react-dom": "^18.3.1" + }, + "devDependencies": { + "@vitejs/plugin-react": "^4.3.4", + "vite": "^5.4.11" + } +} diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx new file mode 100644 index 0000000..321477d --- /dev/null +++ b/frontend/src/App.jsx @@ -0,0 +1,202 @@ +import { useState, useEffect, useCallback, useRef } from 'react' +import { fetchArchives, fetchEntries, searchEntries, fetchRuns, fetchTags } from './api' +import Topbar from './components/Topbar' +import CaptureDialog from './components/CaptureDialog' +import EntriesView from './components/EntriesView' +import RunsView from './components/RunsView' +import AdminView from './components/AdminView' +import TagsView from './components/TagsView' +import ContextRail from './components/ContextRail' + +export default function App() { + const [archives, setArchives] = useState([]) + const [archiveId, setArchiveId] = useState(null) + const [entries, setEntries] = useState([]) + const [selectedEntryUid, setSelectedEntryUid] = useState(null) + const [selectedEntry, setSelectedEntry] = useState(null) + const [tagFilter, setTagFilter] = useState(null) + const [view, setView] = useState('archive') + const [searchQuery, setSearchQuery] = useState('') + const [resultCount, setResultCount] = useState('') + const [searchBusy, setSearchBusy] = useState(false) + const [runs, setRuns] = useState([]) + const [tagNodes, setTagNodes] = useState([]) + const [captureDialogOpen, setCaptureDialogOpen] = useState(false) + + const loadEntries = useCallback(async (aid, q, tag) => { + if (!aid) return + setSearchBusy(true) + try { + let results + if (q || tag) { + results = await searchEntries(aid, q, tag) + } else { + results = await fetchEntries(aid) + } + setEntries(results) + setResultCount(results.length === 0 ? 'No results' : `${results.length} result${results.length === 1 ? '' : 's'}`) + } catch { + setEntries([]) + setResultCount('Search failed. Try again.') + } finally { + setSearchBusy(false) + } + }, []) + + // Mount: load archives, pick first, then parallel load + useEffect(() => { + fetchArchives().then(list => { + setArchives(list) + if (list.length > 0) { + const first = list[0].id + setArchiveId(first) + } + }) + }, []) + + // Archive change: parallel load entries + runs + tags + useEffect(() => { + if (!archiveId) return + setTagFilter(null) + setSelectedEntry(null) + setSelectedEntryUid(null) + Promise.all([ + loadEntries(archiveId, '', null), + fetchRuns(archiveId).then(setRuns), + fetchTags(archiveId).then(setTagNodes), + ]) + }, [archiveId]) // intentionally not including loadEntries to avoid re-running on its recreation + + // Debounced search + useEffect(() => { + if (archiveId === null) return + const timer = setTimeout(() => { + loadEntries(archiveId, searchQuery, tagFilter) + }, 300) + return () => clearTimeout(timer) + }, [searchQuery, archiveId]) // tagFilter handled separately below + + // Tag filter change: switch to archive view, reload + useEffect(() => { + if (archiveId === null) return + setView('archive') + loadEntries(archiveId, searchQuery, tagFilter) + }, [tagFilter, archiveId]) // intentional: searchQuery excluded to avoid double-fire + + const handleArchiveChange = useCallback((id) => { + setArchiveId(id) + }, []) + + const handleViewChange = useCallback((name) => { + setView(name) + if (name === 'tags' && archiveId) { + fetchTags(archiveId).then(setTagNodes) + } + }, [archiveId]) + + const selectEntry = useCallback((entry) => { + setSelectedEntryUid(entry ? entry.entry_uid : null) + setSelectedEntry(entry) + }, []) + + const handleTagFilterSet = useCallback((fullPath) => { + setTagFilter(fullPath) + }, []) + + const handleClearTagFilter = useCallback(() => { + setTagFilter(null) + }, []) + + const handleTagsRefresh = useCallback(() => { + if (archiveId) fetchTags(archiveId).then(setTagNodes) + }, [archiveId]) + + const handleCaptureClick = useCallback(() => { + setCaptureDialogOpen(true) + }, []) + + const handleCaptureClose = useCallback(() => { + setCaptureDialogOpen(false) + }, []) + + const handleCaptured = useCallback(() => { + if (!archiveId) return + Promise.all([ + loadEntries(archiveId, searchQuery, tagFilter), + fetchRuns(archiveId).then(setRuns), + ]) + }, [archiveId, searchQuery, tagFilter, loadEntries]) + + return ( + <> + +
+
+ {view === 'archive' && ( +
+ setSearchQuery(e.target.value)} + /> +
+ {resultCount} + {tagFilter && ( + + )} +
+
+ )} + {view === 'archive' && ( + + )} + {view === 'runs' && } + {view === 'admin' && } + {view === 'tags' && ( + + )} +
+ +
+ + + ) +} diff --git a/frontend/src/api.js b/frontend/src/api.js new file mode 100644 index 0000000..0ce034b --- /dev/null +++ b/frontend/src/api.js @@ -0,0 +1,70 @@ +async function getJson(url) { + const response = await fetch(url); + if (!response.ok) { + throw new Error(`${response.status} ${response.statusText}`); + } + return response.json(); +} + +export async function fetchArchives() { + return getJson("/api/archives"); +} + +export async function fetchEntries(archiveId) { + return getJson(`/api/archives/${archiveId}/entries`); +} + +export async function searchEntries(archiveId, q, tag) { + const params = new URLSearchParams(); + if (q) params.set("q", q); + if (tag) params.set("tag", tag); + return getJson(`/api/archives/${archiveId}/entries/search?${params}`); +} + +export async function fetchEntryDetail(archiveId, entryUid) { + return getJson(`/api/archives/${archiveId}/entries/${entryUid}`); +} + +export async function fetchEntryTags(archiveId, entryUid) { + return getJson(`/api/archives/${archiveId}/entries/${entryUid}/tags`); +} + +export async function assignTag(archiveId, entryUid, tagPath) { + const resp = await fetch( + `/api/archives/${archiveId}/entries/${entryUid}/tags`, + { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ tag_path: tagPath }), + } + ); + if (!resp.ok) throw new Error(`Failed to add tag (${resp.status})`); +} + +export async function removeTag(archiveId, entryUid, tagUid) { + const resp = await fetch( + `/api/archives/${archiveId}/entries/${entryUid}/tags/${tagUid}`, + { method: "DELETE" } + ); + if (!resp.ok) throw new Error(`Remove failed (${resp.status})`); +} + +export async function fetchRuns(archiveId) { + return getJson(`/api/archives/${archiveId}/runs`); +} + +export async function fetchTags(archiveId) { + return getJson(`/api/archives/${archiveId}/tags`); +} + +export async function submitCapture(archiveId, locator) { + const res = await fetch(`/api/archives/${archiveId}/captures`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ locator }), + }); + if (!res.ok) { + const msg = await res.text(); + throw new Error(msg || `HTTP ${res.status}`); + } +} diff --git a/frontend/src/components/AdminView.jsx b/frontend/src/components/AdminView.jsx new file mode 100644 index 0000000..f9520c2 --- /dev/null +++ b/frontend/src/components/AdminView.jsx @@ -0,0 +1,15 @@ +export default function AdminView({ archives }) { + return ( +
+

Mounted Archives

+
+ {archives.map(archive => ( +
+ {archive.label} +
{archive.archive_path}
+
+ ))} +
+
+ ) +} diff --git a/frontend/src/components/CaptureDialog.jsx b/frontend/src/components/CaptureDialog.jsx new file mode 100644 index 0000000..9a6c73c --- /dev/null +++ b/frontend/src/components/CaptureDialog.jsx @@ -0,0 +1,65 @@ +import { useRef, useEffect, useState } from 'react' +import { submitCapture } from '../api' + +export default function CaptureDialog({ open, archiveId, onClose, onCaptured }) { + const dialogRef = useRef(null) + const [locator, setLocator] = useState('') + const [error, setError] = useState(null) + const [busy, setBusy] = useState(false) + + useEffect(() => { + const dialog = dialogRef.current + if (!dialog) return + const handleClose = () => onClose() + dialog.addEventListener('close', handleClose) + return () => dialog.removeEventListener('close', handleClose) + }, [onClose]) + + useEffect(() => { + const dialog = dialogRef.current + if (!dialog) return + if (open) { + setLocator('') + setError(null) + if (!dialog.open) dialog.showModal() + } else { + if (dialog.open) dialog.close() + } + }, [open]) + + async function handleSubmit() { + if (!locator.trim()) { setError('Enter a locator.'); return } + setBusy(true) + setError(null) + try { + await submitCapture(archiveId, locator.trim()) + dialogRef.current?.close() + onCaptured() + } catch (e) { + setError(e.message) + } finally { + setBusy(false) + } + } + + return ( + +
+

Capture

+ + setLocator(e.target.value)} + onKeyDown={e => { if (e.key === 'Enter') handleSubmit() }} + autoComplete="off" /> + {error &&
{error}
} +
+ + +
+
+
+ ) +} diff --git a/frontend/src/components/ContextRail.jsx b/frontend/src/components/ContextRail.jsx new file mode 100644 index 0000000..ff497fc --- /dev/null +++ b/frontend/src/components/ContextRail.jsx @@ -0,0 +1,163 @@ +import { useState, useEffect, useRef } from 'react' +import { fetchEntryDetail, fetchEntryTags, assignTag, removeTag } from '../api' +import { formatTimestamp, formatBytes, valueText } from '../utils' + +export default function ContextRail({ archiveId, selectedEntry, onTagFilterSet, tagNodes, onTagsRefresh }) { + const [detail, setDetail] = useState(null) + const [tags, setTags] = useState([]) + const [assignInput, setAssignInput] = useState('') + const [assignError, setAssignError] = useState('') + const selectSeqRef = useRef(0) + + useEffect(() => { + if (!selectedEntry || !archiveId) { + setDetail(null) + setTags([]) + return + } + const seq = ++selectSeqRef.current + setDetail(null) + setTags([]) + Promise.all([ + fetchEntryDetail(archiveId, selectedEntry.entry_uid), + fetchEntryTags(archiveId, selectedEntry.entry_uid), + ]).then(([det, tgs]) => { + if (seq !== selectSeqRef.current) return + setDetail(det) + setTags(tgs) + }).catch(() => {}) + }, [selectedEntry, archiveId]) + + async function handleAssignTag() { + const path = assignInput.trim() + if (!path || !selectedEntry) return + try { + await assignTag(archiveId, selectedEntry.entry_uid, path) + setAssignInput('') + setAssignError('') + const updated = await fetchEntryTags(archiveId, selectedEntry.entry_uid) + setTags(updated) + onTagsRefresh() + } catch (e) { + setAssignError(e.message) + } + } + + async function handleRemoveTag(tagUid) { + try { + await removeTag(archiveId, selectedEntry.entry_uid, tagUid) + const updated = await fetchEntryTags(archiveId, selectedEntry.entry_uid) + setTags(updated) + onTagsRefresh() + } catch (e) { + // silently ignore for now; could add error state + } + } + + return ( + + ) +} diff --git a/frontend/src/components/EntriesView.jsx b/frontend/src/components/EntriesView.jsx new file mode 100644 index 0000000..72e47f9 --- /dev/null +++ b/frontend/src/components/EntriesView.jsx @@ -0,0 +1,27 @@ +import EntryRow from './EntryRow'; + +export default function EntriesView({ entries, selectedEntryUid, onSelectEntry }) { + return ( +
+
+
+
Added
+
Title
+
Type
+
Size
+
Original URL
+
+
+ {entries.map(entry => ( + onSelectEntry(entry)} + /> + ))} +
+
+
+ ); +} diff --git a/frontend/src/components/EntryRow.jsx b/frontend/src/components/EntryRow.jsx new file mode 100644 index 0000000..b5dc03c --- /dev/null +++ b/frontend/src/components/EntryRow.jsx @@ -0,0 +1,24 @@ +import { formatTimestamp, formatBytes, valueText, sourceIconSvg } from '../utils'; + +export default function EntryRow({ entry, isSelected, onSelect }) { + return ( +
{ if (e.key === 'Enter') onSelect(); }} + > +
{formatTimestamp(entry.archived_at)}
+
+ + {valueText(entry.title) || valueText(entry.entry_uid)} +
+
+ {valueText(entry.entity_kind)} +
+
{formatBytes(entry.total_artifact_bytes)}
+
{valueText(entry.original_url)}
+
+ ); +} diff --git a/frontend/src/components/RunsView.jsx b/frontend/src/components/RunsView.jsx new file mode 100644 index 0000000..4e843c7 --- /dev/null +++ b/frontend/src/components/RunsView.jsx @@ -0,0 +1,24 @@ +export default function RunsView({ runs }) { + return ( +
+ + + + + + + + {runs.map((run, i) => ( + + + + + + + + ))} + +
StartedStatusRequestedCompletedFailed
{run.started_at ?? ''}{run.status ?? ''}{run.requested_count ?? ''}{run.completed_count ?? ''}{run.failed_count ?? ''}
+
+ ) +} diff --git a/frontend/src/components/TagsView.jsx b/frontend/src/components/TagsView.jsx new file mode 100644 index 0000000..3afe8e7 --- /dev/null +++ b/frontend/src/components/TagsView.jsx @@ -0,0 +1,47 @@ +function TagNode({ node, tagFilter, onTagFilterSet, onViewChange }) { + const isActive = tagFilter === node.tag.full_path + function handleClick() { + const next = isActive ? null : node.tag.full_path + onTagFilterSet(next) + onViewChange('archive') + } + return ( +
  • + + {node.children?.length > 0 && ( +
    +
      + {node.children.map(child => ( + + ))} +
    +
    + )} +
  • + ) +} + +export default function TagsView({ tagNodes, tagFilter, onTagFilterSet, onViewChange }) { + return ( +
    +
    + {tagNodes.length === 0 ? ( +
    No tags yet.
    + ) : ( +
      + {tagNodes.map(node => ( + + ))} +
    + )} +
    +
    + ) +} diff --git a/frontend/src/components/Topbar.jsx b/frontend/src/components/Topbar.jsx new file mode 100644 index 0000000..b81d72a --- /dev/null +++ b/frontend/src/components/Topbar.jsx @@ -0,0 +1,20 @@ +export default function Topbar({ archives, archiveId, onArchiveChange, view, onViewChange, onCaptureClick }) { + return ( +
    +
    Archivr
    + + + +
    + ) +} diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx new file mode 100644 index 0000000..6f68ebc --- /dev/null +++ b/frontend/src/main.jsx @@ -0,0 +1,8 @@ +import { StrictMode } from 'react' +import { createRoot } from 'react-dom/client' +import './styles.css' +import App from './App' + +createRoot(document.getElementById('root')).render( + +) diff --git a/crates/archivr-server/static/styles.css b/frontend/src/styles.css similarity index 100% rename from crates/archivr-server/static/styles.css rename to frontend/src/styles.css diff --git a/frontend/src/utils.js b/frontend/src/utils.js new file mode 100644 index 0000000..24d600d --- /dev/null +++ b/frontend/src/utils.js @@ -0,0 +1,40 @@ +export function formatBytes(bytes) { + if (!bytes) return "0 B"; + const units = ["B", "KB", "MB", "GB"]; + let size = bytes; + let unit = 0; + while (size >= 1024 && unit < units.length - 1) { + size /= 1024; + unit += 1; + } + return `${size.toFixed(unit === 0 ? 0 : 1)} ${units[unit]}`; +} + +export function valueText(value) { + return value ?? ""; +} + +export function formatTimestamp(value) { + if (!value) return ""; + const d = new Date(value); + if (isNaN(d)) return value; + const pad = (n) => String(n).padStart(2, "0"); + return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`; +} + +export const SOURCE_ICONS = { + youtube: ``, + x: ``, + instagram: ``, + facebook: ``, + tiktok: ``, + reddit: ``, + snapchat: ``, + local: ``, + web: ``, + other: `?`, +}; + +export function sourceIconSvg(kind) { + return SOURCE_ICONS[kind] ?? SOURCE_ICONS.other; +} diff --git a/frontend/vite.config.js b/frontend/vite.config.js new file mode 100644 index 0000000..6281e6b --- /dev/null +++ b/frontend/vite.config.js @@ -0,0 +1,11 @@ +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; + +export default defineConfig({ + plugins: [react()], + build: { + outDir: "../crates/archivr-server/static", + emptyOutDir: false, + assetsDir: "assets", + }, +}); From a76dcf647f11aff54e2da122f5aa04623bcd3644 Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:31:56 +0200 Subject: [PATCH 7/9] fix(server): serve /assets/* from static_dir/assets/ for Vite output --- crates/archivr-server/src/routes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/archivr-server/src/routes.rs b/crates/archivr-server/src/routes.rs index 014544a..f856c48 100644 --- a/crates/archivr-server/src/routes.rs +++ b/crates/archivr-server/src/routes.rs @@ -78,7 +78,7 @@ pub fn app(registry: ServerRegistry) -> Router { "/api/archives/:archive_id/entries/:entry_uid/tags/:tag_uid", delete(remove_entry_tag_handler), ) - .nest_service("/assets", ServeDir::new(&static_dir)) + .nest_service("/assets", ServeDir::new(static_dir.join("assets"))) .fallback_service(ServeFile::new(static_dir.join("index.html"))) .with_state(state) } From 03abfb4d18cc3bd6f01435a34e536850296f5939 Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Wed, 24 Jun 2026 14:37:08 +0200 Subject: [PATCH 8/9] feat(core): generic HTTP/S file URL capture (Track 1) - Add crates/archivr-core/src/downloader/http.rs - download(url, store_path, timestamp) -> Result<(hash, extension)> - Rejects text/html responses with a clear error - Derives extension from URL path or Content-Type header - Follows redirects (capped at 10), user-agent archivr/0.1 - 10 unit tests for extension/content-type helpers - Add Source::Url variant to capture::Source enum - determine_source: unmatched http/https URLs route to Source::Url - source_metadata: Source::Url => ("web", "file", "file") - generate_entry_title: Source::Url arm -> "Downloaded File" fallback - perform_capture: Source::Url arm calls http::download, uses existing temp -> hash_exists -> move_temp_to_raw -> record_media_entry pipeline - Update test expectations: 3 plain https:// cases now expect Source::Url - Add reqwest 0.12 (blocking) to workspace and archivr-core deps - Mark URLs milestone done in docs/README.md - Update NEXT.md Track 1 status --- Cargo.lock | 799 ++++++++++++++++++++- Cargo.toml | 1 + crates/archivr-core/Cargo.toml | 1 + crates/archivr-core/src/capture.rs | 69 +- crates/archivr-core/src/downloader/http.rs | 163 +++++ crates/archivr-core/src/downloader/mod.rs | 1 + docs/README.md | 2 +- 7 files changed, 1017 insertions(+), 19 deletions(-) create mode 100644 crates/archivr-core/src/downloader/http.rs diff --git a/Cargo.lock b/Cargo.lock index e220753..d024ee2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,6 +109,7 @@ dependencies = [ "chrono", "hex", "regex", + "reqwest", "rusqlite", "serde", "serde_json", @@ -210,6 +211,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bitflags" version = "2.11.1" @@ -312,6 +319,26 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -347,6 +374,26 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "displaydoc" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -360,7 +407,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -387,6 +434,27 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.2" @@ -403,6 +471,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -411,6 +480,12 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + [[package]] name = "futures-sink" version = "0.3.32" @@ -430,7 +505,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" dependencies = [ "futures-core", + "futures-io", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "slab", ] @@ -445,6 +523,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.3.3" @@ -457,6 +546,25 @@ dependencies = [ "wasi 0.14.7+wasi-0.2.4", ] +[[package]] +name = "h2" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cb093c84e8bd9b188d4c4a8cb6579fc016968d14c99882163cd3ff402a4f155" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.14.5" @@ -554,6 +662,7 @@ dependencies = [ "bytes", "futures-channel", "futures-core", + "h2", "http", "http-body", "httparse", @@ -562,6 +671,38 @@ dependencies = [ "pin-project-lite", "smallvec", "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", ] [[package]] @@ -570,13 +711,23 @@ version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" dependencies = [ + "base64", "bytes", + "futures-channel", + "futures-util", "http", "http-body", "hyper", + "ipnet", + "libc", + "percent-encoding", "pin-project-lite", + "socket2", + "system-configuration", "tokio", "tower-service", + "tracing", + "windows-registry", ] [[package]] @@ -603,6 +754,108 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "indexmap" version = "2.14.0" @@ -613,6 +866,12 @@ dependencies = [ "hashbrown 0.17.1", ] +[[package]] +name = "ipnet" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -667,6 +926,12 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" +[[package]] +name = "litemap" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" + [[package]] name = "log" version = "0.4.28" @@ -712,6 +977,23 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "native-tls" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -733,6 +1015,49 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" +[[package]] +name = "openssl" +version = "0.10.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "percent-encoding" version = "2.3.2" @@ -751,6 +1076,15 @@ version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + [[package]] name = "proc-macro2" version = "1.0.101" @@ -804,6 +1138,62 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "js-sys", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-native-tls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rusqlite" version = "0.32.1" @@ -828,7 +1218,40 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.60.2", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b92b125634d9b795e7beca796cc790df15a7fb38323bf3196fda83292d06b1f" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] @@ -843,6 +1266,38 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation 0.10.1", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "serde" version = "1.0.228" @@ -953,15 +1408,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.106" @@ -978,6 +1445,41 @@ name = "sync_wrapper" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "system-configuration" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" +dependencies = [ + "bitflags", + "core-foundation 0.9.4", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] [[package]] name = "tempfile" @@ -986,10 +1488,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom", + "getrandom 0.3.3", "once_cell", "rustix", - "windows-sys 0.60.2", + "windows-sys 0.61.2", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", ] [[package]] @@ -1018,6 +1530,26 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.18" @@ -1109,9 +1641,11 @@ dependencies = [ "pin-project-lite", "tokio", "tokio-util", + "tower", "tower-layer", "tower-service", "tracing", + "url", ] [[package]] @@ -1146,6 +1680,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.19.0" @@ -1164,6 +1704,30 @@ version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -1176,7 +1740,7 @@ version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" dependencies = [ - "getrandom", + "getrandom 0.3.3", "js-sys", "wasm-bindgen", ] @@ -1193,6 +1757,15 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" @@ -1244,6 +1817,19 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e038d41e478cc73bae0ff9b36c60cff1c98b8f38f8d7e8061e79ee63608ac5c" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.104" @@ -1276,6 +1862,16 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "web-sys" +version = "0.3.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9367c417a924a74cae129e6a2ae3b47fabb1f8995595ab474029da749a8be120" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "windows-core" version = "0.62.2" @@ -1317,6 +1913,17 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link", + "windows-result", + "windows-strings", +] + [[package]] name = "windows-result" version = "0.4.1" @@ -1335,13 +1942,22 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets", + "windows-targets 0.53.5", ] [[package]] @@ -1353,6 +1969,22 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + [[package]] name = "windows-targets" version = "0.53.5" @@ -1360,58 +1992,106 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ "windows-link", - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_gnullvm" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_aarch64_msvc" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + [[package]] name = "windows_i686_gnu" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_gnullvm" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_i686_msvc" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnu" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_gnullvm" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "windows_x86_64_msvc" version = "0.53.1" @@ -1433,6 +2113,35 @@ version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" +[[package]] +name = "writeable" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.8.48" @@ -1453,6 +2162,66 @@ dependencies = [ "syn", ] +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "zmij" version = "1.0.21" diff --git a/Cargo.toml b/Cargo.toml index 62f4b6b..5a9d811 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,3 +27,4 @@ toml = "0.8.19" tower = "0.5.1" tower-http = { version = "0.6.2", features = ["fs", "trace"] } uuid = { version = "1.18.1", features = ["v4"] } +reqwest = { version = "0.12", features = ["blocking"] } diff --git a/crates/archivr-core/Cargo.toml b/crates/archivr-core/Cargo.toml index 2325fdf..c446710 100644 --- a/crates/archivr-core/Cargo.toml +++ b/crates/archivr-core/Cargo.toml @@ -13,3 +13,4 @@ serde.workspace = true serde_json.workspace = true sha3.workspace = true uuid.workspace = true +reqwest = { workspace = true } diff --git a/crates/archivr-core/src/capture.rs b/crates/archivr-core/src/capture.rs index a71ae48..0e0a2f9 100644 --- a/crates/archivr-core/src/capture.rs +++ b/crates/archivr-core/src/capture.rs @@ -22,6 +22,7 @@ pub enum Source { Reddit, Snapchat, Local, + Url, Other, } @@ -86,6 +87,7 @@ fn generate_entry_title(source: Source, meta: &PlatformMetadata) -> String { ), Source::Snapchat => format!("Snap by {}", meta.author.as_deref().unwrap_or("unknown")), Source::Local => meta.title.clone().unwrap_or_else(|| "Local File".to_string()), + Source::Url => meta.title.clone().unwrap_or_else(|| "Downloaded File".to_string()), Source::Other => "Archived Content".to_string(), } } @@ -317,6 +319,8 @@ fn determine_source(path: &str) -> Source { { return Source::Snapchat; } + // No platform matched — treat as a generic file URL + return Source::Url; } if Path::new(path).exists() { return Source::Local; @@ -411,6 +415,7 @@ fn source_metadata(source: Source) -> (&'static str, &'static str, &'static str) Source::Reddit => ("reddit", "post", "video"), Source::Snapchat => ("snapchat", "story", "video"), Source::Local => ("local", "file", "file"), + Source::Url => ("web", "file", "file"), Source::Other => ("other", "unknown", "unknown"), } } @@ -699,6 +704,64 @@ pub fn perform_capture(archive_paths: &ArchivePaths, locator: &str) -> Result { + let temp_file = store_path + .join("temp") + .join(×tamp) + .join(format!("{timestamp}{file_extension}")); + let byte_size = fs::metadata(&temp_file) + .with_context(|| format!("failed to stat staged file {}", temp_file.display()))? + .len() as i64; + + let hash_exists = hash_exists(&hash, &file_extension, store_path)?; + if hash_exists { + let _ = fs::remove_dir_all(store_path.join("temp").join(×tamp)); + } else { + move_temp_to_raw( + &store_path + .join("temp") + .join(×tamp) + .join(format!("{timestamp}{file_extension}")), + &hash, + store_path, + )?; + let _ = fs::remove_dir_all(store_path.join("temp").join(×tamp)); + } + + record_media_entry( + &conn, + store_path, + user_id, + &run, + &item, + locator, + locator, + source, + &hash, + &file_extension, + byte_size, + None, + )?; + database::finish_archive_run(&conn, run.id)?; + return Ok(CaptureResult { + run_uid: run.run_uid.clone(), + status: "completed".to_string(), + }); + } + Err(e) => { + return Err(fail_run( + &conn, + &run, + &item, + &format!("Failed to download URL: {e}"), + )); + } + } + } + // Sources: Tweets or Twitter Threads if matches!(source, Source::Tweet | Source::TweetThread) { let tweet_id = match tweet_id_from_archive_path(locator) { @@ -1210,15 +1273,15 @@ mod tests { }, TestCase { url: "https://example.com/", - expected: Source::Other, + expected: Source::Url, }, TestCase { url: "https://example.com/?redirect=instagram.com/reel/ABC123", - expected: Source::Other, + expected: Source::Url, }, TestCase { url: "https://notfacebook.com/watch?v=123456", - expected: Source::Other, + expected: Source::Url, }, ]; diff --git a/crates/archivr-core/src/downloader/http.rs b/crates/archivr-core/src/downloader/http.rs new file mode 100644 index 0000000..e876c10 --- /dev/null +++ b/crates/archivr-core/src/downloader/http.rs @@ -0,0 +1,163 @@ +use anyhow::{Context, Result, bail}; +use std::path::Path; + +use crate::hash::hash_file; + +/// Downloads a file from `url` into `store_path/temp/timestamp/`. +/// +/// Returns `(sha256_hex, extension_with_leading_dot)` on success. +/// +/// Errors if: +/// - The request fails or returns a non-2xx status. +/// - The response Content-Type is `text/html` (caller should use a web-page archiver instead). +/// - The body cannot be written to disk. +pub fn download(url: &str, store_path: &Path, timestamp: &str) -> Result<(String, String)> { + let client = reqwest::blocking::Client::builder() + .redirect(reqwest::redirect::Policy::limited(10)) + .user_agent("archivr/0.1") + .build() + .context("failed to build HTTP client")?; + + let response = client + .get(url) + .send() + .with_context(|| format!("failed to fetch {url}"))?; + + if !response.status().is_success() { + bail!("HTTP {} fetching {url}", response.status()); + } + + let content_type = response + .headers() + .get(reqwest::header::CONTENT_TYPE) + .and_then(|v| v.to_str().ok()) + .unwrap_or("") + .to_string(); + + if content_type_is_html(&content_type) { + bail!( + "URL returned HTML (Content-Type: {content_type}); \ + use a web-page archiver for this URL" + ); + } + + let extension = extension_from_url(url) + .or_else(|| extension_from_content_type(&content_type)) + .unwrap_or_default(); + + let temp_dir = store_path.join("temp").join(timestamp); + std::fs::create_dir_all(&temp_dir).context("failed to create temp dir")?; + + let out_file = temp_dir.join(format!("{timestamp}{extension}")); + + let bytes = response + .bytes() + .with_context(|| format!("failed to read response body from {url}"))?; + std::fs::write(&out_file, &bytes) + .with_context(|| format!("failed to write downloaded file to {}", out_file.display()))?; + + let hash = hash_file(&out_file)?; + Ok((hash, extension)) +} + +fn content_type_is_html(content_type: &str) -> bool { + let ct = content_type.split(';').next().unwrap_or("").trim(); + ct == "text/html" || ct == "application/xhtml+xml" +} + +/// Derives a file extension (e.g. `".pdf"`) from the URL path component. +/// Strips query strings first. Returns `None` if no recognizable extension found. +fn extension_from_url(url: &str) -> Option { + let path = url.split('?').next().unwrap_or(url); + let last_segment = path.rsplit('/').next().unwrap_or(""); + if let Some(dot_pos) = last_segment.rfind('.') { + let ext = &last_segment[dot_pos..]; + // Accept only short, alphanumeric extensions (1–5 chars after the dot) + if ext.len() >= 2 && ext.len() <= 6 && ext[1..].chars().all(|c| c.is_ascii_alphanumeric()) { + return Some(ext.to_ascii_lowercase()); + } + } + None +} + +/// Maps a MIME type to a file extension. Returns `None` for unrecognized types. +fn extension_from_content_type(content_type: &str) -> Option { + let ct = content_type.split(';').next().unwrap_or("").trim(); + match ct { + "application/pdf" => Some(".pdf".to_string()), + "image/jpeg" | "image/jpg" => Some(".jpg".to_string()), + "image/png" => Some(".png".to_string()), + "image/gif" => Some(".gif".to_string()), + "image/webp" => Some(".webp".to_string()), + "image/svg+xml" => Some(".svg".to_string()), + "video/mp4" => Some(".mp4".to_string()), + "video/webm" => Some(".webm".to_string()), + "video/ogg" => Some(".ogv".to_string()), + "audio/mpeg" | "audio/mp3" => Some(".mp3".to_string()), + "audio/ogg" => Some(".ogg".to_string()), + "audio/wav" => Some(".wav".to_string()), + "application/zip" => Some(".zip".to_string()), + "application/gzip" => Some(".gz".to_string()), + "application/json" => Some(".json".to_string()), + "text/plain" => Some(".txt".to_string()), + "text/csv" => Some(".csv".to_string()), + "text/xml" | "application/xml" => Some(".xml".to_string()), + "application/epub+zip" => Some(".epub".to_string()), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn extension_from_url_pdf() { + assert_eq!(extension_from_url("https://example.com/paper.pdf"), Some(".pdf".to_string())); + } + + #[test] + fn extension_from_url_strips_query() { + assert_eq!(extension_from_url("https://example.com/file.zip?token=abc"), Some(".zip".to_string())); + } + + #[test] + fn extension_from_url_no_extension() { + assert_eq!(extension_from_url("https://example.com/page"), None); + } + + #[test] + fn extension_from_url_rejects_long_ext() { + assert_eq!(extension_from_url("https://example.com/file.toolongext"), None); + } + + #[test] + fn extension_from_content_type_pdf() { + assert_eq!(extension_from_content_type("application/pdf"), Some(".pdf".to_string())); + } + + #[test] + fn extension_from_content_type_with_params() { + assert_eq!(extension_from_content_type("application/pdf; charset=utf-8"), Some(".pdf".to_string())); + } + + #[test] + fn content_type_is_html_plain() { + assert!(content_type_is_html("text/html")); + } + + #[test] + fn content_type_is_html_with_charset() { + assert!(content_type_is_html("text/html; charset=utf-8")); + } + + #[test] + fn content_type_is_html_xhtml() { + assert!(content_type_is_html("application/xhtml+xml")); + } + + #[test] + fn content_type_is_html_pdf_is_not_html() { + assert!(!content_type_is_html("application/pdf")); + } +} diff --git a/crates/archivr-core/src/downloader/mod.rs b/crates/archivr-core/src/downloader/mod.rs index d0ba3d8..21c6b34 100644 --- a/crates/archivr-core/src/downloader/mod.rs +++ b/crates/archivr-core/src/downloader/mod.rs @@ -3,3 +3,4 @@ pub mod store; pub mod tweets; pub mod ytdlp; pub mod metadata; +pub mod http; diff --git a/docs/README.md b/docs/README.md index 7917645..2b7dc3a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -17,7 +17,7 @@ An open-source self-hosted archiving tool. Work in progress. - [x] Archiving local files - [x] Archiving Twitter Tweets, Threads, and Articles - [ ] Archiving files from cloud storage services (Google Drive, Dropbox, OneDrive) and from URLs - - [ ] URLs + - [x] URLs - [ ] Google Drive - [ ] Dropbox - [ ] OneDrive From 143f71bc17f83f922b1a774dae995a1f553ee70e Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Wed, 24 Jun 2026 14:56:48 +0200 Subject: [PATCH 9/9] feat(core): auto-title for HTTP/S URL downloads http::download now returns (hash, extension, Option). Title is derived from Content-Disposition filename header (RFC 5987 filename*= preferred over plain filename=), falling back to the last path segment of the final URL after redirects (percent-decoded). capture.rs Source::Url arm passes the title through to record_media_entry instead of None, so entries like 'Facharbeit.pdf' or 'facharbeit' appear in the Title column instead of the raw entry_uid. Adds percent_decode(), title_from_content_disposition(), title_from_url() helpers with 10 new unit tests (122 total, all green). --- crates/archivr-core/src/capture.rs | 4 +- crates/archivr-core/src/downloader/http.rs | 169 ++++++++++++++++++++- 2 files changed, 166 insertions(+), 7 deletions(-) diff --git a/crates/archivr-core/src/capture.rs b/crates/archivr-core/src/capture.rs index 0e0a2f9..7edbb1f 100644 --- a/crates/archivr-core/src/capture.rs +++ b/crates/archivr-core/src/capture.rs @@ -707,7 +707,7 @@ pub fn perform_capture(archive_paths: &ArchivePaths, locator: &str) -> Result { + Ok((hash, file_extension, title_hint)) => { let temp_file = store_path .join("temp") .join(×tamp) @@ -743,7 +743,7 @@ pub fn perform_capture(archive_paths: &ArchivePaths, locator: &str) -> Result Result<(String, String)> { +pub fn download(url: &str, store_path: &Path, timestamp: &str) -> Result<(String, String, Option)> { let client = reqwest::blocking::Client::builder() .redirect(reqwest::redirect::Policy::limited(10)) .user_agent("archivr/0.1") @@ -45,6 +45,16 @@ pub fn download(url: &str, store_path: &Path, timestamp: &str) -> Result<(String .or_else(|| extension_from_content_type(&content_type)) .unwrap_or_default(); + // Extract title before consuming the response body. + let title_hint = title_from_content_disposition( + response + .headers() + .get(reqwest::header::CONTENT_DISPOSITION) + .and_then(|v| v.to_str().ok()) + .unwrap_or(""), + ) + .or_else(|| title_from_url(response.url().path())); + let temp_dir = store_path.join("temp").join(timestamp); std::fs::create_dir_all(&temp_dir).context("failed to create temp dir")?; @@ -57,7 +67,7 @@ pub fn download(url: &str, store_path: &Path, timestamp: &str) -> Result<(String .with_context(|| format!("failed to write downloaded file to {}", out_file.display()))?; let hash = hash_file(&out_file)?; - Ok((hash, extension)) + Ok((hash, extension, title_hint)) } fn content_type_is_html(content_type: &str) -> bool { @@ -107,6 +117,87 @@ fn extension_from_content_type(content_type: &str) -> Option { } } +/// Extracts a filename from a `Content-Disposition` header value. +/// +/// Prefers `filename*=` (RFC 5987 percent-encoded, e.g. `filename*=UTF-8''Report%20Final.pdf`) +/// over plain `filename=`. Returns `None` if neither is present or the value is empty. +fn title_from_content_disposition(cd: &str) -> Option { + // RFC 5987: filename*=charset'language'encoded + for part in cd.split(';') { + let part = part.trim(); + if let Some(val) = part.strip_prefix("filename*=") { + let val = val.trim().trim_matches('"'); + // encoded portion is after the second apostrophe + if let Some(encoded) = val.splitn(3, '\'').nth(2) { + let name = percent_decode(encoded); + if !name.is_empty() { + return Some(name); + } + } + } + } + // Plain filename= + for part in cd.split(';') { + let part = part.trim(); + if let Some(val) = part.strip_prefix("filename=") { + let val = val.trim().trim_matches('"'); + if !val.is_empty() { + return Some(val.to_string()); + } + } + } + None +} + +/// Derives a title from the last non-empty path segment of a URL path string. +/// +/// Input is the raw percent-encoded path from the final URL after redirects +/// (e.g. `/papers/Facharbeit.pdf`). Returns `None` if the path has no meaningful segment. +fn title_from_url(path: &str) -> Option { + let segment = path + .split('?') + .next() + .unwrap_or(path) + .rsplit('/') + .find(|s| !s.is_empty())?; + let decoded = percent_decode(segment); + if decoded.is_empty() { None } else { Some(decoded) } +} + +/// Percent-decodes a string. Handles ASCII percent-encoded sequences; multi-byte +/// UTF-8 sequences are decoded correctly when each byte is encoded as `%XX`. +fn percent_decode(s: &str) -> String { + let mut bytes: Vec = Vec::with_capacity(s.len()); + let src = s.as_bytes(); + let mut i = 0; + while i < src.len() { + if src[i] == b'%' && i + 2 < src.len() { + let hi = src[i + 1]; + let lo = src[i + 2]; + let nibble = |b: u8| -> Option { + match b { + b'0'..=b'9' => Some(b - b'0'), + b'a'..=b'f' => Some(b - b'a' + 10), + b'A'..=b'F' => Some(b - b'A' + 10), + _ => None, + } + }; + if let (Some(h), Some(l)) = (nibble(hi), nibble(lo)) { + bytes.push((h << 4) | l); + i += 3; + continue; + } + } + if src[i] == b'+' { + bytes.push(b' '); + } else { + bytes.push(src[i]); + } + i += 1; + } + String::from_utf8(bytes).unwrap_or_else(|e| String::from_utf8_lossy(e.as_bytes()).into_owned()) +} + #[cfg(test)] mod tests { use super::*; @@ -160,4 +251,72 @@ mod tests { fn content_type_is_html_pdf_is_not_html() { assert!(!content_type_is_html("application/pdf")); } + + #[test] + fn title_from_url_plain_filename() { + assert_eq!( + title_from_url("/papers/Facharbeit.pdf"), + Some("Facharbeit.pdf".to_string()) + ); + } + + #[test] + fn title_from_url_encoded() { + assert_eq!( + title_from_url("/files/My%20Report%202026.pdf"), + Some("My Report 2026.pdf".to_string()) + ); + } + + #[test] + fn title_from_url_root_is_none() { + assert_eq!(title_from_url("/"), None); + } + + #[test] + fn title_from_url_no_slash() { + assert_eq!(title_from_url("data.csv"), Some("data.csv".to_string())); + } + + #[test] + fn title_from_content_disposition_plain() { + assert_eq!( + title_from_content_disposition("attachment; filename=\"Facharbeit.pdf\""), + Some("Facharbeit.pdf".to_string()) + ); + } + + #[test] + fn title_from_content_disposition_rfc5987() { + assert_eq!( + title_from_content_disposition("attachment; filename*=UTF-8''Facharbeit%20Final.pdf"), + Some("Facharbeit Final.pdf".to_string()) + ); + } + + #[test] + fn title_from_content_disposition_empty() { + assert_eq!(title_from_content_disposition(""), None); + } + + #[test] + fn title_from_content_disposition_prefers_rfc5987() { + assert_eq!( + title_from_content_disposition( + "attachment; filename=\"old.pdf\"; filename*=UTF-8''new.pdf" + ), + Some("new.pdf".to_string()) + ); + } + + #[test] + fn percent_decode_utf8() { + // ä = 0xC3 0xA4 + assert_eq!(percent_decode("%C3%A4"), "ä"); + } + + #[test] + fn percent_decode_plus_is_space() { + assert_eq!(percent_decode("hello+world"), "hello world"); + } }