From 1589eb68b5ae8e7c79591d98dc5b93c40647c90f Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Sun, 12 Jul 2026 15:45:02 +0200 Subject: [PATCH] feat: server-side t.co resolver + frontend augmentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Server (routes.rs): POST /api/util/resolve-tco — unauthenticated, accepts JSON array of https://t.co/ URLs only (strict regex validation, no SSRF via input), capped at 50 per batch, 3 s timeout, redirect(Policy::none) so the server only ever touches t.co itself. HEAD first, GET fallback if HEAD returns no Location. Location sanitized to http/https only — javascript:/data:/etc. fall back to the original t.co. api.js: resolveTcoUrls(urls) — project-convention wrapper for the new endpoint. Returns {} on failure (callers degrade gracefully to bare t.co links). TweetPreview.jsx: After tweet data loads, per-tweet range-based coverage detection: builds covered [start,end) from existing entity fromIndex/toIndex or indices fallback, then finds regex matches whose span is NOT covered. Resolves unique uncovered t.co URLs via resolveTcoUrls(), synthesises one entity per occurrence (with exact fromIndex/toIndex so normalizeUrlAnn gets correct bounds even for duplicate t.co URLs in the same tweet). Augments entities.urls before setTweets() so all rendering paths see expanded URLs. --- Cargo.lock | 1 + crates/archivr-server/Cargo.toml | 1 + crates/archivr-server/src/routes.rs | 69 ++++++++++++++++++ .../static/assets/index-CBWT1bsB.js | 47 ++++++++++++ .../static/assets/index-WdvYwWGH.js | 47 ------------ crates/archivr-server/static/index.html | 2 +- frontend/src/api.js | 14 ++++ frontend/src/components/TweetPreview.jsx | 54 +++++++++++++- ...scrape_user_tweet_contents.cpython-313.pyc | Bin 0 -> 55503 bytes 9 files changed, 185 insertions(+), 50 deletions(-) create mode 100644 crates/archivr-server/static/assets/index-CBWT1bsB.js delete mode 100644 crates/archivr-server/static/assets/index-WdvYwWGH.js create mode 100644 vendor/twitter/__pycache__/scrape_user_tweet_contents.cpython-313.pyc diff --git a/Cargo.lock b/Cargo.lock index caa23f6..6d983b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,6 +133,7 @@ dependencies = [ "parking_lot", "rand", "regex", + "reqwest", "rusqlite", "serde", "serde_json", diff --git a/crates/archivr-server/Cargo.toml b/crates/archivr-server/Cargo.toml index 59cc33f..7e584c4 100644 --- a/crates/archivr-server/Cargo.toml +++ b/crates/archivr-server/Cargo.toml @@ -21,6 +21,7 @@ serde_json.workspace = true rusqlite.workspace = true parking_lot.workspace = true regex.workspace = true +reqwest.workspace = true [dev-dependencies] tempfile.workspace = true diff --git a/crates/archivr-server/src/routes.rs b/crates/archivr-server/src/routes.rs index 2b13a3a..11d40bd 100644 --- a/crates/archivr-server/src/routes.rs +++ b/crates/archivr-server/src/routes.rs @@ -328,6 +328,7 @@ pub fn app_with_state(state: AppState) -> Router { "/api/archives/:archive_id/blob-cleanup", get(blob_cleanup_scan_handler).delete(blob_cleanup_delete_handler), ) + .route("/api/util/resolve-tco", post(resolve_tco_handler)) .nest_service("/assets", ServeDir::new(static_dir.join("assets"))) .fallback_service(ServeFile::new(static_dir.join("index.html"))) .layer(axum::middleware::from_fn_with_state(state.clone(), setup_guard)) @@ -1908,6 +1909,74 @@ async fn delete_collection_handler( } } +// ── t.co resolver ────────────────────────────────────────────────────────────── +// POST /api/util/resolve-tco +// Body: JSON array of t.co short URLs (max 50). +// Returns: JSON object mapping each input URL to its expanded destination. +// +// Security: +// - Input restricted to https://t.co/ only (no SSRF via input). +// - redirect(Policy::none()): makes ONE HEAD to t.co, reads Location header, never +// fetches the expanded destination (no open-proxy). +// - 3 s timeout, 1-hop max. +// - No auth required (t.co is public; no data exposed). + +static TCO_RE: std::sync::LazyLock = std::sync::LazyLock::new(|| { + regex::Regex::new(r"^https://t\.co/[A-Za-z0-9]+$").unwrap() +}); + +async fn resolve_tco_handler( + Json(urls): Json>, +) -> Result>, ApiError> { + const MAX_BATCH: usize = 50; + let urls: Vec = urls + .into_iter() + .filter(|u| TCO_RE.is_match(u)) + .take(MAX_BATCH) + .collect(); + + let client = reqwest::Client::builder() + .redirect(reqwest::redirect::Policy::none()) + .timeout(Duration::from_secs(3)) + .build() + .map_err(|e| ApiError::internal(&format!("http client: {e}")))?; + + let mut map = std::collections::HashMap::new(); + let futs: Vec<_> = urls.iter().map(|url| { + let client = client.clone(); + let url = url.clone(); + tokio::spawn(async move { + // Try HEAD first; fall back to GET if HEAD returns no Location. + // Neither follows redirects (Policy::none), so the server only + // ever connects to t.co itself — never to the destination. + // Only accept http/https destinations — never javascript:, data:, etc. + let safe_location = |resp: reqwest::Response| { + resp.headers() + .get(reqwest::header::LOCATION) + .and_then(|v| v.to_str().ok()) + .map(|s| s.to_string()) + .filter(|s| s.starts_with("http://") || s.starts_with("https://")) + }; + let expanded = match client.head(&url).send().await.ok().and_then(safe_location) { + Some(loc) => loc, + None => match client.get(&url).send().await.ok().and_then(safe_location) { + Some(loc) => loc, + None => url.clone(), + }, + }; + (url, expanded) + }) + }).collect(); + + for fut in futs { + if let Ok((k, v)) = fut.await { + map.insert(k, v); + } + } + + Ok(Json(map)) +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/archivr-server/static/assets/index-CBWT1bsB.js b/crates/archivr-server/static/assets/index-CBWT1bsB.js new file mode 100644 index 0000000..578049c --- /dev/null +++ b/crates/archivr-server/static/assets/index-CBWT1bsB.js @@ -0,0 +1,47 @@ +(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 s of l)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(l){const s={};return l.integrity&&(s.integrity=l.integrity),l.referrerPolicy&&(s.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?s.credentials="include":l.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(l){if(l.ep)return;l.ep=!0;const s=n(l);fetch(l.href,s)}})();var $o={exports:{}},Tl={},bo={exports:{}},K={};/** + * @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 kr=Symbol.for("react.element"),xd=Symbol.for("react.portal"),wd=Symbol.for("react.fragment"),kd=Symbol.for("react.strict_mode"),jd=Symbol.for("react.profiler"),Sd=Symbol.for("react.provider"),Nd=Symbol.for("react.context"),_d=Symbol.for("react.forward_ref"),Cd=Symbol.for("react.suspense"),Ed=Symbol.for("react.memo"),Td=Symbol.for("react.lazy"),ga=Symbol.iterator;function Pd(e){return e===null||typeof e!="object"?null:(e=ga&&e[ga]||e["@@iterator"],typeof e=="function"?e:null)}var Ao={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Fo=Object.assign,Mo={};function Ln(e,t,n){this.props=e,this.context=t,this.refs=Mo,this.updater=n||Ao}Ln.prototype.isReactComponent={};Ln.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")};Ln.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Bo(){}Bo.prototype=Ln.prototype;function yi(e,t,n){this.props=e,this.context=t,this.refs=Mo,this.updater=n||Ao}var xi=yi.prototype=new Bo;xi.constructor=yi;Fo(xi,Ln.prototype);xi.isPureReactComponent=!0;var va=Array.isArray,Uo=Object.prototype.hasOwnProperty,wi={current:null},Ho={key:!0,ref:!0,__self:!0,__source:!0};function Wo(e,t,n){var r,l={},s=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(s=""+t.key),t)Uo.call(t,r)&&!Ho.hasOwnProperty(r)&&(l[r]=t[r]);var o=arguments.length-2;if(o===1)l.children=n;else if(1>>1,C=R[j];if(0>>1;jl(U,B))Yl(Q,U)?(R[j]=Q,R[Y]=B,j=Y):(R[j]=U,R[M]=B,j=M);else if(Yl(Q,B))R[j]=Q,R[Y]=B,j=Y;else break e}}return _}function l(R,_){var B=R.sortIndex-_.sortIndex;return B!==0?B:R.id-_.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();e.unstable_now=function(){return a.now()-o}}var u=[],c=[],g=1,m=null,f=3,w=!1,y=!1,x=!1,z=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(R){for(var _=n(c);_!==null;){if(_.callback===null)r(c);else if(_.startTime<=R)r(c),_.sortIndex=_.expirationTime,t(u,_);else break;_=n(c)}}function k(R){if(x=!1,v(R),!y)if(n(u)!==null)y=!0,Ee(S);else{var _=n(c);_!==null&&ye(k,_.startTime-R)}}function S(R,_){y=!1,x&&(x=!1,h(N),N=-1),w=!0;var B=f;try{for(v(_),m=n(u);m!==null&&(!(m.expirationTime>_)||R&&!H());){var j=m.callback;if(typeof j=="function"){m.callback=null,f=m.priorityLevel;var C=j(m.expirationTime<=_);_=e.unstable_now(),typeof C=="function"?m.callback=C:m===n(u)&&r(u),v(_)}else r(u);m=n(u)}if(m!==null)var F=!0;else{var M=n(c);M!==null&&ye(k,M.startTime-_),F=!1}return F}finally{m=null,f=B,w=!1}}var T=!1,E=null,N=-1,O=5,I=-1;function H(){return!(e.unstable_now()-IR||125j?(R.sortIndex=B,t(c,R),n(u)===null&&R===n(c)&&(x?(h(N),N=-1):x=!0,ye(k,B-j))):(R.sortIndex=C,t(u,R),y||w||(y=!0,Ee(S))),R},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(R){var _=f;return function(){var B=f;f=_;try{return R.apply(this,arguments)}finally{f=B}}}})(Jo);Xo.exports=Jo;var Md=Xo.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 Bd=p,Be=Md;function P(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"),js=Object.prototype.hasOwnProperty,Ud=/^[: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]*$/,xa={},wa={};function Hd(e){return js.call(wa,e)?!0:js.call(xa,e)?!1:Ud.test(e)?wa[e]=!0:(xa[e]=!0,!1)}function Wd(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 Vd(e,t,n,r){if(t===null||typeof t>"u"||Wd(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 Re(e,t,n,r,l,s,a){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=s,this.removeEmptyString=a}var ke={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ke[e]=new Re(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ke[t]=new Re(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ke[e]=new Re(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ke[e]=new Re(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){ke[e]=new Re(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ke[e]=new Re(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ke[e]=new Re(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ke[e]=new Re(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ke[e]=new Re(e,5,!1,e.toLowerCase(),null,!1,!1)});var ji=/[\-:]([a-z])/g;function Si(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(ji,Si);ke[t]=new Re(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(ji,Si);ke[t]=new Re(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(ji,Si);ke[t]=new Re(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ke[e]=new Re(e,1,!1,e.toLowerCase(),null,!1,!1)});ke.xlinkHref=new Re("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ke[e]=new Re(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ni(e,t,n,r){var l=ke.hasOwnProperty(t)?ke[t]:null;(l!==null?l.type!==0:r||!(2o||l[a]!==s[o]){var u=` +`+l[a].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=a&&0<=o);break}}}finally{Xl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Hn(e):""}function Qd(e){switch(e.tag){case 5:return Hn(e.type);case 16:return Hn("Lazy");case 13:return Hn("Suspense");case 19:return Hn("SuspenseList");case 0:case 2:case 15:return e=Jl(e.type,!1),e;case 11:return e=Jl(e.type.render,!1),e;case 1:return e=Jl(e.type,!0),e;default:return""}}function Cs(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 sn:return"Fragment";case ln:return"Portal";case Ss:return"Profiler";case _i:return"StrictMode";case Ns:return"Suspense";case _s:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case qo:return(e.displayName||"Context")+".Consumer";case Yo:return(e._context.displayName||"Context")+".Provider";case Ci:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ei:return t=e.displayName||null,t!==null?t:Cs(e.type)||"Memo";case St:t=e._payload,e=e._init;try{return Cs(e(t))}catch{}}return null}function Kd(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 Cs(t);case 8:return t===_i?"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 bt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function eu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Xd(e){var t=eu(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,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(a){r=""+a,s.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Tr(e){e._valueTracker||(e._valueTracker=Xd(e))}function tu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=eu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function rl(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 Es(e,t){var n=t.checked;return ue({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ja(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=bt(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 nu(e,t){t=t.checked,t!=null&&Ni(e,"checked",t,!1)}function Ts(e,t){nu(e,t);var n=bt(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")?Ps(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ps(e,t.type,bt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Sa(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 Ps(e,t,n){(t!=="number"||rl(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Wn=Array.isArray;function vn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Pr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function lr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Xn={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},Jd=["Webkit","ms","Moz","O"];Object.keys(Xn).forEach(function(e){Jd.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Xn[t]=Xn[e]})});function iu(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Xn.hasOwnProperty(e)&&Xn[e]?(""+t).trim():t+"px"}function au(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=iu(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Gd=ue({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 zs(e,t){if(t){if(Gd[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(P(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(P(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(P(61))}if(t.style!=null&&typeof t.style!="object")throw Error(P(62))}}function Ds(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 Is=null;function Ti(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Os=null,yn=null,xn=null;function Ca(e){if(e=Nr(e)){if(typeof Os!="function")throw Error(P(280));var t=e.stateNode;t&&(t=Dl(t),Os(e.stateNode,e.type,t))}}function ou(e){yn?xn?xn.push(e):xn=[e]:yn=e}function uu(){if(yn){var e=yn,t=xn;if(xn=yn=null,Ca(e),t)for(e=0;e>>=0,e===0?32:31-(of(e)/uf|0)|0}var Lr=64,Rr=4194304;function Vn(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 al(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,s=e.pingedLanes,a=n&268435455;if(a!==0){var o=a&~l;o!==0?r=Vn(o):(s&=a,s!==0&&(r=Vn(s)))}else a=n&~l,a!==0?r=Vn(a):s!==0&&(r=Vn(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,s=t&-t,l>=s||l===16&&(s&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 jr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-rt(t),e[t]=n}function pf(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=Gn),Oa=" ",$a=!1;function Pu(e,t){switch(e){case"keyup":return Bf.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Lu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var an=!1;function Hf(e,t){switch(e){case"compositionend":return Lu(t);case"keypress":return t.which!==32?null:($a=!0,Oa);case"textInput":return e=t.data,e===Oa&&$a?null:e;default:return null}}function Wf(e,t){if(an)return e==="compositionend"||!$i&&Pu(e,t)?(e=Eu(),Xr=Di=Et=null,an=!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=Ma(n)}}function Iu(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Iu(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ou(){for(var e=window,t=rl();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=rl(e.document)}return t}function bi(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 Zf(e){var t=Ou(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Iu(n.ownerDocument.documentElement,n)){if(r!==null&&bi(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,s=Math.min(r.start,l);r=r.end===void 0?s:Math.min(r.end,l),!e.extend&&s>r&&(l=r,r=s,s=l),l=Ba(n,s);var a=Ba(n,r);l&&a&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.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,on=null,Bs=null,qn=null,Us=!1;function Ua(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Us||on==null||on!==rl(r)||(r=on,"selectionStart"in r&&bi(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}),qn&&cr(qn,r)||(qn=r,r=cl(Bs,"onSelect"),0dn||(e.current=Xs[dn],Xs[dn]=null,dn--)}function ne(e,t){dn++,Xs[dn]=e.current,e.current=t}var At={},Ce=Mt(At),Ie=Mt(!1),Gt=At;function Nn(e,t){var n=e.type.contextTypes;if(!n)return At;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},s;for(s in n)l[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function Oe(e){return e=e.childContextTypes,e!=null}function fl(){le(Ie),le(Ce)}function Ja(e,t,n){if(Ce.current!==At)throw Error(P(168));ne(Ce,t),ne(Ie,n)}function Wu(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(P(108,Kd(e)||"Unknown",l));return ue({},n,r)}function pl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||At,Gt=Ce.current,ne(Ce,e),ne(Ie,Ie.current),!0}function Ga(e,t,n){var r=e.stateNode;if(!r)throw Error(P(169));n?(e=Wu(e,t,Gt),r.__reactInternalMemoizedMergedChildContext=e,le(Ie),le(Ce),ne(Ce,e)):le(Ie),ne(Ie,n)}var pt=null,Il=!1,us=!1;function Vu(e){pt===null?pt=[e]:pt.push(e)}function dp(e){Il=!0,Vu(e)}function Bt(){if(!us&&pt!==null){us=!0;var e=0,t=q;try{var n=pt;for(q=1;e>=a,l-=a,ht=1<<32-rt(t)+l|n<N?(O=E,E=null):O=E.sibling;var I=f(h,E,v[N],k);if(I===null){E===null&&(E=O);break}e&&E&&I.alternate===null&&t(h,E),d=s(I,d,N),T===null?S=I:T.sibling=I,T=I,E=O}if(N===v.length)return n(h,E),ie&&Ut(h,N),S;if(E===null){for(;NN?(O=E,E=null):O=E.sibling;var H=f(h,E,I.value,k);if(H===null){E===null&&(E=O);break}e&&E&&H.alternate===null&&t(h,E),d=s(H,d,N),T===null?S=H:T.sibling=H,T=H,E=O}if(I.done)return n(h,E),ie&&Ut(h,N),S;if(E===null){for(;!I.done;N++,I=v.next())I=m(h,I.value,k),I!==null&&(d=s(I,d,N),T===null?S=I:T.sibling=I,T=I);return ie&&Ut(h,N),S}for(E=r(h,E);!I.done;N++,I=v.next())I=w(E,h,N,I.value,k),I!==null&&(e&&I.alternate!==null&&E.delete(I.key===null?N:I.key),d=s(I,d,N),T===null?S=I:T.sibling=I,T=I);return e&&E.forEach(function(ee){return t(h,ee)}),ie&&Ut(h,N),S}function z(h,d,v,k){if(typeof v=="object"&&v!==null&&v.type===sn&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case Er:e:{for(var S=v.key,T=d;T!==null;){if(T.key===S){if(S=v.type,S===sn){if(T.tag===7){n(h,T.sibling),d=l(T,v.props.children),d.return=h,h=d;break e}}else if(T.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===St&&Za(S)===T.type){n(h,T.sibling),d=l(T,v.props),d.ref=Fn(h,T,v),d.return=h,h=d;break e}n(h,T);break}else t(h,T);T=T.sibling}v.type===sn?(d=Jt(v.props.children,h.mode,k,v.key),d.return=h,h=d):(k=nl(v.type,v.key,v.props,null,h.mode,k),k.ref=Fn(h,d,v),k.return=h,h=k)}return a(h);case ln:e:{for(T=v.key;d!==null;){if(d.key===T)if(d.tag===4&&d.stateNode.containerInfo===v.containerInfo&&d.stateNode.implementation===v.implementation){n(h,d.sibling),d=l(d,v.children||[]),d.return=h,h=d;break e}else{n(h,d);break}else t(h,d);d=d.sibling}d=vs(v,h.mode,k),d.return=h,h=d}return a(h);case St:return T=v._init,z(h,d,T(v._payload),k)}if(Wn(v))return y(h,d,v,k);if(In(v))return x(h,d,v,k);Ar(h,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,d!==null&&d.tag===6?(n(h,d.sibling),d=l(d,v),d.return=h,h=d):(n(h,d),d=gs(v,h.mode,k),d.return=h,h=d),a(h)):n(h,d)}return z}var Cn=Ju(!0),Gu=Ju(!1),gl=Mt(null),vl=null,hn=null,Bi=null;function Ui(){Bi=hn=vl=null}function Hi(e){var t=gl.current;le(gl),e._currentValue=t}function Ys(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 kn(e,t){vl=e,Bi=hn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(De=!0),e.firstContext=null)}function Ye(e){var t=e._currentValue;if(Bi!==e)if(e={context:e,memoizedValue:t,next:null},hn===null){if(vl===null)throw Error(P(308));hn=e,vl.dependencies={lanes:0,firstContext:e}}else hn=hn.next=e;return t}var Vt=null;function Wi(e){Vt===null?Vt=[e]:Vt.push(e)}function Yu(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Wi(t)):(n.next=l.next,l.next=n),t.interleaved=n,xt(e,r)}function xt(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 Nt=!1;function Vi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function qu(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 gt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Dt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,G&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,xt(e,n)}return l=r.interleaved,l===null?(t.next=t,Wi(r)):(t.next=l.next,l.next=t),r.interleaved=t,xt(e,n)}function Gr(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,Li(e,n)}}function eo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?l=s=a:s=s.next=a,n=n.next}while(n!==null);s===null?l=s=t:s=s.next=t}else l=s=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:s,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 yl(e,t,n,r){var l=e.updateQueue;Nt=!1;var s=l.firstBaseUpdate,a=l.lastBaseUpdate,o=l.shared.pending;if(o!==null){l.shared.pending=null;var u=o,c=u.next;u.next=null,a===null?s=c:a.next=c,a=u;var g=e.alternate;g!==null&&(g=g.updateQueue,o=g.lastBaseUpdate,o!==a&&(o===null?g.firstBaseUpdate=c:o.next=c,g.lastBaseUpdate=u))}if(s!==null){var m=l.baseState;a=0,g=c=u=null,o=s;do{var f=o.lane,w=o.eventTime;if((r&f)===f){g!==null&&(g=g.next={eventTime:w,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var y=e,x=o;switch(f=t,w=n,x.tag){case 1:if(y=x.payload,typeof y=="function"){m=y.call(w,m,f);break e}m=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=x.payload,f=typeof y=="function"?y.call(w,m,f):y,f==null)break e;m=ue({},m,f);break e;case 2:Nt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,f=l.effects,f===null?l.effects=[o]:f.push(o))}else w={eventTime:w,lane:f,tag:o.tag,payload:o.payload,callback:o.callback,next:null},g===null?(c=g=w,u=m):g=g.next=w,a|=f;if(o=o.next,o===null){if(o=l.shared.pending,o===null)break;f=o,o=f.next,f.next=null,l.lastBaseUpdate=f,l.shared.pending=null}}while(!0);if(g===null&&(u=m),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=g,t=l.shared.interleaved,t!==null){l=t;do a|=l.lane,l=l.next;while(l!==t)}else s===null&&(l.shared.lanes=0);Zt|=a,e.lanes=a,e.memoizedState=m}}function to(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ds.transition;ds.transition={};try{e(!1),t()}finally{q=n,ds.transition=r}}function mc(){return qe().memoizedState}function mp(e,t,n){var r=Ot(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},gc(e))vc(t,n);else if(n=Yu(e,t,n,r),n!==null){var l=Pe();lt(n,e,r,l),yc(n,t,r)}}function gp(e,t,n){var r=Ot(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(gc(e))vc(t,l);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var a=t.lastRenderedState,o=s(a,n);if(l.hasEagerState=!0,l.eagerState=o,st(o,a)){var u=t.interleaved;u===null?(l.next=l,Wi(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=Yu(e,t,l,r),n!==null&&(l=Pe(),lt(n,e,r,l),yc(n,t,r))}}function gc(e){var t=e.alternate;return e===oe||t!==null&&t===oe}function vc(e,t){Zn=wl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function yc(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Li(e,n)}}var kl={readContext:Ye,useCallback:Se,useContext:Se,useEffect:Se,useImperativeHandle:Se,useInsertionEffect:Se,useLayoutEffect:Se,useMemo:Se,useReducer:Se,useRef:Se,useState:Se,useDebugValue:Se,useDeferredValue:Se,useTransition:Se,useMutableSource:Se,useSyncExternalStore:Se,useId:Se,unstable_isNewReconciler:!1},vp={readContext:Ye,useCallback:function(e,t){return at().memoizedState=[e,t===void 0?null:t],e},useContext:Ye,useEffect:ro,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,qr(4194308,4,cc.bind(null,t,e),n)},useLayoutEffect:function(e,t){return qr(4194308,4,e,t)},useInsertionEffect:function(e,t){return qr(4,2,e,t)},useMemo:function(e,t){var n=at();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=at();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=mp.bind(null,oe,e),[r.memoizedState,e]},useRef:function(e){var t=at();return e={current:e},t.memoizedState=e},useState:no,useDebugValue:Zi,useDeferredValue:function(e){return at().memoizedState=e},useTransition:function(){var e=no(!1),t=e[0];return e=hp.bind(null,e[1]),at().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=oe,l=at();if(ie){if(n===void 0)throw Error(P(407));n=n()}else{if(n=t(),ve===null)throw Error(P(349));qt&30||nc(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,ro(lc.bind(null,r,s,e),[e]),r.flags|=2048,yr(9,rc.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=at(),t=ve.identifierPrefix;if(ie){var n=mt,r=ht;n=(r&~(1<<32-rt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=gr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[ot]=t,e[pr]=r,Tc(e,t,!1,!1),t.stateNode=e;e:{switch(a=Ds(n,r),n){case"dialog":re("cancel",e),re("close",e),l=r;break;case"iframe":case"object":case"embed":re("load",e),l=r;break;case"video":case"audio":for(l=0;lPn&&(t.flags|=128,r=!0,Mn(s,!1),t.lanes=4194304)}else{if(!r)if(e=xl(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Mn(s,!0),s.tail===null&&s.tailMode==="hidden"&&!a.alternate&&!ie)return Ne(t),null}else 2*de()-s.renderingStartTime>Pn&&n!==1073741824&&(t.flags|=128,r=!0,Mn(s,!1),t.lanes=4194304);s.isBackwards?(a.sibling=t.child,t.child=a):(n=s.last,n!==null?n.sibling=a:t.child=a,s.last=a)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=de(),t.sibling=null,n=ae.current,ne(ae,r?n&1|2:n&1),t):(Ne(t),null);case 22:case 23:return sa(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ae&1073741824&&(Ne(t),t.subtreeFlags&6&&(t.flags|=8192)):Ne(t),null;case 24:return null;case 25:return null}throw Error(P(156,t.tag))}function _p(e,t){switch(Fi(t),t.tag){case 1:return Oe(t.type)&&fl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return En(),le(Ie),le(Ce),Xi(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ki(t),null;case 13:if(le(ae),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(P(340));_n()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return le(ae),null;case 4:return En(),null;case 10:return Hi(t.type._context),null;case 22:case 23:return sa(),null;case 24:return null;default:return null}}var Mr=!1,_e=!1,Cp=typeof WeakSet=="function"?WeakSet:Set,b=null;function mn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ce(e,t,r)}else n.current=null}function ii(e,t,n){try{n()}catch(r){ce(e,t,r)}}var mo=!1;function Ep(e,t){if(Hs=ol,e=Ou(),bi(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,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var a=0,o=-1,u=-1,c=0,g=0,m=e,f=null;t:for(;;){for(var w;m!==n||l!==0&&m.nodeType!==3||(o=a+l),m!==s||r!==0&&m.nodeType!==3||(u=a+r),m.nodeType===3&&(a+=m.nodeValue.length),(w=m.firstChild)!==null;)f=m,m=w;for(;;){if(m===e)break t;if(f===n&&++c===l&&(o=a),f===s&&++g===r&&(u=a),(w=m.nextSibling)!==null)break;m=f,f=m.parentNode}m=w}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ws={focusedElem:e,selectionRange:n},ol=!1,b=t;b!==null;)if(t=b,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,b=e;else for(;b!==null;){t=b;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var x=y.memoizedProps,z=y.memoizedState,h=t.stateNode,d=h.getSnapshotBeforeUpdate(t.elementType===t.type?x:et(t.type,x),z);h.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(P(163))}}catch(k){ce(t,t.return,k)}if(e=t.sibling,e!==null){e.return=t.return,b=e;break}b=t.return}return y=mo,mo=!1,y}function er(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 s=l.destroy;l.destroy=void 0,s!==void 0&&ii(t,n,s)}l=l.next}while(l!==r)}}function bl(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 ai(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 Rc(e){var t=e.alternate;t!==null&&(e.alternate=null,Rc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ot],delete t[pr],delete t[Ks],delete t[up],delete t[cp])),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 zc(e){return e.tag===5||e.tag===3||e.tag===4}function go(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||zc(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 oi(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=dl));else if(r!==4&&(e=e.child,e!==null))for(oi(e,t,n),e=e.sibling;e!==null;)oi(e,t,n),e=e.sibling}function ui(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(ui(e,t,n),e=e.sibling;e!==null;)ui(e,t,n),e=e.sibling}var xe=null,tt=!1;function jt(e,t,n){for(n=n.child;n!==null;)Dc(e,t,n),n=n.sibling}function Dc(e,t,n){if(ut&&typeof ut.onCommitFiberUnmount=="function")try{ut.onCommitFiberUnmount(Pl,n)}catch{}switch(n.tag){case 5:_e||mn(n,t);case 6:var r=xe,l=tt;xe=null,jt(e,t,n),xe=r,tt=l,xe!==null&&(tt?(e=xe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):xe.removeChild(n.stateNode));break;case 18:xe!==null&&(tt?(e=xe,n=n.stateNode,e.nodeType===8?os(e.parentNode,n):e.nodeType===1&&os(e,n),or(e)):os(xe,n.stateNode));break;case 4:r=xe,l=tt,xe=n.stateNode.containerInfo,tt=!0,jt(e,t,n),xe=r,tt=l;break;case 0:case 11:case 14:case 15:if(!_e&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var s=l,a=s.destroy;s=s.tag,a!==void 0&&(s&2||s&4)&&ii(n,t,a),l=l.next}while(l!==r)}jt(e,t,n);break;case 1:if(!_e&&(mn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ce(n,t,o)}jt(e,t,n);break;case 21:jt(e,t,n);break;case 22:n.mode&1?(_e=(r=_e)||n.memoizedState!==null,jt(e,t,n),_e=r):jt(e,t,n);break;default:jt(e,t,n)}}function vo(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Cp),t.forEach(function(r){var l=$p.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Ze(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=a),r&=~s}if(r=l,r=de()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Pp(r/1960))-r,10e?16:e,Tt===null)var r=!1;else{if(e=Tt,Tt=null,Nl=0,G&6)throw Error(P(331));var l=G;for(G|=4,b=e.current;b!==null;){var s=b,a=s.child;if(b.flags&16){var o=s.deletions;if(o!==null){for(var u=0;ude()-ra?Xt(e,0):na|=n),$e(e,t)}function Bc(e,t){t===0&&(e.mode&1?(t=Rr,Rr<<=1,!(Rr&130023424)&&(Rr=4194304)):t=1);var n=Pe();e=xt(e,t),e!==null&&(jr(e,t,n),$e(e,n))}function Op(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bc(e,n)}function $p(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(P(314))}r!==null&&r.delete(t),Bc(e,n)}var Uc;Uc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ie.current)De=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return De=!1,Sp(e,t,n);De=!!(e.flags&131072)}else De=!1,ie&&t.flags&1048576&&Qu(t,ml,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Zr(e,t),e=t.pendingProps;var l=Nn(t,Ce.current);kn(t,n),l=Gi(null,t,r,e,l,n);var s=Yi();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,Oe(r)?(s=!0,pl(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Vi(t),l.updater=$l,t.stateNode=l,l._reactInternals=t,Zs(t,r,e,n),t=ni(null,t,r,!0,s,n)):(t.tag=0,ie&&s&&Ai(t),Te(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Zr(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Ap(r),e=et(r,e),l){case 0:t=ti(null,t,r,e,n);break e;case 1:t=fo(null,t,r,e,n);break e;case 11:t=uo(null,t,r,e,n);break e;case 14:t=co(null,t,r,et(r.type,e),n);break e}throw Error(P(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:et(r,l),ti(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:et(r,l),fo(e,t,r,l,n);case 3:e:{if(_c(t),e===null)throw Error(P(387));r=t.pendingProps,s=t.memoizedState,l=s.element,qu(e,t),yl(t,r,null,n);var a=t.memoizedState;if(r=a.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){l=Tn(Error(P(423)),t),t=po(e,t,r,n,l);break e}else if(r!==l){l=Tn(Error(P(424)),t),t=po(e,t,r,n,l);break e}else for(Fe=zt(t.stateNode.containerInfo.firstChild),Me=t,ie=!0,nt=null,n=Gu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(_n(),r===l){t=wt(e,t,n);break e}Te(e,t,r,n)}t=t.child}return t;case 5:return Zu(t),e===null&&Gs(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,a=l.children,Vs(r,l)?a=null:s!==null&&Vs(r,s)&&(t.flags|=32),Nc(e,t),Te(e,t,a,n),t.child;case 6:return e===null&&Gs(t),null;case 13:return Cc(e,t,n);case 4:return Qi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Cn(t,null,r,n):Te(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:et(r,l),uo(e,t,r,l,n);case 7:return Te(e,t,t.pendingProps,n),t.child;case 8:return Te(e,t,t.pendingProps.children,n),t.child;case 12:return Te(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,s=t.memoizedProps,a=l.value,ne(gl,r._currentValue),r._currentValue=a,s!==null)if(st(s.value,a)){if(s.children===l.children&&!Ie.current){t=wt(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var o=s.dependencies;if(o!==null){a=s.child;for(var u=o.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=gt(-1,n&-n),u.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var g=c.pending;g===null?u.next=u:(u.next=g.next,g.next=u),c.pending=u}}s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),Ys(s.return,n,t),o.lanes|=n;break}u=u.next}}else if(s.tag===10)a=s.type===t.type?null:s.child;else if(s.tag===18){if(a=s.return,a===null)throw Error(P(341));a.lanes|=n,o=a.alternate,o!==null&&(o.lanes|=n),Ys(a,n,t),a=s.sibling}else a=s.child;if(a!==null)a.return=s;else for(a=s;a!==null;){if(a===t){a=null;break}if(s=a.sibling,s!==null){s.return=a.return,a=s;break}a=a.return}s=a}Te(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,kn(t,n),l=Ye(l),r=r(l),t.flags|=1,Te(e,t,r,n),t.child;case 14:return r=t.type,l=et(r,t.pendingProps),l=et(r.type,l),co(e,t,r,l,n);case 15:return jc(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:et(r,l),Zr(e,t),t.tag=1,Oe(r)?(e=!0,pl(t)):e=!1,kn(t,n),xc(t,r,l),Zs(t,r,l,n),ni(null,t,r,!0,e,n);case 19:return Ec(e,t,n);case 22:return Sc(e,t,n)}throw Error(P(156,t.tag))};function Hc(e,t){return gu(e,t)}function bp(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 Je(e,t,n,r){return new bp(e,t,n,r)}function aa(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ap(e){if(typeof e=="function")return aa(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ci)return 11;if(e===Ei)return 14}return 2}function $t(e,t){var n=e.alternate;return n===null?(n=Je(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 nl(e,t,n,r,l,s){var a=2;if(r=e,typeof e=="function")aa(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case sn:return Jt(n.children,l,s,t);case _i:a=8,l|=8;break;case Ss:return e=Je(12,n,t,l|2),e.elementType=Ss,e.lanes=s,e;case Ns:return e=Je(13,n,t,l),e.elementType=Ns,e.lanes=s,e;case _s:return e=Je(19,n,t,l),e.elementType=_s,e.lanes=s,e;case Zo:return Fl(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Yo:a=10;break e;case qo:a=9;break e;case Ci:a=11;break e;case Ei:a=14;break e;case St:a=16,r=null;break e}throw Error(P(130,e==null?e:typeof e,""))}return t=Je(a,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function Jt(e,t,n,r){return e=Je(7,e,r,t),e.lanes=n,e}function Fl(e,t,n,r){return e=Je(22,e,r,t),e.elementType=Zo,e.lanes=n,e.stateNode={isHidden:!1},e}function gs(e,t,n){return e=Je(6,e,null,t),e.lanes=n,e}function vs(e,t,n){return t=Je(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Fp(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=Yl(0),this.expirationTimes=Yl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yl(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function oa(e,t,n,r,l,s,a,o,u){return e=new Fp(e,t,n,o,u),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Je(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Vi(s),e}function Mp(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Kc)}catch(e){console.error(e)}}Kc(),Ko.exports=Ue;var Vp=Ko.exports,Xc,_o=Vp;Xc=_o.createRoot,_o.hydrateRoot;async function me(e){const t=await fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.json()}async function Qp(){return me("/api/archives")}async function Kp(e){return me(`/api/archives/${e}/entries`)}async function Xp(e,t,n){const r=new URLSearchParams;return t&&r.set("q",t),n&&r.set("tag",n),me(`/api/archives/${e}/entries/search?${r}`)}async function hi(e,t){return me(`/api/archives/${e}/entries/${t}`)}function Jp(e,t,n){return Promise.all(n.map(r=>me(`/api/archives/${e}/entries/${t}/artifacts/${r}`)))}async function Gp(e){if(!e||e.length===0)return{};const t=await fetch("/api/util/resolve-tco",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.ok?t.json():{}}async function Yp(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n??null})});if(!r.ok)throw new Error(await r.text())}async function Hr(e,t){return me(`/api/archives/${e}/entries/${t}/tags`)}async function qp(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 Zp(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 eh(e,t){const n=await fetch(`/api/archives/${e}/entries/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`Delete failed (${n.status})`)}async function th(e,t,n){const r=await fetch(`/api/archives/${e}/tags/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n})});if(!r.ok)throw new Error(await r.text());return r.json()}async function nh(e,t){const n=await fetch(`/api/archives/${e}/tags/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(await n.text())}async function Co(e){return me(`/api/archives/${e}/runs`)}async function ys(e){return me(`/api/archives/${e}/tags`)}async function rh(e,t,n=null,r=null){const l={locator:t};n&&n!=="best"&&(l.quality=n),r&&(typeof r.ublock_enabled=="boolean"&&(l.ublock_enabled=r.ublock_enabled),typeof r.reader_mode=="boolean"&&(l.reader_mode=r.reader_mode),typeof r.cookie_ext_enabled=="boolean"&&(l.cookie_ext_enabled=r.cookie_ext_enabled));const s=await fetch(`/api/archives/${e}/captures`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error(a.error||`HTTP ${s.status}`)}return s.json()}async function lh(e,t){return me(`/api/archives/${e}/captures/probe?locator=${encodeURIComponent(t)}`)}async function Jc(e,t){return me(`/api/archives/${e}/capture_jobs/${t}`)}async function sh(){return(await(await fetch("/api/auth/setup")).json()).setup_required===!0}async function ih(e,t){const n=await fetch("/api/auth/setup",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!n.ok)throw new Error((await n.json()).error||"Setup failed");return n.json()}async function ah(e,t){const n=await fetch("/api/auth/login",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!n.ok)throw new Error((await n.json()).error||"Login failed");return n.json()}async function oh(){await fetch("/api/auth/logout",{method:"POST"})}async function uh(){const e=await fetch("/api/auth/me");return e.status===401?null:e.json()}async function ch(e){const t=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({display_name:e})});if(!t.ok)throw new Error(await t.text())}async function dh(e){const t=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await t.text())}async function fh(e,t){const n=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({current_password:e,new_password:t})});if(!n.ok){let r=await n.text();try{r=JSON.parse(r).error??r}catch{}throw new Error(r)}}async function ph(){return me("/api/auth/tokens")}async function hh(e){const t=await fetch("/api/auth/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})});if(!t.ok)throw new Error(await t.text());return t.json()}async function mh(e){const t=await fetch(`/api/auth/tokens/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(await t.text())}async function fa(){return me("/api/admin/instance-settings")}async function mi(e){const t=await fetch("/api/admin/instance-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await t.text())}async function gh(){return me("/api/admin/users")}async function vh(e,t,n){const r=await fetch("/api/admin/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,email:n||void 0})});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error||`HTTP ${r.status}`)}return r.json()}async function yh(e,t){const n=await fetch(`/api/admin/users/${e}/status`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function xh(){return me("/api/admin/roles")}async function wh(e,t){const n=await fetch("/api/admin/roles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:e,name:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function kh(e){return me(`/api/archives/${e}/collections`)}async function jh(e,t,n,r=2){const l=await fetch(`/api/archives/${e}/collections`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:t,slug:n,default_visibility_bits:r})});if(!l.ok){const s=await l.json().catch(()=>({error:l.statusText}));throw new Error(s.error||l.statusText)}return l.json()}async function Sh(e,t){return me(`/api/archives/${e}/collections/${t}`)}async function Nh(e,t,n,r=2){const l=await fetch(`/api/archives/${e}/collections/${t}/entries`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({entry_uid:n,visibility_bits:r})});if(!l.ok){const s=await l.json().catch(()=>({error:l.statusText}));throw new Error(s.error||l.statusText)}}async function _h(e,t,n){const r=await fetch(`/api/archives/${e}/collections/${t}/entries/${n}`,{method:"DELETE"});if(!r.ok){const l=await r.json().catch(()=>({error:r.statusText}));throw new Error(l.error||r.statusText)}}async function Ch(e,t,n,r){const l=await fetch(`/api/archives/${e}/collections/${t}/entries/${n}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({visibility_bits:r})});if(!l.ok){const s=await l.json().catch(()=>({error:l.statusText}));throw new Error(s.error||l.statusText)}}async function Eh(e,t){return me(`/api/archives/${e}/entries/${t}/collections`)}async function Eo(e,t,n){const r=await fetch(`/api/archives/${e}/collections/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error??r.statusText)}}async function Th(e,t){const n=await fetch(`/api/archives/${e}/collections/${t}`,{method:"DELETE"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error??n.statusText)}}async function Ph(e){return me(`/api/archives/${e}/blob-cleanup`)}async function Lh(e){const t=await fetch(`/api/archives/${e}/blob-cleanup`,{method:"DELETE"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error??t.statusText)}return t.json()}async function Rh(e,t){const n=await fetch(`/api/archives/${e}/entries/${t}/rearchive`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.message||`rearchive failed: ${n.status}`)}return n.json()}async function zh(){return me("/api/admin/cookie-rules")}async function Dh(e,t,n){const r=await fetch("/api/admin/cookie-rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url_pattern:e||null,pattern_kind:t,cookies_json:n})});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.message||`HTTP ${r.status}`)}return r.json()}async function Ih(e,t){const n=await fetch(`/api/admin/cookie-rules/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.message||`HTTP ${n.status}`)}}async function Oh(e){const t=await fetch(`/api/admin/cookie-rules/${e}`,{method:"DELETE"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.message||`HTTP ${t.status}`)}}const $h=window.fetch;window.fetch=async(...e)=>{var n;const t=await $h(...e);return t.status===401&&((typeof e[0]=="string"?e[0]:((n=e[0])==null?void 0:n.url)??"").includes("/api/auth/")||window.dispatchEvent(new CustomEvent("auth:expired"))),t};function bh({onLogin:e}){const[t,n]=p.useState(""),[r,l]=p.useState(""),[s,a]=p.useState(null),[o,u]=p.useState(!1);async function c(g){g.preventDefault(),a(null),u(!0);try{const m=await ah(t,r);e(m)}catch(m){a(m.message)}finally{u(!1)}}return i.jsx("div",{className:"login-page",children:i.jsxs("div",{className:"login-card",children:[i.jsx("h1",{className:"login-brand",children:"Archivr"}),i.jsx("p",{className:"login-tagline",children:"Sign in to your archive"}),i.jsxs("form",{onSubmit:c,children:[i.jsxs("div",{className:"login-field",children:[i.jsx("label",{className:"login-label",htmlFor:"login-username",children:"Username"}),i.jsx("input",{className:"login-input",id:"login-username",type:"text",value:t,onChange:g=>n(g.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),i.jsxs("div",{className:"login-field",children:[i.jsx("label",{className:"login-label",htmlFor:"login-password",children:"Password"}),i.jsx("input",{className:"login-input",id:"login-password",type:"password",value:r,onChange:g=>l(g.target.value),required:!0,autoComplete:"current-password"})]}),s&&i.jsx("p",{className:"login-error",children:s}),i.jsx("button",{className:"login-submit",type:"submit",disabled:o,children:o?"Signing in…":"Sign in"})]})]})})}function Ah({onComplete:e}){const[t,n]=p.useState(""),[r,l]=p.useState(""),[s,a]=p.useState(""),[o,u]=p.useState(null),[c,g]=p.useState(!1);async function m(f){if(f.preventDefault(),r!==s){u("Passwords do not match");return}if(r.length<8){u("Password must be at least 8 characters");return}u(null),g(!0);try{await ih(t,r),e()}catch(w){u(w.message)}finally{g(!1)}}return i.jsx("div",{className:"setup-page",children:i.jsxs("div",{className:"setup-card",children:[i.jsx("h1",{className:"setup-brand",children:"Archivr"}),i.jsx("p",{className:"setup-tagline",children:"Create your owner account to get started."}),i.jsxs("form",{onSubmit:m,children:[i.jsxs("div",{className:"setup-field",children:[i.jsx("label",{className:"setup-label",htmlFor:"setup-username",children:"Username"}),i.jsx("input",{className:"setup-input",id:"setup-username",type:"text",value:t,onChange:f=>n(f.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),i.jsxs("div",{className:"setup-field",children:[i.jsx("label",{className:"setup-label",htmlFor:"setup-password",children:"Password"}),i.jsx("input",{className:"setup-input",id:"setup-password",type:"password",value:r,onChange:f=>l(f.target.value),required:!0,autoComplete:"new-password"})]}),i.jsxs("div",{className:"setup-field",children:[i.jsx("label",{className:"setup-label",htmlFor:"setup-confirm",children:"Confirm password"}),i.jsx("input",{className:"setup-input",id:"setup-confirm",type:"password",value:s,onChange:f=>a(f.target.value),required:!0,autoComplete:"new-password"})]}),o&&i.jsx("p",{className:"setup-error",children:o}),i.jsx("button",{className:"setup-submit",type:"submit",disabled:c,children:c?"Creating account…":"Create account"})]})]})})}function Fh({archives:e,archiveId:t,onArchiveChange:n,view:r,onViewChange:l,onCaptureClick:s}){const{currentUser:a,setCurrentUser:o}=p.useContext(Wl)??{},[u,c]=p.useState(!1);async function g(){c(!0),await oh(),o(null),window.location.reload()}return i.jsxs("header",{className:"topbar",children:[i.jsx("div",{className:"brand",children:"Archivr"}),i.jsx("div",{className:"switcher",children:i.jsx("select",{"aria-label":"Select archive",value:t??"",onChange:m=>n(m.target.value),children:e.map(m=>i.jsx("option",{value:m.id,children:m.label},m.id))})}),i.jsx("nav",{className:"nav","aria-label":"Primary",children:["archive","tags","collections","runs","admin","settings"].map(m=>i.jsx("button",{className:`nav-link${r===m?" is-active":""}`,onClick:()=>l(m),children:m.charAt(0).toUpperCase()+m.slice(1)},m))}),i.jsx("button",{className:"capture-button",onClick:s,children:"Capture"}),a&&i.jsxs("div",{className:"user-menu",children:[i.jsx("span",{className:"user-name",children:a.display_name||a.username}),i.jsx("button",{className:"logout-btn",onClick:g,disabled:u,children:u?"Logging out…":"Log out"})]})]})}let gi=1;function Gc(e){const t=e.trim(),n=t.toLowerCase();for(const r of["yt:","youtube:"])if(n.startsWith(r)){const l=n.slice(r.length);return l.startsWith("video/")||l.startsWith("short/")||l.startsWith("shorts/")}if(n.startsWith("ytm:"))return!n.slice(4).startsWith("playlist/");for(const r of["x:","twitter:","tweet:"])if(n.startsWith(r))return n.slice(r.length).startsWith("media:");if(n.startsWith("spotify:"))return!1;if(n.startsWith("instagram:")||n.startsWith("facebook:")||n.startsWith("tiktok:")||n.startsWith("reddit:")||n.startsWith("snapchat:"))return!0;if(n.startsWith("http://")||n.startsWith("https://")){if(/^https?:\/\/music\.youtube\.com\/watch/.test(n)||/^https?:\/\/(?:www\.)?(?:youtu\.be\/[0-9A-Za-z_-]+|youtube\.com\/watch\?v=[0-9A-Za-z_-]+|youtube\.com\/shorts\/[0-9A-Za-z_-]+)/.test(t)||n.startsWith("https://x.com/")||n.startsWith("http://x.com/")||/^https?:\/\/(?:www\.)?instagram\.com\//.test(n)||/^https?:\/\/(?:www\.)?facebook\.com\//.test(n)||n.startsWith("https://fb.watch/")||n.startsWith("http://fb.watch/")||/^https?:\/\/(?:www\.)?tiktok\.com\//.test(n)||/^https?:\/\/(?:www\.)?reddit\.com\//.test(n)||n.startsWith("https://redd.it/")||n.startsWith("http://redd.it/")||/^https?:\/\/(?:www\.)?snapchat\.com\//.test(n))return!0;if(n.startsWith("https://open.spotify.com/")||n.startsWith("http://open.spotify.com/"))return!1}return!1}function Un(e=""){return{id:gi++,locator:e,quality:"best",probeState:"idle",probeQualities:null,probeHasAudio:!1,status:"idle",error:null,jobUid:null,archiveId:null}}function To(e){return e.some(t=>t.status==="submitting"||t.status==="running")}function Mh({open:e,archiveId:t,onClose:n,onCaptured:r,onToast:l}){const s=p.useRef(null),a=p.useRef(!0),o=p.useRef(new Map),u=p.useRef(new Map),c=p.useRef(new Map),g=p.useRef(t);p.useEffect(()=>{g.current=t},[t]);const m=p.useRef(r),f=p.useRef(l);p.useEffect(()=>{m.current=r},[r]),p.useEffect(()=>{f.current=l},[l]);const[w,y]=p.useState(()=>{try{const j=JSON.parse(sessionStorage.getItem("captureItems")||"null");if(Array.isArray(j)&&j.length>0)return j.forEach(C=>{C.id>=gi&&(gi=C.id+1)}),j}catch{}return[Un()]});p.useEffect(()=>{sessionStorage.setItem("captureItems",JSON.stringify(w))},[w]);const[x,z]=p.useState(!1),[h,d]=p.useState(null),[v,k]=p.useState(null),[S,T]=p.useState(!0);p.useEffect(()=>{fa().then(j=>{k(j),T(j.cookie_ext_enabled??!0)}).catch(()=>k({}))},[]);const E=h!==null?h:(v==null?void 0:v.ublock_enabled)??!0,[N,O]=p.useState(!1);p.useEffect(()=>{["captureDialogLocator","captureDialogError","captureDialogBusy","captureDialogJobStatus","captureDialogJobUid"].forEach(j=>sessionStorage.removeItem(j)),y(j=>j.map(C=>C.status==="submitting"?{...C,status:"idle",error:null}:C)),w.forEach(j=>{j.status==="running"&&j.jobUid&&j.archiveId&&!o.current.has(j.jobUid)&&I(j.id,j.jobUid,j.locator,j.archiveId)})},[]),p.useEffect(()=>{const j=s.current;if(!j)return;const C=()=>{u.current.forEach(F=>clearTimeout(F)),u.current.clear(),n()};return j.addEventListener("close",C),()=>j.removeEventListener("close",C)},[n]),p.useEffect(()=>{const j=s.current;j&&(e?(!a.current&&!To(w)&&y([Un()]),a.current=!1,j.open||j.showModal()):(u.current.forEach(C=>clearTimeout(C)),u.current.clear(),j.open&&j.close()))},[e]),p.useEffect(()=>()=>{o.current.forEach(j=>clearInterval(j)),u.current.forEach(j=>clearTimeout(j))},[]);function I(j,C,F,M,U=null){if(o.current.has(C))return;const Y=setInterval(async()=>{try{const Q=await Jc(M,C);if(Q.status==="completed"){clearInterval(o.current.get(C)),o.current.delete(C),y(J=>J.map(L=>L.id===j?{...L,status:"completed"}:L)),setTimeout(()=>{y(J=>{const L=J.filter(X=>X.id!==j);return L.length===0?[Un()]:L})},1400),m.current();try{const J=Q.notes_json?JSON.parse(Q.notes_json):null;if(J!=null&&J.ublock_skipped||J!=null&&J.cookie_ext_skipped){const X=J.ublock_skipped&&J.cookie_ext_skipped?"Captured without ad-blocking or cookie-consent extension. Check ARCHIVR_UBLOCK_EXT and ARCHIVR_COOKIE_EXT in your server config.":J.ublock_skipped?"Captured without ad-blocking. ARCHIVR_UBLOCK=true but ARCHIVR_UBLOCK_EXT is not set or the path is invalid.":"Captured without cookie-consent extension. ARCHIVR_COOKIE_EXT is not set or the path is invalid.";f.current(X,F,"warning"),H(U,"warning",F)}else U||f.current(null,F,"success"),H(U,"archived")}catch{U||f.current(null,F,"success"),H(U,"archived")}}else if(Q.status==="failed"){clearInterval(o.current.get(C)),o.current.delete(C);const J=Q.error_text||"Capture failed.";y(L=>L.map(X=>X.id===j?{...X,status:"failed",error:J}:X)),f.current(J,F),H(U,"failed",F)}}catch(Q){clearInterval(o.current.get(C)),o.current.delete(C);const J=Q.message||"Network error";y(L=>L.map(X=>X.id===j?{...X,status:"failed",error:J}:X)),f.current(J,F),H(U,"failed",F)}},500);o.current.set(C,Y)}function H(j,C,F=null){if(!j)return;const M=c.current.get(j);if(!M||(C==="archived"||C==="warning"?(M.archived++,C==="warning"&&(M.warnings++,F&&M.warningLocators.push(F))):(M.failed++,F&&M.failedLocators.push(F)),M.archived+M.failed0?`${U} archived (${Y} with warnings)`:`${U} archived`;X=Q>0?`${W}, ${Q} failed`:W}const We=U===0?"error":Q>0||Y>0?"warning":"success",Ve=[];J.length>0&&Ve.push(`Failed: +${J.map(W=>` ${W}`).join(` +`)}`),L.length>0&&Ve.push(`With warnings: +${L.map(W=>` ${W}`).join(` +`)}`);const D=Ve.length>0?Ve.join(` +`):null;f.current(D,null,We,X)}async function ee(j,C=null){if(!j.locator.trim())return;const F=t,M=j.locator.trim(),U=j.quality||"best";y(Y=>Y.map(Q=>Q.id===j.id?{...Q,status:"submitting",error:null}:Q));try{const Q=await rh(F,M,U,{ublock_enabled:E,reader_mode:N,cookie_ext_enabled:S});y(J=>J.map(L=>L.id===j.id?{...L,status:"running",jobUid:Q.job_uid,archiveId:F}:L)),I(j.id,Q.job_uid,M,F,C)}catch(Y){const Q=Y.message||"Submission failed.";y(J=>J.map(L=>L.id===j.id?{...L,status:"failed",error:Q}:L)),f.current(Q,M),H(C,"failed",M)}}function Z(){var F,M;const j=w.filter(U=>U.status==="idle"&&U.locator.trim());if(j.length===0)return;const C=j.length>1?((F=crypto.randomUUID)==null?void 0:F.call(crypto))??`batch-${Date.now()}`:null;C&&c.current.set(C,{total:j.length,archived:0,warnings:0,failed:0,failedLocators:[],warningLocators:[]}),j.forEach(U=>ee(U,C)),(M=s.current)==null||M.close()}function te(){y(j=>[...j,Un()])}function je(j){clearTimeout(u.current.get(j)),u.current.delete(j),y(C=>{const F=C.filter(M=>M.id!==j);return F.length===0?[Un()]:F})}function Ee(j){y(C=>C.map(F=>F.id===j?{...F,status:"idle",error:null}:F))}function ye(j,C){if(clearTimeout(u.current.get(j)),y(M=>M.map(U=>U.id===j?{...U,locator:C,probeState:"idle",probeQualities:null,probeHasAudio:!1,quality:"best"}:U)),!Gc(C))return;const F=setTimeout(async()=>{u.current.delete(j),y(M=>M.map(U=>U.id===j?{...U,probeState:"probing"}:U));try{const M=await lh(g.current,C.trim());y(U=>U.map(Y=>{if(Y.id!==j||Y.locator!==C)return Y;const Q=M.qualities??[],J=M.has_audio??!1,L=Q.length===0&&J?"audio":"best";return{...Y,probeState:"done",probeQualities:Q,probeHasAudio:J,quality:L}}))}catch{y(M=>M.map(U=>U.id===j?{...U,probeState:"idle",probeQualities:null}:U))}},600);u.current.set(j,F)}function R(j,C){y(F=>F.map(M=>M.id===j?{...M,quality:C}:M))}const _=w.filter(j=>j.status==="idle"&&j.locator.trim()).length,B=To(w);return i.jsx("dialog",{ref:s,className:"capture-dialog",children:i.jsxs("div",{className:"capture-dialog-inner",children:[i.jsxs("div",{className:"capture-dialog-header",children:[i.jsx("h2",{className:"capture-dialog-title",children:"Capture"}),i.jsx("button",{type:"button",className:"capture-dialog-close",onClick:()=>{var j;return(j=s.current)==null?void 0:j.close()},"aria-label":"Close",children:i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),i.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),i.jsx("div",{className:"capture-rows",children:w.map((j,C)=>i.jsx(Bh,{item:j,autoFocus:C===w.length-1&&j.status==="idle",onLocatorChange:F=>ye(j.id,F),onQualityChange:F=>R(j.id,F),onRemove:()=>je(j.id),onReset:()=>Ee(j.id),onSubmit:Z},j.id))}),i.jsxs("button",{type:"button",className:"capture-add-row",onClick:te,children:[i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"14"}),i.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"})]}),"Add another"]}),i.jsxs("div",{className:"capture-advanced",children:[i.jsxs("button",{type:"button",className:"capture-advanced-toggle",onClick:()=>z(j=>!j),"aria-expanded":x,children:[i.jsx("svg",{className:`capture-chevron${x?" capture-chevron--open":""}`,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("polyline",{points:"4 6 8 10 12 6"})}),"Advanced options"]}),x&&i.jsxs("div",{className:"capture-advanced-panel",children:[i.jsxs("label",{className:"capture-ext-row",children:[i.jsxs("span",{className:"capture-ext-label",children:[i.jsx("span",{className:"capture-ext-name",children:"uBlock Origin Lite"}),i.jsx("span",{className:"capture-ext-desc",children:"Block ads during this capture"})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":E,className:`ext-toggle ext-toggle--sm${E?" ext-toggle--on":""}`,onClick:()=>d(j=>j===null?!E:!j),"aria-label":"Toggle uBlock for this capture",children:i.jsx("span",{className:"ext-toggle-knob"})})]}),i.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[i.jsxs("span",{className:"capture-ext-label",children:[i.jsx("span",{className:"capture-ext-name",children:"Block cookie banners"}),i.jsx("span",{className:"capture-ext-desc",children:"Dismiss cookie consent banners during this capture"}),!(v!=null&&v.cookie_ext_available)&&i.jsxs("span",{className:"capture-ext-hint",children:["Not configured — set ",i.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})]})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":S,className:`ext-toggle ext-toggle--sm${S?" ext-toggle--on":""}`,onClick:()=>T(j=>!j),"aria-label":"Toggle cookie banner blocking for this capture",children:i.jsx("span",{className:"ext-toggle-knob"})})]}),i.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[i.jsxs("span",{className:"capture-ext-label",children:[i.jsx("span",{className:"capture-ext-name",children:"Reader mode"}),i.jsx("span",{className:"capture-ext-desc",children:"Distil to article text via Readability (off by default)"})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":N,className:`ext-toggle ext-toggle--sm${N?" ext-toggle--on":""}`,onClick:()=>O(j=>!j),"aria-label":"Toggle reader mode for this capture",children:i.jsx("span",{className:"ext-toggle-knob"})})]})]})]}),i.jsxs("div",{className:"capture-actions",children:[i.jsx("button",{type:"button",className:"capture-submit",onClick:Z,disabled:_===0,children:_>1?`Archive ${_}`:"Archive"}),i.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var j;return(j=s.current)==null?void 0:j.close()},children:B?"Close":"Cancel"})]})]})})}function Bh({item:e,autoFocus:t,onLocatorChange:n,onQualityChange:r,onRemove:l,onReset:s,onSubmit:a}){const o=p.useRef(null),u=e.status==="submitting"||e.status==="running";p.useEffect(()=>{var g;t&&e.status==="idle"&&((g=o.current)==null||g.focus())},[t]);const c=(()=>{if(e.status==="completed"||u||!Gc(e.locator))return null;if(e.probeState==="probing")return i.jsx("span",{className:"capture-quality-probing","aria-label":"Checking available qualities",children:"…"});if(e.probeState==="done"){const g=e.probeQualities??[],m=e.probeHasAudio??!1;return g.length===0&&!m?i.jsx("span",{className:"capture-quality-hint",children:"No media detected"}):g.length===0&&m?i.jsx("select",{className:"capture-quality",value:"audio",onChange:f=>r(f.target.value),"aria-label":"Video quality",children:i.jsx("option",{value:"audio",children:"Audio only"})}):i.jsxs("select",{className:"capture-quality",value:e.quality||"best",onChange:f=>r(f.target.value),"aria-label":"Video quality",children:[i.jsx("option",{value:"best",children:"Best quality"}),g.map(f=>i.jsx("option",{value:f,children:f},f)),m&&i.jsx("option",{value:"audio",children:"Audio only"})]})}return null})();return i.jsxs("div",{className:`capture-row capture-row--${e.status}`,children:[i.jsxs("div",{className:"capture-row-main",children:[i.jsx(Uh,{status:e.status}),i.jsx("input",{ref:o,className:"capture-input",type:"text",placeholder:"https://… · yt:ID · ytm:ID · tweet:ID · x:ID",value:e.locator,onChange:g=>n(g.target.value),onKeyDown:g=>{g.key==="Enter"&&a()},disabled:u||e.status==="completed",autoComplete:"off",spellCheck:!1}),c,e.status==="failed"&&i.jsx("button",{type:"button",className:"capture-row-action",onClick:s,title:"Retry",children:i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M13 2.5A7 7 0 1 1 6.5 1"}),i.jsx("polyline",{points:"6.5 1 4 3.5 6.5 6"})]})}),!u&&e.status!=="completed"&&e.status!=="failed"&&i.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:l,"aria-label":"Remove",children:i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),i.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),e.error&&i.jsx("p",{className:"capture-row-error",children:e.error})]})}function Uh({status:e}){return e==="submitting"||e==="running"?i.jsx("span",{className:"cap-dot cap-dot--running","aria-label":"Running",children:i.jsx("span",{className:"cap-spinner"})}):e==="completed"?i.jsx("span",{className:"cap-dot cap-dot--ok","aria-label":"Done",children:"✓"}):e==="failed"?i.jsx("span",{className:"cap-dot cap-dot--err","aria-label":"Failed",children:"✕"}):i.jsx("span",{className:"cap-dot cap-dot--idle","aria-hidden":"true"})}function vi(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&r").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}function Kt(e){return Hh(e)??""}function Yc(e){if(!e)return"";const t=new Date(e);if(isNaN(t))return e;const n=r=>String(r).padStart(2,"0");return`${t.getUTCFullYear()}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}const Po={youtube:'',youtube_music:'',spotify:'',x:'',instagram:'',facebook:'',tiktok:'',reddit:'',snapchat:'',local:'',web:'',other:'?'};function pa(e){return Po[e]??Po.other}function qc(e){return e.split("/").map(t=>t?t.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):"").join("/")}function Wh({entry:e,archiveId:t,isSelected:n,onSelect:r}){const[l,s]=p.useState(!1),o=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!l?i.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>s(!0),style:{objectFit:"contain"}}):i.jsx("span",{dangerouslySetInnerHTML:{__html:pa(e.source_kind)}});return i.jsxs("div",{className:n?"is-selected":void 0,tabIndex:0,"data-entry-uid":e.entry_uid,onClick:r,onKeyDown:u=>{u.key==="Enter"&&r()},children:[i.jsx("div",{className:"col-added",children:Yc(e.archived_at)}),i.jsxs("div",{className:"col-title",children:[i.jsx("span",{className:"source-icon",children:o}),i.jsx("span",{className:"entry-title",children:Kt(e.title)||Kt(e.entry_uid)})]}),i.jsx("div",{className:"col-type",children:i.jsx("span",{className:"type-pill",children:Kt(e.entity_kind)})}),i.jsxs("div",{className:"col-size",children:[i.jsx("span",{className:"size-total",children:vi(e.total_artifact_bytes)}),e.cached_bytes>0&&e.total_artifact_bytes>0&&i.jsxs("span",{className:"size-cached-pct",title:`${vi(e.cached_bytes)} already on disk from an earlier entry`,children:[Math.round(e.cached_bytes/e.total_artifact_bytes*100),"% cached"]})]}),i.jsx("div",{className:"url-cell col-url",children:Kt(e.original_url)})]})}function Vh({entries:e,selectedEntryUid:t,onSelectEntry:n,archiveId:r}){return i.jsx("section",{id:"archive-view",className:"view is-active",children:i.jsxs("div",{className:"entry-table",children:[i.jsxs("div",{className:"entry-header-row",children:[i.jsx("div",{className:"col-added",children:"Added"}),i.jsx("div",{className:"col-title",children:"Title"}),i.jsx("div",{className:"col-type",children:"Type"}),i.jsx("div",{className:"col-size",children:"Size"}),i.jsx("div",{className:"col-url",children:"Original URL"})]}),i.jsx("div",{id:"entries-body",children:e.map(l=>i.jsx(Wh,{entry:l,archiveId:r,isSelected:l.entry_uid===t,onSelect:()=>n(l)},l.entry_uid))})]})})}function Qh(e){if(!e)return"—";try{return new Date(e).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}function Kh({status:e}){const t=e==="completed"?"run-status--completed":e==="failed"?"run-status--failed":e==="in_progress"?"run-status--in-progress":"",n=e?e.replace(/_/g," "):"—";return i.jsx("span",{className:`run-status ${t}`,children:n})}function Xh({runs:e}){const[t,n]=p.useState(null);function r(l){n(s=>s===l?null:l)}return i.jsx("section",{id:"runs-view",className:"view is-active",children:i.jsxs("table",{className:"entry-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Started"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Requested"}),i.jsx("th",{children:"Completed"}),i.jsx("th",{children:"Failed"})]})}),i.jsx("tbody",{children:e.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:5,style:{color:"var(--muted)",padding:"24px 16px",textAlign:"center"},children:"No runs yet."})}):e.map(l=>{const s=l.status==="failed"&&l.error_summary,a=t===l.run_uid;return[i.jsxs("tr",{className:s?"run-row run-row--failed":"run-row",onClick:s?()=>r(l.run_uid):void 0,title:s?a?"Click to hide error":"Click to view error":void 0,children:[i.jsx("td",{children:Qh(l.started_at)}),i.jsxs("td",{children:[i.jsx(Kh,{status:l.status}),s&&i.jsx("span",{className:"run-expand-hint","aria-hidden":"true",children:a?"▴":"▾"})]}),i.jsx("td",{children:l.requested_count??"—"}),i.jsx("td",{children:l.completed_count??"—"}),i.jsx("td",{children:l.failed_count??"—"})]},l.run_uid),s&&a&&i.jsx("tr",{className:"run-error-row",children:i.jsx("td",{colSpan:5,children:i.jsx("pre",{className:"run-error-detail",children:l.error_summary})})},`${l.run_uid}-detail`)]})})]})})}const Jh=4;function Gh({archives:e}){const{currentUser:t}=p.useContext(Wl)??{},n=t&&(t.role_bits&Jh)!==0,[r,l]=p.useState("users"),[s,a]=p.useState([]),[o,u]=p.useState([]),[c,g]=p.useState(!1),[m,f]=p.useState(null),[w,y]=p.useState(""),[x,z]=p.useState(""),[h,d]=p.useState(""),[v,k]=p.useState(null),[S,T]=p.useState(!1),[E,N]=p.useState(""),[O,I]=p.useState(""),[H,ee]=p.useState(null),[Z,te]=p.useState(!1),je=p.useCallback(async()=>{if(n){g(!0),f(null);try{const[_,B]=await Promise.all([gh(),xh()]);a(_),u(B)}catch(_){f(_.message)}finally{g(!1)}}},[n]);p.useEffect(()=>{je()},[je]);async function Ee(_){const B=_.status==="active"?"disabled":"active";try{await yh(_.user_uid,B),a(j=>j.map(C=>C.user_uid===_.user_uid?{...C,status:B}:C))}catch(j){f(j.message)}}async function ye(_){if(_.preventDefault(),!w.trim()||!x){k("Username and password required");return}T(!0),k(null);try{await vh(w.trim(),x,h.trim()||void 0),y(""),z(""),d(""),await je()}catch(B){k(B.message)}finally{T(!1)}}async function R(_){if(_.preventDefault(),!E.trim()||!O.trim()){ee("Slug and name required");return}te(!0),ee(null);try{await wh(E.trim(),O.trim()),N(""),I(""),await je()}catch(B){ee(B.message)}finally{te(!1)}}return n?i.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[i.jsx("h1",{children:"Admin"}),i.jsxs("div",{className:"view-tabs",children:[i.jsx("button",{className:`view-tab${r==="users"?" is-active":""}`,onClick:()=>l("users"),children:"Users"}),i.jsx("button",{className:`view-tab${r==="roles"?" is-active":""}`,onClick:()=>l("roles"),children:"Roles"}),i.jsx("button",{className:`view-tab${r==="archives"?" is-active":""}`,onClick:()=>l("archives"),children:"Archives"})]}),m&&i.jsx("div",{className:"form-msg form-msg--err",children:m}),r==="users"&&i.jsxs("div",{className:"admin-section",children:[i.jsx("h2",{children:"Users"}),c?i.jsx("p",{className:"muted",children:"Loading…"}):i.jsxs("table",{className:"admin-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Username"}),i.jsx("th",{children:"Email"}),i.jsx("th",{children:"Roles"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Actions"})]})}),i.jsx("tbody",{children:s.map(_=>i.jsxs("tr",{className:_.status==="disabled"?"admin-row-disabled":"",children:[i.jsx("td",{children:_.username}),i.jsx("td",{className:"muted",children:_.email||"—"}),i.jsx("td",{children:_.role_slugs.join(", ")||"—"}),i.jsx("td",{children:i.jsx("span",{className:`status-badge status-${_.status}`,children:_.status})}),i.jsx("td",{children:i.jsx("button",{className:"admin-action-btn",onClick:()=>Ee(_),children:_.status==="active"?"Ban":"Unban"})})]},_.user_uid))})]}),i.jsx("h3",{children:"Create User"}),i.jsxs("form",{className:"admin-form",onSubmit:ye,children:[i.jsx("input",{className:"admin-input",placeholder:"Username",value:w,onChange:_=>y(_.target.value),required:!0}),i.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:x,onChange:_=>z(_.target.value),required:!0}),i.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:h,onChange:_=>d(_.target.value)}),v&&i.jsx("div",{className:"form-msg form-msg--err",children:v}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:S,children:S?"Creating…":"Create User"})]})]}),r==="roles"&&i.jsxs("div",{className:"admin-section",children:[i.jsx("h2",{children:"Roles"}),c?i.jsx("p",{className:"muted",children:"Loading…"}):i.jsxs("table",{className:"admin-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Slug"}),i.jsx("th",{children:"Name"}),i.jsx("th",{children:"Level"}),i.jsx("th",{children:"Bit"}),i.jsx("th",{children:"Built-in"})]})}),i.jsx("tbody",{children:o.map(_=>i.jsxs("tr",{children:[i.jsx("td",{children:i.jsx("code",{children:_.slug})}),i.jsx("td",{children:_.name}),i.jsx("td",{children:_.level}),i.jsx("td",{children:_.bit_position}),i.jsx("td",{children:_.is_builtin?"✓":""})]},_.role_uid))})]}),i.jsx("h3",{children:"Create Custom Role"}),i.jsxs("form",{className:"admin-form",onSubmit:R,children:[i.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:E,onChange:_=>N(_.target.value),required:!0}),i.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:O,onChange:_=>I(_.target.value),required:!0}),H&&i.jsx("div",{className:"form-msg form-msg--err",children:H}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:Z,children:Z?"Creating…":"Create Role"})]})]}),r==="archives"&&i.jsxs("div",{className:"admin-section",children:[i.jsx("h2",{children:"Mounted Archives"}),i.jsx("div",{className:"admin-list",children:e.map(_=>i.jsxs("div",{className:"admin-archive",children:[i.jsx("strong",{children:_.label}),i.jsx("div",{className:"muted",children:_.archive_path})]},_.id))})]})]}):i.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[i.jsx("h1",{children:"Admin"}),i.jsx("p",{className:"muted",children:"You need admin privileges to access this panel."}),i.jsx("h2",{children:"Mounted Archives"}),i.jsx("div",{className:"admin-list",children:e.map(_=>i.jsxs("div",{className:"admin-archive",children:[i.jsx("strong",{children:_.label}),i.jsx("div",{className:"muted",children:_.archive_path})]},_.id))})]})}function Zc({node:e,archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){var k;const c=n===e.tag.full_path,[g,m]=p.useState(!1),[f,w]=p.useState(""),y=p.useRef(!1);function x(){if(g)return;const S=c?null:e.tag.full_path;r(S),l("archive")}function z(S){S.stopPropagation(),w(e.tag.slug),m(!0)}async function h(){const S=f.trim();if(!S||S===e.tag.slug){m(!1);return}try{const T=await th(t,e.tag.tag_uid,S);s(e.tag.full_path,T.full_path),o()}catch{}finally{m(!1)}}async function d(S){var E;S.stopPropagation();const T=((E=e.children)==null?void 0:E.length)>0?`Delete tag "${e.tag.full_path}" and all its child tags? This cannot be undone.`:`Delete tag "${e.tag.full_path}"? This cannot be undone.`;if(window.confirm(T))try{await nh(t,e.tag.tag_uid),a(e.tag.full_path),o()}catch{}}const v={archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u};return i.jsxs("li",{children:[i.jsxs("div",{className:"tag-node-row",children:[g?i.jsx("input",{className:"tag-rename-input",autoFocus:!0,value:f,onChange:S=>w(S.target.value),onKeyDown:S=>{S.key==="Enter"&&S.currentTarget.blur(),S.key==="Escape"&&(y.current=!0,S.currentTarget.blur())},onBlur:()=>{y.current?(y.current=!1,m(!1)):h()}}):i.jsxs("button",{className:`tag-node-btn${c?" is-active":""}`,title:e.tag.full_path,onClick:x,onDoubleClick:z,children:[u?e.tag.name:e.tag.slug,i.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",onClick:S=>{S.stopPropagation(),z(S)},children:i.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),i.jsx("button",{className:"remove tag-node-delete",title:`Delete tag ${e.tag.full_path}`,onClick:d,"aria-label":`Delete tag ${e.tag.full_path}`,children:"×"})]}),((k=e.children)==null?void 0:k.length)>0&&i.jsx("div",{className:"tag-children",children:i.jsx("ul",{className:"tag-tree-list",children:e.children.map(S=>i.jsx(Zc,{node:S,...v},S.tag.tag_uid))})})]})}function Yh({archiveId:e,tagNodes:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){return i.jsx("section",{id:"tags-view",className:"view is-active",children:i.jsxs("div",{className:"tag-tree",children:[i.jsxs("div",{className:"tag-tree-header",children:[i.jsx("span",{className:"tag-tree-title",children:"Tags"}),n&&i.jsxs("span",{className:"tag-tree-active",children:["Filtering: ",n]})]}),t.length===0?i.jsx("p",{className:"muted",style:{padding:"8px 0"},children:"No tags yet."}):i.jsx("ul",{className:"tag-tree-list",children:t.map(c=>i.jsx(Zc,{node:c,archiveId:e,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u},c.tag.tag_uid))})]})})}const Kn=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],qh=e=>{var t;return((t=Kn.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function Zh({archiveId:e}){const[t,n]=p.useState([]),[r,l]=p.useState(!1),[s,a]=p.useState(null),[o,u]=p.useState(null),[c,g]=p.useState(null),[m,f]=p.useState(!1),[w,y]=p.useState(null),[x,z]=p.useState(""),[h,d]=p.useState(""),[v,k]=p.useState(2),[S,T]=p.useState(!1),[E,N]=p.useState(null),[O,I]=p.useState(""),[H,ee]=p.useState(2),[Z,te]=p.useState(!1),[je,Ee]=p.useState(null),[ye,R]=p.useState(!1),[_,B]=p.useState(""),j=p.useRef(null),C=t.find(D=>D.collection_uid===o)??null,F=(C==null?void 0:C.slug)==="_default_",M=p.useCallback(async()=>{if(e){l(!0),a(null);try{const D=await kh(e);n(D)}catch(D){a(D.message)}finally{l(!1)}}},[e]),U=p.useCallback(async D=>{if(!D){g(null);return}f(!0),y(null);try{const W=await Sh(e,D);g(W)}catch(W){y(W.message)}finally{f(!1)}},[e]);p.useEffect(()=>{M()},[M]),p.useEffect(()=>{U(o)},[o,U]),p.useEffect(()=>{ye&&j.current&&j.current.focus()},[ye]);async function Y(D){D.preventDefault();const W=x.trim(),be=h.trim();if(!(!W||!be)){T(!0),N(null);try{const dt=await jh(e,W,be,v);z(""),d(""),k(2),await M(),u(dt.collection_uid)}catch(dt){N(dt.message)}finally{T(!1)}}}async function Q(){const D=_.trim();if(!D||!C){R(!1);return}try{await Eo(e,C.collection_uid,{name:D}),await M(),g(W=>W&&{...W,name:D})}catch(W){a(W.message)}finally{R(!1)}}async function J(D){if(C)try{await Eo(e,C.collection_uid,{default_visibility_bits:D}),await M(),g(W=>W&&{...W,default_visibility_bits:D})}catch(W){a(W.message)}}async function L(){if(C&&window.confirm(`Delete collection "${C.name}"? Entries will not be deleted.`))try{await Th(e,C.collection_uid),u(null),g(null),await M()}catch(D){a(D.message)}}async function X(D){D.preventDefault();const W=O.trim();if(!(!W||!C)){te(!0),Ee(null);try{await Nh(e,C.collection_uid,W,H),I(""),await U(C.collection_uid)}catch(be){Ee(be.message)}finally{te(!1)}}}async function We(D){if(C)try{await _h(e,C.collection_uid,D),await U(C.collection_uid)}catch(W){y(W.message)}}async function Ve(D,W){if(C)try{await Ch(e,C.collection_uid,D,W),g(be=>be&&{...be,entries:be.entries.map(dt=>dt.entry_uid===D?{...dt,collection_visibility_bits:W}:dt)})}catch(be){y(be.message)}}return e?i.jsxs("div",{className:"collections-view",children:[i.jsx("h2",{className:"collections-heading",children:"Collections"}),r&&i.jsx("div",{className:"muted",children:"Loading…"}),s&&i.jsxs("div",{className:"collections-error",children:[s," ",i.jsx("button",{onClick:()=>a(null),className:"coll-dismiss",children:"×"})]}),i.jsxs("div",{className:"collections-layout",children:[i.jsxs("div",{className:"collections-sidebar",children:[t.map(D=>i.jsxs("button",{className:`coll-sidebar-row${o===D.collection_uid?" is-active":""}`,onClick:()=>u(D.collection_uid),children:[i.jsx("span",{className:"coll-row-name",children:D.name}),i.jsx("span",{className:"coll-row-meta",children:qh(D.default_visibility_bits)})]},D.collection_uid)),t.length===0&&!r&&i.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),C?i.jsxs("div",{className:"coll-detail",children:[i.jsxs("div",{className:"coll-detail-header",children:[ye?i.jsx("input",{ref:j,className:"coll-rename-input",value:_,onChange:D=>B(D.target.value),onBlur:Q,onKeyDown:D=>{D.key==="Enter"&&Q(),D.key==="Escape"&&R(!1)}}):i.jsxs("h3",{className:`coll-detail-name${F?"":" coll-detail-name--editable"}`,title:F?void 0:"Click to rename",onClick:()=>{F||(B(C.name),R(!0))},children:[(c==null?void 0:c.name)??C.name,!F&&i.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!F&&i.jsx("button",{className:"coll-delete-btn",onClick:L,title:"Delete collection",children:"Delete"})]}),i.jsxs("div",{className:"coll-detail-vis",children:[i.jsx("span",{className:"coll-vis-label",children:"Default visibility"}),i.jsx("select",{className:"coll-vis-select",value:(c==null?void 0:c.default_visibility_bits)??C.default_visibility_bits,onChange:D=>J(Number(D.target.value)),disabled:F,children:Kn.map(D=>i.jsx("option",{value:D.value,children:D.label},D.value))})]}),i.jsxs("div",{className:"coll-entries-section",children:[i.jsx("div",{className:"coll-section-heading",children:"Entries"}),m&&i.jsx("div",{className:"muted",children:"Loading…"}),w&&i.jsx("div",{className:"collections-error",children:w}),!m&&c&&(c.entries.length===0?i.jsx("div",{className:"muted",children:"No entries in this collection."}):i.jsx("ul",{className:"coll-entries-list",children:c.entries.map(D=>i.jsxs("li",{className:"coll-entry-row",children:[i.jsxs("div",{className:"coll-entry-info",children:[i.jsx("span",{className:"coll-entry-title",children:D.title||D.entry_uid}),i.jsx("span",{className:"coll-entry-kind muted",children:D.source_kind})]}),i.jsxs("div",{className:"coll-entry-actions",children:[i.jsx("select",{className:"coll-entry-vis-select",value:D.collection_visibility_bits,onChange:W=>Ve(D.entry_uid,Number(W.target.value)),children:Kn.map(W=>i.jsx("option",{value:W.value,children:W.label},W.value))}),!F&&i.jsx("button",{className:"coll-entry-remove",onClick:()=>We(D.entry_uid),title:"Remove from collection",children:"×"})]})]},D.entry_uid))}))]}),!F&&i.jsxs("form",{className:"coll-add-entry-form",onSubmit:X,children:[i.jsx("div",{className:"coll-section-heading",children:"Add entry"}),i.jsxs("div",{className:"coll-add-entry-row",children:[i.jsx("input",{className:"coll-add-entry-input",type:"text",value:O,onChange:D=>I(D.target.value),placeholder:"entry_uid",required:!0}),i.jsx("select",{className:"coll-vis-select",value:H,onChange:D=>ee(Number(D.target.value)),children:Kn.map(D=>i.jsx("option",{value:D.value,children:D.label},D.value))}),i.jsx("button",{className:"coll-add-btn",type:"submit",disabled:Z,children:Z?"…":"Add"})]}),je&&i.jsx("div",{className:"collections-error",style:{marginTop:4},children:je})]})]}):i.jsx("div",{className:"coll-detail coll-detail--empty",children:i.jsx("div",{className:"muted",children:"Select a collection to view details."})})]}),i.jsxs("details",{className:"coll-create-details",children:[i.jsx("summary",{children:"+ Create collection"}),i.jsxs("form",{className:"coll-create-form",onSubmit:Y,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"coll-name",children:"Name"}),i.jsx("input",{className:"capture-input",id:"coll-name",type:"text",value:x,onChange:D=>{z(D.target.value),h||d(D.target.value.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"My Collection",required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"coll-slug",children:"Slug"}),i.jsx("input",{className:"capture-input",id:"coll-slug",type:"text",value:h,onChange:D=>d(D.target.value),placeholder:"my-collection",required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"coll-vis",children:"Default visibility"}),i.jsx("select",{className:"capture-input",id:"coll-vis",style:{height:42},value:v,onChange:D=>k(Number(D.target.value)),children:Kn.map(D=>i.jsx("option",{value:D.value,children:D.label},D.value))})]}),E&&i.jsx("div",{className:"collections-error",children:E}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:S,children:S?"Creating…":"Create collection"})]})]})]}):i.jsx("div",{className:"view-placeholder",children:"Select an archive."})}const em=4;function tm({tab:e,onTabChange:t,archiveId:n}){const{currentUser:r,setCurrentUser:l}=p.useContext(Wl)??{},s=r&&(r.role_bits&em)!==0,a=["profile","tokens",...s?["instance","cookies","extensions","storage"]:[]],o={profile:"Profile",tokens:"API Tokens",instance:"Instance",cookies:"Cookies",extensions:"Extensions",storage:"Storage"};return i.jsxs("section",{className:"admin-view",children:[i.jsx("h1",{children:"Settings"}),i.jsx("div",{className:"view-tabs",children:a.map(u=>i.jsx("button",{className:`view-tab${e===u?" is-active":""}`,onClick:()=>t(u),children:o[u]},u))}),e==="profile"&&i.jsx(nm,{currentUser:r,setCurrentUser:l}),e==="tokens"&&i.jsx(rm,{}),e==="instance"&&s&&i.jsx(lm,{}),e==="cookies"&&s&&i.jsx(im,{}),e==="extensions"&&s&&i.jsx(am,{}),e==="storage"&&s&&i.jsx(sm,{archiveId:n})]})}function nm({currentUser:e,setCurrentUser:t}){const[n,r]=p.useState((e==null?void 0:e.display_name)??""),[l,s]=p.useState(!1),[a,o]=p.useState(null),[u,c]=p.useState(""),[g,m]=p.useState(""),[f,w]=p.useState(""),[y,x]=p.useState(!1),[z,h]=p.useState(null);async function d(k){k.preventDefault(),s(!0),o(null);try{await ch(n),t(S=>({...S,display_name:n||null})),o({ok:!0,text:"Saved."})}catch(S){o({ok:!1,text:S.message})}finally{s(!1)}}async function v(k){if(k.preventDefault(),g!==f){h({ok:!1,text:"Passwords do not match."});return}x(!0),h(null);try{await fh(u,g),c(""),m(""),w(""),h({ok:!0,text:"Password changed."})}catch(S){h({ok:!1,text:S.message})}finally{x(!1)}}return i.jsxs("div",{style:{maxWidth:440},children:[i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Display Name"}),i.jsxs("form",{onSubmit:d,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"display-name",children:"Name shown in the UI"}),i.jsx("input",{className:"field-input",id:"display-name",placeholder:(e==null?void 0:e.username)??"",value:n,onChange:k=>r(k.target.value)})]}),a&&i.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:l,children:l?"Saving…":"Save"})]})]}),i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Display Preferences"}),i.jsxs("label",{className:"checkbox-row",children:[i.jsx("input",{type:"checkbox",checked:(e==null?void 0:e.humanize_slugs)??!1,onChange:async k=>{const S=k.target.checked;try{await dh({humanize_slugs:S}),t(T=>({...T,humanize_slugs:S}))}catch{}}}),i.jsx("span",{className:"form-label",style:{margin:0},children:"Humanize tag display"})]}),i.jsx("p",{className:"muted",style:{fontSize:13,margin:"4px 0 0"},children:'When on, tag paths show as "X / Articles" instead of "x/articles".'})]}),i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Change Password"}),i.jsxs("form",{onSubmit:v,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"cur-pw",children:"Current password"}),i.jsx("input",{className:"field-input",id:"cur-pw",type:"password",value:u,onChange:k=>c(k.target.value),required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"new-pw",children:"New password"}),i.jsx("input",{className:"field-input",id:"new-pw",type:"password",value:g,onChange:k=>m(k.target.value),required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"confirm-pw",children:"Confirm new password"}),i.jsx("input",{className:"field-input",id:"confirm-pw",type:"password",value:f,onChange:k=>w(k.target.value),required:!0})]}),z&&i.jsx("div",{className:`form-msg form-msg--${z.ok?"ok":"err"}`,children:z.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:y,children:y?"Changing…":"Change Password"})]})]})]})}function rm(){const[e,t]=p.useState([]),[n,r]=p.useState(!0),[l,s]=p.useState(null),[a,o]=p.useState(""),[u,c]=p.useState(!1),[g,m]=p.useState(null),f=p.useCallback(async()=>{r(!0),s(null);try{t(await ph())}catch(x){s(x.message)}finally{r(!1)}},[]);p.useEffect(()=>{f()},[f]);async function w(x){if(x.preventDefault(),!!a.trim()){c(!0);try{const z=await hh(a.trim());m(z),o(""),f()}catch(z){s(z.message)}finally{c(!1)}}}async function y(x){try{await mh(x),t(z=>z.filter(h=>h.token_uid!==x))}catch(z){s(z.message)}}return i.jsx("div",{style:{maxWidth:600},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"API Tokens"}),g&&i.jsxs("div",{className:"token-banner",children:[i.jsx("strong",{children:"Token created."})," Copy it now — it won't be shown again.",i.jsx("code",{children:g.raw_token}),i.jsx("button",{className:"token-dismiss",onClick:()=>m(null),children:"Dismiss"})]}),i.jsxs("form",{className:"token-create-row",onSubmit:w,children:[i.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:a,onChange:x=>o(x.target.value),required:!0}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:u,children:u?"Creating…":"Create token"})]}),l&&i.jsx("div",{className:"form-msg form-msg--err",children:l}),n?i.jsx("div",{className:"muted",children:"Loading…"}):i.jsxs("div",{children:[e.length===0&&i.jsx("div",{className:"muted",children:"No tokens yet."}),e.map(x=>i.jsxs("div",{className:"token-row",children:[i.jsxs("div",{className:"token-row-info",children:[i.jsx("strong",{children:x.name}),i.jsxs("div",{className:"muted",children:["Created ",x.created_at.slice(0,10),x.last_used_at&&` · Last used ${x.last_used_at.slice(0,10)}`]})]}),i.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>y(x.token_uid),children:"Revoke"})]},x.token_uid))]})]})})}function lm(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,s]=p.useState(null),[a,o]=p.useState(!1),[u,c]=p.useState(null);p.useEffect(()=>{(async()=>{try{t(await fa())}catch(m){s(m.message)}finally{r(!1)}})()},[]);async function g(m){m.preventDefault(),o(!0),c(null);try{await mi(e),c({ok:!0,text:"Saved."})}catch(f){c({ok:!1,text:f.message})}finally{o(!1)}}return n?i.jsx("div",{className:"muted",children:"Loading…"}):l?i.jsx("div",{className:"form-msg form-msg--err",children:l}):e?i.jsx("div",{style:{maxWidth:440},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Instance Settings"}),i.jsxs("form",{onSubmit:g,children:[[["public_index_enabled","Public index (unauthenticated browsing)"],["public_entry_content_enabled","Public entry content"],["open_registration_enabled","Open registration"]].map(([m,f])=>i.jsxs("label",{className:"checkbox-row",children:[i.jsx("input",{type:"checkbox",checked:!!e[m],onChange:w=>t(y=>({...y,[m]:w.target.checked}))}),f]},m)),i.jsxs("div",{className:"form-field",style:{marginTop:4},children:[i.jsx("label",{className:"form-label",children:"Default entry visibility"}),i.jsxs("select",{className:"field-input",value:e.default_entry_visibility,onChange:m=>t(f=>({...f,default_entry_visibility:Number(m.target.value)})),children:[i.jsx("option",{value:0,children:"Private"}),i.jsx("option",{value:2,children:"Unlisted"}),i.jsx("option",{value:3,children:"Public"})]})]}),u&&i.jsx("div",{className:`form-msg form-msg--${u.ok?"ok":"err"}`,children:u.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:a,children:a?"Saving…":"Save Settings"})]})]})}):null}function xs(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,n)).toFixed(n===0?0:1)} ${t[n]}`}function sm({archiveId:e}){const[t,n]=p.useState("idle"),[r,l]=p.useState(null),[s,a]=p.useState(null),[o,u]=p.useState(null);function c(){n("idle"),l(null),a(null),u(null)}async function g(){n("scanning"),u(null),l(null);try{const w=await Ph(e);l(w),n("scanned")}catch(w){u(w.message),n("error")}}async function m(){n("deleting"),u(null);try{const w=await Lh(e);a(w),n("done")}catch(w){u(w.message),n("error")}}const f=r&&r.deletable_files===0&&r.orphaned_blob_rows===0;return i.jsx("div",{style:{maxWidth:440},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Orphan Cleanup"}),i.jsxs("p",{className:"muted",style:{marginBottom:16},children:["Scan for blob files and database records that are no longer referenced by any archive entry and safely delete them."," ",i.jsx("strong",{children:"Cleanup is blocked while captures are running."})]}),!e&&i.jsx("div",{className:"muted",children:"No archive selected."}),e&&t==="idle"&&i.jsx("button",{className:"btn-ghost",onClick:g,children:"Scan for orphaned blobs"}),t==="scanning"&&i.jsx("div",{className:"muted",children:"Scanning…"}),t==="scanned"&&r&&f&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"form-msg form-msg--ok",children:"Archive is clean — nothing to remove."}),i.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Done"})]}),t==="scanned"&&r&&!f&&i.jsxs("div",{children:[i.jsxs("div",{style:{marginBottom:14,lineHeight:1.6},children:["Found ",i.jsx("strong",{children:r.deletable_files})," unreferenced file",r.deletable_files!==1?"s":""," ","and ",i.jsx("strong",{children:r.orphaned_blob_rows})," orphaned DB record",r.orphaned_blob_rows!==1?"s":""," ","— ",i.jsx("strong",{children:xs(r.total_bytes)})," recoverable."]}),i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsxs("button",{className:"btn-danger",onClick:m,children:["Delete (",xs(r.total_bytes),")"]}),i.jsx("button",{className:"btn-ghost",onClick:c,children:"Cancel"})]})]}),t==="deleting"&&i.jsx("div",{className:"muted",children:"Deleting…"}),t==="done"&&s&&i.jsxs("div",{children:[i.jsxs("div",{className:"form-msg form-msg--ok",children:["Freed ",i.jsx("strong",{children:xs(s.freed_bytes)})," ","— removed ",s.deleted_files," file",s.deleted_files!==1?"s":""," ","and ",s.deleted_blob_rows," DB record",s.deleted_blob_rows!==1?"s":"","."]}),s.errors&&s.errors.length>0&&i.jsxs("div",{className:"form-msg form-msg--err",style:{marginTop:6},children:[s.errors.length," file",s.errors.length!==1?"s":""," could not be deleted."]}),i.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Scan again"})]}),t==="error"&&i.jsxs("div",{children:[i.jsx("div",{className:"form-msg form-msg--err",children:o}),i.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Try again"})]})]})})}function im(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,s]=p.useState(null),[a,o]=p.useState("global"),[u,c]=p.useState(""),[g,m]=p.useState("{}"),[f,w]=p.useState(null),[y,x]=p.useState(!1),[z,h]=p.useState({});p.useEffect(()=>{d()},[]);async function d(){r(!0),s(null);try{t(await zh())}catch(N){s(N.message)}finally{r(!1)}}async function v(N){N.preventDefault();try{JSON.parse(g)}catch{w({ok:!1,text:'cookies must be valid JSON, e.g. {"session": "abc"}'});return}x(!0),w(null);try{await Dh(a==="global"?null:u.trim(),a,g),c(""),m("{}"),o("global"),w({ok:!0,text:"Rule added."}),await d()}catch(O){w({ok:!1,text:O.message})}finally{x(!1)}}async function k(N){try{await Oh(N),await d()}catch(O){s(O.message)}}function S(N){h(O=>({...O,[N.rule_uid]:{cookiesInput:N.cookies_json,saving:!1,msg:null}}))}function T(N){h(O=>{const I={...O};return delete I[N],I})}async function E(N){const O=z[N.rule_uid];try{JSON.parse(O.cookiesInput)}catch{h(I=>({...I,[N.rule_uid]:{...I[N.rule_uid],msg:{ok:!1,text:"Invalid JSON"}}}));return}h(I=>({...I,[N.rule_uid]:{...I[N.rule_uid],saving:!0,msg:null}}));try{await Ih(N.rule_uid,{cookies_json:O.cookiesInput}),T(N.rule_uid),await d()}catch(I){h(H=>({...H,[N.rule_uid]:{...H[N.rule_uid],saving:!1,msg:{ok:!1,text:I.message}}}))}}return n?i.jsx("div",{className:"muted",children:"Loading…"}):l?i.jsx("div",{className:"form-msg form-msg--err",children:l}):i.jsx("div",{style:{maxWidth:560},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Cookie Rules"}),i.jsx("p",{className:"muted",style:{marginBottom:12},children:"Cookies are injected into every capture network request (yt-dlp, HTTP downloads, web-page snapshots). Global rules apply to all URLs; wildcard and regex rules apply only to matching URLs."}),e&&e.length>0?i.jsxs("table",{className:"data-table",style:{width:"100%",marginBottom:16},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Pattern"}),i.jsx("th",{children:"Cookies"}),i.jsx("th",{style:{width:100},children:"Actions"})]})}),i.jsx("tbody",{children:e.map(N=>{const O=z[N.rule_uid],I=N.url_pattern?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"muted",children:[N.pattern_kind,":"]})," ",i.jsx("code",{children:N.url_pattern})]}):i.jsx("span",{className:"muted",children:"global (all URLs)"});return i.jsxs("tr",{children:[i.jsx("td",{children:I}),i.jsx("td",{children:O?i.jsxs(i.Fragment,{children:[i.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:12,width:"100%",minHeight:60},value:O.cookiesInput,onChange:H=>h(ee=>({...ee,[N.rule_uid]:{...ee[N.rule_uid],cookiesInput:H.target.value}}))}),O.msg&&i.jsx("div",{className:`form-msg form-msg--${O.msg.ok?"ok":"err"}`,children:O.msg.text}),i.jsxs("div",{style:{display:"flex",gap:8,marginTop:4},children:[i.jsx("button",{className:"btn-primary",style:{fontSize:12,padding:"2px 8px"},disabled:O.saving,onClick:()=>E(N),children:O.saving?"Saving…":"Save"}),i.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>T(N.rule_uid),children:"Cancel"})]})]}):i.jsx("code",{style:{fontSize:12,wordBreak:"break-all"},children:N.cookies_json})}),i.jsx("td",{children:!O&&i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>S(N),children:"Edit"}),i.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"2px 8px"},onClick:()=>k(N.rule_uid),children:"Del"})]})})]},N.rule_uid)})})]}):i.jsx("p",{className:"muted",style:{marginBottom:16},children:"No cookie rules defined."}),i.jsx("h3",{style:{marginBottom:8},children:"Add Rule"}),i.jsxs("form",{onSubmit:v,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",children:"Pattern type"}),i.jsxs("select",{className:"field-input",value:a,onChange:N=>o(N.target.value),children:[i.jsx("option",{value:"global",children:"Global (all URLs)"}),i.jsx("option",{value:"wildcard",children:"Wildcard (e.g. *.youtube.com)"}),i.jsx("option",{value:"regex",children:"Regex (matched against full URL)"})]})]}),a!=="global"&&i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",children:a==="wildcard"?"URL/hostname pattern":"Regex pattern"}),i.jsx("input",{className:"field-input",type:"text",value:u,onChange:N=>c(N.target.value),placeholder:a==="wildcard"?"*.youtube.com or https://example.com/*":".*\\.youtube\\.com.*",required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",children:"Cookies (JSON object)"}),i.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:13,minHeight:70},value:g,onChange:N=>m(N.target.value),placeholder:'{"SESSION": "abc123", "token": "xyz"}',required:!0})]}),f&&i.jsx("div",{className:`form-msg form-msg--${f.ok?"ok":"err"}`,children:f.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:y,children:y?"Adding…":"Add Rule"})]})]})})}function am(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,s]=p.useState(!1),[a,o]=p.useState(null);p.useEffect(()=>{(async()=>{try{t(await fa())}catch(y){o({ok:!1,text:y.message})}finally{r(!1)}})()},[]);async function u(y){s(!0),o(null);try{await mi({ublock_enabled:y}),t(x=>({...x,ublock_enabled:y})),o({ok:!0,text:"Saved."})}catch(x){o({ok:!1,text:x.message})}finally{s(!1)}}async function c(y){s(!0),o(null);try{await mi({cookie_ext_enabled:y}),t(x=>({...x,cookie_ext_enabled:y})),o({ok:!0,text:"Saved."})}catch(x){o({ok:!1,text:x.message})}finally{s(!1)}}if(n)return i.jsx("div",{className:"muted",children:"Loading\\u2026"});const g=(e==null?void 0:e.ublock_ext_available)??!1,m=(e==null?void 0:e.ublock_enabled)??!0,f=(e==null?void 0:e.cookie_ext_available)??!1,w=(e==null?void 0:e.cookie_ext_enabled)??!0;return i.jsx("div",{style:{maxWidth:560},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Extensions"}),i.jsx("p",{className:"form-hint",style:{marginBottom:20},children:"Extensions run inside the browser during WebPage captures and can block ads, accept cookie banners, and more. Changes take effect on the next capture."}),i.jsx("div",{className:"ext-card",children:i.jsxs("div",{className:"ext-card-header",children:[i.jsxs("div",{className:"ext-card-info",children:[i.jsx("span",{className:"ext-card-name",children:"uBlock Origin Lite"}),i.jsx("span",{className:"ext-card-desc",children:"Blocks ads, trackers, and other page clutter during archiving via Chrome’s declarativeNetRequest API (Manifest V3)."}),!g&&i.jsxs("span",{className:"ext-card-hint",children:["Not configured — set ",i.jsx("code",{children:"ARCHIVR_UBLOCK_EXT"})," to the unpacked extension directory to enable."]})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":m,className:`ext-toggle${m?" ext-toggle--on":""}`,onClick:()=>u(!m),disabled:l,"aria-label":"Toggle uBlock Origin Lite",children:i.jsx("span",{className:"ext-toggle-knob"})})]})}),i.jsx("div",{className:"ext-card",children:i.jsxs("div",{className:"ext-card-header",children:[i.jsxs("div",{className:"ext-card-info",children:[i.jsx("span",{className:"ext-card-name",children:"I Still Don’t Care About Cookies"}),i.jsx("span",{className:"ext-card-desc",children:"Dismiss cookie consent banners during archiving."}),!f&&i.jsxs("span",{className:"ext-card-hint",children:["Not configured — set ",i.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})," to the unpacked extension directory to enable."]})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":w,className:`ext-toggle${w?" ext-toggle--on":""}`,onClick:()=>c(!w),disabled:l,"aria-label":"Toggle I Still Don't Care About Cookies",children:i.jsx("span",{className:"ext-toggle-knob"})})]})}),a&&i.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text})]})})}const Lo={0:"Private",1:"Public",2:"Users only",3:"Public"},om=()=>i.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M7 17 17 7M9 7h8v8"})});function um({archiveId:e,selectedEntry:t,detail:n,onTagFilterSet:r,tagNodes:l,onTagsRefresh:s,onEntryTitleChange:a,onEntryDeleted:o,humanizeTags:u,onDetailRefresh:c,onOpenPreview:g,onPlay:m}){const[f,w]=p.useState([]),[y,x]=p.useState(""),[z,h]=p.useState([]),[d,v]=p.useState(""),k=p.useRef(0),S=p.useRef(!1),[T,E]=p.useState(!1),[N,O]=p.useState(""),[I,H]=p.useState("idle"),[ee,Z]=p.useState(""),te=p.useRef(null);p.useEffect(()=>{const L=++k.current;if(te.current&&(clearInterval(te.current),te.current=null),H("idle"),Z(""),!t||!e){w([]),h([]);return}E(!1),O(""),S.current=!1,w([]),Promise.all([Hr(e,t.entry_uid),Eh(e,t.entry_uid)]).then(([X,We])=>{L===k.current&&(w(X),h(We))}).catch(()=>{})},[t,e]),p.useEffect(()=>()=>{clearInterval(te.current)},[]);async function je(){const L=N.trim()||null;try{await Yp(e,t.entry_uid,L),a==null||a(t.entry_uid,L)}catch{}finally{E(!1)}}async function Ee(){const L=y.trim();if(!(!L||!t))try{await qp(e,t.entry_uid,L),x(""),v("");const X=await Hr(e,t.entry_uid);w(X),s()}catch(X){v(X.message)}}async function ye(L){try{await Zp(e,t.entry_uid,L);const X=await Hr(e,t.entry_uid);w(X),s()}catch{}}async function R(){if(!(!t||!e)&&window.confirm("Delete this entry? This cannot be undone."))try{await eh(e,t.entry_uid),o==null||o(t.entry_uid)}catch{}}async function _(){if(!t||!e||I==="running")return;const L=k.current,X=t.entry_uid;H("running"),Z("");try{const{job_uid:We}=await Rh(e,X);if(k.current!==L)return;te.current=setInterval(async()=>{try{const Ve=await Jc(e,We);if(Ve.status==="completed"){if(clearInterval(te.current),te.current=null,k.current!==L)return;H("done");const D=await Hr(e,X);if(k.current!==L)return;w(D),c==null||c()}else if(Ve.status==="failed"){if(clearInterval(te.current),te.current=null,k.current!==L)return;H("error"),Z(Ve.error_text||"Re-archive failed.")}}catch{if(clearInterval(te.current),te.current=null,k.current!==L)return;H("error"),Z("Network error while polling.")}},500)}catch(We){if(k.current!==L)return;H("error"),Z(We.message||"Failed to start re-archive.")}}const B=n?[["Added",Yc(n.summary.archived_at)],["Source",n.summary.source_kind],["Type",n.summary.entity_kind],["Visibility",Lo[n.summary.visibility]??n.summary.visibility],["Root",n.structured_root_relpath]]:[],j=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),C=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv","pdf","html","htm","jpg","jpeg","png","gif","webp","avif","svg","bmp"]),F=n?n.artifacts.findIndex(L=>L.artifact_role==="primary_media"):-1,M=F>=0?n.artifacts[F]:null,U=M?M.relpath.split(".").pop().toLowerCase():"",Y=M&&j.has(U),Q=F>=0&&t?`/api/archives/${e}/entries/${t.entry_uid}/artifacts/${F}`:null,J=n&&!Y&&(n.summary.entity_kind==="tweet"||n.summary.entity_kind==="tweet_thread"||M&&C.has(U));return i.jsxs("aside",{className:"context-rail",children:[i.jsx("div",{className:"rail-eyebrow",children:"Context"}),t?n?i.jsxs(i.Fragment,{children:[T?i.jsx("input",{className:"rail-title-input",autoFocus:!0,value:N,onChange:L=>O(L.target.value),onKeyDown:L=>{L.key==="Enter"&&L.currentTarget.blur(),L.key==="Escape"&&(S.current=!0,L.currentTarget.blur())},onBlur:()=>{S.current?E(!1):je(),S.current=!1}}):i.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{O(n.summary.title??""),E(!0)},children:[Kt(n.summary.title)||Kt(n.summary.entry_uid),i.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),n.summary.original_url&&i.jsxs("a",{className:"url-tile",href:n.summary.original_url,target:"_blank",rel:"noopener noreferrer",children:[i.jsx("span",{className:"ico",dangerouslySetInnerHTML:{__html:pa(n.summary.source_kind)}}),i.jsx("span",{className:"u-text",children:n.summary.original_url}),i.jsx("span",{className:"ext",children:i.jsx(om,{})})]}),Y&&m&&i.jsx("button",{className:"rail-preview-btn",onClick:()=>m(Q,t),children:"▶ Play"}),J&&g&&i.jsx("button",{className:"rail-preview-btn",onClick:g,children:"Preview"}),i.jsx("div",{className:"meta-list",children:B.filter(([,L])=>L!=null&&L!=="").map(([L,X])=>i.jsxs("div",{className:"meta-item",children:[i.jsx("span",{className:"meta-k",children:L}),i.jsx("span",{className:`meta-v${L==="Root"?" mono":""}`,children:Kt(X)})]},L))}),n.artifacts.length>0&&i.jsxs("div",{className:"rail-section",children:[i.jsxs("div",{className:"rail-section-heading",children:["Artifacts ",i.jsx("span",{className:"num",children:n.artifacts.length})]}),i.jsx("ul",{className:"artifact-list",children:n.artifacts.map((L,X)=>i.jsx("li",{children:i.jsxs("a",{href:`/api/archives/${e}/entries/${n.summary.entry_uid}/artifacts/${X}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[i.jsx("span",{className:"artifact-name",children:L.artifact_role.replace(/_/g," ")}),i.jsx("span",{className:"artifact-size",children:L.byte_size!=null?vi(L.byte_size):"—"})]})},X))})]})]}):i.jsx("p",{className:"tags-empty",children:"Loading…"}):i.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Tags"}),f.length===0?i.jsx("p",{className:"tags-empty",children:"No tags yet."}):i.jsx("div",{className:"tags-wrap",children:f.map(L=>i.jsxs("span",{className:"tag-pill",title:L.full_path,children:[u?qc(L.full_path):L.full_path,i.jsx("button",{className:"remove",title:`Remove tag ${L.full_path}`,onClick:()=>ye(L.tag_uid),children:"×"})]},L.tag_uid))}),d&&i.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:d}),i.jsxs("div",{className:"tag-input-wrap",children:[i.jsx("span",{className:"hash",children:"/"}),i.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:y,onChange:L=>x(L.target.value),onKeyDown:L=>{L.key==="Enter"&&Ee()}}),i.jsx("button",{className:"tag-add-btn",onClick:Ee,children:"Add"})]})]}),z.length>0&&i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Collections"}),z.map(L=>i.jsxs("div",{className:"coll-row",children:[i.jsx("span",{className:"coll-name",children:L.collection_uid}),i.jsx("span",{className:"vis-badge",children:Lo[L.visibility_bits]??`bits:${L.visibility_bits}`})]},L.collection_uid))]}),n&&(n.summary.entity_kind==="tweet"||n.summary.entity_kind==="tweet_thread")&&i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Actions"}),i.jsx("button",{className:"rail-rearchive-btn",onClick:_,disabled:I==="running",children:I==="running"?"Re-archiving…":"Re-archive"}),I==="done"&&i.jsx("p",{className:"form-msg form-msg--ok",style:{marginTop:"6px"},children:"Re-archived successfully."}),I==="error"&&i.jsx("p",{className:"form-msg form-msg--err",style:{marginTop:"6px"},children:ee})]}),i.jsx("div",{className:"rail-delete-zone",children:i.jsx("button",{className:"rail-delete-btn",onClick:R,children:"Delete entry"})})]})]})}function cm({src:e}){const t=p.useRef(null);return p.useEffect(()=>{t.current&&t.current.load()},[e]),i.jsx("div",{className:"preview-video-wrap",style:{background:"#111",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:"240px"},children:e?i.jsxs("video",{ref:t,controls:!0,autoPlay:!1,style:{width:"100%",maxHeight:"100%",display:"block"},children:[i.jsx("source",{src:e}),"Your browser does not support the video element."]}):i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No video available"})})}function Ro({src:e,type:t,title:n,originalUrl:r}){const l=r||e,s=n||null;return i.jsxs("div",{className:"preview-iframe-wrap",style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[i.jsxs("div",{className:"preview-iframe-toolbar",style:{display:"flex",flexDirection:"column",gap:"2px",padding:"6px 12px",borderBottom:"1px solid var(--line-soft)",background:"var(--paper-2)",flexShrink:0},children:[s&&i.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--ink)",fontFamily:"var(--sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[i.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.78rem",color:"var(--muted)",fontFamily:"var(--sans)"},children:l}),i.jsx("a",{href:e,target:"_blank",rel:"noreferrer noopener",style:{fontSize:"0.78rem",color:"var(--accent)",textDecoration:"none",whiteSpace:"nowrap",fontFamily:"var(--sans)",flexShrink:0},children:t==="pdf"?"Open PDF ↗":"Open in new tab ↗"})]})]}),i.jsx("iframe",{src:e,sandbox:"allow-same-origin allow-popups",allow:"autoplay 'none'",referrerPolicy:"no-referrer",style:{flex:1,border:"none",width:"100%",minHeight:0},title:s||(t==="pdf"?"PDF preview":"Page preview")})]})}function dm({src:e,alt:t}){return i.jsx("div",{className:"preview-image-wrap",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",background:"var(--paper-2)",overflow:"hidden"},children:i.jsx("a",{href:e,target:"_blank",rel:"noreferrer noopener",style:{display:"contents"},children:i.jsx("img",{src:e,alt:t||"",style:{objectFit:"contain",maxHeight:"100%",maxWidth:"100%",display:"block",cursor:"pointer"}})})})}function ed(e){return e?new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(e*1e3)):""}function zo(e){return!e||!e.includes("&")?e:e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}const $={card:{background:"var(--paper)",border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",maxWidth:"560px",margin:"0 auto",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},threadOuter:{border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",maxWidth:"560px",margin:"0 auto",background:"var(--paper)",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},tweetRow:{display:"flex",gap:"10px",padding:"10px 12px"},tweetRowThread:{display:"flex",gap:"10px",padding:"10px 12px 0"},leftCol:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0,width:"36px"},rightCol:{flex:1,minWidth:0,paddingBottom:"8px"},avatar:{width:"36px",height:"36px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},avatarPh:{width:"36px",height:"36px",borderRadius:"50%",background:"var(--line)",flexShrink:0},threadLine:{flex:1,width:"2px",background:"var(--line-soft, var(--line))",margin:"4px 0",minHeight:"12px",borderRadius:"1px"},authorRow:{display:"flex",alignItems:"baseline",gap:"4px",flexWrap:"wrap",marginBottom:"4px",lineHeight:"1.3"},authorName:{fontWeight:"700",fontSize:"14px",color:"var(--ink)"},authorHandle:{fontSize:"13px",color:"var(--muted)"},datePart:{fontSize:"13px",color:"var(--muted)"},tweetText:{fontSize:"14px",lineHeight:"1.5",color:"var(--ink)",whiteSpace:"pre-line",marginBottom:"8px",wordBreak:"break-word"},stats:{display:"flex",gap:"12px",fontSize:"13px",color:"var(--muted)"},link:{color:"var(--accent)",textDecoration:"none"},loading:{padding:"24px 16px",textAlign:"center",color:"var(--muted)",fontSize:"14px"},error:{padding:"24px 16px",textAlign:"center",color:"var(--alert)",fontSize:"14px"},mediaGrid:{marginBottom:"8px",borderRadius:"10px",overflow:"hidden",border:"1px solid var(--line)"},mediaImg:{display:"block",width:"100%",objectFit:"cover",maxHeight:"260px"},mediaVideo:{display:"block",width:"100%",maxHeight:"260px",background:"#000"},article:{maxWidth:"560px",margin:"0 auto",border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",background:"var(--paper)",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},aCover:{width:"100%",display:"block",objectFit:"cover",maxHeight:"280px"},aMeta:{padding:"10px 14px 0"},aTweetTitle:{fontSize:"20px",fontWeight:"800",letterSpacing:"-0.3px",color:"var(--ink)",lineHeight:"1.3",marginBottom:"8px"},aAuthorRow:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},aAvatar:{width:"36px",height:"36px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},aAvatarPh:{width:"36px",height:"36px",borderRadius:"50%",background:"var(--line)",flexShrink:0},aAuthorName:{fontSize:"14px",fontWeight:"700",color:"var(--ink)",lineHeight:"1.3"},aAuthorSub:{fontSize:"13px",color:"var(--muted)",lineHeight:"1.3"},aDivider:{border:"none",borderTop:"1px solid var(--line)",margin:"0"},aBody:{padding:"4px 14px 16px"},bH1:{fontSize:"22px",fontWeight:"800",letterSpacing:"-0.4px",color:"var(--ink)",lineHeight:"1.25",margin:"16px 0 6px"},bH2:{fontSize:"18px",fontWeight:"700",letterSpacing:"-0.2px",color:"var(--ink)",lineHeight:"1.3",margin:"14px 0 4px"},bP:{fontSize:"15px",color:"var(--ink)",lineHeight:"1.65",marginBottom:"12px",marginTop:"0"},bSpacer:{height:"4px",display:"block"},bQuote:{borderLeft:"3px solid var(--line)",padding:"2px 12px",margin:"12px 0",color:"var(--muted)",fontSize:"15px",lineHeight:"1.6"},bHr:{border:"none",borderTop:"1px solid var(--line)",margin:"14px 0"},bImg:{width:"100%",display:"block",borderRadius:"8px",margin:"12px 0"},bUl:{margin:"8px 0 12px",paddingLeft:"24px"},bOl:{margin:"8px 0 12px",paddingLeft:"24px"},bLi:{fontSize:"15px",color:"var(--ink)",lineHeight:"1.6",marginBottom:"4px"},bTweet:{display:"flex",alignItems:"center",gap:"10px",border:"1px solid var(--line)",borderRadius:"10px",padding:"10px 14px",margin:"12px 0",color:"var(--muted)",fontSize:"14px",textDecoration:"none"},bMdPre:{borderRadius:"8px",margin:"10px 0",overflow:"auto",background:"var(--paper-3, var(--field))",padding:"12px 14px"},bMdCode:{fontFamily:"ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, Consolas, monospace",fontSize:"12px",lineHeight:"1.6",color:"var(--ink)",background:"transparent",display:"block"},iCode:{fontFamily:"ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace",fontSize:"0.875em",background:"var(--paper-3, var(--field))",padding:"1px 5px",borderRadius:"4px",color:"var(--ink)"},qtBadge:{fontSize:"11px",color:"var(--muted)",display:"inline-flex",alignItems:"center",gap:"2px",marginLeft:"4px",letterSpacing:"0.03em",flexShrink:0},lightboxBackdrop:{position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.92)",display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},lightboxContent:{display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",maxWidth:"90vw",maxHeight:"90vh"},lightboxToolbar:{display:"flex",alignItems:"center",gap:"10px",alignSelf:"flex-end"},lightboxImg:{maxWidth:"88vw",maxHeight:"80vh",objectFit:"contain",borderRadius:"6px",display:"block"},lightboxNav:{display:"flex",gap:"12px",alignItems:"center"},lightboxNavBtn:{background:"rgba(255,255,255,0.18)",border:"none",color:"#fff",fontSize:"20px",cursor:"pointer",borderRadius:"50%",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,flexShrink:0},lightboxBtn:{background:"rgba(255,255,255,0.18)",border:"none",color:"#fff",fontSize:"16px",cursor:"pointer",borderRadius:"50%",width:"30px",height:"30px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,flexShrink:0},lightboxLink:{color:"rgba(255,255,255,0.7)",textDecoration:"none",fontSize:"14px"},lightboxCounter:{color:"rgba(255,255,255,0.6)",fontSize:"13px"}};function fm(e,t,n){const r={};return n&&n.forEach((l,s)=>{l.relpath&&(r[l.relpath]=`/api/archives/${e}/entries/${t}/artifacts/${s}`)}),r}function wr(e,t,n){return e&&n[e]?n[e]:t||null}function td(){return i.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",style:{flexShrink:0,color:"var(--ink)"},children:i.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.748l7.73-8.835L1.254 2.25H8.08l4.259 5.63L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117L17.083 19.77z"})})}function nd(e,t,...n){var r;if(e.fromIndex!=null&&e.toIndex!=null)return{s:e.fromIndex,e:e.toIndex};if(((r=e.indices)==null?void 0:r.length)===2)return{s:e.indices[0],e:e.indices[1]};if(t)for(const l of n){if(!l)continue;const s=t.indexOf(l);if(s!==-1)return{s,e:s+l.length}}return null}function rd(e,t){const n=e.expanded_url||e.url||e.text||"",r=e.display_url||e.expanded_url||e.url||e.text||"",l=nd(e,t,e.url,e.text,e.display_url,e.expanded_url);return!l||!n?null:{...l,kind:"url",href:n,display:r}}function ld(e,t){const n=e.screen_name||e.name||e.text||"",r=n?`@${n}`:null,l=nd(e,t,r);return!l||!n?null:{...l,kind:"mention",screen_name:n}}const Do=/https?:\/\/[^\s<>"'\])]+/g,pm=/[.,;:!?)()]+$/;function El(e,t){const n=[];let r=0,l;for(Do.lastIndex=0;(l=Do.exec(e))!==null;){l.index>r&&n.push(e.slice(r,l.index));let s=l[0].replace(pm,"");n.push(i.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:t,children:s},l.index));const a=l[0].slice(s.length);a&&n.push(a),r=l.index+l[0].length}return r===0?e:(rrd(s,e)).filter(Boolean),...(t.user_mentions||[]).map(s=>ld(s,e)).filter(Boolean)];if(n.length===0)return El(zo(e),$.link);const r=new Set([0,e.length]);for(const s of n)s.s>=0&&s.s<=e.length&&r.add(s.s),s.e>=0&&s.e<=e.length&&r.add(s.e);const l=[...r].sort((s,a)=>s-a);return l.slice(0,-1).map((s,a)=>{const o=l[a+1],u=e.slice(s,o),c=n.filter(f=>f.s<=s&&f.e>=o),g=c.find(f=>f.kind==="url");if(g)return i.jsx("a",{href:g.href,target:"_blank",rel:"noopener noreferrer",style:$.link,children:g.display||u},a);const m=c.find(f=>f.kind==="mention");return m?i.jsx("a",{href:`https://x.com/${m.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:$.link,children:u},a):i.jsx("span",{children:El(zo(u),$.link)},a)})}function mm(e,t,n,r){if(!e)return null;t=t||[],n=n||[],r=r||[];const l=[];for(const o of t)o.length>0&&l.push({s:o.offset,e:o.offset+o.length,kind:"style",style:o.style});for(const o of n){const u=rd(o,e);u&&l.push(u)}for(const o of r){const u=ld(o,e);u&&l.push(u)}if(l.length===0)return El(e,$.link);const s=new Set([0,e.length]);for(const o of l)o.s>=0&&o.s<=e.length&&s.add(o.s),o.e>=0&&o.e<=e.length&&s.add(o.e);const a=[...s].sort((o,u)=>o-u);return a.slice(0,-1).map((o,u)=>{const c=a[u+1],g=l.filter(x=>x.s<=o&&x.e>=c),m=e.slice(o,c);let f;if(m.includes(` +`)){const x=m.split(` +`);f=x.flatMap((z,h)=>hx.kind==="style"&&x.style==="Code")&&(f=i.jsx("code",{style:$.iCode,children:f})),g.some(x=>x.kind==="style"&&x.style==="Bold")&&(f=i.jsx("strong",{children:f})),g.some(x=>x.kind==="style"&&x.style==="Italic")&&(f=i.jsx("em",{children:f})),g.some(x=>x.kind==="style"&&x.style==="Underline")&&(f=i.jsx("u",{children:f})),g.some(x=>x.kind==="style"&&x.style==="Strikethrough")&&(f=i.jsx("s",{children:f}));const w=g.find(x=>x.kind==="url");if(w){const x=/^https?:\/\/t\.co\//i.test(f);f=i.jsx("a",{href:w.href,target:"_blank",rel:"noopener noreferrer",style:$.link,children:x?w.display:f})}const y=g.find(x=>x.kind==="mention");return y&&(f=i.jsx("a",{href:`https://x.com/${y.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:$.link,children:f})),i.jsx("span",{children:typeof f=="string"?El(f,$.link):f},u)})}function gm(e,t,n){const r=e.resolved_entities||[];return r.length===0?null:r.map((l,s)=>{var a;switch(l.type){case"divider":return i.jsx("hr",{style:$.bHr},s);case"media":{const o=wr(l.local_path,l.url,t);return o?i.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:u=>{var c;!u.metaKey&&!u.ctrlKey&&(u.preventDefault(),(c=n==null?void 0:n.onImgClick)==null||c.call(n,o))},children:i.jsx("img",{src:o,style:$.bImg,loading:"lazy",alt:""})},s):null}case"tweet":return l.tweet_id?i.jsxs("a",{href:`https://x.com/i/status/${l.tweet_id}`,target:"_blank",rel:"noopener noreferrer",style:$.bTweet,children:[i.jsx(td,{}),"View post on X"]},s):null;case"link":return l.url?i.jsx("p",{style:$.bP,children:i.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",style:$.link,children:l.url})},s):null;case"markdown":{const o=l.markdown??((a=l.data)==null?void 0:a.markdown)??"";return i.jsx("pre",{style:$.bMdPre,children:i.jsx("code",{style:$.bMdCode,children:o})},s)}case"emoji":return l.url?i.jsx("img",{src:l.url,alt:"",style:{height:"1.2em",verticalAlign:"middle",margin:"0 1px"}},s):null;default:return null}})}function ws(e,t,n,r){const l=e.type||"",s=e.text||"",a=e.inline_style_ranges||[],o=e.data||{},u=mm(s,a,o.urls||[],o.mentions||[]);switch(l){case"header-one":return i.jsx("h1",{style:$.bH1,children:u},t);case"header-two":{const c=s.match(/(?:x\.com|twitter\.com)\/i\/status\/(\d+)/);return c?i.jsxs("a",{href:`https://x.com/i/status/${c[1]}`,target:"_blank",rel:"noopener noreferrer",style:$.bTweet,children:[i.jsx(td,{}),"View post on X"]},t):i.jsx("h2",{style:$.bH2,children:u},t)}case"unstyled":return s.trim()?i.jsx("p",{style:$.bP,children:u},t):i.jsx("span",{style:$.bSpacer},t);case"blockquote":return i.jsx("blockquote",{style:$.bQuote,children:u},t);case"unordered-list-item":case"ordered-list-item":return i.jsx("li",{style:$.bLi,children:u},t);case"atomic":return i.jsx("span",{children:gm(e,n,r)},t);default:return s?i.jsx("p",{style:$.bP,children:u},t):null}}function vm(e,t,n){const r=[];let l=0;for(;ll(null)}),g&&i.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:f=>{!f.metaKey&&!f.ctrlKey&&(f.preventDefault(),l(g))},children:i.jsx("img",{src:g,style:$.aCover,alt:"Article cover"})}),i.jsxs("div",{style:$.aMeta,children:[e.title&&i.jsx("div",{style:$.aTweetTitle,children:e.title}),i.jsxs("div",{style:$.aAuthorRow,children:[m?i.jsx("img",{src:m,style:$.aAvatar,alt:a.name||""}):i.jsx("div",{style:$.aAvatarPh}),i.jsxs("div",{children:[i.jsx("div",{style:$.aAuthorName,children:a.name||a.screen_name||"Unknown"}),c&&i.jsx("div",{style:$.aAuthorSub,children:c})]})]})]}),i.jsx("hr",{style:$.aDivider}),i.jsx("div",{style:$.aBody,children:vm(e.blocks||[],n,{onImgClick:l})})]})}function xm({photos:e,onOpen:t}){const n=e.length;if(n===0)return null;if(n===1)return i.jsx("a",{href:e[0].src,target:"_blank",rel:"noopener noreferrer",style:{display:"block"},onClick:l=>{!l.metaKey&&!l.ctrlKey&&(l.preventDefault(),t(0))},children:i.jsx("img",{src:e[0].src,alt:e[0].alt||"",style:$.mediaImg,loading:"lazy"})});const r=n<=2?"180px":"140px";return i.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gridTemplateRows:n===2?r:`${r} ${r}`,gap:"2px"},children:e.map((l,s)=>i.jsx("a",{href:l.src,target:"_blank",rel:"noopener noreferrer",style:{display:"block",overflow:"hidden",gridRow:n===3&&s===0?"span 2":void 0},onClick:a=>{!a.metaKey&&!a.ctrlKey&&(a.preventDefault(),t(s))},children:i.jsx("img",{src:l.src,alt:l.alt||"",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})},s))})}function sd({items:e,startIndex:t,onClose:n}){const[r,l]=p.useState(t);p.useEffect(()=>{const a=o=>{(o.key==="Escape"||o.key==="ArrowLeft"||o.key==="ArrowRight")&&(o.stopPropagation(),o.preventDefault()),o.key==="Escape"&&n(),o.key==="ArrowRight"&&l(u=>Math.min(u+1,e.length-1)),o.key==="ArrowLeft"&&l(u=>Math.max(u-1,0))};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[n,e.length]);const s=e[r];return i.jsx("div",{style:$.lightboxBackdrop,onClick:n,children:i.jsxs("div",{style:$.lightboxContent,onClick:a=>a.stopPropagation(),children:[i.jsxs("div",{style:$.lightboxToolbar,children:[e.length>1&&i.jsxs("span",{style:$.lightboxCounter,children:[r+1," / ",e.length]}),i.jsx("a",{href:s.src,target:"_blank",rel:"noopener noreferrer",style:$.lightboxLink,title:"Open in new tab",children:"↗"}),i.jsx("button",{style:$.lightboxBtn,onClick:n,"aria-label":"Close",children:"×"})]}),i.jsx("img",{src:s.src,alt:s.alt||"",style:$.lightboxImg}),e.length>1&&i.jsxs("div",{style:$.lightboxNav,children:[i.jsx("button",{style:$.lightboxNavBtn,onClick:()=>l(a=>Math.max(a-1,0)),disabled:r===0,children:"‹"}),i.jsx("button",{style:$.lightboxNavBtn,onClick:()=>l(a=>Math.min(a+1,e.length-1)),disabled:r===e.length-1,children:"›"})]})]})})}function Io({tweet:e,isInThread:t,isLast:n,artifactMap:r}){var z,h;const[l,s]=p.useState(null),a=e.author||{},o=e.created_at_secs?ed(e.created_at_secs):"",u=e.entities||{},c=wr(a.avatar_local_path,a.avatar_url,r),g=t&&!n,m=e.is_quote_status===!0,f=t?$.tweetRowThread:$.tweetRow,w=((h=(z=e.extended_entities)==null?void 0:z.media)!=null&&h.length?e.extended_entities.media:u.media)||[],y=[],x=[];for(const d of w)if(d.type==="photo"){const v=wr(d.local_path,d.media_url_https,r);v&&y.push({kind:"photo",src:v,alt:d.alt_text||""})}else if(d.type==="video"||d.type==="animated_gif"){const v=d.local_path&&r[d.local_path]||(()=>{var S,T;return(T=(((S=d.video_info)==null?void 0:S.variants)||[]).filter(E=>E.content_type==="video/mp4").sort((E,N)=>(N.bitrate||0)-(E.bitrate||0))[0])==null?void 0:T.url})();v&&x.push({kind:d.type==="animated_gif"?"gif":"video",src:v})}return i.jsxs(i.Fragment,{children:[l!==null&&i.jsx(sd,{items:y,startIndex:l,onClose:()=>s(null)}),i.jsxs("div",{style:f,children:[i.jsxs("div",{style:$.leftCol,children:[c?i.jsx("img",{src:c,style:$.avatar,alt:a.name||""}):i.jsx("div",{style:$.avatarPh}),g&&i.jsx("div",{style:$.threadLine})]}),i.jsxs("div",{style:$.rightCol,children:[i.jsxs("div",{style:$.authorRow,children:[i.jsx("span",{style:$.authorName,children:a.name||a.screen_name||"Unknown"}),a.screen_name&&i.jsxs("span",{style:$.authorHandle,children:["@",a.screen_name]}),o&&i.jsxs("span",{style:$.datePart,children:["· ",o]}),m&&i.jsx("span",{style:$.qtBadge,title:"Quote tweet",children:"↻ QT"})]}),i.jsx("div",{style:$.tweetText,children:hm(e.full_text||"",u)}),y.length>0&&i.jsx("div",{style:$.mediaGrid,children:i.jsx(xm,{photos:y,onOpen:d=>s(d)})}),x.map((d,v)=>i.jsx("div",{style:$.mediaGrid,children:i.jsx("video",{src:d.src,style:$.mediaVideo,controls:!0,loop:d.kind==="gif",muted:d.kind==="gif",autoPlay:d.kind==="gif"})},v)),(e.retweet_count>0||e.favorite_count>0)&&i.jsxs("div",{style:$.stats,children:[e.favorite_count>0&&i.jsxs("span",{children:["❤️ ",e.favorite_count.toLocaleString()]}),e.retweet_count>0&&i.jsxs("span",{children:["🔁 ",e.retweet_count.toLocaleString()]})]})]})]})]})}function wm({archiveId:e,entryUid:t,artifacts:n,entityKind:r}){const[l,s]=p.useState(!0),[a,o]=p.useState(null),[u,c]=p.useState([]);if(p.useEffect(()=>{if(s(!0),o(null),c([]),!n||!e||!t){s(!1);return}const f=n.map((y,x)=>({...y,index:x})).filter(y=>y.artifact_role==="raw_tweet_json");if(f.length===0){o("No tweet data found."),s(!1);return}let w=!1;return Jp(e,t,f.map(y=>y.index)).then(async y=>{if(w)return;const x=/https?:\/\/t\.co\/[A-Za-z0-9]+/g,z=S=>{var E;const T=S.full_text||"";return(((E=S.entities)==null?void 0:E.urls)||[]).map(N=>{var O;if(N.fromIndex!=null&&N.toIndex!=null)return[N.fromIndex,N.toIndex];if(((O=N.indices)==null?void 0:O.length)===2)return[N.indices[0],N.indices[1]];if(N.url){const I=T.indexOf(N.url);if(I!==-1)return[I,I+N.url.length]}return null}).filter(Boolean)},h=(S,T,E)=>S.some(([N,O])=>N<=T&&O>=E),d=new Set;for(const S of y){const T=S.full_text||"",E=z(S);let N;for(x.lastIndex=0;(N=x.exec(T))!==null;)h(E,N.index,N.index+N[0].length)||d.add(N[0])}const v=d.size>0?await Gp([...d]).catch(()=>({})):{},k=y.map(S=>{var I;const T=S.full_text||"",E=z(S),N=[];let O;for(x.lastIndex=0;(O=x.exec(T))!==null;){const H=O[0],ee=v[H];ee&&ee!==H&&!h(E,O.index,O.index+H.length)&&N.push({url:H,expanded_url:ee,display_url:(()=>{try{const Z=new URL(ee);return Z.hostname+(Z.pathname.length>1?"/…":"")}catch{return ee}})(),fromIndex:O.index,toIndex:O.index+H.length})}return N.length===0?S:{...S,entities:{...S.entities||{},urls:[...((I=S.entities)==null?void 0:I.urls)||[],...N]}}});w||c(k)}).catch(y=>{w||o(y.message||"Failed to load tweet.")}).finally(()=>{w||s(!1)}),()=>{w=!0}},[e,t,n]),l)return i.jsx("div",{style:$.loading,children:"Loading…"});if(a)return i.jsxs("div",{style:$.error,children:["Error: ",a]});if(u.length===0)return null;const g=fm(e,t,n);if(r==="tweet_thread")return i.jsx("div",{style:$.threadOuter,children:u.map((f,w)=>i.jsx(Io,{tweet:f,isInThread:!0,isLast:w===u.length-1,artifactMap:g},f.id||w))});const m=u[0];return m.is_article&&m.article?i.jsx(ym,{article:m.article,tweetAuthor:m.author,artifactMap:g}):i.jsx("div",{style:$.card,children:i.jsx(Io,{tweet:m,isInThread:!1,isLast:!0,artifactMap:g})})}const km=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv"]),jm=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),Sm=new Set(["jpg","jpeg","png","gif","webp","avif","svg","bmp"]);function id({archiveId:e,entry:t,detail:n}){if(!t)return i.jsx("div",{className:"preview-panel preview-panel--empty",children:i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Select an entry to preview"})});if(!n)return i.jsx("div",{className:"preview-panel preview-panel--loading",children:i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Loading…"})});const{summary:r,artifacts:l}=n,s=r.entry_uid,a=r.entity_kind;if(a==="tweet"||a==="tweet_thread")return i.jsx("div",{className:"preview-tweet-wrap",children:i.jsx(wm,{archiveId:e,entryUid:s,artifacts:l,entityKind:a})});const o=l.findIndex(m=>m.artifact_role==="primary_media");if(o===-1)return i.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),l.length>0&&i.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:l.map((m,f)=>i.jsxs("li",{children:[m.artifact_role,": ",m.relpath]},f))})]});const u=l[o],c=`/api/archives/${e}/entries/${s}/artifacts/${o}`,g=u.relpath.split(".").pop().toLowerCase();return km.has(g)?i.jsx("div",{className:"preview-panel",children:i.jsx(cm,{src:c})}):jm.has(g)?i.jsxs("div",{className:"preview-panel preview-panel--audio",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"12px",padding:"24px",fontFamily:"var(--sans)"},children:[i.jsx("span",{style:{fontSize:"2rem"},children:"🎵"}),i.jsx("span",{style:{color:"var(--ink)",fontSize:"0.95rem",fontWeight:600},children:r.title||s}),i.jsx("audio",{src:c,controls:!0,style:{marginTop:"8px",width:"100%",maxWidth:"400px"}})]}):g==="pdf"?i.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:i.jsx(Ro,{src:c,type:"pdf",title:r.title,originalUrl:r.original_url})}):g==="html"||g==="htm"?i.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:i.jsx(Ro,{src:c,type:"page",title:r.title,originalUrl:r.original_url})}):Sm.has(g)?i.jsx("div",{className:"preview-panel",style:{height:"100%"},children:i.jsx(dm,{src:c,alt:r.title||"Image"})}):i.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),i.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:l.map((m,f)=>i.jsxs("li",{children:[m.artifact_role,": ",m.relpath]},f))})]})}function Nm({archiveId:e,entry:t,detail:n,onClose:r}){var l,s;return p.useEffect(()=>{const a=o=>{o.key==="Escape"&&r()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),i.jsx("div",{className:"preview-modal-backdrop",onClick:r,children:i.jsxs("div",{className:`preview-modal${((l=n==null?void 0:n.summary)==null?void 0:l.entity_kind)==="tweet"||((s=n==null?void 0:n.summary)==null?void 0:s.entity_kind)==="tweet_thread"?"":" preview-modal--full"}`,onClick:a=>a.stopPropagation(),children:[i.jsxs("div",{className:"preview-modal-header",children:[i.jsx("span",{className:"preview-modal-title",children:(t==null?void 0:t.title)||(t==null?void 0:t.entry_uid)||"Preview"}),i.jsx("a",{className:"preview-modal-newtab",href:`/preview/${e}/${t==null?void 0:t.entry_uid}`,target:"_blank",rel:"noopener noreferrer",title:"Open in new tab",children:"↗"}),i.jsx("button",{className:"preview-modal-close",onClick:r,"aria-label":"Close preview",children:"×"})]}),i.jsx("div",{className:"preview-modal-body",children:i.jsx(id,{archiveId:e,entry:t,detail:n})})]})})}function Oo(e){if(!isFinite(e)||isNaN(e))return"--:--";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,"0")}`}function _m({entry:e,src:t,archiveId:n,onClose:r}){const l=p.useRef(null),[s,a]=p.useState(!1),[o,u]=p.useState(0),[c,g]=p.useState(NaN),[m,f]=p.useState(1);p.useEffect(()=>{!l.current||!t||(l.current.load(),u(0),g(NaN),a(!1))},[t]),p.useEffect(()=>{l.current&&(l.current.volume=m)},[m]);function w(){const d=l.current;d&&(s?d.pause():d.play().catch(()=>{}))}function y(d){const v=l.current;if(!v||!isFinite(c))return;const k=Number(d.target.value);v.currentTime=k,u(k)}function x(d){f(Number(d.target.value))}const z=(e==null?void 0:e.title)||(e==null?void 0:e.entry_uid)||"Unknown",h=(e==null?void 0:e.source_kind)||"other";return i.jsxs(i.Fragment,{children:[i.jsx("audio",{ref:l,src:t||void 0,preload:"auto",onPlay:()=>a(!0),onPause:()=>a(!1),onEnded:()=>a(!1),onTimeUpdate:()=>{var d;return u(((d=l.current)==null?void 0:d.currentTime)??0)},onLoadedMetadata:()=>{var d;return g(((d=l.current)==null?void 0:d.duration)??NaN)},onDurationChange:()=>{var d;return g(((d=l.current)==null?void 0:d.duration)??NaN)},style:{display:"none"}}),i.jsxs("div",{className:"audio-bar",style:{position:"fixed",bottom:0,left:0,right:0,zIndex:100,background:"var(--paper-3)",borderTop:"1px solid var(--line)",display:"flex",alignItems:"center",gap:"16px",padding:"0 16px",height:"56px",fontFamily:"var(--sans)"},children:[i.jsxs("div",{className:"audio-bar-info",style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0,flex:"0 1 220px",overflow:"hidden"},children:[i.jsx("span",{className:"source-icon",style:{flexShrink:0,width:"18px",height:"18px",display:"flex",alignItems:"center"},dangerouslySetInnerHTML:{__html:pa(h)}}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.85rem",color:"var(--ink)"},title:z,children:z})]}),i.jsxs("div",{className:"audio-bar-controls",style:{display:"flex",alignItems:"center",gap:"10px",flex:"1 1 0",minWidth:0},children:[i.jsx("button",{onClick:w,"aria-label":s?"Pause":"Play",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--ink)",flexShrink:0,fontSize:"1.2rem",lineHeight:1},children:s?"⏸":"▶"}),i.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:Oo(o)}),i.jsx("input",{type:"range",min:0,max:isFinite(c)?c:0,step:.1,value:isFinite(o)?o:0,onChange:y,"aria-label":"Seek",style:{flex:1,minWidth:0,accentColor:"var(--accent)"}}),i.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:Oo(c)})]}),i.jsxs("div",{className:"audio-bar-right",style:{display:"flex",alignItems:"center",gap:"8px",flex:"0 1 160px"},children:[i.jsx("span",{style:{fontSize:"0.85rem",color:"var(--muted)",flexShrink:0},children:"🔊"}),i.jsx("input",{type:"range",min:0,max:1,step:.01,value:m,onChange:x,"aria-label":"Volume",style:{width:"80px",accentColor:"var(--accent)"}}),i.jsx("button",{onClick:r,"aria-label":"Close audio player",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--muted)",fontSize:"1rem",lineHeight:1,marginLeft:"4px"},children:"✕"})]})]})]})}function Cm({archiveId:e,entryUid:t}){var g,m;const[n,r]=p.useState(null),[l,s]=p.useState(!0),[a,o]=p.useState(null);p.useEffect(()=>{hi(e,t).then(f=>{r(f),s(!1)}).catch(f=>{o((f==null?void 0:f.message)||"Failed to load entry"),s(!1)})},[e,t]);const u=((g=n==null?void 0:n.summary)==null?void 0:g.title)||t,c=(m=n==null?void 0:n.summary)==null?void 0:m.original_url;return i.jsxs("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column",background:"var(--paper)",fontFamily:"var(--sans)"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 16px",borderBottom:"1px solid var(--line)",flexShrink:0,background:"var(--paper-2)"},children:[i.jsx("a",{href:"/",style:{color:"var(--accent)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"← Archive"}),i.jsx("span",{style:{flex:1,fontSize:"14px",fontWeight:600,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),c&&i.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--muted)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"Original ↗"})]}),i.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",display:"flex",flexDirection:"column"},children:[l&&i.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--muted)",fontSize:"14px"},children:"Loading…"}),a&&i.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--alert)",fontSize:"14px"},children:a}),n&&i.jsx(id,{archiveId:e,entry:n.summary,detail:n})]})]})}const Em=7e3;function Tm({toasts:e,onDismiss:t,onIgnoreUblock:n}){return e.length?i.jsx("div",{className:"toast-stack",role:"log","aria-live":"polite","aria-label":"Notifications",children:e.map(r=>i.jsx(Lm,{toast:r,onDismiss:t,onIgnoreUblock:n},r.id))}):null}function Pm(e){if(!e)return null;if(e.length<=52)return e;try{const{hostname:t,pathname:n,search:r}=new URL(e),l=n.split("/").filter(Boolean),s=(l[l.length-1]??"")+r,a=s?`${t}/…/${s}`:t;return a.length<=56?a:a.slice(0,53)+"…"}catch{return"…"+e.slice(-51)}}function Lm({toast:e,onDismiss:t,onIgnoreUblock:n}){const[r,l]=p.useState(!1),s=e.type==="warning",a=e.type==="success";p.useEffect(()=>{if(r)return;const u=setTimeout(()=>t(e.id),Em);return()=>clearTimeout(u)},[r,e.id,t]);const o=Pm(e.locator);return a?i.jsx("div",{className:"toast toast--success",role:"alert","aria-atomic":"true",children:i.jsxs("div",{className:"toast-top",children:[i.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"✓"}),i.jsxs("div",{className:"toast-body",children:[i.jsx("span",{className:"toast-headline",children:e.headline||"Archived"}),o&&i.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),i.jsx("div",{className:"toast-btns",children:i.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})})]})}):s?i.jsxs("div",{className:"toast toast--warning",role:"alert","aria-atomic":"true",children:[i.jsxs("div",{className:"toast-top",children:[i.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"⚠"}),i.jsxs("div",{className:"toast-body",children:[i.jsx("span",{className:"toast-headline",children:e.headline||"Archived with warnings"}),o&&i.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),i.jsxs("div",{className:"toast-btns",children:[e.text&&i.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),"aria-expanded":r,children:r?"Hide":"Details"}),e.locator&&i.jsx("button",{type:"button",className:"toast-view-btn toast-ignore-btn",onClick:()=>{n==null||n(),t(e.id)},children:"Ignore"}),i.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})]})]}),r&&i.jsx("p",{className:"toast-warning-detail",children:e.text||"The page was captured but one or more browser extensions were unavailable (ad-blocking or cookie-consent). Check ARCHIVR_UBLOCK_EXT and ARCHIVR_COOKIE_EXT in your server config."})]}):i.jsxs("div",{className:"toast toast--error",role:"alert","aria-atomic":"true",children:[i.jsxs("div",{className:"toast-top",children:[i.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"✕"}),i.jsxs("div",{className:"toast-body",children:[i.jsx("span",{className:"toast-headline",children:e.headline||"Capture failed"}),o&&i.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),i.jsxs("div",{className:"toast-btns",children:[e.text&&i.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),children:r?"Hide":"View error"}),i.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})]})]}),r&&e.text&&i.jsx("pre",{className:"toast-error-detail",children:e.text})]})}const Wl=p.createContext(null),Wr=(()=>{const e=window.location.pathname.match(/^\/preview\/([^/]+)\/([^/]+)/);return e?{archiveId:e[1],entryUid:e[2]}:null})(),Rm=["archive","tags","collections","runs","admin","settings"],zm=["profile","tokens","instance","storage"];function ks(){const e=window.location.pathname.split("/").filter(Boolean),t=Rm.includes(e[0])?e[0]:"archive",n=t==="settings"&&zm.includes(e[1])?e[1]:"profile";return{view:t,settingsTab:n}}function Dm(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function Im(){const[e,t]=p.useState("loading"),[n,r]=p.useState(null);p.useEffect(()=>{(async()=>{if(await sh()){t("setup");return}const V=await uh();if(!V){t("login");return}r(V),t("authenticated")})()},[]),p.useEffect(()=>{const A=()=>{r(null),t("login")};return window.addEventListener("auth:expired",A),()=>window.removeEventListener("auth:expired",A)},[]),p.useEffect(()=>{const A=()=>{const{view:V,settingsTab:se}=ks();h(V),v(se)};return window.addEventListener("popstate",A),()=>window.removeEventListener("popstate",A)},[]);const[l,s]=p.useState([]),[a,o]=p.useState(null),[u,c]=p.useState([]),[g,m]=p.useState(null),[f,w]=p.useState(null),[y,x]=p.useState(null),[z,h]=p.useState(()=>ks().view),[d,v]=p.useState(()=>ks().settingsTab),[k,S]=p.useState(""),[T,E]=p.useState(""),[N,O]=p.useState(!1),[I,H]=p.useState([]),[ee,Z]=p.useState([]),[te,je]=p.useState(()=>sessionStorage.getItem("captureDialogOpen")==="true"),[Ee,ye]=p.useState([]),R=p.useRef(0),[_,B]=p.useState(()=>sessionStorage.getItem("ublockWarningIgnored")==="true"),[j,C]=p.useState(null),F=p.useRef(0),M=(n==null?void 0:n.humanize_slugs)??!1;p.useEffect(()=>{const A=++F.current;C(null),!(!f||!a)&&hi(a,f.entry_uid).then(V=>{A===F.current&&C(V)}).catch(()=>{})},[f,a]),p.useEffect(()=>{sessionStorage.setItem("captureDialogOpen",te)},[te]);const U=p.useCallback(async(A,V,se)=>{if(A){O(!0);try{let Qe;V||se?Qe=await Xp(A,V,se):Qe=await Kp(A),c(Qe),E(Qe.length===0?"No results":`${Qe.length} result${Qe.length===1?"":"s"}`)}catch{c([]),E("Search failed. Try again.")}finally{O(!1)}}},[]);p.useEffect(()=>{e==="authenticated"&&Qp().then(A=>{if(s(A),A.length>0){const V=A[0].id;o(V)}})},[e]),p.useEffect(()=>{a&&(x(null),w(null),m(null),Promise.all([U(a,"",null),Co(a).then(H),ys(a).then(Z)]))},[a]),p.useEffect(()=>{if(a===null)return;const A=setTimeout(()=>{U(a,k,y)},300);return()=>clearTimeout(A)},[k,a]),p.useEffect(()=>{a!==null&&(y!==null&&h("archive"),U(a,k,y))},[y,a]);const Y=p.useCallback(A=>{o(A)},[]),Q=p.useCallback(A=>{h(A),A==="tags"&&a&&ys(a).then(Z)},[a]);p.useEffect(()=>{if(Wr)return;const A=Dm(z,d);window.location.pathname!==A&&history.pushState(null,"",A)},[z,d]);const J=p.useCallback(A=>{m(A?A.entry_uid:null),w(A)},[]),L=p.useCallback(A=>{x(A)},[]),X=p.useCallback(()=>{x(null)},[]),We=p.useCallback(()=>{a&&ys(a).then(Z)},[a]),Ve=p.useCallback((A,V)=>{y===A?x(V):y!=null&&y.startsWith(A+"/")&&x(V+y.slice(A.length))},[y]),D=p.useCallback(A=>{(y===A||y!=null&&y.startsWith(A+"/"))&&x(null)},[y]),W=p.useCallback((A,V)=>{c(se=>se.map(Qe=>Qe.entry_uid===A?{...Qe,title:V}:Qe)),w(se=>se&&se.entry_uid===A?{...se,title:V}:se),C(se=>se&&se.summary.entry_uid===A?{...se,summary:{...se.summary,title:V}}:se)},[]),be=p.useCallback(()=>{if(!a||!f)return;const A=++F.current;hi(a,f.entry_uid).then(V=>{A===F.current&&C(V)}).catch(()=>{})},[a,f]),dt=p.useCallback(A=>{c(V=>V.filter(se=>se.entry_uid!==A)),w(V=>(V==null?void 0:V.entry_uid)===A?null:V),m(V=>V===A?null:V)},[]),ad=p.useCallback(()=>{je(!0)},[]),od=p.useCallback(()=>{je(!1)},[]),ud=p.useCallback(()=>{a&&Promise.all([U(a,k,y),Co(a).then(H)])},[a,k,y,U]),cd=p.useCallback((A,V,se="error",Qe=null)=>{if(se==="warning"&&_&&V)return;const vd=++R.current;ye(yd=>[...yd,{id:vd,text:A,locator:V,type:se,headline:Qe}])},[_]),dd=p.useCallback(A=>{ye(V=>V.filter(se=>se.id!==A))},[]),fd=p.useCallback(()=>{sessionStorage.setItem("ublockWarningIgnored","true"),B(!0),ye(A=>A.filter(V=>!(V.type==="warning"&&V.locator)))},[]),[ha,Vl]=p.useState(null),[Dn,ma]=p.useState(null),pd=p.useCallback(()=>{f&&Vl(f.entry_uid)},[f]),hd=p.useCallback(()=>Vl(null),[]),md=p.useCallback((A,V)=>{ma({src:A,entry:V})},[]),gd=p.useCallback(()=>ma(null),[]);return p.useEffect(()=>{Vl(null)},[f]),p.useEffect(()=>(document.body.classList.toggle("has-audio-bar",!!Dn),()=>document.body.classList.remove("has-audio-bar")),[Dn]),e==="loading"?i.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?i.jsx(Ah,{onComplete:()=>t("login")}):e==="login"?i.jsx(bh,{onLogin:A=>{r(A),t("authenticated")}}):Wr?i.jsx(Cm,{archiveId:Wr.archiveId,entryUid:Wr.entryUid}):i.jsx(Wl.Provider,{value:{currentUser:n,setCurrentUser:r},children:i.jsxs(i.Fragment,{children:[i.jsx(Fh,{archives:l,archiveId:a,onArchiveChange:Y,view:z,onViewChange:Q,onCaptureClick:ad}),i.jsxs("main",{className:"app-shell",children:[i.jsxs("div",{className:"workspace",children:[z==="archive"&&i.jsxs("div",{className:"toolbar",children:[i.jsxs("div",{className:"search-field",children:[i.jsx("span",{className:"ico","aria-hidden":"true",children:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("circle",{cx:"11",cy:"11",r:"7"}),i.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}),i.jsx("input",{className:"search-input",type:"search","aria-label":"Search archive","aria-busy":N,placeholder:"Search titles, URLs, types, tags…",value:k,onChange:A=>S(A.target.value)}),i.jsx("span",{className:"kbd",children:"⌘K"})]}),i.jsxs("span",{className:"result-count",children:[T&&i.jsxs(i.Fragment,{children:[i.jsx("b",{children:T.split(" ")[0]})," ",T.split(" ").slice(1).join(" ")]}),y&&i.jsxs("button",{className:"tag-filter-badge",onClick:X,children:["× ",M?qc(y):y]})]})]}),z==="archive"&&i.jsx(Vh,{entries:u,selectedEntryUid:g,onSelectEntry:J,archiveId:a,tagFilter:y,onClearTagFilter:X,searchQuery:k,onSearchChange:S,resultCount:T,searchBusy:N}),z==="runs"&&i.jsx(Xh,{runs:I}),z==="admin"&&i.jsx(Gh,{archives:l}),z==="tags"&&i.jsx(Yh,{archiveId:a,tagNodes:ee,tagFilter:y,onTagFilterSet:L,onViewChange:Q,onTagRenamed:Ve,onTagDeleted:D,onTagsRefresh:We,humanizeTags:M}),z==="collections"&&i.jsx(Zh,{archiveId:a}),z==="settings"&&i.jsx(tm,{tab:d,onTabChange:v,archiveId:a})]}),i.jsx(um,{archiveId:a,selectedEntry:f,detail:j,onTagFilterSet:L,tagNodes:ee,onTagsRefresh:We,onEntryTitleChange:W,onEntryDeleted:dt,humanizeTags:M,onDetailRefresh:be,onOpenPreview:pd,onPlay:md})]}),ha&&f&&f.entry_uid===ha&&i.jsx(Nm,{archiveId:a,entry:f,detail:j,onClose:hd}),Dn&&i.jsx(_m,{entry:Dn.entry,src:Dn.src,archiveId:a,onClose:gd}),i.jsx(Mh,{open:te,archiveId:a,onClose:od,onCaptured:ud,onToast:cd}),i.jsx(Tm,{toasts:Ee,onDismiss:dd,onIgnoreUblock:fd})]})})}Xc(document.getElementById("root")).render(i.jsx(p.StrictMode,{children:i.jsx(Im,{})})); diff --git a/crates/archivr-server/static/assets/index-WdvYwWGH.js b/crates/archivr-server/static/assets/index-WdvYwWGH.js deleted file mode 100644 index 48cceb6..0000000 --- a/crates/archivr-server/static/assets/index-WdvYwWGH.js +++ /dev/null @@ -1,47 +0,0 @@ -(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 s of l)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(l){const s={};return l.integrity&&(s.integrity=l.integrity),l.referrerPolicy&&(s.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?s.credentials="include":l.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(l){if(l.ep)return;l.ep=!0;const s=n(l);fetch(l.href,s)}})();var Oo={exports:{}},Tl={},Io={exports:{}},K={};/** - * @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 kr=Symbol.for("react.element"),xd=Symbol.for("react.portal"),wd=Symbol.for("react.fragment"),kd=Symbol.for("react.strict_mode"),jd=Symbol.for("react.profiler"),Sd=Symbol.for("react.provider"),Nd=Symbol.for("react.context"),_d=Symbol.for("react.forward_ref"),Cd=Symbol.for("react.suspense"),Ed=Symbol.for("react.memo"),Td=Symbol.for("react.lazy"),ga=Symbol.iterator;function Pd(e){return e===null||typeof e!="object"?null:(e=ga&&e[ga]||e["@@iterator"],typeof e=="function"?e:null)}var Ao={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Fo=Object.assign,Mo={};function Ln(e,t,n){this.props=e,this.context=t,this.refs=Mo,this.updater=n||Ao}Ln.prototype.isReactComponent={};Ln.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")};Ln.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Bo(){}Bo.prototype=Ln.prototype;function yi(e,t,n){this.props=e,this.context=t,this.refs=Mo,this.updater=n||Ao}var xi=yi.prototype=new Bo;xi.constructor=yi;Fo(xi,Ln.prototype);xi.isPureReactComponent=!0;var va=Array.isArray,Uo=Object.prototype.hasOwnProperty,wi={current:null},Ho={key:!0,ref:!0,__self:!0,__source:!0};function Wo(e,t,n){var r,l={},s=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(s=""+t.key),t)Uo.call(t,r)&&!Ho.hasOwnProperty(r)&&(l[r]=t[r]);var o=arguments.length-2;if(o===1)l.children=n;else if(1>>1,C=R[j];if(0>>1;jl(U,B))Yl(Q,U)?(R[j]=Q,R[Y]=B,j=Y):(R[j]=U,R[F]=B,j=F);else if(Yl(Q,B))R[j]=Q,R[Y]=B,j=Y;else break e}}return _}function l(R,_){var B=R.sortIndex-_.sortIndex;return B!==0?B:R.id-_.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();e.unstable_now=function(){return a.now()-o}}var u=[],c=[],g=1,h=null,f=3,w=!1,y=!1,x=!1,D=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(R){for(var _=n(c);_!==null;){if(_.callback===null)r(c);else if(_.startTime<=R)r(c),_.sortIndex=_.expirationTime,t(u,_);else break;_=n(c)}}function k(R){if(x=!1,v(R),!y)if(n(u)!==null)y=!0,Ee(S);else{var _=n(c);_!==null&&ye(k,_.startTime-R)}}function S(R,_){y=!1,x&&(x=!1,m(N),N=-1),w=!0;var B=f;try{for(v(_),h=n(u);h!==null&&(!(h.expirationTime>_)||R&&!V());){var j=h.callback;if(typeof j=="function"){h.callback=null,f=h.priorityLevel;var C=j(h.expirationTime<=_);_=e.unstable_now(),typeof C=="function"?h.callback=C:h===n(u)&&r(u),v(_)}else r(u);h=n(u)}if(h!==null)var A=!0;else{var F=n(c);F!==null&&ye(k,F.startTime-_),A=!1}return A}finally{h=null,f=B,w=!1}}var P=!1,T=null,N=-1,M=5,O=-1;function V(){return!(e.unstable_now()-OR||125j?(R.sortIndex=B,t(c,R),n(u)===null&&R===n(c)&&(x?(m(N),N=-1):x=!0,ye(k,B-j))):(R.sortIndex=C,t(u,R),y||w||(y=!0,Ee(S))),R},e.unstable_shouldYield=V,e.unstable_wrapCallback=function(R){var _=f;return function(){var B=f;f=_;try{return R.apply(this,arguments)}finally{f=B}}}})(Jo);Xo.exports=Jo;var Md=Xo.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 Bd=p,Be=Md;function E(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"),js=Object.prototype.hasOwnProperty,Ud=/^[: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]*$/,xa={},wa={};function Hd(e){return js.call(wa,e)?!0:js.call(xa,e)?!1:Ud.test(e)?wa[e]=!0:(xa[e]=!0,!1)}function Wd(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 Vd(e,t,n,r){if(t===null||typeof t>"u"||Wd(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 Re(e,t,n,r,l,s,a){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=s,this.removeEmptyString=a}var ke={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ke[e]=new Re(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ke[t]=new Re(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ke[e]=new Re(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ke[e]=new Re(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){ke[e]=new Re(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ke[e]=new Re(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ke[e]=new Re(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ke[e]=new Re(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ke[e]=new Re(e,5,!1,e.toLowerCase(),null,!1,!1)});var ji=/[\-:]([a-z])/g;function Si(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(ji,Si);ke[t]=new Re(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(ji,Si);ke[t]=new Re(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(ji,Si);ke[t]=new Re(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ke[e]=new Re(e,1,!1,e.toLowerCase(),null,!1,!1)});ke.xlinkHref=new Re("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ke[e]=new Re(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ni(e,t,n,r){var l=ke.hasOwnProperty(t)?ke[t]:null;(l!==null?l.type!==0:r||!(2o||l[a]!==s[o]){var u=` -`+l[a].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=a&&0<=o);break}}}finally{Xl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Hn(e):""}function Qd(e){switch(e.tag){case 5:return Hn(e.type);case 16:return Hn("Lazy");case 13:return Hn("Suspense");case 19:return Hn("SuspenseList");case 0:case 2:case 15:return e=Jl(e.type,!1),e;case 11:return e=Jl(e.type.render,!1),e;case 1:return e=Jl(e.type,!0),e;default:return""}}function Cs(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 sn:return"Fragment";case ln:return"Portal";case Ss:return"Profiler";case _i:return"StrictMode";case Ns:return"Suspense";case _s:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case qo:return(e.displayName||"Context")+".Consumer";case Yo:return(e._context.displayName||"Context")+".Provider";case Ci:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ei:return t=e.displayName||null,t!==null?t:Cs(e.type)||"Memo";case St:t=e._payload,e=e._init;try{return Cs(e(t))}catch{}}return null}function Kd(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 Cs(t);case 8:return t===_i?"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 It(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function eu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Xd(e){var t=eu(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,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(a){r=""+a,s.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Tr(e){e._valueTracker||(e._valueTracker=Xd(e))}function tu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=eu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function rl(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 Es(e,t){var n=t.checked;return oe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ja(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=It(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 nu(e,t){t=t.checked,t!=null&&Ni(e,"checked",t,!1)}function Ts(e,t){nu(e,t);var n=It(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")?Ps(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ps(e,t.type,It(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Sa(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 Ps(e,t,n){(t!=="number"||rl(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Wn=Array.isArray;function vn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Pr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function lr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Xn={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},Jd=["Webkit","ms","Moz","O"];Object.keys(Xn).forEach(function(e){Jd.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Xn[t]=Xn[e]})});function iu(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Xn.hasOwnProperty(e)&&Xn[e]?(""+t).trim():t+"px"}function au(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=iu(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Gd=oe({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 zs(e,t){if(t){if(Gd[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Ds(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 $s=null;function Ti(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var bs=null,yn=null,xn=null;function Ca(e){if(e=Nr(e)){if(typeof bs!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Dl(t),bs(e.stateNode,e.type,t))}}function ou(e){yn?xn?xn.push(e):xn=[e]:yn=e}function uu(){if(yn){var e=yn,t=xn;if(xn=yn=null,Ca(e),t)for(e=0;e>>=0,e===0?32:31-(of(e)/uf|0)|0}var Lr=64,Rr=4194304;function Vn(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 al(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,s=e.pingedLanes,a=n&268435455;if(a!==0){var o=a&~l;o!==0?r=Vn(o):(s&=a,s!==0&&(r=Vn(s)))}else a=n&~l,a!==0?r=Vn(a):s!==0&&(r=Vn(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,s=t&-t,l>=s||l===16&&(s&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 jr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-rt(t),e[t]=n}function pf(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=Gn),ba=" ",Oa=!1;function Pu(e,t){switch(e){case"keyup":return Bf.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Lu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var an=!1;function Hf(e,t){switch(e){case"compositionend":return Lu(t);case"keypress":return t.which!==32?null:(Oa=!0,ba);case"textInput":return e=t.data,e===ba&&Oa?null:e;default:return null}}function Wf(e,t){if(an)return e==="compositionend"||!Oi&&Pu(e,t)?(e=Eu(),Xr=Di=Et=null,an=!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=Ma(n)}}function $u(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?$u(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function bu(){for(var e=window,t=rl();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=rl(e.document)}return t}function Ii(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 Zf(e){var t=bu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&$u(n.ownerDocument.documentElement,n)){if(r!==null&&Ii(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,s=Math.min(r.start,l);r=r.end===void 0?s:Math.min(r.end,l),!e.extend&&s>r&&(l=r,r=s,s=l),l=Ba(n,s);var a=Ba(n,r);l&&a&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.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,on=null,Bs=null,qn=null,Us=!1;function Ua(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Us||on==null||on!==rl(r)||(r=on,"selectionStart"in r&&Ii(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}),qn&&cr(qn,r)||(qn=r,r=cl(Bs,"onSelect"),0dn||(e.current=Xs[dn],Xs[dn]=null,dn--)}function ee(e,t){dn++,Xs[dn]=e.current,e.current=t}var At={},Ce=Mt(At),$e=Mt(!1),Gt=At;function Nn(e,t){var n=e.type.contextTypes;if(!n)return At;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},s;for(s in n)l[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function be(e){return e=e.childContextTypes,e!=null}function fl(){ne($e),ne(Ce)}function Ja(e,t,n){if(Ce.current!==At)throw Error(E(168));ee(Ce,t),ee($e,n)}function Wu(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(E(108,Kd(e)||"Unknown",l));return oe({},n,r)}function pl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||At,Gt=Ce.current,ee(Ce,e),ee($e,$e.current),!0}function Ga(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=Wu(e,t,Gt),r.__reactInternalMemoizedMergedChildContext=e,ne($e),ne(Ce),ee(Ce,e)):ne($e),ee($e,n)}var pt=null,$l=!1,us=!1;function Vu(e){pt===null?pt=[e]:pt.push(e)}function dp(e){$l=!0,Vu(e)}function Bt(){if(!us&&pt!==null){us=!0;var e=0,t=q;try{var n=pt;for(q=1;e>=a,l-=a,ht=1<<32-rt(t)+l|n<N?(M=T,T=null):M=T.sibling;var O=f(m,T,v[N],k);if(O===null){T===null&&(T=M);break}e&&T&&O.alternate===null&&t(m,T),d=s(O,d,N),P===null?S=O:P.sibling=O,P=O,T=M}if(N===v.length)return n(m,T),se&&Ut(m,N),S;if(T===null){for(;NN?(M=T,T=null):M=T.sibling;var V=f(m,T,O.value,k);if(V===null){T===null&&(T=M);break}e&&T&&V.alternate===null&&t(m,T),d=s(V,d,N),P===null?S=V:P.sibling=V,P=V,T=M}if(O.done)return n(m,T),se&&Ut(m,N),S;if(T===null){for(;!O.done;N++,O=v.next())O=h(m,O.value,k),O!==null&&(d=s(O,d,N),P===null?S=O:P.sibling=O,P=O);return se&&Ut(m,N),S}for(T=r(m,T);!O.done;N++,O=v.next())O=w(T,m,N,O.value,k),O!==null&&(e&&O.alternate!==null&&T.delete(O.key===null?N:O.key),d=s(O,d,N),P===null?S=O:P.sibling=O,P=O);return e&&T.forEach(function(ce){return t(m,ce)}),se&&Ut(m,N),S}function D(m,d,v,k){if(typeof v=="object"&&v!==null&&v.type===sn&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case Er:e:{for(var S=v.key,P=d;P!==null;){if(P.key===S){if(S=v.type,S===sn){if(P.tag===7){n(m,P.sibling),d=l(P,v.props.children),d.return=m,m=d;break e}}else if(P.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===St&&Za(S)===P.type){n(m,P.sibling),d=l(P,v.props),d.ref=Fn(m,P,v),d.return=m,m=d;break e}n(m,P);break}else t(m,P);P=P.sibling}v.type===sn?(d=Jt(v.props.children,m.mode,k,v.key),d.return=m,m=d):(k=nl(v.type,v.key,v.props,null,m.mode,k),k.ref=Fn(m,d,v),k.return=m,m=k)}return a(m);case ln:e:{for(P=v.key;d!==null;){if(d.key===P)if(d.tag===4&&d.stateNode.containerInfo===v.containerInfo&&d.stateNode.implementation===v.implementation){n(m,d.sibling),d=l(d,v.children||[]),d.return=m,m=d;break e}else{n(m,d);break}else t(m,d);d=d.sibling}d=vs(v,m.mode,k),d.return=m,m=d}return a(m);case St:return P=v._init,D(m,d,P(v._payload),k)}if(Wn(v))return y(m,d,v,k);if($n(v))return x(m,d,v,k);Ar(m,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,d!==null&&d.tag===6?(n(m,d.sibling),d=l(d,v),d.return=m,m=d):(n(m,d),d=gs(v,m.mode,k),d.return=m,m=d),a(m)):n(m,d)}return D}var Cn=Ju(!0),Gu=Ju(!1),gl=Mt(null),vl=null,hn=null,Bi=null;function Ui(){Bi=hn=vl=null}function Hi(e){var t=gl.current;ne(gl),e._currentValue=t}function Ys(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 kn(e,t){vl=e,Bi=hn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(De=!0),e.firstContext=null)}function Ye(e){var t=e._currentValue;if(Bi!==e)if(e={context:e,memoizedValue:t,next:null},hn===null){if(vl===null)throw Error(E(308));hn=e,vl.dependencies={lanes:0,firstContext:e}}else hn=hn.next=e;return t}var Vt=null;function Wi(e){Vt===null?Vt=[e]:Vt.push(e)}function Yu(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Wi(t)):(n.next=l.next,l.next=n),t.interleaved=n,xt(e,r)}function xt(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 Nt=!1;function Vi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function qu(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 gt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Dt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,G&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,xt(e,n)}return l=r.interleaved,l===null?(t.next=t,Wi(r)):(t.next=l.next,l.next=t),r.interleaved=t,xt(e,n)}function Gr(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,Li(e,n)}}function eo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?l=s=a:s=s.next=a,n=n.next}while(n!==null);s===null?l=s=t:s=s.next=t}else l=s=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:s,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 yl(e,t,n,r){var l=e.updateQueue;Nt=!1;var s=l.firstBaseUpdate,a=l.lastBaseUpdate,o=l.shared.pending;if(o!==null){l.shared.pending=null;var u=o,c=u.next;u.next=null,a===null?s=c:a.next=c,a=u;var g=e.alternate;g!==null&&(g=g.updateQueue,o=g.lastBaseUpdate,o!==a&&(o===null?g.firstBaseUpdate=c:o.next=c,g.lastBaseUpdate=u))}if(s!==null){var h=l.baseState;a=0,g=c=u=null,o=s;do{var f=o.lane,w=o.eventTime;if((r&f)===f){g!==null&&(g=g.next={eventTime:w,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var y=e,x=o;switch(f=t,w=n,x.tag){case 1:if(y=x.payload,typeof y=="function"){h=y.call(w,h,f);break e}h=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=x.payload,f=typeof y=="function"?y.call(w,h,f):y,f==null)break e;h=oe({},h,f);break e;case 2:Nt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,f=l.effects,f===null?l.effects=[o]:f.push(o))}else w={eventTime:w,lane:f,tag:o.tag,payload:o.payload,callback:o.callback,next:null},g===null?(c=g=w,u=h):g=g.next=w,a|=f;if(o=o.next,o===null){if(o=l.shared.pending,o===null)break;f=o,o=f.next,f.next=null,l.lastBaseUpdate=f,l.shared.pending=null}}while(!0);if(g===null&&(u=h),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=g,t=l.shared.interleaved,t!==null){l=t;do a|=l.lane,l=l.next;while(l!==t)}else s===null&&(l.shared.lanes=0);Zt|=a,e.lanes=a,e.memoizedState=h}}function to(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ds.transition;ds.transition={};try{e(!1),t()}finally{q=n,ds.transition=r}}function mc(){return qe().memoizedState}function mp(e,t,n){var r=bt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},gc(e))vc(t,n);else if(n=Yu(e,t,n,r),n!==null){var l=Pe();lt(n,e,r,l),yc(n,t,r)}}function gp(e,t,n){var r=bt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(gc(e))vc(t,l);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var a=t.lastRenderedState,o=s(a,n);if(l.hasEagerState=!0,l.eagerState=o,st(o,a)){var u=t.interleaved;u===null?(l.next=l,Wi(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=Yu(e,t,l,r),n!==null&&(l=Pe(),lt(n,e,r,l),yc(n,t,r))}}function gc(e){var t=e.alternate;return e===ae||t!==null&&t===ae}function vc(e,t){Zn=wl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function yc(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Li(e,n)}}var kl={readContext:Ye,useCallback:Se,useContext:Se,useEffect:Se,useImperativeHandle:Se,useInsertionEffect:Se,useLayoutEffect:Se,useMemo:Se,useReducer:Se,useRef:Se,useState:Se,useDebugValue:Se,useDeferredValue:Se,useTransition:Se,useMutableSource:Se,useSyncExternalStore:Se,useId:Se,unstable_isNewReconciler:!1},vp={readContext:Ye,useCallback:function(e,t){return at().memoizedState=[e,t===void 0?null:t],e},useContext:Ye,useEffect:ro,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,qr(4194308,4,cc.bind(null,t,e),n)},useLayoutEffect:function(e,t){return qr(4194308,4,e,t)},useInsertionEffect:function(e,t){return qr(4,2,e,t)},useMemo:function(e,t){var n=at();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=at();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=mp.bind(null,ae,e),[r.memoizedState,e]},useRef:function(e){var t=at();return e={current:e},t.memoizedState=e},useState:no,useDebugValue:Zi,useDeferredValue:function(e){return at().memoizedState=e},useTransition:function(){var e=no(!1),t=e[0];return e=hp.bind(null,e[1]),at().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ae,l=at();if(se){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),ve===null)throw Error(E(349));qt&30||nc(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,ro(lc.bind(null,r,s,e),[e]),r.flags|=2048,yr(9,rc.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=at(),t=ve.identifierPrefix;if(se){var n=mt,r=ht;n=(r&~(1<<32-rt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=gr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[ot]=t,e[pr]=r,Tc(e,t,!1,!1),t.stateNode=e;e:{switch(a=Ds(n,r),n){case"dialog":te("cancel",e),te("close",e),l=r;break;case"iframe":case"object":case"embed":te("load",e),l=r;break;case"video":case"audio":for(l=0;lPn&&(t.flags|=128,r=!0,Mn(s,!1),t.lanes=4194304)}else{if(!r)if(e=xl(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Mn(s,!0),s.tail===null&&s.tailMode==="hidden"&&!a.alternate&&!se)return Ne(t),null}else 2*de()-s.renderingStartTime>Pn&&n!==1073741824&&(t.flags|=128,r=!0,Mn(s,!1),t.lanes=4194304);s.isBackwards?(a.sibling=t.child,t.child=a):(n=s.last,n!==null?n.sibling=a:t.child=a,s.last=a)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=de(),t.sibling=null,n=ie.current,ee(ie,r?n&1|2:n&1),t):(Ne(t),null);case 22:case 23:return sa(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ae&1073741824&&(Ne(t),t.subtreeFlags&6&&(t.flags|=8192)):Ne(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function _p(e,t){switch(Fi(t),t.tag){case 1:return be(t.type)&&fl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return En(),ne($e),ne(Ce),Xi(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ki(t),null;case 13:if(ne(ie),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));_n()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ne(ie),null;case 4:return En(),null;case 10:return Hi(t.type._context),null;case 22:case 23:return sa(),null;case 24:return null;default:return null}}var Mr=!1,_e=!1,Cp=typeof WeakSet=="function"?WeakSet:Set,b=null;function mn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ue(e,t,r)}else n.current=null}function ii(e,t,n){try{n()}catch(r){ue(e,t,r)}}var mo=!1;function Ep(e,t){if(Hs=ol,e=bu(),Ii(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,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var a=0,o=-1,u=-1,c=0,g=0,h=e,f=null;t:for(;;){for(var w;h!==n||l!==0&&h.nodeType!==3||(o=a+l),h!==s||r!==0&&h.nodeType!==3||(u=a+r),h.nodeType===3&&(a+=h.nodeValue.length),(w=h.firstChild)!==null;)f=h,h=w;for(;;){if(h===e)break t;if(f===n&&++c===l&&(o=a),f===s&&++g===r&&(u=a),(w=h.nextSibling)!==null)break;h=f,f=h.parentNode}h=w}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ws={focusedElem:e,selectionRange:n},ol=!1,b=t;b!==null;)if(t=b,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,b=e;else for(;b!==null;){t=b;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var x=y.memoizedProps,D=y.memoizedState,m=t.stateNode,d=m.getSnapshotBeforeUpdate(t.elementType===t.type?x:et(t.type,x),D);m.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(k){ue(t,t.return,k)}if(e=t.sibling,e!==null){e.return=t.return,b=e;break}b=t.return}return y=mo,mo=!1,y}function er(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 s=l.destroy;l.destroy=void 0,s!==void 0&&ii(t,n,s)}l=l.next}while(l!==r)}}function Il(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 ai(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 Rc(e){var t=e.alternate;t!==null&&(e.alternate=null,Rc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ot],delete t[pr],delete t[Ks],delete t[up],delete t[cp])),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 zc(e){return e.tag===5||e.tag===3||e.tag===4}function go(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||zc(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 oi(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=dl));else if(r!==4&&(e=e.child,e!==null))for(oi(e,t,n),e=e.sibling;e!==null;)oi(e,t,n),e=e.sibling}function ui(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(ui(e,t,n),e=e.sibling;e!==null;)ui(e,t,n),e=e.sibling}var xe=null,tt=!1;function jt(e,t,n){for(n=n.child;n!==null;)Dc(e,t,n),n=n.sibling}function Dc(e,t,n){if(ut&&typeof ut.onCommitFiberUnmount=="function")try{ut.onCommitFiberUnmount(Pl,n)}catch{}switch(n.tag){case 5:_e||mn(n,t);case 6:var r=xe,l=tt;xe=null,jt(e,t,n),xe=r,tt=l,xe!==null&&(tt?(e=xe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):xe.removeChild(n.stateNode));break;case 18:xe!==null&&(tt?(e=xe,n=n.stateNode,e.nodeType===8?os(e.parentNode,n):e.nodeType===1&&os(e,n),or(e)):os(xe,n.stateNode));break;case 4:r=xe,l=tt,xe=n.stateNode.containerInfo,tt=!0,jt(e,t,n),xe=r,tt=l;break;case 0:case 11:case 14:case 15:if(!_e&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var s=l,a=s.destroy;s=s.tag,a!==void 0&&(s&2||s&4)&&ii(n,t,a),l=l.next}while(l!==r)}jt(e,t,n);break;case 1:if(!_e&&(mn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ue(n,t,o)}jt(e,t,n);break;case 21:jt(e,t,n);break;case 22:n.mode&1?(_e=(r=_e)||n.memoizedState!==null,jt(e,t,n),_e=r):jt(e,t,n);break;default:jt(e,t,n)}}function vo(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Cp),t.forEach(function(r){var l=Op.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Ze(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=a),r&=~s}if(r=l,r=de()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Pp(r/1960))-r,10e?16:e,Tt===null)var r=!1;else{if(e=Tt,Tt=null,Nl=0,G&6)throw Error(E(331));var l=G;for(G|=4,b=e.current;b!==null;){var s=b,a=s.child;if(b.flags&16){var o=s.deletions;if(o!==null){for(var u=0;ude()-ra?Xt(e,0):na|=n),Oe(e,t)}function Bc(e,t){t===0&&(e.mode&1?(t=Rr,Rr<<=1,!(Rr&130023424)&&(Rr=4194304)):t=1);var n=Pe();e=xt(e,t),e!==null&&(jr(e,t,n),Oe(e,n))}function bp(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bc(e,n)}function Op(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(E(314))}r!==null&&r.delete(t),Bc(e,n)}var Uc;Uc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||$e.current)De=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return De=!1,Sp(e,t,n);De=!!(e.flags&131072)}else De=!1,se&&t.flags&1048576&&Qu(t,ml,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Zr(e,t),e=t.pendingProps;var l=Nn(t,Ce.current);kn(t,n),l=Gi(null,t,r,e,l,n);var s=Yi();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,be(r)?(s=!0,pl(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Vi(t),l.updater=Ol,t.stateNode=l,l._reactInternals=t,Zs(t,r,e,n),t=ni(null,t,r,!0,s,n)):(t.tag=0,se&&s&&Ai(t),Te(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Zr(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Ap(r),e=et(r,e),l){case 0:t=ti(null,t,r,e,n);break e;case 1:t=fo(null,t,r,e,n);break e;case 11:t=uo(null,t,r,e,n);break e;case 14:t=co(null,t,r,et(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:et(r,l),ti(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:et(r,l),fo(e,t,r,l,n);case 3:e:{if(_c(t),e===null)throw Error(E(387));r=t.pendingProps,s=t.memoizedState,l=s.element,qu(e,t),yl(t,r,null,n);var a=t.memoizedState;if(r=a.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){l=Tn(Error(E(423)),t),t=po(e,t,r,n,l);break e}else if(r!==l){l=Tn(Error(E(424)),t),t=po(e,t,r,n,l);break e}else for(Fe=zt(t.stateNode.containerInfo.firstChild),Me=t,se=!0,nt=null,n=Gu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(_n(),r===l){t=wt(e,t,n);break e}Te(e,t,r,n)}t=t.child}return t;case 5:return Zu(t),e===null&&Gs(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,a=l.children,Vs(r,l)?a=null:s!==null&&Vs(r,s)&&(t.flags|=32),Nc(e,t),Te(e,t,a,n),t.child;case 6:return e===null&&Gs(t),null;case 13:return Cc(e,t,n);case 4:return Qi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Cn(t,null,r,n):Te(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:et(r,l),uo(e,t,r,l,n);case 7:return Te(e,t,t.pendingProps,n),t.child;case 8:return Te(e,t,t.pendingProps.children,n),t.child;case 12:return Te(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,s=t.memoizedProps,a=l.value,ee(gl,r._currentValue),r._currentValue=a,s!==null)if(st(s.value,a)){if(s.children===l.children&&!$e.current){t=wt(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var o=s.dependencies;if(o!==null){a=s.child;for(var u=o.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=gt(-1,n&-n),u.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var g=c.pending;g===null?u.next=u:(u.next=g.next,g.next=u),c.pending=u}}s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),Ys(s.return,n,t),o.lanes|=n;break}u=u.next}}else if(s.tag===10)a=s.type===t.type?null:s.child;else if(s.tag===18){if(a=s.return,a===null)throw Error(E(341));a.lanes|=n,o=a.alternate,o!==null&&(o.lanes|=n),Ys(a,n,t),a=s.sibling}else a=s.child;if(a!==null)a.return=s;else for(a=s;a!==null;){if(a===t){a=null;break}if(s=a.sibling,s!==null){s.return=a.return,a=s;break}a=a.return}s=a}Te(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,kn(t,n),l=Ye(l),r=r(l),t.flags|=1,Te(e,t,r,n),t.child;case 14:return r=t.type,l=et(r,t.pendingProps),l=et(r.type,l),co(e,t,r,l,n);case 15:return jc(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:et(r,l),Zr(e,t),t.tag=1,be(r)?(e=!0,pl(t)):e=!1,kn(t,n),xc(t,r,l),Zs(t,r,l,n),ni(null,t,r,!0,e,n);case 19:return Ec(e,t,n);case 22:return Sc(e,t,n)}throw Error(E(156,t.tag))};function Hc(e,t){return gu(e,t)}function Ip(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 Je(e,t,n,r){return new Ip(e,t,n,r)}function aa(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ap(e){if(typeof e=="function")return aa(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ci)return 11;if(e===Ei)return 14}return 2}function Ot(e,t){var n=e.alternate;return n===null?(n=Je(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 nl(e,t,n,r,l,s){var a=2;if(r=e,typeof e=="function")aa(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case sn:return Jt(n.children,l,s,t);case _i:a=8,l|=8;break;case Ss:return e=Je(12,n,t,l|2),e.elementType=Ss,e.lanes=s,e;case Ns:return e=Je(13,n,t,l),e.elementType=Ns,e.lanes=s,e;case _s:return e=Je(19,n,t,l),e.elementType=_s,e.lanes=s,e;case Zo:return Fl(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Yo:a=10;break e;case qo:a=9;break e;case Ci:a=11;break e;case Ei:a=14;break e;case St:a=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=Je(a,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function Jt(e,t,n,r){return e=Je(7,e,r,t),e.lanes=n,e}function Fl(e,t,n,r){return e=Je(22,e,r,t),e.elementType=Zo,e.lanes=n,e.stateNode={isHidden:!1},e}function gs(e,t,n){return e=Je(6,e,null,t),e.lanes=n,e}function vs(e,t,n){return t=Je(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Fp(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=Yl(0),this.expirationTimes=Yl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yl(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function oa(e,t,n,r,l,s,a,o,u){return e=new Fp(e,t,n,o,u),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Je(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Vi(s),e}function Mp(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Kc)}catch(e){console.error(e)}}Kc(),Ko.exports=Ue;var Vp=Ko.exports,Xc,_o=Vp;Xc=_o.createRoot,_o.hydrateRoot;async function me(e){const t=await fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.json()}async function Qp(){return me("/api/archives")}async function Kp(e){return me(`/api/archives/${e}/entries`)}async function Xp(e,t,n){const r=new URLSearchParams;return t&&r.set("q",t),n&&r.set("tag",n),me(`/api/archives/${e}/entries/search?${r}`)}async function hi(e,t){return me(`/api/archives/${e}/entries/${t}`)}function Jp(e,t,n){return Promise.all(n.map(r=>me(`/api/archives/${e}/entries/${t}/artifacts/${r}`)))}async function Gp(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n??null})});if(!r.ok)throw new Error(await r.text())}async function Hr(e,t){return me(`/api/archives/${e}/entries/${t}/tags`)}async function Yp(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 qp(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 Zp(e,t){const n=await fetch(`/api/archives/${e}/entries/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`Delete failed (${n.status})`)}async function eh(e,t,n){const r=await fetch(`/api/archives/${e}/tags/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n})});if(!r.ok)throw new Error(await r.text());return r.json()}async function th(e,t){const n=await fetch(`/api/archives/${e}/tags/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(await n.text())}async function Co(e){return me(`/api/archives/${e}/runs`)}async function ys(e){return me(`/api/archives/${e}/tags`)}async function nh(e,t,n=null,r=null){const l={locator:t};n&&n!=="best"&&(l.quality=n),r&&(typeof r.ublock_enabled=="boolean"&&(l.ublock_enabled=r.ublock_enabled),typeof r.reader_mode=="boolean"&&(l.reader_mode=r.reader_mode),typeof r.cookie_ext_enabled=="boolean"&&(l.cookie_ext_enabled=r.cookie_ext_enabled));const s=await fetch(`/api/archives/${e}/captures`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error(a.error||`HTTP ${s.status}`)}return s.json()}async function rh(e,t){return me(`/api/archives/${e}/captures/probe?locator=${encodeURIComponent(t)}`)}async function Jc(e,t){return me(`/api/archives/${e}/capture_jobs/${t}`)}async function lh(){return(await(await fetch("/api/auth/setup")).json()).setup_required===!0}async function sh(e,t){const n=await fetch("/api/auth/setup",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!n.ok)throw new Error((await n.json()).error||"Setup failed");return n.json()}async function ih(e,t){const n=await fetch("/api/auth/login",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!n.ok)throw new Error((await n.json()).error||"Login failed");return n.json()}async function ah(){await fetch("/api/auth/logout",{method:"POST"})}async function oh(){const e=await fetch("/api/auth/me");return e.status===401?null:e.json()}async function uh(e){const t=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({display_name:e})});if(!t.ok)throw new Error(await t.text())}async function ch(e){const t=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await t.text())}async function dh(e,t){const n=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({current_password:e,new_password:t})});if(!n.ok){let r=await n.text();try{r=JSON.parse(r).error??r}catch{}throw new Error(r)}}async function fh(){return me("/api/auth/tokens")}async function ph(e){const t=await fetch("/api/auth/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})});if(!t.ok)throw new Error(await t.text());return t.json()}async function hh(e){const t=await fetch(`/api/auth/tokens/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(await t.text())}async function fa(){return me("/api/admin/instance-settings")}async function mi(e){const t=await fetch("/api/admin/instance-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await t.text())}async function mh(){return me("/api/admin/users")}async function gh(e,t,n){const r=await fetch("/api/admin/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,email:n||void 0})});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error||`HTTP ${r.status}`)}return r.json()}async function vh(e,t){const n=await fetch(`/api/admin/users/${e}/status`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function yh(){return me("/api/admin/roles")}async function xh(e,t){const n=await fetch("/api/admin/roles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:e,name:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function wh(e){return me(`/api/archives/${e}/collections`)}async function kh(e,t,n,r=2){const l=await fetch(`/api/archives/${e}/collections`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:t,slug:n,default_visibility_bits:r})});if(!l.ok){const s=await l.json().catch(()=>({error:l.statusText}));throw new Error(s.error||l.statusText)}return l.json()}async function jh(e,t){return me(`/api/archives/${e}/collections/${t}`)}async function Sh(e,t,n,r=2){const l=await fetch(`/api/archives/${e}/collections/${t}/entries`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({entry_uid:n,visibility_bits:r})});if(!l.ok){const s=await l.json().catch(()=>({error:l.statusText}));throw new Error(s.error||l.statusText)}}async function Nh(e,t,n){const r=await fetch(`/api/archives/${e}/collections/${t}/entries/${n}`,{method:"DELETE"});if(!r.ok){const l=await r.json().catch(()=>({error:r.statusText}));throw new Error(l.error||r.statusText)}}async function _h(e,t,n,r){const l=await fetch(`/api/archives/${e}/collections/${t}/entries/${n}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({visibility_bits:r})});if(!l.ok){const s=await l.json().catch(()=>({error:l.statusText}));throw new Error(s.error||l.statusText)}}async function Ch(e,t){return me(`/api/archives/${e}/entries/${t}/collections`)}async function Eo(e,t,n){const r=await fetch(`/api/archives/${e}/collections/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error??r.statusText)}}async function Eh(e,t){const n=await fetch(`/api/archives/${e}/collections/${t}`,{method:"DELETE"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error??n.statusText)}}async function Th(e){return me(`/api/archives/${e}/blob-cleanup`)}async function Ph(e){const t=await fetch(`/api/archives/${e}/blob-cleanup`,{method:"DELETE"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error??t.statusText)}return t.json()}async function Lh(e,t){const n=await fetch(`/api/archives/${e}/entries/${t}/rearchive`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.message||`rearchive failed: ${n.status}`)}return n.json()}async function Rh(){return me("/api/admin/cookie-rules")}async function zh(e,t,n){const r=await fetch("/api/admin/cookie-rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url_pattern:e||null,pattern_kind:t,cookies_json:n})});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.message||`HTTP ${r.status}`)}return r.json()}async function Dh(e,t){const n=await fetch(`/api/admin/cookie-rules/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.message||`HTTP ${n.status}`)}}async function $h(e){const t=await fetch(`/api/admin/cookie-rules/${e}`,{method:"DELETE"});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.message||`HTTP ${t.status}`)}}const bh=window.fetch;window.fetch=async(...e)=>{var n;const t=await bh(...e);return t.status===401&&((typeof e[0]=="string"?e[0]:((n=e[0])==null?void 0:n.url)??"").includes("/api/auth/")||window.dispatchEvent(new CustomEvent("auth:expired"))),t};function Oh({onLogin:e}){const[t,n]=p.useState(""),[r,l]=p.useState(""),[s,a]=p.useState(null),[o,u]=p.useState(!1);async function c(g){g.preventDefault(),a(null),u(!0);try{const h=await ih(t,r);e(h)}catch(h){a(h.message)}finally{u(!1)}}return i.jsx("div",{className:"login-page",children:i.jsxs("div",{className:"login-card",children:[i.jsx("h1",{className:"login-brand",children:"Archivr"}),i.jsx("p",{className:"login-tagline",children:"Sign in to your archive"}),i.jsxs("form",{onSubmit:c,children:[i.jsxs("div",{className:"login-field",children:[i.jsx("label",{className:"login-label",htmlFor:"login-username",children:"Username"}),i.jsx("input",{className:"login-input",id:"login-username",type:"text",value:t,onChange:g=>n(g.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),i.jsxs("div",{className:"login-field",children:[i.jsx("label",{className:"login-label",htmlFor:"login-password",children:"Password"}),i.jsx("input",{className:"login-input",id:"login-password",type:"password",value:r,onChange:g=>l(g.target.value),required:!0,autoComplete:"current-password"})]}),s&&i.jsx("p",{className:"login-error",children:s}),i.jsx("button",{className:"login-submit",type:"submit",disabled:o,children:o?"Signing in…":"Sign in"})]})]})})}function Ih({onComplete:e}){const[t,n]=p.useState(""),[r,l]=p.useState(""),[s,a]=p.useState(""),[o,u]=p.useState(null),[c,g]=p.useState(!1);async function h(f){if(f.preventDefault(),r!==s){u("Passwords do not match");return}if(r.length<8){u("Password must be at least 8 characters");return}u(null),g(!0);try{await sh(t,r),e()}catch(w){u(w.message)}finally{g(!1)}}return i.jsx("div",{className:"setup-page",children:i.jsxs("div",{className:"setup-card",children:[i.jsx("h1",{className:"setup-brand",children:"Archivr"}),i.jsx("p",{className:"setup-tagline",children:"Create your owner account to get started."}),i.jsxs("form",{onSubmit:h,children:[i.jsxs("div",{className:"setup-field",children:[i.jsx("label",{className:"setup-label",htmlFor:"setup-username",children:"Username"}),i.jsx("input",{className:"setup-input",id:"setup-username",type:"text",value:t,onChange:f=>n(f.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),i.jsxs("div",{className:"setup-field",children:[i.jsx("label",{className:"setup-label",htmlFor:"setup-password",children:"Password"}),i.jsx("input",{className:"setup-input",id:"setup-password",type:"password",value:r,onChange:f=>l(f.target.value),required:!0,autoComplete:"new-password"})]}),i.jsxs("div",{className:"setup-field",children:[i.jsx("label",{className:"setup-label",htmlFor:"setup-confirm",children:"Confirm password"}),i.jsx("input",{className:"setup-input",id:"setup-confirm",type:"password",value:s,onChange:f=>a(f.target.value),required:!0,autoComplete:"new-password"})]}),o&&i.jsx("p",{className:"setup-error",children:o}),i.jsx("button",{className:"setup-submit",type:"submit",disabled:c,children:c?"Creating account…":"Create account"})]})]})})}function Ah({archives:e,archiveId:t,onArchiveChange:n,view:r,onViewChange:l,onCaptureClick:s}){const{currentUser:a,setCurrentUser:o}=p.useContext(Wl)??{},[u,c]=p.useState(!1);async function g(){c(!0),await ah(),o(null),window.location.reload()}return i.jsxs("header",{className:"topbar",children:[i.jsx("div",{className:"brand",children:"Archivr"}),i.jsx("div",{className:"switcher",children:i.jsx("select",{"aria-label":"Select archive",value:t??"",onChange:h=>n(h.target.value),children:e.map(h=>i.jsx("option",{value:h.id,children:h.label},h.id))})}),i.jsx("nav",{className:"nav","aria-label":"Primary",children:["archive","tags","collections","runs","admin","settings"].map(h=>i.jsx("button",{className:`nav-link${r===h?" is-active":""}`,onClick:()=>l(h),children:h.charAt(0).toUpperCase()+h.slice(1)},h))}),i.jsx("button",{className:"capture-button",onClick:s,children:"Capture"}),a&&i.jsxs("div",{className:"user-menu",children:[i.jsx("span",{className:"user-name",children:a.display_name||a.username}),i.jsx("button",{className:"logout-btn",onClick:g,disabled:u,children:u?"Logging out…":"Log out"})]})]})}let gi=1;function Gc(e){const t=e.trim(),n=t.toLowerCase();for(const r of["yt:","youtube:"])if(n.startsWith(r)){const l=n.slice(r.length);return l.startsWith("video/")||l.startsWith("short/")||l.startsWith("shorts/")}if(n.startsWith("ytm:"))return!n.slice(4).startsWith("playlist/");for(const r of["x:","twitter:","tweet:"])if(n.startsWith(r))return n.slice(r.length).startsWith("media:");if(n.startsWith("spotify:"))return!1;if(n.startsWith("instagram:")||n.startsWith("facebook:")||n.startsWith("tiktok:")||n.startsWith("reddit:")||n.startsWith("snapchat:"))return!0;if(n.startsWith("http://")||n.startsWith("https://")){if(/^https?:\/\/music\.youtube\.com\/watch/.test(n)||/^https?:\/\/(?:www\.)?(?:youtu\.be\/[0-9A-Za-z_-]+|youtube\.com\/watch\?v=[0-9A-Za-z_-]+|youtube\.com\/shorts\/[0-9A-Za-z_-]+)/.test(t)||n.startsWith("https://x.com/")||n.startsWith("http://x.com/")||/^https?:\/\/(?:www\.)?instagram\.com\//.test(n)||/^https?:\/\/(?:www\.)?facebook\.com\//.test(n)||n.startsWith("https://fb.watch/")||n.startsWith("http://fb.watch/")||/^https?:\/\/(?:www\.)?tiktok\.com\//.test(n)||/^https?:\/\/(?:www\.)?reddit\.com\//.test(n)||n.startsWith("https://redd.it/")||n.startsWith("http://redd.it/")||/^https?:\/\/(?:www\.)?snapchat\.com\//.test(n))return!0;if(n.startsWith("https://open.spotify.com/")||n.startsWith("http://open.spotify.com/"))return!1}return!1}function Un(e=""){return{id:gi++,locator:e,quality:"best",probeState:"idle",probeQualities:null,probeHasAudio:!1,status:"idle",error:null,jobUid:null,archiveId:null}}function To(e){return e.some(t=>t.status==="submitting"||t.status==="running")}function Fh({open:e,archiveId:t,onClose:n,onCaptured:r,onToast:l}){const s=p.useRef(null),a=p.useRef(!0),o=p.useRef(new Map),u=p.useRef(new Map),c=p.useRef(new Map),g=p.useRef(t);p.useEffect(()=>{g.current=t},[t]);const h=p.useRef(r),f=p.useRef(l);p.useEffect(()=>{h.current=r},[r]),p.useEffect(()=>{f.current=l},[l]);const[w,y]=p.useState(()=>{try{const j=JSON.parse(sessionStorage.getItem("captureItems")||"null");if(Array.isArray(j)&&j.length>0)return j.forEach(C=>{C.id>=gi&&(gi=C.id+1)}),j}catch{}return[Un()]});p.useEffect(()=>{sessionStorage.setItem("captureItems",JSON.stringify(w))},[w]);const[x,D]=p.useState(!1),[m,d]=p.useState(null),[v,k]=p.useState(null),[S,P]=p.useState(!0);p.useEffect(()=>{fa().then(j=>{k(j),P(j.cookie_ext_enabled??!0)}).catch(()=>k({}))},[]);const T=m!==null?m:(v==null?void 0:v.ublock_enabled)??!0,[N,M]=p.useState(!1);p.useEffect(()=>{["captureDialogLocator","captureDialogError","captureDialogBusy","captureDialogJobStatus","captureDialogJobUid"].forEach(j=>sessionStorage.removeItem(j)),y(j=>j.map(C=>C.status==="submitting"?{...C,status:"idle",error:null}:C)),w.forEach(j=>{j.status==="running"&&j.jobUid&&j.archiveId&&!o.current.has(j.jobUid)&&O(j.id,j.jobUid,j.locator,j.archiveId)})},[]),p.useEffect(()=>{const j=s.current;if(!j)return;const C=()=>{u.current.forEach(A=>clearTimeout(A)),u.current.clear(),n()};return j.addEventListener("close",C),()=>j.removeEventListener("close",C)},[n]),p.useEffect(()=>{const j=s.current;j&&(e?(!a.current&&!To(w)&&y([Un()]),a.current=!1,j.open||j.showModal()):(u.current.forEach(C=>clearTimeout(C)),u.current.clear(),j.open&&j.close()))},[e]),p.useEffect(()=>()=>{o.current.forEach(j=>clearInterval(j)),u.current.forEach(j=>clearTimeout(j))},[]);function O(j,C,A,F,U=null){if(o.current.has(C))return;const Y=setInterval(async()=>{try{const Q=await Jc(F,C);if(Q.status==="completed"){clearInterval(o.current.get(C)),o.current.delete(C),y(J=>J.map(L=>L.id===j?{...L,status:"completed"}:L)),setTimeout(()=>{y(J=>{const L=J.filter(X=>X.id!==j);return L.length===0?[Un()]:L})},1400),h.current();try{const J=Q.notes_json?JSON.parse(Q.notes_json):null;if(J!=null&&J.ublock_skipped||J!=null&&J.cookie_ext_skipped){const X=J.ublock_skipped&&J.cookie_ext_skipped?"Captured without ad-blocking or cookie-consent extension. Check ARCHIVR_UBLOCK_EXT and ARCHIVR_COOKIE_EXT in your server config.":J.ublock_skipped?"Captured without ad-blocking. ARCHIVR_UBLOCK=true but ARCHIVR_UBLOCK_EXT is not set or the path is invalid.":"Captured without cookie-consent extension. ARCHIVR_COOKIE_EXT is not set or the path is invalid.";f.current(X,A,"warning"),V(U,"warning",A)}else U||f.current(null,A,"success"),V(U,"archived")}catch{U||f.current(null,A,"success"),V(U,"archived")}}else if(Q.status==="failed"){clearInterval(o.current.get(C)),o.current.delete(C);const J=Q.error_text||"Capture failed.";y(L=>L.map(X=>X.id===j?{...X,status:"failed",error:J}:X)),f.current(J,A),V(U,"failed",A)}}catch(Q){clearInterval(o.current.get(C)),o.current.delete(C);const J=Q.message||"Network error";y(L=>L.map(X=>X.id===j?{...X,status:"failed",error:J}:X)),f.current(J,A),V(U,"failed",A)}},500);o.current.set(C,Y)}function V(j,C,A=null){if(!j)return;const F=c.current.get(j);if(!F||(C==="archived"||C==="warning"?(F.archived++,C==="warning"&&(F.warnings++,A&&F.warningLocators.push(A))):(F.failed++,A&&F.failedLocators.push(A)),F.archived+F.failed0?`${U} archived (${Y} with warnings)`:`${U} archived`;X=Q>0?`${H}, ${Q} failed`:H}const We=U===0?"error":Q>0||Y>0?"warning":"success",Ve=[];J.length>0&&Ve.push(`Failed: -${J.map(H=>` ${H}`).join(` -`)}`),L.length>0&&Ve.push(`With warnings: -${L.map(H=>` ${H}`).join(` -`)}`);const z=Ve.length>0?Ve.join(` -`):null;f.current(z,null,We,X)}async function ce(j,C=null){if(!j.locator.trim())return;const A=t,F=j.locator.trim(),U=j.quality||"best";y(Y=>Y.map(Q=>Q.id===j.id?{...Q,status:"submitting",error:null}:Q));try{const Q=await nh(A,F,U,{ublock_enabled:T,reader_mode:N,cookie_ext_enabled:S});y(J=>J.map(L=>L.id===j.id?{...L,status:"running",jobUid:Q.job_uid,archiveId:A}:L)),O(j.id,Q.job_uid,F,A,C)}catch(Y){const Q=Y.message||"Submission failed.";y(J=>J.map(L=>L.id===j.id?{...L,status:"failed",error:Q}:L)),f.current(Q,F),V(C,"failed",F)}}function re(){var A,F;const j=w.filter(U=>U.status==="idle"&&U.locator.trim());if(j.length===0)return;const C=j.length>1?((A=crypto.randomUUID)==null?void 0:A.call(crypto))??`batch-${Date.now()}`:null;C&&c.current.set(C,{total:j.length,archived:0,warnings:0,failed:0,failedLocators:[],warningLocators:[]}),j.forEach(U=>ce(U,C)),(F=s.current)==null||F.close()}function Z(){y(j=>[...j,Un()])}function je(j){clearTimeout(u.current.get(j)),u.current.delete(j),y(C=>{const A=C.filter(F=>F.id!==j);return A.length===0?[Un()]:A})}function Ee(j){y(C=>C.map(A=>A.id===j?{...A,status:"idle",error:null}:A))}function ye(j,C){if(clearTimeout(u.current.get(j)),y(F=>F.map(U=>U.id===j?{...U,locator:C,probeState:"idle",probeQualities:null,probeHasAudio:!1,quality:"best"}:U)),!Gc(C))return;const A=setTimeout(async()=>{u.current.delete(j),y(F=>F.map(U=>U.id===j?{...U,probeState:"probing"}:U));try{const F=await rh(g.current,C.trim());y(U=>U.map(Y=>{if(Y.id!==j||Y.locator!==C)return Y;const Q=F.qualities??[],J=F.has_audio??!1,L=Q.length===0&&J?"audio":"best";return{...Y,probeState:"done",probeQualities:Q,probeHasAudio:J,quality:L}}))}catch{y(F=>F.map(U=>U.id===j?{...U,probeState:"idle",probeQualities:null}:U))}},600);u.current.set(j,A)}function R(j,C){y(A=>A.map(F=>F.id===j?{...F,quality:C}:F))}const _=w.filter(j=>j.status==="idle"&&j.locator.trim()).length,B=To(w);return i.jsx("dialog",{ref:s,className:"capture-dialog",children:i.jsxs("div",{className:"capture-dialog-inner",children:[i.jsxs("div",{className:"capture-dialog-header",children:[i.jsx("h2",{className:"capture-dialog-title",children:"Capture"}),i.jsx("button",{type:"button",className:"capture-dialog-close",onClick:()=>{var j;return(j=s.current)==null?void 0:j.close()},"aria-label":"Close",children:i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),i.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),i.jsx("div",{className:"capture-rows",children:w.map((j,C)=>i.jsx(Mh,{item:j,autoFocus:C===w.length-1&&j.status==="idle",onLocatorChange:A=>ye(j.id,A),onQualityChange:A=>R(j.id,A),onRemove:()=>je(j.id),onReset:()=>Ee(j.id),onSubmit:re},j.id))}),i.jsxs("button",{type:"button",className:"capture-add-row",onClick:Z,children:[i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"14"}),i.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"})]}),"Add another"]}),i.jsxs("div",{className:"capture-advanced",children:[i.jsxs("button",{type:"button",className:"capture-advanced-toggle",onClick:()=>D(j=>!j),"aria-expanded":x,children:[i.jsx("svg",{className:`capture-chevron${x?" capture-chevron--open":""}`,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("polyline",{points:"4 6 8 10 12 6"})}),"Advanced options"]}),x&&i.jsxs("div",{className:"capture-advanced-panel",children:[i.jsxs("label",{className:"capture-ext-row",children:[i.jsxs("span",{className:"capture-ext-label",children:[i.jsx("span",{className:"capture-ext-name",children:"uBlock Origin Lite"}),i.jsx("span",{className:"capture-ext-desc",children:"Block ads during this capture"})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":T,className:`ext-toggle ext-toggle--sm${T?" ext-toggle--on":""}`,onClick:()=>d(j=>j===null?!T:!j),"aria-label":"Toggle uBlock for this capture",children:i.jsx("span",{className:"ext-toggle-knob"})})]}),i.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[i.jsxs("span",{className:"capture-ext-label",children:[i.jsx("span",{className:"capture-ext-name",children:"Block cookie banners"}),i.jsx("span",{className:"capture-ext-desc",children:"Dismiss cookie consent banners during this capture"}),!(v!=null&&v.cookie_ext_available)&&i.jsxs("span",{className:"capture-ext-hint",children:["Not configured — set ",i.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})]})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":S,className:`ext-toggle ext-toggle--sm${S?" ext-toggle--on":""}`,onClick:()=>P(j=>!j),"aria-label":"Toggle cookie banner blocking for this capture",children:i.jsx("span",{className:"ext-toggle-knob"})})]}),i.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[i.jsxs("span",{className:"capture-ext-label",children:[i.jsx("span",{className:"capture-ext-name",children:"Reader mode"}),i.jsx("span",{className:"capture-ext-desc",children:"Distil to article text via Readability (off by default)"})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":N,className:`ext-toggle ext-toggle--sm${N?" ext-toggle--on":""}`,onClick:()=>M(j=>!j),"aria-label":"Toggle reader mode for this capture",children:i.jsx("span",{className:"ext-toggle-knob"})})]})]})]}),i.jsxs("div",{className:"capture-actions",children:[i.jsx("button",{type:"button",className:"capture-submit",onClick:re,disabled:_===0,children:_>1?`Archive ${_}`:"Archive"}),i.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var j;return(j=s.current)==null?void 0:j.close()},children:B?"Close":"Cancel"})]})]})})}function Mh({item:e,autoFocus:t,onLocatorChange:n,onQualityChange:r,onRemove:l,onReset:s,onSubmit:a}){const o=p.useRef(null),u=e.status==="submitting"||e.status==="running";p.useEffect(()=>{var g;t&&e.status==="idle"&&((g=o.current)==null||g.focus())},[t]);const c=(()=>{if(e.status==="completed"||u||!Gc(e.locator))return null;if(e.probeState==="probing")return i.jsx("span",{className:"capture-quality-probing","aria-label":"Checking available qualities",children:"…"});if(e.probeState==="done"){const g=e.probeQualities??[],h=e.probeHasAudio??!1;return g.length===0&&!h?i.jsx("span",{className:"capture-quality-hint",children:"No media detected"}):g.length===0&&h?i.jsx("select",{className:"capture-quality",value:"audio",onChange:f=>r(f.target.value),"aria-label":"Video quality",children:i.jsx("option",{value:"audio",children:"Audio only"})}):i.jsxs("select",{className:"capture-quality",value:e.quality||"best",onChange:f=>r(f.target.value),"aria-label":"Video quality",children:[i.jsx("option",{value:"best",children:"Best quality"}),g.map(f=>i.jsx("option",{value:f,children:f},f)),h&&i.jsx("option",{value:"audio",children:"Audio only"})]})}return null})();return i.jsxs("div",{className:`capture-row capture-row--${e.status}`,children:[i.jsxs("div",{className:"capture-row-main",children:[i.jsx(Bh,{status:e.status}),i.jsx("input",{ref:o,className:"capture-input",type:"text",placeholder:"https://… · yt:ID · ytm:ID · tweet:ID · x:ID",value:e.locator,onChange:g=>n(g.target.value),onKeyDown:g=>{g.key==="Enter"&&a()},disabled:u||e.status==="completed",autoComplete:"off",spellCheck:!1}),c,e.status==="failed"&&i.jsx("button",{type:"button",className:"capture-row-action",onClick:s,title:"Retry",children:i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M13 2.5A7 7 0 1 1 6.5 1"}),i.jsx("polyline",{points:"6.5 1 4 3.5 6.5 6"})]})}),!u&&e.status!=="completed"&&e.status!=="failed"&&i.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:l,"aria-label":"Remove",children:i.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),i.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),e.error&&i.jsx("p",{className:"capture-row-error",children:e.error})]})}function Bh({status:e}){return e==="submitting"||e==="running"?i.jsx("span",{className:"cap-dot cap-dot--running","aria-label":"Running",children:i.jsx("span",{className:"cap-spinner"})}):e==="completed"?i.jsx("span",{className:"cap-dot cap-dot--ok","aria-label":"Done",children:"✓"}):e==="failed"?i.jsx("span",{className:"cap-dot cap-dot--err","aria-label":"Failed",children:"✕"}):i.jsx("span",{className:"cap-dot cap-dot--idle","aria-hidden":"true"})}function vi(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&r").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}function Kt(e){return Uh(e)??""}function Yc(e){if(!e)return"";const t=new Date(e);if(isNaN(t))return e;const n=r=>String(r).padStart(2,"0");return`${t.getUTCFullYear()}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}const Po={youtube:'',youtube_music:'',spotify:'',x:'',instagram:'',facebook:'',tiktok:'',reddit:'',snapchat:'',local:'',web:'',other:'?'};function pa(e){return Po[e]??Po.other}function qc(e){return e.split("/").map(t=>t?t.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):"").join("/")}function Hh({entry:e,archiveId:t,isSelected:n,onSelect:r}){const[l,s]=p.useState(!1),o=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!l?i.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>s(!0),style:{objectFit:"contain"}}):i.jsx("span",{dangerouslySetInnerHTML:{__html:pa(e.source_kind)}});return i.jsxs("div",{className:n?"is-selected":void 0,tabIndex:0,"data-entry-uid":e.entry_uid,onClick:r,onKeyDown:u=>{u.key==="Enter"&&r()},children:[i.jsx("div",{className:"col-added",children:Yc(e.archived_at)}),i.jsxs("div",{className:"col-title",children:[i.jsx("span",{className:"source-icon",children:o}),i.jsx("span",{className:"entry-title",children:Kt(e.title)||Kt(e.entry_uid)})]}),i.jsx("div",{className:"col-type",children:i.jsx("span",{className:"type-pill",children:Kt(e.entity_kind)})}),i.jsxs("div",{className:"col-size",children:[i.jsx("span",{className:"size-total",children:vi(e.total_artifact_bytes)}),e.cached_bytes>0&&e.total_artifact_bytes>0&&i.jsxs("span",{className:"size-cached-pct",title:`${vi(e.cached_bytes)} already on disk from an earlier entry`,children:[Math.round(e.cached_bytes/e.total_artifact_bytes*100),"% cached"]})]}),i.jsx("div",{className:"url-cell col-url",children:Kt(e.original_url)})]})}function Wh({entries:e,selectedEntryUid:t,onSelectEntry:n,archiveId:r}){return i.jsx("section",{id:"archive-view",className:"view is-active",children:i.jsxs("div",{className:"entry-table",children:[i.jsxs("div",{className:"entry-header-row",children:[i.jsx("div",{className:"col-added",children:"Added"}),i.jsx("div",{className:"col-title",children:"Title"}),i.jsx("div",{className:"col-type",children:"Type"}),i.jsx("div",{className:"col-size",children:"Size"}),i.jsx("div",{className:"col-url",children:"Original URL"})]}),i.jsx("div",{id:"entries-body",children:e.map(l=>i.jsx(Hh,{entry:l,archiveId:r,isSelected:l.entry_uid===t,onSelect:()=>n(l)},l.entry_uid))})]})})}function Vh(e){if(!e)return"—";try{return new Date(e).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}function Qh({status:e}){const t=e==="completed"?"run-status--completed":e==="failed"?"run-status--failed":e==="in_progress"?"run-status--in-progress":"",n=e?e.replace(/_/g," "):"—";return i.jsx("span",{className:`run-status ${t}`,children:n})}function Kh({runs:e}){const[t,n]=p.useState(null);function r(l){n(s=>s===l?null:l)}return i.jsx("section",{id:"runs-view",className:"view is-active",children:i.jsxs("table",{className:"entry-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Started"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Requested"}),i.jsx("th",{children:"Completed"}),i.jsx("th",{children:"Failed"})]})}),i.jsx("tbody",{children:e.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:5,style:{color:"var(--muted)",padding:"24px 16px",textAlign:"center"},children:"No runs yet."})}):e.map(l=>{const s=l.status==="failed"&&l.error_summary,a=t===l.run_uid;return[i.jsxs("tr",{className:s?"run-row run-row--failed":"run-row",onClick:s?()=>r(l.run_uid):void 0,title:s?a?"Click to hide error":"Click to view error":void 0,children:[i.jsx("td",{children:Vh(l.started_at)}),i.jsxs("td",{children:[i.jsx(Qh,{status:l.status}),s&&i.jsx("span",{className:"run-expand-hint","aria-hidden":"true",children:a?"▴":"▾"})]}),i.jsx("td",{children:l.requested_count??"—"}),i.jsx("td",{children:l.completed_count??"—"}),i.jsx("td",{children:l.failed_count??"—"})]},l.run_uid),s&&a&&i.jsx("tr",{className:"run-error-row",children:i.jsx("td",{colSpan:5,children:i.jsx("pre",{className:"run-error-detail",children:l.error_summary})})},`${l.run_uid}-detail`)]})})]})})}const Xh=4;function Jh({archives:e}){const{currentUser:t}=p.useContext(Wl)??{},n=t&&(t.role_bits&Xh)!==0,[r,l]=p.useState("users"),[s,a]=p.useState([]),[o,u]=p.useState([]),[c,g]=p.useState(!1),[h,f]=p.useState(null),[w,y]=p.useState(""),[x,D]=p.useState(""),[m,d]=p.useState(""),[v,k]=p.useState(null),[S,P]=p.useState(!1),[T,N]=p.useState(""),[M,O]=p.useState(""),[V,ce]=p.useState(null),[re,Z]=p.useState(!1),je=p.useCallback(async()=>{if(n){g(!0),f(null);try{const[_,B]=await Promise.all([mh(),yh()]);a(_),u(B)}catch(_){f(_.message)}finally{g(!1)}}},[n]);p.useEffect(()=>{je()},[je]);async function Ee(_){const B=_.status==="active"?"disabled":"active";try{await vh(_.user_uid,B),a(j=>j.map(C=>C.user_uid===_.user_uid?{...C,status:B}:C))}catch(j){f(j.message)}}async function ye(_){if(_.preventDefault(),!w.trim()||!x){k("Username and password required");return}P(!0),k(null);try{await gh(w.trim(),x,m.trim()||void 0),y(""),D(""),d(""),await je()}catch(B){k(B.message)}finally{P(!1)}}async function R(_){if(_.preventDefault(),!T.trim()||!M.trim()){ce("Slug and name required");return}Z(!0),ce(null);try{await xh(T.trim(),M.trim()),N(""),O(""),await je()}catch(B){ce(B.message)}finally{Z(!1)}}return n?i.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[i.jsx("h1",{children:"Admin"}),i.jsxs("div",{className:"view-tabs",children:[i.jsx("button",{className:`view-tab${r==="users"?" is-active":""}`,onClick:()=>l("users"),children:"Users"}),i.jsx("button",{className:`view-tab${r==="roles"?" is-active":""}`,onClick:()=>l("roles"),children:"Roles"}),i.jsx("button",{className:`view-tab${r==="archives"?" is-active":""}`,onClick:()=>l("archives"),children:"Archives"})]}),h&&i.jsx("div",{className:"form-msg form-msg--err",children:h}),r==="users"&&i.jsxs("div",{className:"admin-section",children:[i.jsx("h2",{children:"Users"}),c?i.jsx("p",{className:"muted",children:"Loading…"}):i.jsxs("table",{className:"admin-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Username"}),i.jsx("th",{children:"Email"}),i.jsx("th",{children:"Roles"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Actions"})]})}),i.jsx("tbody",{children:s.map(_=>i.jsxs("tr",{className:_.status==="disabled"?"admin-row-disabled":"",children:[i.jsx("td",{children:_.username}),i.jsx("td",{className:"muted",children:_.email||"—"}),i.jsx("td",{children:_.role_slugs.join(", ")||"—"}),i.jsx("td",{children:i.jsx("span",{className:`status-badge status-${_.status}`,children:_.status})}),i.jsx("td",{children:i.jsx("button",{className:"admin-action-btn",onClick:()=>Ee(_),children:_.status==="active"?"Ban":"Unban"})})]},_.user_uid))})]}),i.jsx("h3",{children:"Create User"}),i.jsxs("form",{className:"admin-form",onSubmit:ye,children:[i.jsx("input",{className:"admin-input",placeholder:"Username",value:w,onChange:_=>y(_.target.value),required:!0}),i.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:x,onChange:_=>D(_.target.value),required:!0}),i.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:m,onChange:_=>d(_.target.value)}),v&&i.jsx("div",{className:"form-msg form-msg--err",children:v}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:S,children:S?"Creating…":"Create User"})]})]}),r==="roles"&&i.jsxs("div",{className:"admin-section",children:[i.jsx("h2",{children:"Roles"}),c?i.jsx("p",{className:"muted",children:"Loading…"}):i.jsxs("table",{className:"admin-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Slug"}),i.jsx("th",{children:"Name"}),i.jsx("th",{children:"Level"}),i.jsx("th",{children:"Bit"}),i.jsx("th",{children:"Built-in"})]})}),i.jsx("tbody",{children:o.map(_=>i.jsxs("tr",{children:[i.jsx("td",{children:i.jsx("code",{children:_.slug})}),i.jsx("td",{children:_.name}),i.jsx("td",{children:_.level}),i.jsx("td",{children:_.bit_position}),i.jsx("td",{children:_.is_builtin?"✓":""})]},_.role_uid))})]}),i.jsx("h3",{children:"Create Custom Role"}),i.jsxs("form",{className:"admin-form",onSubmit:R,children:[i.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:T,onChange:_=>N(_.target.value),required:!0}),i.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:M,onChange:_=>O(_.target.value),required:!0}),V&&i.jsx("div",{className:"form-msg form-msg--err",children:V}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:re,children:re?"Creating…":"Create Role"})]})]}),r==="archives"&&i.jsxs("div",{className:"admin-section",children:[i.jsx("h2",{children:"Mounted Archives"}),i.jsx("div",{className:"admin-list",children:e.map(_=>i.jsxs("div",{className:"admin-archive",children:[i.jsx("strong",{children:_.label}),i.jsx("div",{className:"muted",children:_.archive_path})]},_.id))})]})]}):i.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[i.jsx("h1",{children:"Admin"}),i.jsx("p",{className:"muted",children:"You need admin privileges to access this panel."}),i.jsx("h2",{children:"Mounted Archives"}),i.jsx("div",{className:"admin-list",children:e.map(_=>i.jsxs("div",{className:"admin-archive",children:[i.jsx("strong",{children:_.label}),i.jsx("div",{className:"muted",children:_.archive_path})]},_.id))})]})}function Zc({node:e,archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){var k;const c=n===e.tag.full_path,[g,h]=p.useState(!1),[f,w]=p.useState(""),y=p.useRef(!1);function x(){if(g)return;const S=c?null:e.tag.full_path;r(S),l("archive")}function D(S){S.stopPropagation(),w(e.tag.slug),h(!0)}async function m(){const S=f.trim();if(!S||S===e.tag.slug){h(!1);return}try{const P=await eh(t,e.tag.tag_uid,S);s(e.tag.full_path,P.full_path),o()}catch{}finally{h(!1)}}async function d(S){var T;S.stopPropagation();const P=((T=e.children)==null?void 0:T.length)>0?`Delete tag "${e.tag.full_path}" and all its child tags? This cannot be undone.`:`Delete tag "${e.tag.full_path}"? This cannot be undone.`;if(window.confirm(P))try{await th(t,e.tag.tag_uid),a(e.tag.full_path),o()}catch{}}const v={archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u};return i.jsxs("li",{children:[i.jsxs("div",{className:"tag-node-row",children:[g?i.jsx("input",{className:"tag-rename-input",autoFocus:!0,value:f,onChange:S=>w(S.target.value),onKeyDown:S=>{S.key==="Enter"&&S.currentTarget.blur(),S.key==="Escape"&&(y.current=!0,S.currentTarget.blur())},onBlur:()=>{y.current?(y.current=!1,h(!1)):m()}}):i.jsxs("button",{className:`tag-node-btn${c?" is-active":""}`,title:e.tag.full_path,onClick:x,onDoubleClick:D,children:[u?e.tag.name:e.tag.slug,i.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",onClick:S=>{S.stopPropagation(),D(S)},children:i.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),i.jsx("button",{className:"remove tag-node-delete",title:`Delete tag ${e.tag.full_path}`,onClick:d,"aria-label":`Delete tag ${e.tag.full_path}`,children:"×"})]}),((k=e.children)==null?void 0:k.length)>0&&i.jsx("div",{className:"tag-children",children:i.jsx("ul",{className:"tag-tree-list",children:e.children.map(S=>i.jsx(Zc,{node:S,...v},S.tag.tag_uid))})})]})}function Gh({archiveId:e,tagNodes:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){return i.jsx("section",{id:"tags-view",className:"view is-active",children:i.jsxs("div",{className:"tag-tree",children:[i.jsxs("div",{className:"tag-tree-header",children:[i.jsx("span",{className:"tag-tree-title",children:"Tags"}),n&&i.jsxs("span",{className:"tag-tree-active",children:["Filtering: ",n]})]}),t.length===0?i.jsx("p",{className:"muted",style:{padding:"8px 0"},children:"No tags yet."}):i.jsx("ul",{className:"tag-tree-list",children:t.map(c=>i.jsx(Zc,{node:c,archiveId:e,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u},c.tag.tag_uid))})]})})}const Kn=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],Yh=e=>{var t;return((t=Kn.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function qh({archiveId:e}){const[t,n]=p.useState([]),[r,l]=p.useState(!1),[s,a]=p.useState(null),[o,u]=p.useState(null),[c,g]=p.useState(null),[h,f]=p.useState(!1),[w,y]=p.useState(null),[x,D]=p.useState(""),[m,d]=p.useState(""),[v,k]=p.useState(2),[S,P]=p.useState(!1),[T,N]=p.useState(null),[M,O]=p.useState(""),[V,ce]=p.useState(2),[re,Z]=p.useState(!1),[je,Ee]=p.useState(null),[ye,R]=p.useState(!1),[_,B]=p.useState(""),j=p.useRef(null),C=t.find(z=>z.collection_uid===o)??null,A=(C==null?void 0:C.slug)==="_default_",F=p.useCallback(async()=>{if(e){l(!0),a(null);try{const z=await wh(e);n(z)}catch(z){a(z.message)}finally{l(!1)}}},[e]),U=p.useCallback(async z=>{if(!z){g(null);return}f(!0),y(null);try{const H=await jh(e,z);g(H)}catch(H){y(H.message)}finally{f(!1)}},[e]);p.useEffect(()=>{F()},[F]),p.useEffect(()=>{U(o)},[o,U]),p.useEffect(()=>{ye&&j.current&&j.current.focus()},[ye]);async function Y(z){z.preventDefault();const H=x.trim(),Ie=m.trim();if(!(!H||!Ie)){P(!0),N(null);try{const dt=await kh(e,H,Ie,v);D(""),d(""),k(2),await F(),u(dt.collection_uid)}catch(dt){N(dt.message)}finally{P(!1)}}}async function Q(){const z=_.trim();if(!z||!C){R(!1);return}try{await Eo(e,C.collection_uid,{name:z}),await F(),g(H=>H&&{...H,name:z})}catch(H){a(H.message)}finally{R(!1)}}async function J(z){if(C)try{await Eo(e,C.collection_uid,{default_visibility_bits:z}),await F(),g(H=>H&&{...H,default_visibility_bits:z})}catch(H){a(H.message)}}async function L(){if(C&&window.confirm(`Delete collection "${C.name}"? Entries will not be deleted.`))try{await Eh(e,C.collection_uid),u(null),g(null),await F()}catch(z){a(z.message)}}async function X(z){z.preventDefault();const H=M.trim();if(!(!H||!C)){Z(!0),Ee(null);try{await Sh(e,C.collection_uid,H,V),O(""),await U(C.collection_uid)}catch(Ie){Ee(Ie.message)}finally{Z(!1)}}}async function We(z){if(C)try{await Nh(e,C.collection_uid,z),await U(C.collection_uid)}catch(H){y(H.message)}}async function Ve(z,H){if(C)try{await _h(e,C.collection_uid,z,H),g(Ie=>Ie&&{...Ie,entries:Ie.entries.map(dt=>dt.entry_uid===z?{...dt,collection_visibility_bits:H}:dt)})}catch(Ie){y(Ie.message)}}return e?i.jsxs("div",{className:"collections-view",children:[i.jsx("h2",{className:"collections-heading",children:"Collections"}),r&&i.jsx("div",{className:"muted",children:"Loading…"}),s&&i.jsxs("div",{className:"collections-error",children:[s," ",i.jsx("button",{onClick:()=>a(null),className:"coll-dismiss",children:"×"})]}),i.jsxs("div",{className:"collections-layout",children:[i.jsxs("div",{className:"collections-sidebar",children:[t.map(z=>i.jsxs("button",{className:`coll-sidebar-row${o===z.collection_uid?" is-active":""}`,onClick:()=>u(z.collection_uid),children:[i.jsx("span",{className:"coll-row-name",children:z.name}),i.jsx("span",{className:"coll-row-meta",children:Yh(z.default_visibility_bits)})]},z.collection_uid)),t.length===0&&!r&&i.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),C?i.jsxs("div",{className:"coll-detail",children:[i.jsxs("div",{className:"coll-detail-header",children:[ye?i.jsx("input",{ref:j,className:"coll-rename-input",value:_,onChange:z=>B(z.target.value),onBlur:Q,onKeyDown:z=>{z.key==="Enter"&&Q(),z.key==="Escape"&&R(!1)}}):i.jsxs("h3",{className:`coll-detail-name${A?"":" coll-detail-name--editable"}`,title:A?void 0:"Click to rename",onClick:()=>{A||(B(C.name),R(!0))},children:[(c==null?void 0:c.name)??C.name,!A&&i.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!A&&i.jsx("button",{className:"coll-delete-btn",onClick:L,title:"Delete collection",children:"Delete"})]}),i.jsxs("div",{className:"coll-detail-vis",children:[i.jsx("span",{className:"coll-vis-label",children:"Default visibility"}),i.jsx("select",{className:"coll-vis-select",value:(c==null?void 0:c.default_visibility_bits)??C.default_visibility_bits,onChange:z=>J(Number(z.target.value)),disabled:A,children:Kn.map(z=>i.jsx("option",{value:z.value,children:z.label},z.value))})]}),i.jsxs("div",{className:"coll-entries-section",children:[i.jsx("div",{className:"coll-section-heading",children:"Entries"}),h&&i.jsx("div",{className:"muted",children:"Loading…"}),w&&i.jsx("div",{className:"collections-error",children:w}),!h&&c&&(c.entries.length===0?i.jsx("div",{className:"muted",children:"No entries in this collection."}):i.jsx("ul",{className:"coll-entries-list",children:c.entries.map(z=>i.jsxs("li",{className:"coll-entry-row",children:[i.jsxs("div",{className:"coll-entry-info",children:[i.jsx("span",{className:"coll-entry-title",children:z.title||z.entry_uid}),i.jsx("span",{className:"coll-entry-kind muted",children:z.source_kind})]}),i.jsxs("div",{className:"coll-entry-actions",children:[i.jsx("select",{className:"coll-entry-vis-select",value:z.collection_visibility_bits,onChange:H=>Ve(z.entry_uid,Number(H.target.value)),children:Kn.map(H=>i.jsx("option",{value:H.value,children:H.label},H.value))}),!A&&i.jsx("button",{className:"coll-entry-remove",onClick:()=>We(z.entry_uid),title:"Remove from collection",children:"×"})]})]},z.entry_uid))}))]}),!A&&i.jsxs("form",{className:"coll-add-entry-form",onSubmit:X,children:[i.jsx("div",{className:"coll-section-heading",children:"Add entry"}),i.jsxs("div",{className:"coll-add-entry-row",children:[i.jsx("input",{className:"coll-add-entry-input",type:"text",value:M,onChange:z=>O(z.target.value),placeholder:"entry_uid",required:!0}),i.jsx("select",{className:"coll-vis-select",value:V,onChange:z=>ce(Number(z.target.value)),children:Kn.map(z=>i.jsx("option",{value:z.value,children:z.label},z.value))}),i.jsx("button",{className:"coll-add-btn",type:"submit",disabled:re,children:re?"…":"Add"})]}),je&&i.jsx("div",{className:"collections-error",style:{marginTop:4},children:je})]})]}):i.jsx("div",{className:"coll-detail coll-detail--empty",children:i.jsx("div",{className:"muted",children:"Select a collection to view details."})})]}),i.jsxs("details",{className:"coll-create-details",children:[i.jsx("summary",{children:"+ Create collection"}),i.jsxs("form",{className:"coll-create-form",onSubmit:Y,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"coll-name",children:"Name"}),i.jsx("input",{className:"capture-input",id:"coll-name",type:"text",value:x,onChange:z=>{D(z.target.value),m||d(z.target.value.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"My Collection",required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"coll-slug",children:"Slug"}),i.jsx("input",{className:"capture-input",id:"coll-slug",type:"text",value:m,onChange:z=>d(z.target.value),placeholder:"my-collection",required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"coll-vis",children:"Default visibility"}),i.jsx("select",{className:"capture-input",id:"coll-vis",style:{height:42},value:v,onChange:z=>k(Number(z.target.value)),children:Kn.map(z=>i.jsx("option",{value:z.value,children:z.label},z.value))})]}),T&&i.jsx("div",{className:"collections-error",children:T}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:S,children:S?"Creating…":"Create collection"})]})]})]}):i.jsx("div",{className:"view-placeholder",children:"Select an archive."})}const Zh=4;function em({tab:e,onTabChange:t,archiveId:n}){const{currentUser:r,setCurrentUser:l}=p.useContext(Wl)??{},s=r&&(r.role_bits&Zh)!==0,a=["profile","tokens",...s?["instance","cookies","extensions","storage"]:[]],o={profile:"Profile",tokens:"API Tokens",instance:"Instance",cookies:"Cookies",extensions:"Extensions",storage:"Storage"};return i.jsxs("section",{className:"admin-view",children:[i.jsx("h1",{children:"Settings"}),i.jsx("div",{className:"view-tabs",children:a.map(u=>i.jsx("button",{className:`view-tab${e===u?" is-active":""}`,onClick:()=>t(u),children:o[u]},u))}),e==="profile"&&i.jsx(tm,{currentUser:r,setCurrentUser:l}),e==="tokens"&&i.jsx(nm,{}),e==="instance"&&s&&i.jsx(rm,{}),e==="cookies"&&s&&i.jsx(sm,{}),e==="extensions"&&s&&i.jsx(im,{}),e==="storage"&&s&&i.jsx(lm,{archiveId:n})]})}function tm({currentUser:e,setCurrentUser:t}){const[n,r]=p.useState((e==null?void 0:e.display_name)??""),[l,s]=p.useState(!1),[a,o]=p.useState(null),[u,c]=p.useState(""),[g,h]=p.useState(""),[f,w]=p.useState(""),[y,x]=p.useState(!1),[D,m]=p.useState(null);async function d(k){k.preventDefault(),s(!0),o(null);try{await uh(n),t(S=>({...S,display_name:n||null})),o({ok:!0,text:"Saved."})}catch(S){o({ok:!1,text:S.message})}finally{s(!1)}}async function v(k){if(k.preventDefault(),g!==f){m({ok:!1,text:"Passwords do not match."});return}x(!0),m(null);try{await dh(u,g),c(""),h(""),w(""),m({ok:!0,text:"Password changed."})}catch(S){m({ok:!1,text:S.message})}finally{x(!1)}}return i.jsxs("div",{style:{maxWidth:440},children:[i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Display Name"}),i.jsxs("form",{onSubmit:d,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"display-name",children:"Name shown in the UI"}),i.jsx("input",{className:"field-input",id:"display-name",placeholder:(e==null?void 0:e.username)??"",value:n,onChange:k=>r(k.target.value)})]}),a&&i.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:l,children:l?"Saving…":"Save"})]})]}),i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Display Preferences"}),i.jsxs("label",{className:"checkbox-row",children:[i.jsx("input",{type:"checkbox",checked:(e==null?void 0:e.humanize_slugs)??!1,onChange:async k=>{const S=k.target.checked;try{await ch({humanize_slugs:S}),t(P=>({...P,humanize_slugs:S}))}catch{}}}),i.jsx("span",{className:"form-label",style:{margin:0},children:"Humanize tag display"})]}),i.jsx("p",{className:"muted",style:{fontSize:13,margin:"4px 0 0"},children:'When on, tag paths show as "X / Articles" instead of "x/articles".'})]}),i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Change Password"}),i.jsxs("form",{onSubmit:v,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"cur-pw",children:"Current password"}),i.jsx("input",{className:"field-input",id:"cur-pw",type:"password",value:u,onChange:k=>c(k.target.value),required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"new-pw",children:"New password"}),i.jsx("input",{className:"field-input",id:"new-pw",type:"password",value:g,onChange:k=>h(k.target.value),required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",htmlFor:"confirm-pw",children:"Confirm new password"}),i.jsx("input",{className:"field-input",id:"confirm-pw",type:"password",value:f,onChange:k=>w(k.target.value),required:!0})]}),D&&i.jsx("div",{className:`form-msg form-msg--${D.ok?"ok":"err"}`,children:D.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:y,children:y?"Changing…":"Change Password"})]})]})]})}function nm(){const[e,t]=p.useState([]),[n,r]=p.useState(!0),[l,s]=p.useState(null),[a,o]=p.useState(""),[u,c]=p.useState(!1),[g,h]=p.useState(null),f=p.useCallback(async()=>{r(!0),s(null);try{t(await fh())}catch(x){s(x.message)}finally{r(!1)}},[]);p.useEffect(()=>{f()},[f]);async function w(x){if(x.preventDefault(),!!a.trim()){c(!0);try{const D=await ph(a.trim());h(D),o(""),f()}catch(D){s(D.message)}finally{c(!1)}}}async function y(x){try{await hh(x),t(D=>D.filter(m=>m.token_uid!==x))}catch(D){s(D.message)}}return i.jsx("div",{style:{maxWidth:600},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"API Tokens"}),g&&i.jsxs("div",{className:"token-banner",children:[i.jsx("strong",{children:"Token created."})," Copy it now — it won't be shown again.",i.jsx("code",{children:g.raw_token}),i.jsx("button",{className:"token-dismiss",onClick:()=>h(null),children:"Dismiss"})]}),i.jsxs("form",{className:"token-create-row",onSubmit:w,children:[i.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:a,onChange:x=>o(x.target.value),required:!0}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:u,children:u?"Creating…":"Create token"})]}),l&&i.jsx("div",{className:"form-msg form-msg--err",children:l}),n?i.jsx("div",{className:"muted",children:"Loading…"}):i.jsxs("div",{children:[e.length===0&&i.jsx("div",{className:"muted",children:"No tokens yet."}),e.map(x=>i.jsxs("div",{className:"token-row",children:[i.jsxs("div",{className:"token-row-info",children:[i.jsx("strong",{children:x.name}),i.jsxs("div",{className:"muted",children:["Created ",x.created_at.slice(0,10),x.last_used_at&&` · Last used ${x.last_used_at.slice(0,10)}`]})]}),i.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>y(x.token_uid),children:"Revoke"})]},x.token_uid))]})]})})}function rm(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,s]=p.useState(null),[a,o]=p.useState(!1),[u,c]=p.useState(null);p.useEffect(()=>{(async()=>{try{t(await fa())}catch(h){s(h.message)}finally{r(!1)}})()},[]);async function g(h){h.preventDefault(),o(!0),c(null);try{await mi(e),c({ok:!0,text:"Saved."})}catch(f){c({ok:!1,text:f.message})}finally{o(!1)}}return n?i.jsx("div",{className:"muted",children:"Loading…"}):l?i.jsx("div",{className:"form-msg form-msg--err",children:l}):e?i.jsx("div",{style:{maxWidth:440},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Instance Settings"}),i.jsxs("form",{onSubmit:g,children:[[["public_index_enabled","Public index (unauthenticated browsing)"],["public_entry_content_enabled","Public entry content"],["open_registration_enabled","Open registration"]].map(([h,f])=>i.jsxs("label",{className:"checkbox-row",children:[i.jsx("input",{type:"checkbox",checked:!!e[h],onChange:w=>t(y=>({...y,[h]:w.target.checked}))}),f]},h)),i.jsxs("div",{className:"form-field",style:{marginTop:4},children:[i.jsx("label",{className:"form-label",children:"Default entry visibility"}),i.jsxs("select",{className:"field-input",value:e.default_entry_visibility,onChange:h=>t(f=>({...f,default_entry_visibility:Number(h.target.value)})),children:[i.jsx("option",{value:0,children:"Private"}),i.jsx("option",{value:2,children:"Unlisted"}),i.jsx("option",{value:3,children:"Public"})]})]}),u&&i.jsx("div",{className:`form-msg form-msg--${u.ok?"ok":"err"}`,children:u.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:a,children:a?"Saving…":"Save Settings"})]})]})}):null}function xs(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,n)).toFixed(n===0?0:1)} ${t[n]}`}function lm({archiveId:e}){const[t,n]=p.useState("idle"),[r,l]=p.useState(null),[s,a]=p.useState(null),[o,u]=p.useState(null);function c(){n("idle"),l(null),a(null),u(null)}async function g(){n("scanning"),u(null),l(null);try{const w=await Th(e);l(w),n("scanned")}catch(w){u(w.message),n("error")}}async function h(){n("deleting"),u(null);try{const w=await Ph(e);a(w),n("done")}catch(w){u(w.message),n("error")}}const f=r&&r.deletable_files===0&&r.orphaned_blob_rows===0;return i.jsx("div",{style:{maxWidth:440},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Orphan Cleanup"}),i.jsxs("p",{className:"muted",style:{marginBottom:16},children:["Scan for blob files and database records that are no longer referenced by any archive entry and safely delete them."," ",i.jsx("strong",{children:"Cleanup is blocked while captures are running."})]}),!e&&i.jsx("div",{className:"muted",children:"No archive selected."}),e&&t==="idle"&&i.jsx("button",{className:"btn-ghost",onClick:g,children:"Scan for orphaned blobs"}),t==="scanning"&&i.jsx("div",{className:"muted",children:"Scanning…"}),t==="scanned"&&r&&f&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"form-msg form-msg--ok",children:"Archive is clean — nothing to remove."}),i.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Done"})]}),t==="scanned"&&r&&!f&&i.jsxs("div",{children:[i.jsxs("div",{style:{marginBottom:14,lineHeight:1.6},children:["Found ",i.jsx("strong",{children:r.deletable_files})," unreferenced file",r.deletable_files!==1?"s":""," ","and ",i.jsx("strong",{children:r.orphaned_blob_rows})," orphaned DB record",r.orphaned_blob_rows!==1?"s":""," ","— ",i.jsx("strong",{children:xs(r.total_bytes)})," recoverable."]}),i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsxs("button",{className:"btn-danger",onClick:h,children:["Delete (",xs(r.total_bytes),")"]}),i.jsx("button",{className:"btn-ghost",onClick:c,children:"Cancel"})]})]}),t==="deleting"&&i.jsx("div",{className:"muted",children:"Deleting…"}),t==="done"&&s&&i.jsxs("div",{children:[i.jsxs("div",{className:"form-msg form-msg--ok",children:["Freed ",i.jsx("strong",{children:xs(s.freed_bytes)})," ","— removed ",s.deleted_files," file",s.deleted_files!==1?"s":""," ","and ",s.deleted_blob_rows," DB record",s.deleted_blob_rows!==1?"s":"","."]}),s.errors&&s.errors.length>0&&i.jsxs("div",{className:"form-msg form-msg--err",style:{marginTop:6},children:[s.errors.length," file",s.errors.length!==1?"s":""," could not be deleted."]}),i.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Scan again"})]}),t==="error"&&i.jsxs("div",{children:[i.jsx("div",{className:"form-msg form-msg--err",children:o}),i.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Try again"})]})]})})}function sm(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,s]=p.useState(null),[a,o]=p.useState("global"),[u,c]=p.useState(""),[g,h]=p.useState("{}"),[f,w]=p.useState(null),[y,x]=p.useState(!1),[D,m]=p.useState({});p.useEffect(()=>{d()},[]);async function d(){r(!0),s(null);try{t(await Rh())}catch(N){s(N.message)}finally{r(!1)}}async function v(N){N.preventDefault();try{JSON.parse(g)}catch{w({ok:!1,text:'cookies must be valid JSON, e.g. {"session": "abc"}'});return}x(!0),w(null);try{await zh(a==="global"?null:u.trim(),a,g),c(""),h("{}"),o("global"),w({ok:!0,text:"Rule added."}),await d()}catch(M){w({ok:!1,text:M.message})}finally{x(!1)}}async function k(N){try{await $h(N),await d()}catch(M){s(M.message)}}function S(N){m(M=>({...M,[N.rule_uid]:{cookiesInput:N.cookies_json,saving:!1,msg:null}}))}function P(N){m(M=>{const O={...M};return delete O[N],O})}async function T(N){const M=D[N.rule_uid];try{JSON.parse(M.cookiesInput)}catch{m(O=>({...O,[N.rule_uid]:{...O[N.rule_uid],msg:{ok:!1,text:"Invalid JSON"}}}));return}m(O=>({...O,[N.rule_uid]:{...O[N.rule_uid],saving:!0,msg:null}}));try{await Dh(N.rule_uid,{cookies_json:M.cookiesInput}),P(N.rule_uid),await d()}catch(O){m(V=>({...V,[N.rule_uid]:{...V[N.rule_uid],saving:!1,msg:{ok:!1,text:O.message}}}))}}return n?i.jsx("div",{className:"muted",children:"Loading…"}):l?i.jsx("div",{className:"form-msg form-msg--err",children:l}):i.jsx("div",{style:{maxWidth:560},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Cookie Rules"}),i.jsx("p",{className:"muted",style:{marginBottom:12},children:"Cookies are injected into every capture network request (yt-dlp, HTTP downloads, web-page snapshots). Global rules apply to all URLs; wildcard and regex rules apply only to matching URLs."}),e&&e.length>0?i.jsxs("table",{className:"data-table",style:{width:"100%",marginBottom:16},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Pattern"}),i.jsx("th",{children:"Cookies"}),i.jsx("th",{style:{width:100},children:"Actions"})]})}),i.jsx("tbody",{children:e.map(N=>{const M=D[N.rule_uid],O=N.url_pattern?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"muted",children:[N.pattern_kind,":"]})," ",i.jsx("code",{children:N.url_pattern})]}):i.jsx("span",{className:"muted",children:"global (all URLs)"});return i.jsxs("tr",{children:[i.jsx("td",{children:O}),i.jsx("td",{children:M?i.jsxs(i.Fragment,{children:[i.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:12,width:"100%",minHeight:60},value:M.cookiesInput,onChange:V=>m(ce=>({...ce,[N.rule_uid]:{...ce[N.rule_uid],cookiesInput:V.target.value}}))}),M.msg&&i.jsx("div",{className:`form-msg form-msg--${M.msg.ok?"ok":"err"}`,children:M.msg.text}),i.jsxs("div",{style:{display:"flex",gap:8,marginTop:4},children:[i.jsx("button",{className:"btn-primary",style:{fontSize:12,padding:"2px 8px"},disabled:M.saving,onClick:()=>T(N),children:M.saving?"Saving…":"Save"}),i.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>P(N.rule_uid),children:"Cancel"})]})]}):i.jsx("code",{style:{fontSize:12,wordBreak:"break-all"},children:N.cookies_json})}),i.jsx("td",{children:!M&&i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>S(N),children:"Edit"}),i.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"2px 8px"},onClick:()=>k(N.rule_uid),children:"Del"})]})})]},N.rule_uid)})})]}):i.jsx("p",{className:"muted",style:{marginBottom:16},children:"No cookie rules defined."}),i.jsx("h3",{style:{marginBottom:8},children:"Add Rule"}),i.jsxs("form",{onSubmit:v,children:[i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",children:"Pattern type"}),i.jsxs("select",{className:"field-input",value:a,onChange:N=>o(N.target.value),children:[i.jsx("option",{value:"global",children:"Global (all URLs)"}),i.jsx("option",{value:"wildcard",children:"Wildcard (e.g. *.youtube.com)"}),i.jsx("option",{value:"regex",children:"Regex (matched against full URL)"})]})]}),a!=="global"&&i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",children:a==="wildcard"?"URL/hostname pattern":"Regex pattern"}),i.jsx("input",{className:"field-input",type:"text",value:u,onChange:N=>c(N.target.value),placeholder:a==="wildcard"?"*.youtube.com or https://example.com/*":".*\\.youtube\\.com.*",required:!0})]}),i.jsxs("div",{className:"form-field",children:[i.jsx("label",{className:"form-label",children:"Cookies (JSON object)"}),i.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:13,minHeight:70},value:g,onChange:N=>h(N.target.value),placeholder:'{"SESSION": "abc123", "token": "xyz"}',required:!0})]}),f&&i.jsx("div",{className:`form-msg form-msg--${f.ok?"ok":"err"}`,children:f.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:y,children:y?"Adding…":"Add Rule"})]})]})})}function im(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,s]=p.useState(!1),[a,o]=p.useState(null);p.useEffect(()=>{(async()=>{try{t(await fa())}catch(y){o({ok:!1,text:y.message})}finally{r(!1)}})()},[]);async function u(y){s(!0),o(null);try{await mi({ublock_enabled:y}),t(x=>({...x,ublock_enabled:y})),o({ok:!0,text:"Saved."})}catch(x){o({ok:!1,text:x.message})}finally{s(!1)}}async function c(y){s(!0),o(null);try{await mi({cookie_ext_enabled:y}),t(x=>({...x,cookie_ext_enabled:y})),o({ok:!0,text:"Saved."})}catch(x){o({ok:!1,text:x.message})}finally{s(!1)}}if(n)return i.jsx("div",{className:"muted",children:"Loading\\u2026"});const g=(e==null?void 0:e.ublock_ext_available)??!1,h=(e==null?void 0:e.ublock_enabled)??!0,f=(e==null?void 0:e.cookie_ext_available)??!1,w=(e==null?void 0:e.cookie_ext_enabled)??!0;return i.jsx("div",{style:{maxWidth:560},children:i.jsxs("div",{className:"form-section",children:[i.jsx("h2",{children:"Extensions"}),i.jsx("p",{className:"form-hint",style:{marginBottom:20},children:"Extensions run inside the browser during WebPage captures and can block ads, accept cookie banners, and more. Changes take effect on the next capture."}),i.jsx("div",{className:"ext-card",children:i.jsxs("div",{className:"ext-card-header",children:[i.jsxs("div",{className:"ext-card-info",children:[i.jsx("span",{className:"ext-card-name",children:"uBlock Origin Lite"}),i.jsx("span",{className:"ext-card-desc",children:"Blocks ads, trackers, and other page clutter during archiving via Chrome’s declarativeNetRequest API (Manifest V3)."}),!g&&i.jsxs("span",{className:"ext-card-hint",children:["Not configured — set ",i.jsx("code",{children:"ARCHIVR_UBLOCK_EXT"})," to the unpacked extension directory to enable."]})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":h,className:`ext-toggle${h?" ext-toggle--on":""}`,onClick:()=>u(!h),disabled:l,"aria-label":"Toggle uBlock Origin Lite",children:i.jsx("span",{className:"ext-toggle-knob"})})]})}),i.jsx("div",{className:"ext-card",children:i.jsxs("div",{className:"ext-card-header",children:[i.jsxs("div",{className:"ext-card-info",children:[i.jsx("span",{className:"ext-card-name",children:"I Still Don’t Care About Cookies"}),i.jsx("span",{className:"ext-card-desc",children:"Dismiss cookie consent banners during archiving."}),!f&&i.jsxs("span",{className:"ext-card-hint",children:["Not configured — set ",i.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})," to the unpacked extension directory to enable."]})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":w,className:`ext-toggle${w?" ext-toggle--on":""}`,onClick:()=>c(!w),disabled:l,"aria-label":"Toggle I Still Don't Care About Cookies",children:i.jsx("span",{className:"ext-toggle-knob"})})]})}),a&&i.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text})]})})}const Lo={0:"Private",1:"Public",2:"Users only",3:"Public"},am=()=>i.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M7 17 17 7M9 7h8v8"})});function om({archiveId:e,selectedEntry:t,detail:n,onTagFilterSet:r,tagNodes:l,onTagsRefresh:s,onEntryTitleChange:a,onEntryDeleted:o,humanizeTags:u,onDetailRefresh:c,onOpenPreview:g,onPlay:h}){const[f,w]=p.useState([]),[y,x]=p.useState(""),[D,m]=p.useState([]),[d,v]=p.useState(""),k=p.useRef(0),S=p.useRef(!1),[P,T]=p.useState(!1),[N,M]=p.useState(""),[O,V]=p.useState("idle"),[ce,re]=p.useState(""),Z=p.useRef(null);p.useEffect(()=>{const L=++k.current;if(Z.current&&(clearInterval(Z.current),Z.current=null),V("idle"),re(""),!t||!e){w([]),m([]);return}T(!1),M(""),S.current=!1,w([]),Promise.all([Hr(e,t.entry_uid),Ch(e,t.entry_uid)]).then(([X,We])=>{L===k.current&&(w(X),m(We))}).catch(()=>{})},[t,e]),p.useEffect(()=>()=>{clearInterval(Z.current)},[]);async function je(){const L=N.trim()||null;try{await Gp(e,t.entry_uid,L),a==null||a(t.entry_uid,L)}catch{}finally{T(!1)}}async function Ee(){const L=y.trim();if(!(!L||!t))try{await Yp(e,t.entry_uid,L),x(""),v("");const X=await Hr(e,t.entry_uid);w(X),s()}catch(X){v(X.message)}}async function ye(L){try{await qp(e,t.entry_uid,L);const X=await Hr(e,t.entry_uid);w(X),s()}catch{}}async function R(){if(!(!t||!e)&&window.confirm("Delete this entry? This cannot be undone."))try{await Zp(e,t.entry_uid),o==null||o(t.entry_uid)}catch{}}async function _(){if(!t||!e||O==="running")return;const L=k.current,X=t.entry_uid;V("running"),re("");try{const{job_uid:We}=await Lh(e,X);if(k.current!==L)return;Z.current=setInterval(async()=>{try{const Ve=await Jc(e,We);if(Ve.status==="completed"){if(clearInterval(Z.current),Z.current=null,k.current!==L)return;V("done");const z=await Hr(e,X);if(k.current!==L)return;w(z),c==null||c()}else if(Ve.status==="failed"){if(clearInterval(Z.current),Z.current=null,k.current!==L)return;V("error"),re(Ve.error_text||"Re-archive failed.")}}catch{if(clearInterval(Z.current),Z.current=null,k.current!==L)return;V("error"),re("Network error while polling.")}},500)}catch(We){if(k.current!==L)return;V("error"),re(We.message||"Failed to start re-archive.")}}const B=n?[["Added",Yc(n.summary.archived_at)],["Source",n.summary.source_kind],["Type",n.summary.entity_kind],["Visibility",Lo[n.summary.visibility]??n.summary.visibility],["Root",n.structured_root_relpath]]:[],j=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),C=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv","pdf","html","htm","jpg","jpeg","png","gif","webp","avif","svg","bmp"]),A=n?n.artifacts.findIndex(L=>L.artifact_role==="primary_media"):-1,F=A>=0?n.artifacts[A]:null,U=F?F.relpath.split(".").pop().toLowerCase():"",Y=F&&j.has(U),Q=A>=0&&t?`/api/archives/${e}/entries/${t.entry_uid}/artifacts/${A}`:null,J=n&&!Y&&(n.summary.entity_kind==="tweet"||n.summary.entity_kind==="tweet_thread"||F&&C.has(U));return i.jsxs("aside",{className:"context-rail",children:[i.jsx("div",{className:"rail-eyebrow",children:"Context"}),t?n?i.jsxs(i.Fragment,{children:[P?i.jsx("input",{className:"rail-title-input",autoFocus:!0,value:N,onChange:L=>M(L.target.value),onKeyDown:L=>{L.key==="Enter"&&L.currentTarget.blur(),L.key==="Escape"&&(S.current=!0,L.currentTarget.blur())},onBlur:()=>{S.current?T(!1):je(),S.current=!1}}):i.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{M(n.summary.title??""),T(!0)},children:[Kt(n.summary.title)||Kt(n.summary.entry_uid),i.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),n.summary.original_url&&i.jsxs("a",{className:"url-tile",href:n.summary.original_url,target:"_blank",rel:"noopener noreferrer",children:[i.jsx("span",{className:"ico",dangerouslySetInnerHTML:{__html:pa(n.summary.source_kind)}}),i.jsx("span",{className:"u-text",children:n.summary.original_url}),i.jsx("span",{className:"ext",children:i.jsx(am,{})})]}),Y&&h&&i.jsx("button",{className:"rail-preview-btn",onClick:()=>h(Q,t),children:"▶ Play"}),J&&g&&i.jsx("button",{className:"rail-preview-btn",onClick:g,children:"Preview"}),i.jsx("div",{className:"meta-list",children:B.filter(([,L])=>L!=null&&L!=="").map(([L,X])=>i.jsxs("div",{className:"meta-item",children:[i.jsx("span",{className:"meta-k",children:L}),i.jsx("span",{className:`meta-v${L==="Root"?" mono":""}`,children:Kt(X)})]},L))}),n.artifacts.length>0&&i.jsxs("div",{className:"rail-section",children:[i.jsxs("div",{className:"rail-section-heading",children:["Artifacts ",i.jsx("span",{className:"num",children:n.artifacts.length})]}),i.jsx("ul",{className:"artifact-list",children:n.artifacts.map((L,X)=>i.jsx("li",{children:i.jsxs("a",{href:`/api/archives/${e}/entries/${n.summary.entry_uid}/artifacts/${X}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[i.jsx("span",{className:"artifact-name",children:L.artifact_role.replace(/_/g," ")}),i.jsx("span",{className:"artifact-size",children:L.byte_size!=null?vi(L.byte_size):"—"})]})},X))})]})]}):i.jsx("p",{className:"tags-empty",children:"Loading…"}):i.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Tags"}),f.length===0?i.jsx("p",{className:"tags-empty",children:"No tags yet."}):i.jsx("div",{className:"tags-wrap",children:f.map(L=>i.jsxs("span",{className:"tag-pill",title:L.full_path,children:[u?qc(L.full_path):L.full_path,i.jsx("button",{className:"remove",title:`Remove tag ${L.full_path}`,onClick:()=>ye(L.tag_uid),children:"×"})]},L.tag_uid))}),d&&i.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:d}),i.jsxs("div",{className:"tag-input-wrap",children:[i.jsx("span",{className:"hash",children:"/"}),i.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:y,onChange:L=>x(L.target.value),onKeyDown:L=>{L.key==="Enter"&&Ee()}}),i.jsx("button",{className:"tag-add-btn",onClick:Ee,children:"Add"})]})]}),D.length>0&&i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Collections"}),D.map(L=>i.jsxs("div",{className:"coll-row",children:[i.jsx("span",{className:"coll-name",children:L.collection_uid}),i.jsx("span",{className:"vis-badge",children:Lo[L.visibility_bits]??`bits:${L.visibility_bits}`})]},L.collection_uid))]}),n&&(n.summary.entity_kind==="tweet"||n.summary.entity_kind==="tweet_thread")&&i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Actions"}),i.jsx("button",{className:"rail-rearchive-btn",onClick:_,disabled:O==="running",children:O==="running"?"Re-archiving…":"Re-archive"}),O==="done"&&i.jsx("p",{className:"form-msg form-msg--ok",style:{marginTop:"6px"},children:"Re-archived successfully."}),O==="error"&&i.jsx("p",{className:"form-msg form-msg--err",style:{marginTop:"6px"},children:ce})]}),i.jsx("div",{className:"rail-delete-zone",children:i.jsx("button",{className:"rail-delete-btn",onClick:R,children:"Delete entry"})})]})]})}function um({src:e}){const t=p.useRef(null);return p.useEffect(()=>{t.current&&t.current.load()},[e]),i.jsx("div",{className:"preview-video-wrap",style:{background:"#111",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:"240px"},children:e?i.jsxs("video",{ref:t,controls:!0,autoPlay:!1,style:{width:"100%",maxHeight:"100%",display:"block"},children:[i.jsx("source",{src:e}),"Your browser does not support the video element."]}):i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No video available"})})}function Ro({src:e,type:t,title:n,originalUrl:r}){const l=r||e,s=n||null;return i.jsxs("div",{className:"preview-iframe-wrap",style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[i.jsxs("div",{className:"preview-iframe-toolbar",style:{display:"flex",flexDirection:"column",gap:"2px",padding:"6px 12px",borderBottom:"1px solid var(--line-soft)",background:"var(--paper-2)",flexShrink:0},children:[s&&i.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--ink)",fontFamily:"var(--sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[i.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.78rem",color:"var(--muted)",fontFamily:"var(--sans)"},children:l}),i.jsx("a",{href:e,target:"_blank",rel:"noreferrer noopener",style:{fontSize:"0.78rem",color:"var(--accent)",textDecoration:"none",whiteSpace:"nowrap",fontFamily:"var(--sans)",flexShrink:0},children:t==="pdf"?"Open PDF ↗":"Open in new tab ↗"})]})]}),i.jsx("iframe",{src:e,sandbox:"allow-same-origin allow-popups",allow:"autoplay 'none'",referrerPolicy:"no-referrer",style:{flex:1,border:"none",width:"100%",minHeight:0},title:s||(t==="pdf"?"PDF preview":"Page preview")})]})}function cm({src:e,alt:t}){return i.jsx("div",{className:"preview-image-wrap",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",background:"var(--paper-2)",overflow:"hidden"},children:i.jsx("a",{href:e,target:"_blank",rel:"noreferrer noopener",style:{display:"contents"},children:i.jsx("img",{src:e,alt:t||"",style:{objectFit:"contain",maxHeight:"100%",maxWidth:"100%",display:"block",cursor:"pointer"}})})})}function ed(e){return e?new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(e*1e3)):""}function zo(e){return!e||!e.includes("&")?e:e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}const $={card:{background:"var(--paper)",border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",maxWidth:"560px",margin:"0 auto",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},threadOuter:{border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",maxWidth:"560px",margin:"0 auto",background:"var(--paper)",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},tweetRow:{display:"flex",gap:"10px",padding:"10px 12px"},tweetRowThread:{display:"flex",gap:"10px",padding:"10px 12px 0"},leftCol:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0,width:"36px"},rightCol:{flex:1,minWidth:0,paddingBottom:"8px"},avatar:{width:"36px",height:"36px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},avatarPh:{width:"36px",height:"36px",borderRadius:"50%",background:"var(--line)",flexShrink:0},threadLine:{flex:1,width:"2px",background:"var(--line-soft, var(--line))",margin:"4px 0",minHeight:"12px",borderRadius:"1px"},authorRow:{display:"flex",alignItems:"baseline",gap:"4px",flexWrap:"wrap",marginBottom:"4px",lineHeight:"1.3"},authorName:{fontWeight:"700",fontSize:"14px",color:"var(--ink)"},authorHandle:{fontSize:"13px",color:"var(--muted)"},datePart:{fontSize:"13px",color:"var(--muted)"},tweetText:{fontSize:"14px",lineHeight:"1.5",color:"var(--ink)",whiteSpace:"pre-line",marginBottom:"8px",wordBreak:"break-word"},stats:{display:"flex",gap:"12px",fontSize:"13px",color:"var(--muted)"},link:{color:"var(--accent)",textDecoration:"none"},loading:{padding:"24px 16px",textAlign:"center",color:"var(--muted)",fontSize:"14px"},error:{padding:"24px 16px",textAlign:"center",color:"var(--alert)",fontSize:"14px"},mediaGrid:{marginBottom:"8px",borderRadius:"10px",overflow:"hidden",border:"1px solid var(--line)"},mediaImg:{display:"block",width:"100%",objectFit:"cover",maxHeight:"260px"},mediaVideo:{display:"block",width:"100%",maxHeight:"260px",background:"#000"},article:{maxWidth:"560px",margin:"0 auto",border:"1px solid var(--line)",borderRadius:"12px",overflow:"hidden",background:"var(--paper)",fontFamily:'var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif)'},aCover:{width:"100%",display:"block",objectFit:"cover",maxHeight:"280px"},aMeta:{padding:"10px 14px 0"},aTweetTitle:{fontSize:"20px",fontWeight:"800",letterSpacing:"-0.3px",color:"var(--ink)",lineHeight:"1.3",marginBottom:"8px"},aAuthorRow:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},aAvatar:{width:"36px",height:"36px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},aAvatarPh:{width:"36px",height:"36px",borderRadius:"50%",background:"var(--line)",flexShrink:0},aAuthorName:{fontSize:"14px",fontWeight:"700",color:"var(--ink)",lineHeight:"1.3"},aAuthorSub:{fontSize:"13px",color:"var(--muted)",lineHeight:"1.3"},aDivider:{border:"none",borderTop:"1px solid var(--line)",margin:"0"},aBody:{padding:"4px 14px 16px"},bH1:{fontSize:"22px",fontWeight:"800",letterSpacing:"-0.4px",color:"var(--ink)",lineHeight:"1.25",margin:"16px 0 6px"},bH2:{fontSize:"18px",fontWeight:"700",letterSpacing:"-0.2px",color:"var(--ink)",lineHeight:"1.3",margin:"14px 0 4px"},bP:{fontSize:"15px",color:"var(--ink)",lineHeight:"1.65",marginBottom:"12px",marginTop:"0"},bSpacer:{height:"4px",display:"block"},bQuote:{borderLeft:"3px solid var(--line)",padding:"2px 12px",margin:"12px 0",color:"var(--muted)",fontSize:"15px",lineHeight:"1.6"},bHr:{border:"none",borderTop:"1px solid var(--line)",margin:"14px 0"},bImg:{width:"100%",display:"block",borderRadius:"8px",margin:"12px 0"},bUl:{margin:"8px 0 12px",paddingLeft:"24px"},bOl:{margin:"8px 0 12px",paddingLeft:"24px"},bLi:{fontSize:"15px",color:"var(--ink)",lineHeight:"1.6",marginBottom:"4px"},bTweet:{display:"flex",alignItems:"center",gap:"10px",border:"1px solid var(--line)",borderRadius:"10px",padding:"10px 14px",margin:"12px 0",color:"var(--muted)",fontSize:"14px",textDecoration:"none"},bMdPre:{borderRadius:"8px",margin:"10px 0",overflow:"auto",background:"var(--paper-3, var(--field))",padding:"12px 14px"},bMdCode:{fontFamily:"ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, Consolas, monospace",fontSize:"12px",lineHeight:"1.6",color:"var(--ink)",background:"transparent",display:"block"},iCode:{fontFamily:"ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace",fontSize:"0.875em",background:"var(--paper-3, var(--field))",padding:"1px 5px",borderRadius:"4px",color:"var(--ink)"},qtBadge:{fontSize:"11px",color:"var(--muted)",display:"inline-flex",alignItems:"center",gap:"2px",marginLeft:"4px",letterSpacing:"0.03em",flexShrink:0},lightboxBackdrop:{position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.92)",display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},lightboxContent:{display:"flex",flexDirection:"column",alignItems:"center",gap:"10px",maxWidth:"90vw",maxHeight:"90vh"},lightboxToolbar:{display:"flex",alignItems:"center",gap:"10px",alignSelf:"flex-end"},lightboxImg:{maxWidth:"88vw",maxHeight:"80vh",objectFit:"contain",borderRadius:"6px",display:"block"},lightboxNav:{display:"flex",gap:"12px",alignItems:"center"},lightboxNavBtn:{background:"rgba(255,255,255,0.18)",border:"none",color:"#fff",fontSize:"20px",cursor:"pointer",borderRadius:"50%",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,flexShrink:0},lightboxBtn:{background:"rgba(255,255,255,0.18)",border:"none",color:"#fff",fontSize:"16px",cursor:"pointer",borderRadius:"50%",width:"30px",height:"30px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,flexShrink:0},lightboxLink:{color:"rgba(255,255,255,0.7)",textDecoration:"none",fontSize:"14px"},lightboxCounter:{color:"rgba(255,255,255,0.6)",fontSize:"13px"}};function dm(e,t,n){const r={};return n&&n.forEach((l,s)=>{l.relpath&&(r[l.relpath]=`/api/archives/${e}/entries/${t}/artifacts/${s}`)}),r}function wr(e,t,n){return e&&n[e]?n[e]:t||null}function td(){return i.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",style:{flexShrink:0,color:"var(--ink)"},children:i.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.748l7.73-8.835L1.254 2.25H8.08l4.259 5.63L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117L17.083 19.77z"})})}function nd(e,t,...n){var r;if(e.fromIndex!=null&&e.toIndex!=null)return{s:e.fromIndex,e:e.toIndex};if(((r=e.indices)==null?void 0:r.length)===2)return{s:e.indices[0],e:e.indices[1]};if(t)for(const l of n){if(!l)continue;const s=t.indexOf(l);if(s!==-1)return{s,e:s+l.length}}return null}function rd(e,t){const n=e.expanded_url||e.url||e.text||"",r=e.display_url||e.expanded_url||e.url||e.text||"",l=nd(e,t,e.url,e.text,e.display_url,e.expanded_url);return!l||!n?null:{...l,kind:"url",href:n,display:r}}function ld(e,t){const n=e.screen_name||e.name||e.text||"",r=n?`@${n}`:null,l=nd(e,t,r);return!l||!n?null:{...l,kind:"mention",screen_name:n}}const Do=/https?:\/\/[^\s<>"'\])]+/g,fm=/[.,;:!?)()]+$/;function El(e,t){const n=[];let r=0,l;for(Do.lastIndex=0;(l=Do.exec(e))!==null;){l.index>r&&n.push(e.slice(r,l.index));let s=l[0].replace(fm,"");n.push(i.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:t,children:s},l.index));const a=l[0].slice(s.length);a&&n.push(a),r=l.index+l[0].length}return r===0?e:(rrd(s,e)).filter(Boolean),...(t.user_mentions||[]).map(s=>ld(s,e)).filter(Boolean)];if(n.length===0)return El(zo(e),$.link);const r=new Set([0,e.length]);for(const s of n)s.s>=0&&s.s<=e.length&&r.add(s.s),s.e>=0&&s.e<=e.length&&r.add(s.e);const l=[...r].sort((s,a)=>s-a);return l.slice(0,-1).map((s,a)=>{const o=l[a+1],u=e.slice(s,o),c=n.filter(f=>f.s<=s&&f.e>=o),g=c.find(f=>f.kind==="url");if(g)return i.jsx("a",{href:g.href,target:"_blank",rel:"noopener noreferrer",style:$.link,children:g.display||u},a);const h=c.find(f=>f.kind==="mention");return h?i.jsx("a",{href:`https://x.com/${h.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:$.link,children:u},a):i.jsx("span",{children:El(zo(u),$.link)},a)})}function hm(e,t,n,r){if(!e)return null;t=t||[],n=n||[],r=r||[];const l=[];for(const o of t)o.length>0&&l.push({s:o.offset,e:o.offset+o.length,kind:"style",style:o.style});for(const o of n){const u=rd(o,e);u&&l.push(u)}for(const o of r){const u=ld(o,e);u&&l.push(u)}if(l.length===0)return El(e,$.link);const s=new Set([0,e.length]);for(const o of l)o.s>=0&&o.s<=e.length&&s.add(o.s),o.e>=0&&o.e<=e.length&&s.add(o.e);const a=[...s].sort((o,u)=>o-u);return a.slice(0,-1).map((o,u)=>{const c=a[u+1],g=l.filter(x=>x.s<=o&&x.e>=c),h=e.slice(o,c);let f;if(h.includes(` -`)){const x=h.split(` -`);f=x.flatMap((D,m)=>mx.kind==="style"&&x.style==="Code")&&(f=i.jsx("code",{style:$.iCode,children:f})),g.some(x=>x.kind==="style"&&x.style==="Bold")&&(f=i.jsx("strong",{children:f})),g.some(x=>x.kind==="style"&&x.style==="Italic")&&(f=i.jsx("em",{children:f})),g.some(x=>x.kind==="style"&&x.style==="Underline")&&(f=i.jsx("u",{children:f})),g.some(x=>x.kind==="style"&&x.style==="Strikethrough")&&(f=i.jsx("s",{children:f}));const w=g.find(x=>x.kind==="url");if(w){const x=/^https?:\/\/t\.co\//i.test(f);f=i.jsx("a",{href:w.href,target:"_blank",rel:"noopener noreferrer",style:$.link,children:x?w.display:f})}const y=g.find(x=>x.kind==="mention");return y&&(f=i.jsx("a",{href:`https://x.com/${y.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:$.link,children:f})),i.jsx("span",{children:typeof f=="string"?El(f,$.link):f},u)})}function mm(e,t,n){const r=e.resolved_entities||[];return r.length===0?null:r.map((l,s)=>{var a;switch(l.type){case"divider":return i.jsx("hr",{style:$.bHr},s);case"media":{const o=wr(l.local_path,l.url,t);return o?i.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:u=>{var c;!u.metaKey&&!u.ctrlKey&&(u.preventDefault(),(c=n==null?void 0:n.onImgClick)==null||c.call(n,o))},children:i.jsx("img",{src:o,style:$.bImg,loading:"lazy",alt:""})},s):null}case"tweet":return l.tweet_id?i.jsxs("a",{href:`https://x.com/i/status/${l.tweet_id}`,target:"_blank",rel:"noopener noreferrer",style:$.bTweet,children:[i.jsx(td,{}),"View post on X"]},s):null;case"link":return l.url?i.jsx("p",{style:$.bP,children:i.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",style:$.link,children:l.url})},s):null;case"markdown":{const o=l.markdown??((a=l.data)==null?void 0:a.markdown)??"";return i.jsx("pre",{style:$.bMdPre,children:i.jsx("code",{style:$.bMdCode,children:o})},s)}case"emoji":return l.url?i.jsx("img",{src:l.url,alt:"",style:{height:"1.2em",verticalAlign:"middle",margin:"0 1px"}},s):null;default:return null}})}function ws(e,t,n,r){const l=e.type||"",s=e.text||"",a=e.inline_style_ranges||[],o=e.data||{},u=hm(s,a,o.urls||[],o.mentions||[]);switch(l){case"header-one":return i.jsx("h1",{style:$.bH1,children:u},t);case"header-two":{const c=s.match(/(?:x\.com|twitter\.com)\/i\/status\/(\d+)/);return c?i.jsxs("a",{href:`https://x.com/i/status/${c[1]}`,target:"_blank",rel:"noopener noreferrer",style:$.bTweet,children:[i.jsx(td,{}),"View post on X"]},t):i.jsx("h2",{style:$.bH2,children:u},t)}case"unstyled":return s.trim()?i.jsx("p",{style:$.bP,children:u},t):i.jsx("span",{style:$.bSpacer},t);case"blockquote":return i.jsx("blockquote",{style:$.bQuote,children:u},t);case"unordered-list-item":case"ordered-list-item":return i.jsx("li",{style:$.bLi,children:u},t);case"atomic":return i.jsx("span",{children:mm(e,n,r)},t);default:return s?i.jsx("p",{style:$.bP,children:u},t):null}}function gm(e,t,n){const r=[];let l=0;for(;ll(null)}),g&&i.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:f=>{!f.metaKey&&!f.ctrlKey&&(f.preventDefault(),l(g))},children:i.jsx("img",{src:g,style:$.aCover,alt:"Article cover"})}),i.jsxs("div",{style:$.aMeta,children:[e.title&&i.jsx("div",{style:$.aTweetTitle,children:e.title}),i.jsxs("div",{style:$.aAuthorRow,children:[h?i.jsx("img",{src:h,style:$.aAvatar,alt:a.name||""}):i.jsx("div",{style:$.aAvatarPh}),i.jsxs("div",{children:[i.jsx("div",{style:$.aAuthorName,children:a.name||a.screen_name||"Unknown"}),c&&i.jsx("div",{style:$.aAuthorSub,children:c})]})]})]}),i.jsx("hr",{style:$.aDivider}),i.jsx("div",{style:$.aBody,children:gm(e.blocks||[],n,{onImgClick:l})})]})}function ym({photos:e,onOpen:t}){const n=e.length;if(n===0)return null;if(n===1)return i.jsx("a",{href:e[0].src,target:"_blank",rel:"noopener noreferrer",style:{display:"block"},onClick:l=>{!l.metaKey&&!l.ctrlKey&&(l.preventDefault(),t(0))},children:i.jsx("img",{src:e[0].src,alt:e[0].alt||"",style:$.mediaImg,loading:"lazy"})});const r=n<=2?"180px":"140px";return i.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gridTemplateRows:n===2?r:`${r} ${r}`,gap:"2px"},children:e.map((l,s)=>i.jsx("a",{href:l.src,target:"_blank",rel:"noopener noreferrer",style:{display:"block",overflow:"hidden",gridRow:n===3&&s===0?"span 2":void 0},onClick:a=>{!a.metaKey&&!a.ctrlKey&&(a.preventDefault(),t(s))},children:i.jsx("img",{src:l.src,alt:l.alt||"",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})},s))})}function sd({items:e,startIndex:t,onClose:n}){const[r,l]=p.useState(t);p.useEffect(()=>{const a=o=>{(o.key==="Escape"||o.key==="ArrowLeft"||o.key==="ArrowRight")&&(o.stopPropagation(),o.preventDefault()),o.key==="Escape"&&n(),o.key==="ArrowRight"&&l(u=>Math.min(u+1,e.length-1)),o.key==="ArrowLeft"&&l(u=>Math.max(u-1,0))};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[n,e.length]);const s=e[r];return i.jsx("div",{style:$.lightboxBackdrop,onClick:n,children:i.jsxs("div",{style:$.lightboxContent,onClick:a=>a.stopPropagation(),children:[i.jsxs("div",{style:$.lightboxToolbar,children:[e.length>1&&i.jsxs("span",{style:$.lightboxCounter,children:[r+1," / ",e.length]}),i.jsx("a",{href:s.src,target:"_blank",rel:"noopener noreferrer",style:$.lightboxLink,title:"Open in new tab",children:"↗"}),i.jsx("button",{style:$.lightboxBtn,onClick:n,"aria-label":"Close",children:"×"})]}),i.jsx("img",{src:s.src,alt:s.alt||"",style:$.lightboxImg}),e.length>1&&i.jsxs("div",{style:$.lightboxNav,children:[i.jsx("button",{style:$.lightboxNavBtn,onClick:()=>l(a=>Math.max(a-1,0)),disabled:r===0,children:"‹"}),i.jsx("button",{style:$.lightboxNavBtn,onClick:()=>l(a=>Math.min(a+1,e.length-1)),disabled:r===e.length-1,children:"›"})]})]})})}function $o({tweet:e,isInThread:t,isLast:n,artifactMap:r}){var D,m;const[l,s]=p.useState(null),a=e.author||{},o=e.created_at_secs?ed(e.created_at_secs):"",u=e.entities||{},c=wr(a.avatar_local_path,a.avatar_url,r),g=t&&!n,h=e.is_quote_status===!0,f=t?$.tweetRowThread:$.tweetRow,w=((m=(D=e.extended_entities)==null?void 0:D.media)!=null&&m.length?e.extended_entities.media:u.media)||[],y=[],x=[];for(const d of w)if(d.type==="photo"){const v=wr(d.local_path,d.media_url_https,r);v&&y.push({kind:"photo",src:v,alt:d.alt_text||""})}else if(d.type==="video"||d.type==="animated_gif"){const v=d.local_path&&r[d.local_path]||(()=>{var S,P;return(P=(((S=d.video_info)==null?void 0:S.variants)||[]).filter(T=>T.content_type==="video/mp4").sort((T,N)=>(N.bitrate||0)-(T.bitrate||0))[0])==null?void 0:P.url})();v&&x.push({kind:d.type==="animated_gif"?"gif":"video",src:v})}return i.jsxs(i.Fragment,{children:[l!==null&&i.jsx(sd,{items:y,startIndex:l,onClose:()=>s(null)}),i.jsxs("div",{style:f,children:[i.jsxs("div",{style:$.leftCol,children:[c?i.jsx("img",{src:c,style:$.avatar,alt:a.name||""}):i.jsx("div",{style:$.avatarPh}),g&&i.jsx("div",{style:$.threadLine})]}),i.jsxs("div",{style:$.rightCol,children:[i.jsxs("div",{style:$.authorRow,children:[i.jsx("span",{style:$.authorName,children:a.name||a.screen_name||"Unknown"}),a.screen_name&&i.jsxs("span",{style:$.authorHandle,children:["@",a.screen_name]}),o&&i.jsxs("span",{style:$.datePart,children:["· ",o]}),h&&i.jsx("span",{style:$.qtBadge,title:"Quote tweet",children:"↻ QT"})]}),i.jsx("div",{style:$.tweetText,children:pm(e.full_text||"",u)}),y.length>0&&i.jsx("div",{style:$.mediaGrid,children:i.jsx(ym,{photos:y,onOpen:d=>s(d)})}),x.map((d,v)=>i.jsx("div",{style:$.mediaGrid,children:i.jsx("video",{src:d.src,style:$.mediaVideo,controls:!0,loop:d.kind==="gif",muted:d.kind==="gif",autoPlay:d.kind==="gif"})},v)),(e.retweet_count>0||e.favorite_count>0)&&i.jsxs("div",{style:$.stats,children:[e.favorite_count>0&&i.jsxs("span",{children:["❤️ ",e.favorite_count.toLocaleString()]}),e.retweet_count>0&&i.jsxs("span",{children:["🔁 ",e.retweet_count.toLocaleString()]})]})]})]})]})}function xm({archiveId:e,entryUid:t,artifacts:n,entityKind:r}){const[l,s]=p.useState(!0),[a,o]=p.useState(null),[u,c]=p.useState([]);if(p.useEffect(()=>{if(s(!0),o(null),c([]),!n||!e||!t){s(!1);return}const f=n.map((y,x)=>({...y,index:x})).filter(y=>y.artifact_role==="raw_tweet_json");if(f.length===0){o("No tweet data found."),s(!1);return}let w=!1;return Jp(e,t,f.map(y=>y.index)).then(y=>{w||c(y)}).catch(y=>{w||o(y.message||"Failed to load tweet.")}).finally(()=>{w||s(!1)}),()=>{w=!0}},[e,t,n]),l)return i.jsx("div",{style:$.loading,children:"Loading…"});if(a)return i.jsxs("div",{style:$.error,children:["Error: ",a]});if(u.length===0)return null;const g=dm(e,t,n);if(r==="tweet_thread")return i.jsx("div",{style:$.threadOuter,children:u.map((f,w)=>i.jsx($o,{tweet:f,isInThread:!0,isLast:w===u.length-1,artifactMap:g},f.id||w))});const h=u[0];return h.is_article&&h.article?i.jsx(vm,{article:h.article,tweetAuthor:h.author,artifactMap:g}):i.jsx("div",{style:$.card,children:i.jsx($o,{tweet:h,isInThread:!1,isLast:!0,artifactMap:g})})}const wm=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv"]),km=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),jm=new Set(["jpg","jpeg","png","gif","webp","avif","svg","bmp"]);function id({archiveId:e,entry:t,detail:n}){if(!t)return i.jsx("div",{className:"preview-panel preview-panel--empty",children:i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Select an entry to preview"})});if(!n)return i.jsx("div",{className:"preview-panel preview-panel--loading",children:i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Loading…"})});const{summary:r,artifacts:l}=n,s=r.entry_uid,a=r.entity_kind;if(a==="tweet"||a==="tweet_thread")return i.jsx("div",{className:"preview-tweet-wrap",children:i.jsx(xm,{archiveId:e,entryUid:s,artifacts:l,entityKind:a})});const o=l.findIndex(h=>h.artifact_role==="primary_media");if(o===-1)return i.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),l.length>0&&i.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:l.map((h,f)=>i.jsxs("li",{children:[h.artifact_role,": ",h.relpath]},f))})]});const u=l[o],c=`/api/archives/${e}/entries/${s}/artifacts/${o}`,g=u.relpath.split(".").pop().toLowerCase();return wm.has(g)?i.jsx("div",{className:"preview-panel",children:i.jsx(um,{src:c})}):km.has(g)?i.jsxs("div",{className:"preview-panel preview-panel--audio",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"12px",padding:"24px",fontFamily:"var(--sans)"},children:[i.jsx("span",{style:{fontSize:"2rem"},children:"🎵"}),i.jsx("span",{style:{color:"var(--ink)",fontSize:"0.95rem",fontWeight:600},children:r.title||s}),i.jsx("audio",{src:c,controls:!0,style:{marginTop:"8px",width:"100%",maxWidth:"400px"}})]}):g==="pdf"?i.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:i.jsx(Ro,{src:c,type:"pdf",title:r.title,originalUrl:r.original_url})}):g==="html"||g==="htm"?i.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:i.jsx(Ro,{src:c,type:"page",title:r.title,originalUrl:r.original_url})}):jm.has(g)?i.jsx("div",{className:"preview-panel",style:{height:"100%"},children:i.jsx(cm,{src:c,alt:r.title||"Image"})}):i.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[i.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),i.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:l.map((h,f)=>i.jsxs("li",{children:[h.artifact_role,": ",h.relpath]},f))})]})}function Sm({archiveId:e,entry:t,detail:n,onClose:r}){var l,s;return p.useEffect(()=>{const a=o=>{o.key==="Escape"&&r()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),i.jsx("div",{className:"preview-modal-backdrop",onClick:r,children:i.jsxs("div",{className:`preview-modal${((l=n==null?void 0:n.summary)==null?void 0:l.entity_kind)==="tweet"||((s=n==null?void 0:n.summary)==null?void 0:s.entity_kind)==="tweet_thread"?"":" preview-modal--full"}`,onClick:a=>a.stopPropagation(),children:[i.jsxs("div",{className:"preview-modal-header",children:[i.jsx("span",{className:"preview-modal-title",children:(t==null?void 0:t.title)||(t==null?void 0:t.entry_uid)||"Preview"}),i.jsx("a",{className:"preview-modal-newtab",href:`/preview/${e}/${t==null?void 0:t.entry_uid}`,target:"_blank",rel:"noopener noreferrer",title:"Open in new tab",children:"↗"}),i.jsx("button",{className:"preview-modal-close",onClick:r,"aria-label":"Close preview",children:"×"})]}),i.jsx("div",{className:"preview-modal-body",children:i.jsx(id,{archiveId:e,entry:t,detail:n})})]})})}function bo(e){if(!isFinite(e)||isNaN(e))return"--:--";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,"0")}`}function Nm({entry:e,src:t,archiveId:n,onClose:r}){const l=p.useRef(null),[s,a]=p.useState(!1),[o,u]=p.useState(0),[c,g]=p.useState(NaN),[h,f]=p.useState(1);p.useEffect(()=>{!l.current||!t||(l.current.load(),u(0),g(NaN),a(!1))},[t]),p.useEffect(()=>{l.current&&(l.current.volume=h)},[h]);function w(){const d=l.current;d&&(s?d.pause():d.play().catch(()=>{}))}function y(d){const v=l.current;if(!v||!isFinite(c))return;const k=Number(d.target.value);v.currentTime=k,u(k)}function x(d){f(Number(d.target.value))}const D=(e==null?void 0:e.title)||(e==null?void 0:e.entry_uid)||"Unknown",m=(e==null?void 0:e.source_kind)||"other";return i.jsxs(i.Fragment,{children:[i.jsx("audio",{ref:l,src:t||void 0,preload:"auto",onPlay:()=>a(!0),onPause:()=>a(!1),onEnded:()=>a(!1),onTimeUpdate:()=>{var d;return u(((d=l.current)==null?void 0:d.currentTime)??0)},onLoadedMetadata:()=>{var d;return g(((d=l.current)==null?void 0:d.duration)??NaN)},onDurationChange:()=>{var d;return g(((d=l.current)==null?void 0:d.duration)??NaN)},style:{display:"none"}}),i.jsxs("div",{className:"audio-bar",style:{position:"fixed",bottom:0,left:0,right:0,zIndex:100,background:"var(--paper-3)",borderTop:"1px solid var(--line)",display:"flex",alignItems:"center",gap:"16px",padding:"0 16px",height:"56px",fontFamily:"var(--sans)"},children:[i.jsxs("div",{className:"audio-bar-info",style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0,flex:"0 1 220px",overflow:"hidden"},children:[i.jsx("span",{className:"source-icon",style:{flexShrink:0,width:"18px",height:"18px",display:"flex",alignItems:"center"},dangerouslySetInnerHTML:{__html:pa(m)}}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.85rem",color:"var(--ink)"},title:D,children:D})]}),i.jsxs("div",{className:"audio-bar-controls",style:{display:"flex",alignItems:"center",gap:"10px",flex:"1 1 0",minWidth:0},children:[i.jsx("button",{onClick:w,"aria-label":s?"Pause":"Play",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--ink)",flexShrink:0,fontSize:"1.2rem",lineHeight:1},children:s?"⏸":"▶"}),i.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:bo(o)}),i.jsx("input",{type:"range",min:0,max:isFinite(c)?c:0,step:.1,value:isFinite(o)?o:0,onChange:y,"aria-label":"Seek",style:{flex:1,minWidth:0,accentColor:"var(--accent)"}}),i.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:bo(c)})]}),i.jsxs("div",{className:"audio-bar-right",style:{display:"flex",alignItems:"center",gap:"8px",flex:"0 1 160px"},children:[i.jsx("span",{style:{fontSize:"0.85rem",color:"var(--muted)",flexShrink:0},children:"🔊"}),i.jsx("input",{type:"range",min:0,max:1,step:.01,value:h,onChange:x,"aria-label":"Volume",style:{width:"80px",accentColor:"var(--accent)"}}),i.jsx("button",{onClick:r,"aria-label":"Close audio player",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--muted)",fontSize:"1rem",lineHeight:1,marginLeft:"4px"},children:"✕"})]})]})]})}function _m({archiveId:e,entryUid:t}){var g,h;const[n,r]=p.useState(null),[l,s]=p.useState(!0),[a,o]=p.useState(null);p.useEffect(()=>{hi(e,t).then(f=>{r(f),s(!1)}).catch(f=>{o((f==null?void 0:f.message)||"Failed to load entry"),s(!1)})},[e,t]);const u=((g=n==null?void 0:n.summary)==null?void 0:g.title)||t,c=(h=n==null?void 0:n.summary)==null?void 0:h.original_url;return i.jsxs("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column",background:"var(--paper)",fontFamily:"var(--sans)"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 16px",borderBottom:"1px solid var(--line)",flexShrink:0,background:"var(--paper-2)"},children:[i.jsx("a",{href:"/",style:{color:"var(--accent)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"← Archive"}),i.jsx("span",{style:{flex:1,fontSize:"14px",fontWeight:600,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),c&&i.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--muted)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"Original ↗"})]}),i.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",display:"flex",flexDirection:"column"},children:[l&&i.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--muted)",fontSize:"14px"},children:"Loading…"}),a&&i.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--alert)",fontSize:"14px"},children:a}),n&&i.jsx(id,{archiveId:e,entry:n.summary,detail:n})]})]})}const Cm=7e3;function Em({toasts:e,onDismiss:t,onIgnoreUblock:n}){return e.length?i.jsx("div",{className:"toast-stack",role:"log","aria-live":"polite","aria-label":"Notifications",children:e.map(r=>i.jsx(Pm,{toast:r,onDismiss:t,onIgnoreUblock:n},r.id))}):null}function Tm(e){if(!e)return null;if(e.length<=52)return e;try{const{hostname:t,pathname:n,search:r}=new URL(e),l=n.split("/").filter(Boolean),s=(l[l.length-1]??"")+r,a=s?`${t}/…/${s}`:t;return a.length<=56?a:a.slice(0,53)+"…"}catch{return"…"+e.slice(-51)}}function Pm({toast:e,onDismiss:t,onIgnoreUblock:n}){const[r,l]=p.useState(!1),s=e.type==="warning",a=e.type==="success";p.useEffect(()=>{if(r)return;const u=setTimeout(()=>t(e.id),Cm);return()=>clearTimeout(u)},[r,e.id,t]);const o=Tm(e.locator);return a?i.jsx("div",{className:"toast toast--success",role:"alert","aria-atomic":"true",children:i.jsxs("div",{className:"toast-top",children:[i.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"✓"}),i.jsxs("div",{className:"toast-body",children:[i.jsx("span",{className:"toast-headline",children:e.headline||"Archived"}),o&&i.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),i.jsx("div",{className:"toast-btns",children:i.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})})]})}):s?i.jsxs("div",{className:"toast toast--warning",role:"alert","aria-atomic":"true",children:[i.jsxs("div",{className:"toast-top",children:[i.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"⚠"}),i.jsxs("div",{className:"toast-body",children:[i.jsx("span",{className:"toast-headline",children:e.headline||"Archived with warnings"}),o&&i.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),i.jsxs("div",{className:"toast-btns",children:[e.text&&i.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),"aria-expanded":r,children:r?"Hide":"Details"}),e.locator&&i.jsx("button",{type:"button",className:"toast-view-btn toast-ignore-btn",onClick:()=>{n==null||n(),t(e.id)},children:"Ignore"}),i.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})]})]}),r&&i.jsx("p",{className:"toast-warning-detail",children:e.text||"The page was captured but one or more browser extensions were unavailable (ad-blocking or cookie-consent). Check ARCHIVR_UBLOCK_EXT and ARCHIVR_COOKIE_EXT in your server config."})]}):i.jsxs("div",{className:"toast toast--error",role:"alert","aria-atomic":"true",children:[i.jsxs("div",{className:"toast-top",children:[i.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"✕"}),i.jsxs("div",{className:"toast-body",children:[i.jsx("span",{className:"toast-headline",children:e.headline||"Capture failed"}),o&&i.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),i.jsxs("div",{className:"toast-btns",children:[e.text&&i.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),children:r?"Hide":"View error"}),i.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})]})]}),r&&e.text&&i.jsx("pre",{className:"toast-error-detail",children:e.text})]})}const Wl=p.createContext(null),Wr=(()=>{const e=window.location.pathname.match(/^\/preview\/([^/]+)\/([^/]+)/);return e?{archiveId:e[1],entryUid:e[2]}:null})(),Lm=["archive","tags","collections","runs","admin","settings"],Rm=["profile","tokens","instance","storage"];function ks(){const e=window.location.pathname.split("/").filter(Boolean),t=Lm.includes(e[0])?e[0]:"archive",n=t==="settings"&&Rm.includes(e[1])?e[1]:"profile";return{view:t,settingsTab:n}}function zm(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function Dm(){const[e,t]=p.useState("loading"),[n,r]=p.useState(null);p.useEffect(()=>{(async()=>{if(await lh()){t("setup");return}const W=await oh();if(!W){t("login");return}r(W),t("authenticated")})()},[]),p.useEffect(()=>{const I=()=>{r(null),t("login")};return window.addEventListener("auth:expired",I),()=>window.removeEventListener("auth:expired",I)},[]),p.useEffect(()=>{const I=()=>{const{view:W,settingsTab:le}=ks();m(W),v(le)};return window.addEventListener("popstate",I),()=>window.removeEventListener("popstate",I)},[]);const[l,s]=p.useState([]),[a,o]=p.useState(null),[u,c]=p.useState([]),[g,h]=p.useState(null),[f,w]=p.useState(null),[y,x]=p.useState(null),[D,m]=p.useState(()=>ks().view),[d,v]=p.useState(()=>ks().settingsTab),[k,S]=p.useState(""),[P,T]=p.useState(""),[N,M]=p.useState(!1),[O,V]=p.useState([]),[ce,re]=p.useState([]),[Z,je]=p.useState(()=>sessionStorage.getItem("captureDialogOpen")==="true"),[Ee,ye]=p.useState([]),R=p.useRef(0),[_,B]=p.useState(()=>sessionStorage.getItem("ublockWarningIgnored")==="true"),[j,C]=p.useState(null),A=p.useRef(0),F=(n==null?void 0:n.humanize_slugs)??!1;p.useEffect(()=>{const I=++A.current;C(null),!(!f||!a)&&hi(a,f.entry_uid).then(W=>{I===A.current&&C(W)}).catch(()=>{})},[f,a]),p.useEffect(()=>{sessionStorage.setItem("captureDialogOpen",Z)},[Z]);const U=p.useCallback(async(I,W,le)=>{if(I){M(!0);try{let Qe;W||le?Qe=await Xp(I,W,le):Qe=await Kp(I),c(Qe),T(Qe.length===0?"No results":`${Qe.length} result${Qe.length===1?"":"s"}`)}catch{c([]),T("Search failed. Try again.")}finally{M(!1)}}},[]);p.useEffect(()=>{e==="authenticated"&&Qp().then(I=>{if(s(I),I.length>0){const W=I[0].id;o(W)}})},[e]),p.useEffect(()=>{a&&(x(null),w(null),h(null),Promise.all([U(a,"",null),Co(a).then(V),ys(a).then(re)]))},[a]),p.useEffect(()=>{if(a===null)return;const I=setTimeout(()=>{U(a,k,y)},300);return()=>clearTimeout(I)},[k,a]),p.useEffect(()=>{a!==null&&(y!==null&&m("archive"),U(a,k,y))},[y,a]);const Y=p.useCallback(I=>{o(I)},[]),Q=p.useCallback(I=>{m(I),I==="tags"&&a&&ys(a).then(re)},[a]);p.useEffect(()=>{if(Wr)return;const I=zm(D,d);window.location.pathname!==I&&history.pushState(null,"",I)},[D,d]);const J=p.useCallback(I=>{h(I?I.entry_uid:null),w(I)},[]),L=p.useCallback(I=>{x(I)},[]),X=p.useCallback(()=>{x(null)},[]),We=p.useCallback(()=>{a&&ys(a).then(re)},[a]),Ve=p.useCallback((I,W)=>{y===I?x(W):y!=null&&y.startsWith(I+"/")&&x(W+y.slice(I.length))},[y]),z=p.useCallback(I=>{(y===I||y!=null&&y.startsWith(I+"/"))&&x(null)},[y]),H=p.useCallback((I,W)=>{c(le=>le.map(Qe=>Qe.entry_uid===I?{...Qe,title:W}:Qe)),w(le=>le&&le.entry_uid===I?{...le,title:W}:le),C(le=>le&&le.summary.entry_uid===I?{...le,summary:{...le.summary,title:W}}:le)},[]),Ie=p.useCallback(()=>{if(!a||!f)return;const I=++A.current;hi(a,f.entry_uid).then(W=>{I===A.current&&C(W)}).catch(()=>{})},[a,f]),dt=p.useCallback(I=>{c(W=>W.filter(le=>le.entry_uid!==I)),w(W=>(W==null?void 0:W.entry_uid)===I?null:W),h(W=>W===I?null:W)},[]),ad=p.useCallback(()=>{je(!0)},[]),od=p.useCallback(()=>{je(!1)},[]),ud=p.useCallback(()=>{a&&Promise.all([U(a,k,y),Co(a).then(V)])},[a,k,y,U]),cd=p.useCallback((I,W,le="error",Qe=null)=>{if(le==="warning"&&_&&W)return;const vd=++R.current;ye(yd=>[...yd,{id:vd,text:I,locator:W,type:le,headline:Qe}])},[_]),dd=p.useCallback(I=>{ye(W=>W.filter(le=>le.id!==I))},[]),fd=p.useCallback(()=>{sessionStorage.setItem("ublockWarningIgnored","true"),B(!0),ye(I=>I.filter(W=>!(W.type==="warning"&&W.locator)))},[]),[ha,Vl]=p.useState(null),[Dn,ma]=p.useState(null),pd=p.useCallback(()=>{f&&Vl(f.entry_uid)},[f]),hd=p.useCallback(()=>Vl(null),[]),md=p.useCallback((I,W)=>{ma({src:I,entry:W})},[]),gd=p.useCallback(()=>ma(null),[]);return p.useEffect(()=>{Vl(null)},[f]),p.useEffect(()=>(document.body.classList.toggle("has-audio-bar",!!Dn),()=>document.body.classList.remove("has-audio-bar")),[Dn]),e==="loading"?i.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?i.jsx(Ih,{onComplete:()=>t("login")}):e==="login"?i.jsx(Oh,{onLogin:I=>{r(I),t("authenticated")}}):Wr?i.jsx(_m,{archiveId:Wr.archiveId,entryUid:Wr.entryUid}):i.jsx(Wl.Provider,{value:{currentUser:n,setCurrentUser:r},children:i.jsxs(i.Fragment,{children:[i.jsx(Ah,{archives:l,archiveId:a,onArchiveChange:Y,view:D,onViewChange:Q,onCaptureClick:ad}),i.jsxs("main",{className:"app-shell",children:[i.jsxs("div",{className:"workspace",children:[D==="archive"&&i.jsxs("div",{className:"toolbar",children:[i.jsxs("div",{className:"search-field",children:[i.jsx("span",{className:"ico","aria-hidden":"true",children:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[i.jsx("circle",{cx:"11",cy:"11",r:"7"}),i.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}),i.jsx("input",{className:"search-input",type:"search","aria-label":"Search archive","aria-busy":N,placeholder:"Search titles, URLs, types, tags…",value:k,onChange:I=>S(I.target.value)}),i.jsx("span",{className:"kbd",children:"⌘K"})]}),i.jsxs("span",{className:"result-count",children:[P&&i.jsxs(i.Fragment,{children:[i.jsx("b",{children:P.split(" ")[0]})," ",P.split(" ").slice(1).join(" ")]}),y&&i.jsxs("button",{className:"tag-filter-badge",onClick:X,children:["× ",F?qc(y):y]})]})]}),D==="archive"&&i.jsx(Wh,{entries:u,selectedEntryUid:g,onSelectEntry:J,archiveId:a,tagFilter:y,onClearTagFilter:X,searchQuery:k,onSearchChange:S,resultCount:P,searchBusy:N}),D==="runs"&&i.jsx(Kh,{runs:O}),D==="admin"&&i.jsx(Jh,{archives:l}),D==="tags"&&i.jsx(Gh,{archiveId:a,tagNodes:ce,tagFilter:y,onTagFilterSet:L,onViewChange:Q,onTagRenamed:Ve,onTagDeleted:z,onTagsRefresh:We,humanizeTags:F}),D==="collections"&&i.jsx(qh,{archiveId:a}),D==="settings"&&i.jsx(em,{tab:d,onTabChange:v,archiveId:a})]}),i.jsx(om,{archiveId:a,selectedEntry:f,detail:j,onTagFilterSet:L,tagNodes:ce,onTagsRefresh:We,onEntryTitleChange:H,onEntryDeleted:dt,humanizeTags:F,onDetailRefresh:Ie,onOpenPreview:pd,onPlay:md})]}),ha&&f&&f.entry_uid===ha&&i.jsx(Sm,{archiveId:a,entry:f,detail:j,onClose:hd}),Dn&&i.jsx(Nm,{entry:Dn.entry,src:Dn.src,archiveId:a,onClose:gd}),i.jsx(Fh,{open:Z,archiveId:a,onClose:od,onCaptured:ud,onToast:cd}),i.jsx(Em,{toasts:Ee,onDismiss:dd,onIgnoreUblock:fd})]})})}Xc(document.getElementById("root")).render(i.jsx(p.StrictMode,{children:i.jsx(Dm,{})})); diff --git a/crates/archivr-server/static/index.html b/crates/archivr-server/static/index.html index 9c1ede8..bc25f0e 100644 --- a/crates/archivr-server/static/index.html +++ b/crates/archivr-server/static/index.html @@ -4,7 +4,7 @@ Archivr - + diff --git a/frontend/src/api.js b/frontend/src/api.js index 242c543..a3dc365 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -35,6 +35,20 @@ export function fetchEntryArtifacts(archiveId, entryUid, indices) { ); } +// Resolve t.co short URLs server-side (HEAD→GET, no-follow). +// Returns a map { [tcoUrl]: expandedUrl }. +// Silently returns {} on failure — callers fall back to plain t.co links. +export async function resolveTcoUrls(urls) { + if (!urls || urls.length === 0) return {}; + const res = await fetch('/api/util/resolve-tco', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(urls), + }); + if (!res.ok) return {}; + return res.json(); +} + export async function updateEntryTitle(archiveId, entryUid, title) { const res = await fetch(`/api/archives/${archiveId}/entries/${entryUid}`, { method: 'PATCH', diff --git a/frontend/src/components/TweetPreview.jsx b/frontend/src/components/TweetPreview.jsx index 305427a..bb08f6b 100644 --- a/frontend/src/components/TweetPreview.jsx +++ b/frontend/src/components/TweetPreview.jsx @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react'; -import { fetchEntryArtifacts } from '../api'; +import { fetchEntryArtifacts, resolveTcoUrls } from '../api'; // ── Date helper ──────────────────────────────────────────────────────────────── @@ -1148,7 +1148,57 @@ export default function TweetPreview({ archiveId, entryUid, artifacts, entityKin let cancelled = false; fetchEntryArtifacts(archiveId, entryUid, tweetArtifacts.map(a => a.index)) - .then(data => { if (!cancelled) setTweets(data); }) + .then(async data => { + if (cancelled) return; + + const tcoRe = /https?:\/\/t\.co\/[A-Za-z0-9]+/g; + + // For each tweet, build the set of [start,end) spans already covered by + // existing URL entities. A regex match is only "entity-less" if its span + // is not covered — avoids skipping real duplicate occurrences. + const coveredRanges = tweet => { + const ft = tweet.full_text || ''; + return (tweet.entities?.urls || []).map(u => { + if (u.fromIndex != null && u.toIndex != null) return [u.fromIndex, u.toIndex]; + if (u.indices?.length === 2) return [u.indices[0], u.indices[1]]; + if (u.url) { const i = ft.indexOf(u.url); if (i !== -1) return [i, i + u.url.length]; } + return null; + }).filter(Boolean); + }; + const isCovered = (ranges, s, e) => ranges.some(([cs, ce]) => cs <= s && ce >= e); + + const uniqueTco = new Set(); + for (const t of data) { + const ft = t.full_text || ''; + const ranges = coveredRanges(t); + let m; tcoRe.lastIndex = 0; + while ((m = tcoRe.exec(ft)) !== null) { + if (!isCovered(ranges, m.index, m.index + m[0].length)) uniqueTco.add(m[0]); + } + } + + const resolved = uniqueTco.size > 0 ? await resolveTcoUrls([...uniqueTco]).catch(() => ({})) : {}; + + const augmented = data.map(t => { + const ft = t.full_text || ''; + const ranges = coveredRanges(t); + const synth = []; + let m; tcoRe.lastIndex = 0; + while ((m = tcoRe.exec(ft)) !== null) { + const tco = m[0]; const exp = resolved[tco]; + if (exp && exp !== tco && !isCovered(ranges, m.index, m.index + tco.length)) { + synth.push({ + url: tco, expanded_url: exp, + display_url: (() => { try { const u = new URL(exp); return u.hostname + (u.pathname.length > 1 ? '/…' : ''); } catch (_) { return exp; } })(), + fromIndex: m.index, toIndex: m.index + tco.length, + }); + } + } + if (synth.length === 0) return t; + return { ...t, entities: { ...(t.entities || {}), urls: [...(t.entities?.urls || []), ...synth] } }; + }); + if (!cancelled) setTweets(augmented); + }) .catch(e => { if (!cancelled) setError(e.message || 'Failed to load tweet.'); }) .finally(() => { if (!cancelled) setLoading(false); }); diff --git a/vendor/twitter/__pycache__/scrape_user_tweet_contents.cpython-313.pyc b/vendor/twitter/__pycache__/scrape_user_tweet_contents.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..29e74b2cc71c0d853b1c442a7b09b207250b38ab GIT binary patch literal 55503 zcmey&%ge>Uz`$^5T5uNoeFlcdAPx*`Lm8isF)=VqWe8>{VhCmoX7Xk%Vg%DnMND9t zxriA|vlOv_Y1SfEFwIuP4yHN4G_yCS7iSTt0>}&&Z!RzHB5p97)tkqQw}{t^uZYi! zzlh&Uph&<=ut?BLs7MGb&*m-cB~m1!z!1zX#ZV*~%pt{4Bo=HP%qhi?#aJXB%oQUL zBf-kRz!1z0XYs@cLc~nif_bGFvRH~FgZW}4f_Y;2q2esT{9tjZV1XFkU_r2)Knx$q z922%+A+VfuFk`SVrt1_Kf< zvccjpvcWttd?p;h5+KdTP7O8?=f*gKYAekaHIfh_cxCz?eaNvW63&=en zcY|!#iIET1jgg0kf?kYluzrkeutAJ$uwjgBuu+U`uyKrRut|(;uxX5ZFvuNdpzsK0 zGSLb)2icXySfm~dGLr|{7890W3y^G)MzEz6Ly=~TR zq%);6Y1&sk=5nnlDN0N(Q79=-O)XJK&d)1J%_}KZNGr#hBts#;pd>RtFEK|UH#H?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