diff --git a/crates/archivr-server/static/assets/index-B7dq_VAM.js b/crates/archivr-server/static/assets/index-B7dq_VAM.js deleted file mode 100644 index 5f370da..0000000 --- a/crates/archivr-server/static/assets/index-B7dq_VAM.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 i of l)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(l){if(l.ep)return;l.ep=!0;const i=n(l);fetch(l.href,i)}})();var iu={exports:{}},Vl={},au={exports:{}},q={};/** - * @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 br=Symbol.for("react.element"),$d=Symbol.for("react.portal"),Id=Symbol.for("react.fragment"),Od=Symbol.for("react.strict_mode"),Ad=Symbol.for("react.profiler"),Md=Symbol.for("react.provider"),Fd=Symbol.for("react.context"),Bd=Symbol.for("react.forward_ref"),Ud=Symbol.for("react.suspense"),Hd=Symbol.for("react.memo"),Wd=Symbol.for("react.lazy"),Ma=Symbol.iterator;function Vd(e){return e===null||typeof e!="object"?null:(e=Ma&&e[Ma]||e["@@iterator"],typeof e=="function"?e:null)}var ou={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},uu=Object.assign,cu={};function Bn(e,t,n){this.props=e,this.context=t,this.refs=cu,this.updater=n||ou}Bn.prototype.isReactComponent={};Bn.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")};Bn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function du(){}du.prototype=Bn.prototype;function Ui(e,t,n){this.props=e,this.context=t,this.refs=cu,this.updater=n||ou}var Hi=Ui.prototype=new du;Hi.constructor=Ui;uu(Hi,Bn.prototype);Hi.isPureReactComponent=!0;var Fa=Array.isArray,fu=Object.prototype.hasOwnProperty,Wi={current:null},pu={key:!0,ref:!0,__self:!0,__source:!0};function hu(e,t,n){var r,l={},i=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(i=""+t.key),t)fu.call(t,r)&&!pu.hasOwnProperty(r)&&(l[r]=t[r]);var o=arguments.length-2;if(o===1)l.children=n;else if(1>>1,B=z[X];if(0>>1;Xl(H,F))Ul(W,H)?(z[X]=W,z[U]=F,X=U):(z[X]=H,z[I]=F,X=I);else if(Ul(W,F))z[X]=W,z[U]=F,X=U;else break e}}return E}function l(z,E){var F=z.sortIndex-E.sortIndex;return F!==0?F:z.id-E.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.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,k=!1,w=!1,y=!1,_=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(z){for(var E=n(c);E!==null;){if(E.callback===null)r(c);else if(E.startTime<=z)r(c),E.sortIndex=E.expirationTime,t(u,E);else break;E=n(c)}}function x(z){if(y=!1,v(z),!w)if(n(u)!==null)w=!0,ye(j);else{var E=n(c);E!==null&&se(x,E.startTime-z)}}function j(z,E){w=!1,y&&(y=!1,h(S),S=-1),k=!0;var F=f;try{for(v(E),m=n(u);m!==null&&(!(m.expirationTime>E)||z&&!G());){var X=m.callback;if(typeof X=="function"){m.callback=null,f=m.priorityLevel;var B=X(m.expirationTime<=E);E=e.unstable_now(),typeof B=="function"?m.callback=B:m===n(u)&&r(u),v(E)}else r(u);m=n(u)}if(m!==null)var N=!0;else{var I=n(c);I!==null&&se(x,I.startTime-E),N=!1}return N}finally{m=null,f=F,k=!1}}var C=!1,T=null,S=-1,D=5,$=-1;function G(){return!(e.unstable_now()-$z||125X?(z.sortIndex=F,t(c,z),n(u)===null&&z===n(c)&&(y?(h(S),S=-1):y=!0,se(x,F-X))):(z.sortIndex=B,t(u,z),w||k||(w=!0,ye(j))),z},e.unstable_shouldYield=G,e.unstable_wrapCallback=function(z){var E=f;return function(){var F=f;f=E;try{return z.apply(this,arguments)}finally{f=F}}}})(xu);yu.exports=xu;var nf=yu.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 rf=p,Xe=nf;function L(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"),Ks=Object.prototype.hasOwnProperty,lf=/^[: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]*$/,Ua={},Ha={};function sf(e){return Ks.call(Ha,e)?!0:Ks.call(Ua,e)?!1:lf.test(e)?Ha[e]=!0:(Ua[e]=!0,!1)}function af(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 of(e,t,n,r){if(t===null||typeof t>"u"||af(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 Me(e,t,n,r,l,i,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=i,this.removeEmptyString=a}var Le={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Le[e]=new Me(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Le[t]=new Me(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Le[e]=new Me(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Le[e]=new Me(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){Le[e]=new Me(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Le[e]=new Me(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Le[e]=new Me(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Le[e]=new Me(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Le[e]=new Me(e,5,!1,e.toLowerCase(),null,!1,!1)});var Qi=/[\-:]([a-z])/g;function Ki(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(Qi,Ki);Le[t]=new Me(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(Qi,Ki);Le[t]=new Me(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(Qi,Ki);Le[t]=new Me(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Le[e]=new Me(e,1,!1,e.toLowerCase(),null,!1,!1)});Le.xlinkHref=new Me("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Le[e]=new Me(e,1,!1,e.toLowerCase(),null,!0,!0)});function Xi(e,t,n,r){var l=Le.hasOwnProperty(t)?Le[t]:null;(l!==null?l.type!==0:r||!(2o||l[a]!==i[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{ws=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?nr(e):""}function uf(e){switch(e.tag){case 5:return nr(e.type);case 16:return nr("Lazy");case 13:return nr("Suspense");case 19:return nr("SuspenseList");case 0:case 2:case 15:return e=ks(e.type,!1),e;case 11:return e=ks(e.type.render,!1),e;case 1:return e=ks(e.type,!0),e;default:return""}}function Gs(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 gn:return"Fragment";case mn:return"Portal";case Xs:return"Profiler";case Ji:return"StrictMode";case Js:return"Suspense";case qs:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ju:return(e.displayName||"Context")+".Consumer";case ku:return(e._context.displayName||"Context")+".Provider";case qi:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Gi:return t=e.displayName||null,t!==null?t:Gs(e.type)||"Memo";case Tt:t=e._payload,e=e._init;try{return Gs(e(t))}catch{}}return null}function cf(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 Gs(t);case 8:return t===Ji?"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 Ut(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Nu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function df(e){var t=Nu(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(a){r=""+a,i.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 Wr(e){e._valueTracker||(e._valueTracker=df(e))}function _u(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Nu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function wl(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 Ys(e,t){var n=t.checked;return he({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Va(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Ut(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 Cu(e,t){t=t.checked,t!=null&&Xi(e,"checked",t,!1)}function Zs(e,t){Cu(e,t);var n=Ut(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")?ei(e,t.type,n):t.hasOwnProperty("defaultValue")&&ei(e,t.type,Ut(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Qa(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 ei(e,t,n){(t!=="number"||wl(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var rr=Array.isArray;function En(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Vr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function vr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ar={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},ff=["Webkit","ms","Moz","O"];Object.keys(ar).forEach(function(e){ff.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ar[t]=ar[e]})});function Lu(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ar.hasOwnProperty(e)&&ar[e]?(""+t).trim():t+"px"}function zu(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Lu(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var pf=he({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 ri(e,t){if(t){if(pf[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(L(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(L(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(L(61))}if(t.style!=null&&typeof t.style!="object")throw Error(L(62))}}function li(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 si=null;function Yi(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ii=null,Tn=null,Pn=null;function Ja(e){if(e=Ir(e)){if(typeof ii!="function")throw Error(L(280));var t=e.stateNode;t&&(t=ql(t),ii(e.stateNode,e.type,t))}}function Ru(e){Tn?Pn?Pn.push(e):Pn=[e]:Tn=e}function bu(){if(Tn){var e=Tn,t=Pn;if(Pn=Tn=null,Ja(e),t)for(e=0;e>>=0,e===0?32:31-(Nf(e)/_f|0)|0}var Qr=64,Kr=4194304;function lr(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 Nl(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,i=e.pingedLanes,a=n&268435455;if(a!==0){var o=a&~l;o!==0?r=lr(o):(i&=a,i!==0&&(r=lr(i)))}else a=n&~l,a!==0?r=lr(a):i!==0&&(r=lr(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,i=t&-t,l>=i||l===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Dr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-ot(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=ur),lo=" ",so=!1;function Zu(e,t){switch(e){case"keyup":return rp.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ec(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var vn=!1;function sp(e,t){switch(e){case"compositionend":return ec(t);case"keypress":return t.which!==32?null:(so=!0,lo);case"textInput":return e=t.data,e===lo&&so?null:e;default:return null}}function ip(e,t){if(vn)return e==="compositionend"||!ia&&Zu(e,t)?(e=Gu(),cl=ra=Rt=null,vn=!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=uo(n)}}function lc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?lc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function sc(){for(var e=window,t=wl();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=wl(e.document)}return t}function aa(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 mp(e){var t=sc(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&lc(n.ownerDocument.documentElement,n)){if(r!==null&&aa(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,i=Math.min(r.start,l);r=r.end===void 0?i:Math.min(r.end,l),!e.extend&&i>r&&(l=r,r=i,i=l),l=co(n,i);var a=co(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(),i>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,yn=null,fi=null,dr=null,pi=!1;function fo(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;pi||yn==null||yn!==wl(r)||(r=yn,"selectionStart"in r&&aa(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}),dr&&Sr(dr,r)||(dr=r,r=El(fi,"onSelect"),0kn||(e.current=xi[kn],xi[kn]=null,kn--)}function ie(e,t){kn++,xi[kn]=e.current,e.current=t}var Ht={},De=Vt(Ht),Ue=Vt(!1),nn=Ht;function $n(e,t){var n=e.type.contextTypes;if(!n)return Ht;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in n)l[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function He(e){return e=e.childContextTypes,e!=null}function Pl(){oe(Ue),oe(De)}function xo(e,t,n){if(De.current!==Ht)throw Error(L(168));ie(De,t),ie(Ue,n)}function hc(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(L(108,cf(e)||"Unknown",l));return he({},n,r)}function Ll(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ht,nn=De.current,ie(De,e),ie(Ue,Ue.current),!0}function wo(e,t,n){var r=e.stateNode;if(!r)throw Error(L(169));n?(e=hc(e,t,nn),r.__reactInternalMemoizedMergedChildContext=e,oe(Ue),oe(De),ie(De,e)):oe(Ue),ie(Ue,n)}var yt=null,Gl=!1,$s=!1;function mc(e){yt===null?yt=[e]:yt.push(e)}function Ep(e){Gl=!0,mc(e)}function Qt(){if(!$s&&yt!==null){$s=!0;var e=0,t=re;try{var n=yt;for(re=1;e>=a,l-=a,xt=1<<32-ot(t)+l|n<S?(D=T,T=null):D=T.sibling;var $=f(h,T,v[S],x);if($===null){T===null&&(T=D);break}e&&T&&$.alternate===null&&t(h,T),d=i($,d,S),C===null?j=$:C.sibling=$,C=$,T=D}if(S===v.length)return n(h,T),ue&&Xt(h,S),j;if(T===null){for(;SS?(D=T,T=null):D=T.sibling;var G=f(h,T,$.value,x);if(G===null){T===null&&(T=D);break}e&&T&&G.alternate===null&&t(h,T),d=i(G,d,S),C===null?j=G:C.sibling=G,C=G,T=D}if($.done)return n(h,T),ue&&Xt(h,S),j;if(T===null){for(;!$.done;S++,$=v.next())$=m(h,$.value,x),$!==null&&(d=i($,d,S),C===null?j=$:C.sibling=$,C=$);return ue&&Xt(h,S),j}for(T=r(h,T);!$.done;S++,$=v.next())$=k(T,h,S,$.value,x),$!==null&&(e&&$.alternate!==null&&T.delete($.key===null?S:$.key),d=i($,d,S),C===null?j=$:C.sibling=$,C=$);return e&&T.forEach(function(te){return t(h,te)}),ue&&Xt(h,S),j}function _(h,d,v,x){if(typeof v=="object"&&v!==null&&v.type===gn&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case Hr:e:{for(var j=v.key,C=d;C!==null;){if(C.key===j){if(j=v.type,j===gn){if(C.tag===7){n(h,C.sibling),d=l(C,v.props.children),d.return=h,h=d;break e}}else if(C.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===Tt&&So(j)===C.type){n(h,C.sibling),d=l(C,v.props),d.ref=Gn(h,C,v),d.return=h,h=d;break e}n(h,C);break}else t(h,C);C=C.sibling}v.type===gn?(d=tn(v.props.children,h.mode,x,v.key),d.return=h,h=d):(x=yl(v.type,v.key,v.props,null,h.mode,x),x.ref=Gn(h,d,v),x.return=h,h=x)}return a(h);case mn:e:{for(C=v.key;d!==null;){if(d.key===C)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=Hs(v,h.mode,x),d.return=h,h=d}return a(h);case Tt:return C=v._init,_(h,d,C(v._payload),x)}if(rr(v))return w(h,d,v,x);if(Qn(v))return y(h,d,v,x);el(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=Us(v,h.mode,x),d.return=h,h=d),a(h)):n(h,d)}return _}var On=xc(!0),wc=xc(!1),bl=Vt(null),Dl=null,Nn=null,da=null;function fa(){da=Nn=Dl=null}function pa(e){var t=bl.current;oe(bl),e._currentValue=t}function ji(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 zn(e,t){Dl=e,da=Nn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Be=!0),e.firstContext=null)}function tt(e){var t=e._currentValue;if(da!==e)if(e={context:e,memoizedValue:t,next:null},Nn===null){if(Dl===null)throw Error(L(308));Nn=e,Dl.dependencies={lanes:0,firstContext:e}}else Nn=Nn.next=e;return t}var Gt=null;function ha(e){Gt===null?Gt=[e]:Gt.push(e)}function kc(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,ha(t)):(n.next=l.next,l.next=n),t.interleaved=n,Nt(e,r)}function Nt(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 Pt=!1;function ma(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function jc(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 kt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function At(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Z&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Nt(e,n)}return l=r.interleaved,l===null?(t.next=t,ha(r)):(t.next=l.next,l.next=t),r.interleaved=t,Nt(e,n)}function fl(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,ea(e,n)}}function No(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?l=i=a:i=i.next=a,n=n.next}while(n!==null);i===null?l=i=t:i=i.next=t}else l=i=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function $l(e,t,n,r){var l=e.updateQueue;Pt=!1;var i=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?i=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(i!==null){var m=l.baseState;a=0,g=c=u=null,o=i;do{var f=o.lane,k=o.eventTime;if((r&f)===f){g!==null&&(g=g.next={eventTime:k,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var w=e,y=o;switch(f=t,k=n,y.tag){case 1:if(w=y.payload,typeof w=="function"){m=w.call(k,m,f);break e}m=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=y.payload,f=typeof w=="function"?w.call(k,m,f):w,f==null)break e;m=he({},m,f);break e;case 2:Pt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,f=l.effects,f===null?l.effects=[o]:f.push(o))}else k={eventTime:k,lane:f,tag:o.tag,payload:o.payload,callback:o.callback,next:null},g===null?(c=g=k,u=m):g=g.next=k,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 i===null&&(l.shared.lanes=0);sn|=a,e.lanes=a,e.memoizedState=m}}function _o(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Os.transition;Os.transition={};try{e(!1),t()}finally{re=n,Os.transition=r}}function Mc(){return nt().memoizedState}function zp(e,t,n){var r=Ft(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Fc(e))Bc(t,n);else if(n=kc(e,t,n,r),n!==null){var l=Oe();ut(n,e,r,l),Uc(n,t,r)}}function Rp(e,t,n){var r=Ft(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Fc(e))Bc(t,l);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,o=i(a,n);if(l.hasEagerState=!0,l.eagerState=o,ct(o,a)){var u=t.interleaved;u===null?(l.next=l,ha(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=kc(e,t,l,r),n!==null&&(l=Oe(),ut(n,e,r,l),Uc(n,t,r))}}function Fc(e){var t=e.alternate;return e===pe||t!==null&&t===pe}function Bc(e,t){fr=Ol=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Uc(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ea(e,n)}}var Al={readContext:tt,useCallback:ze,useContext:ze,useEffect:ze,useImperativeHandle:ze,useInsertionEffect:ze,useLayoutEffect:ze,useMemo:ze,useReducer:ze,useRef:ze,useState:ze,useDebugValue:ze,useDeferredValue:ze,useTransition:ze,useMutableSource:ze,useSyncExternalStore:ze,useId:ze,unstable_isNewReconciler:!1},bp={readContext:tt,useCallback:function(e,t){return ft().memoizedState=[e,t===void 0?null:t],e},useContext:tt,useEffect:Eo,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,hl(4194308,4,Dc.bind(null,t,e),n)},useLayoutEffect:function(e,t){return hl(4194308,4,e,t)},useInsertionEffect:function(e,t){return hl(4,2,e,t)},useMemo:function(e,t){var n=ft();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=ft();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=zp.bind(null,pe,e),[r.memoizedState,e]},useRef:function(e){var t=ft();return e={current:e},t.memoizedState=e},useState:Co,useDebugValue:Sa,useDeferredValue:function(e){return ft().memoizedState=e},useTransition:function(){var e=Co(!1),t=e[0];return e=Lp.bind(null,e[1]),ft().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=pe,l=ft();if(ue){if(n===void 0)throw Error(L(407));n=n()}else{if(n=t(),Ce===null)throw Error(L(349));ln&30||Cc(r,t,n)}l.memoizedState=n;var i={value:n,getSnapshot:t};return l.queue=i,Eo(Tc.bind(null,r,i,e),[e]),r.flags|=2048,zr(9,Ec.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=ft(),t=Ce.identifierPrefix;if(ue){var n=wt,r=xt;n=(r&~(1<<32-ot(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Pr++,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[pt]=t,e[Cr]=r,Yc(e,t,!1,!1),t.stateNode=e;e:{switch(a=li(n,r),n){case"dialog":ae("cancel",e),ae("close",e),l=r;break;case"iframe":case"object":case"embed":ae("load",e),l=r;break;case"video":case"audio":for(l=0;lFn&&(t.flags|=128,r=!0,Yn(i,!1),t.lanes=4194304)}else{if(!r)if(e=Il(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Yn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!ue)return Re(t),null}else 2*ge()-i.renderingStartTime>Fn&&n!==1073741824&&(t.flags|=128,r=!0,Yn(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(n=i.last,n!==null?n.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=ge(),t.sibling=null,n=fe.current,ie(fe,r?n&1|2:n&1),t):(Re(t),null);case 22:case 23:return Pa(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ve&1073741824&&(Re(t),t.subtreeFlags&6&&(t.flags|=8192)):Re(t),null;case 24:return null;case 25:return null}throw Error(L(156,t.tag))}function Bp(e,t){switch(ua(t),t.tag){case 1:return He(t.type)&&Pl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return An(),oe(Ue),oe(De),ya(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return va(t),null;case 13:if(oe(fe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(L(340));In()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return oe(fe),null;case 4:return An(),null;case 10:return pa(t.type._context),null;case 22:case 23:return Pa(),null;case 24:return null;default:return null}}var nl=!1,be=!1,Up=typeof WeakSet=="function"?WeakSet:Set,A=null;function _n(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){me(e,t,r)}else n.current=null}function zi(e,t,n){try{n()}catch(r){me(e,t,r)}}var Ao=!1;function Hp(e,t){if(hi=_l,e=sc(),aa(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var a=0,o=-1,u=-1,c=0,g=0,m=e,f=null;t:for(;;){for(var k;m!==n||l!==0&&m.nodeType!==3||(o=a+l),m!==i||r!==0&&m.nodeType!==3||(u=a+r),m.nodeType===3&&(a+=m.nodeValue.length),(k=m.firstChild)!==null;)f=m,m=k;for(;;){if(m===e)break t;if(f===n&&++c===l&&(o=a),f===i&&++g===r&&(u=a),(k=m.nextSibling)!==null)break;m=f,f=m.parentNode}m=k}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(mi={focusedElem:e,selectionRange:n},_l=!1,A=t;A!==null;)if(t=A,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,A=e;else for(;A!==null;){t=A;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var y=w.memoizedProps,_=w.memoizedState,h=t.stateNode,d=h.getSnapshotBeforeUpdate(t.elementType===t.type?y:st(t.type,y),_);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(L(163))}}catch(x){me(t,t.return,x)}if(e=t.sibling,e!==null){e.return=t.return,A=e;break}A=t.return}return w=Ao,Ao=!1,w}function pr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&zi(t,n,i)}l=l.next}while(l!==r)}}function es(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 Ri(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 td(e){var t=e.alternate;t!==null&&(e.alternate=null,td(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[pt],delete t[Cr],delete t[yi],delete t[_p],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 nd(e){return e.tag===5||e.tag===3||e.tag===4}function Mo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||nd(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 bi(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=Tl));else if(r!==4&&(e=e.child,e!==null))for(bi(e,t,n),e=e.sibling;e!==null;)bi(e,t,n),e=e.sibling}function Di(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(Di(e,t,n),e=e.sibling;e!==null;)Di(e,t,n),e=e.sibling}var Te=null,it=!1;function Et(e,t,n){for(n=n.child;n!==null;)rd(e,t,n),n=n.sibling}function rd(e,t,n){if(ht&&typeof ht.onCommitFiberUnmount=="function")try{ht.onCommitFiberUnmount(Ql,n)}catch{}switch(n.tag){case 5:be||_n(n,t);case 6:var r=Te,l=it;Te=null,Et(e,t,n),Te=r,it=l,Te!==null&&(it?(e=Te,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Te.removeChild(n.stateNode));break;case 18:Te!==null&&(it?(e=Te,n=n.stateNode,e.nodeType===8?Ds(e.parentNode,n):e.nodeType===1&&Ds(e,n),kr(e)):Ds(Te,n.stateNode));break;case 4:r=Te,l=it,Te=n.stateNode.containerInfo,it=!0,Et(e,t,n),Te=r,it=l;break;case 0:case 11:case 14:case 15:if(!be&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&zi(n,t,a),l=l.next}while(l!==r)}Et(e,t,n);break;case 1:if(!be&&(_n(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){me(n,t,o)}Et(e,t,n);break;case 21:Et(e,t,n);break;case 22:n.mode&1?(be=(r=be)||n.memoizedState!==null,Et(e,t,n),be=r):Et(e,t,n);break;default:Et(e,t,n)}}function Fo(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Up),t.forEach(function(r){var l=Yp.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function lt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=a),r&=~i}if(r=l,r=ge()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Vp(r/1960))-r,10e?16:e,bt===null)var r=!1;else{if(e=bt,bt=null,Bl=0,Z&6)throw Error(L(331));var l=Z;for(Z|=4,A=e.current;A!==null;){var i=A,a=i.child;if(A.flags&16){var o=i.deletions;if(o!==null){for(var u=0;uge()-Ea?en(e,0):Ca|=n),We(e,t)}function dd(e,t){t===0&&(e.mode&1?(t=Kr,Kr<<=1,!(Kr&130023424)&&(Kr=4194304)):t=1);var n=Oe();e=Nt(e,t),e!==null&&(Dr(e,t,n),We(e,n))}function Gp(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),dd(e,n)}function Yp(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(L(314))}r!==null&&r.delete(t),dd(e,n)}var fd;fd=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ue.current)Be=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Be=!1,Mp(e,t,n);Be=!!(e.flags&131072)}else Be=!1,ue&&t.flags&1048576&&gc(t,Rl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;ml(e,t),e=t.pendingProps;var l=$n(t,De.current);zn(t,n),l=wa(null,t,r,e,l,n);var i=ka();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,He(r)?(i=!0,Ll(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,ma(t),l.updater=Zl,t.stateNode=l,l._reactInternals=t,Ni(t,r,e,n),t=Ei(null,t,r,!0,i,n)):(t.tag=0,ue&&i&&oa(t),Ie(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(ml(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=eh(r),e=st(r,e),l){case 0:t=Ci(null,t,r,e,n);break e;case 1:t=$o(null,t,r,e,n);break e;case 11:t=bo(null,t,r,e,n);break e;case 14:t=Do(null,t,r,st(r.type,e),n);break e}throw Error(L(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:st(r,l),Ci(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:st(r,l),$o(e,t,r,l,n);case 3:e:{if(Jc(t),e===null)throw Error(L(387));r=t.pendingProps,i=t.memoizedState,l=i.element,jc(e,t),$l(t,r,null,n);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=Mn(Error(L(423)),t),t=Io(e,t,r,n,l);break e}else if(r!==l){l=Mn(Error(L(424)),t),t=Io(e,t,r,n,l);break e}else for(Qe=Ot(t.stateNode.containerInfo.firstChild),Ke=t,ue=!0,at=null,n=wc(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(In(),r===l){t=_t(e,t,n);break e}Ie(e,t,r,n)}t=t.child}return t;case 5:return Sc(t),e===null&&ki(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,a=l.children,gi(r,l)?a=null:i!==null&&gi(r,i)&&(t.flags|=32),Xc(e,t),Ie(e,t,a,n),t.child;case 6:return e===null&&ki(t),null;case 13:return qc(e,t,n);case 4:return ga(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=On(t,null,r,n):Ie(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:st(r,l),bo(e,t,r,l,n);case 7:return Ie(e,t,t.pendingProps,n),t.child;case 8:return Ie(e,t,t.pendingProps.children,n),t.child;case 12:return Ie(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,a=l.value,ie(bl,r._currentValue),r._currentValue=a,i!==null)if(ct(i.value,a)){if(i.children===l.children&&!Ue.current){t=_t(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){a=i.child;for(var u=o.firstContext;u!==null;){if(u.context===r){if(i.tag===1){u=kt(-1,n&-n),u.tag=2;var c=i.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}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),ji(i.return,n,t),o.lanes|=n;break}u=u.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(L(341));a.lanes|=n,o=a.alternate,o!==null&&(o.lanes|=n),ji(a,n,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}Ie(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,zn(t,n),l=tt(l),r=r(l),t.flags|=1,Ie(e,t,r,n),t.child;case 14:return r=t.type,l=st(r,t.pendingProps),l=st(r.type,l),Do(e,t,r,l,n);case 15:return Qc(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:st(r,l),ml(e,t),t.tag=1,He(r)?(e=!0,Ll(t)):e=!1,zn(t,n),Hc(t,r,l),Ni(t,r,l,n),Ei(null,t,r,!0,e,n);case 19:return Gc(e,t,n);case 22:return Kc(e,t,n)}throw Error(L(156,t.tag))};function pd(e,t){return Fu(e,t)}function Zp(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 Ze(e,t,n,r){return new Zp(e,t,n,r)}function za(e){return e=e.prototype,!(!e||!e.isReactComponent)}function eh(e){if(typeof e=="function")return za(e)?1:0;if(e!=null){if(e=e.$$typeof,e===qi)return 11;if(e===Gi)return 14}return 2}function Bt(e,t){var n=e.alternate;return n===null?(n=Ze(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 yl(e,t,n,r,l,i){var a=2;if(r=e,typeof e=="function")za(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case gn:return tn(n.children,l,i,t);case Ji:a=8,l|=8;break;case Xs:return e=Ze(12,n,t,l|2),e.elementType=Xs,e.lanes=i,e;case Js:return e=Ze(13,n,t,l),e.elementType=Js,e.lanes=i,e;case qs:return e=Ze(19,n,t,l),e.elementType=qs,e.lanes=i,e;case Su:return ns(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ku:a=10;break e;case ju:a=9;break e;case qi:a=11;break e;case Gi:a=14;break e;case Tt:a=16,r=null;break e}throw Error(L(130,e==null?e:typeof e,""))}return t=Ze(a,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function tn(e,t,n,r){return e=Ze(7,e,r,t),e.lanes=n,e}function ns(e,t,n,r){return e=Ze(22,e,r,t),e.elementType=Su,e.lanes=n,e.stateNode={isHidden:!1},e}function Us(e,t,n){return e=Ze(6,e,null,t),e.lanes=n,e}function Hs(e,t,n){return t=Ze(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function th(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=Ss(0),this.expirationTimes=Ss(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ss(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Ra(e,t,n,r,l,i,a,o,u){return e=new th(e,t,n,o,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Ze(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ma(i),e}function nh(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(vd)}catch(e){console.error(e)}}vd(),vu.exports=Je;var ah=vu.exports,yd,Xo=ah;yd=Xo.createRoot,Xo.hydrateRoot;async function Ne(e){const t=await fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.json()}async function oh(){return Ne("/api/archives")}async function uh(e){return Ne(`/api/archives/${e}/entries`)}async function ch(e,t,n){const r=new URLSearchParams;return t&&r.set("q",t),n&&r.set("tag",n),Ne(`/api/archives/${e}/entries/search?${r}`)}async function Mi(e,t){return Ne(`/api/archives/${e}/entries/${t}`)}function dh(e,t,n){return Promise.all(n.map(r=>Ne(`/api/archives/${e}/entries/${t}/artifacts/${r}`)))}async function fh(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 ph(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 sl(e,t){return Ne(`/api/archives/${e}/entries/${t}/tags`)}async function Jo(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 hh(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 qo(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 mh(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 gh(e,t){const n=await fetch(`/api/archives/${e}/tags/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(await n.text())}async function Ws(e){return Ne(`/api/archives/${e}/runs`)}async function il(e){return Ne(`/api/archives/${e}/tags`)}async function vh(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),typeof r.modal_closer_enabled=="boolean"&&(l.modal_closer_enabled=r.modal_closer_enabled));const i=await fetch(`/api/archives/${e}/captures`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.error||`HTTP ${i.status}`)}return i.json()}async function yh(e,t){return Ne(`/api/archives/${e}/captures/probe?locator=${encodeURIComponent(t)}`)}async function xd(e,t){return Ne(`/api/archives/${e}/capture_jobs/${t}`)}async function xh(){return(await(await fetch("/api/auth/setup")).json()).setup_required===!0}async function wh(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 kh(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 jh(){await fetch("/api/auth/logout",{method:"POST"})}async function Sh(){const e=await fetch("/api/auth/me");return e.status===401?null:e.json()}async function Nh(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 _h(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 Ch(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 Eh(){return Ne("/api/auth/tokens")}async function Th(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 Ph(e){const t=await fetch(`/api/auth/tokens/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(await t.text())}async function Ia(){return Ne("/api/admin/instance-settings")}async function xl(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 Lh(){return Ne("/api/admin/users")}async function zh(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 Rh(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 bh(){return Ne("/api/admin/roles")}async function Dh(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 wd(e){return Ne(`/api/archives/${e}/collections`)}async function $h(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 i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}return l.json()}async function Ih(e,t){return Ne(`/api/archives/${e}/collections/${t}`)}async function kd(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 i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}}async function Oh(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 Ah(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 i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}}async function Mh(e,t){return Ne(`/api/archives/${e}/entries/${t}/collections`)}async function Go(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 Fh(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 Bh(e){return Ne(`/api/archives/${e}/blob-cleanup`)}async function Uh(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 Hh(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 Wh(){return Ne("/api/admin/cookie-rules")}async function Vh(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 Qh(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 Kh(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 Xh=window.fetch;window.fetch=async(...e)=>{var n;const t=await Xh(...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 Jh({onLogin:e}){const[t,n]=p.useState(""),[r,l]=p.useState(""),[i,a]=p.useState(null),[o,u]=p.useState(!1);async function c(g){g.preventDefault(),a(null),u(!0);try{const m=await kh(t,r);e(m)}catch(m){a(m.message)}finally{u(!1)}}return s.jsx("div",{className:"login-page",children:s.jsxs("div",{className:"login-card",children:[s.jsx("h1",{className:"login-brand",children:"Archivr"}),s.jsx("p",{className:"login-tagline",children:"Sign in to your archive"}),s.jsxs("form",{onSubmit:c,children:[s.jsxs("div",{className:"login-field",children:[s.jsx("label",{className:"login-label",htmlFor:"login-username",children:"Username"}),s.jsx("input",{className:"login-input",id:"login-username",type:"text",value:t,onChange:g=>n(g.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),s.jsxs("div",{className:"login-field",children:[s.jsx("label",{className:"login-label",htmlFor:"login-password",children:"Password"}),s.jsx("input",{className:"login-input",id:"login-password",type:"password",value:r,onChange:g=>l(g.target.value),required:!0,autoComplete:"current-password"})]}),i&&s.jsx("p",{className:"login-error",children:i}),s.jsx("button",{className:"login-submit",type:"submit",disabled:o,children:o?"Signing in…":"Sign in"})]})]})})}function qh({onComplete:e}){const[t,n]=p.useState(""),[r,l]=p.useState(""),[i,a]=p.useState(""),[o,u]=p.useState(null),[c,g]=p.useState(!1);async function m(f){if(f.preventDefault(),r!==i){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 wh(t,r),e()}catch(k){u(k.message)}finally{g(!1)}}return s.jsx("div",{className:"setup-page",children:s.jsxs("div",{className:"setup-card",children:[s.jsx("h1",{className:"setup-brand",children:"Archivr"}),s.jsx("p",{className:"setup-tagline",children:"Create your owner account to get started."}),s.jsxs("form",{onSubmit:m,children:[s.jsxs("div",{className:"setup-field",children:[s.jsx("label",{className:"setup-label",htmlFor:"setup-username",children:"Username"}),s.jsx("input",{className:"setup-input",id:"setup-username",type:"text",value:t,onChange:f=>n(f.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),s.jsxs("div",{className:"setup-field",children:[s.jsx("label",{className:"setup-label",htmlFor:"setup-password",children:"Password"}),s.jsx("input",{className:"setup-input",id:"setup-password",type:"password",value:r,onChange:f=>l(f.target.value),required:!0,autoComplete:"new-password"})]}),s.jsxs("div",{className:"setup-field",children:[s.jsx("label",{className:"setup-label",htmlFor:"setup-confirm",children:"Confirm password"}),s.jsx("input",{className:"setup-input",id:"setup-confirm",type:"password",value:i,onChange:f=>a(f.target.value),required:!0,autoComplete:"new-password"})]}),o&&s.jsx("p",{className:"setup-error",children:o}),s.jsx("button",{className:"setup-submit",type:"submit",disabled:c,children:c?"Creating account…":"Create account"})]})]})})}function Gh({archives:e,archiveId:t,onArchiveChange:n,view:r,onViewChange:l,onCaptureClick:i}){const{currentUser:a,setCurrentUser:o}=p.useContext(as)??{},[u,c]=p.useState(!1);async function g(){c(!0),await jh(),o(null),window.location.reload()}return s.jsxs("header",{className:"topbar",children:[s.jsx("div",{className:"brand",children:"Archivr"}),s.jsx("div",{className:"switcher",children:s.jsx("select",{"aria-label":"Select archive",value:t??"",onChange:m=>n(m.target.value),children:e.map(m=>s.jsx("option",{value:m.id,children:m.label},m.id))})}),s.jsx("nav",{className:"nav","aria-label":"Primary",children:["archive","tags","collections","runs","admin","settings"].map(m=>s.jsx("button",{className:`nav-link${r===m?" is-active":""}`,onClick:()=>l(m),children:m.charAt(0).toUpperCase()+m.slice(1)},m))}),s.jsx("button",{className:"capture-button",onClick:i,children:"Capture"}),a&&s.jsxs("div",{className:"user-menu",children:[s.jsx("span",{className:"user-name",children:a.display_name||a.username}),s.jsx("button",{className:"logout-btn",onClick:g,disabled:u,children:u?"Logging out…":"Log out"})]})]})}let Fi=1;function jd(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 er(e=""){return{id:Fi++,locator:e,quality:"best",probeState:"idle",probeQualities:null,probeHasAudio:!1,status:"idle",error:null,jobUid:null,archiveId:null}}function Yo(e){return e.some(t=>t.status==="submitting"||t.status==="running")}function Yh({open:e,archiveId:t,onClose:n,onCaptured:r,onToast:l}){const i=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[k,w]=p.useState(()=>{try{const N=JSON.parse(sessionStorage.getItem("captureItems")||"null");if(Array.isArray(N)&&N.length>0)return N.forEach(I=>{I.id>=Fi&&(Fi=I.id+1)}),N}catch{}return[er()]});p.useEffect(()=>{sessionStorage.setItem("captureItems",JSON.stringify(k))},[k]);const[y,_]=p.useState(!1),[h,d]=p.useState(null),[v,x]=p.useState(null),[j,C]=p.useState(!0),[T,S]=p.useState(!0);p.useEffect(()=>{Ia().then(N=>{x(N),C(N.cookie_ext_enabled??!0),S(N.modal_closer_enabled??!0)}).catch(()=>x({}))},[]);const D=h!==null?h:(v==null?void 0:v.ublock_enabled)??!0,[$,G]=p.useState(!1);p.useEffect(()=>{["captureDialogLocator","captureDialogError","captureDialogBusy","captureDialogJobStatus","captureDialogJobUid"].forEach(N=>sessionStorage.removeItem(N)),w(N=>N.map(I=>I.status==="submitting"?{...I,status:"idle",error:null}:I)),k.forEach(N=>{N.status==="running"&&N.jobUid&&N.archiveId&&!o.current.has(N.jobUid)&&te(N.id,N.jobUid,N.locator,N.archiveId)})},[]),p.useEffect(()=>{const N=i.current;if(!N)return;const I=()=>{u.current.forEach(H=>clearTimeout(H)),u.current.clear(),n()};return N.addEventListener("close",I),()=>N.removeEventListener("close",I)},[n]),p.useEffect(()=>{const N=i.current;N&&(e?(!a.current&&!Yo(k)&&w([er()]),a.current=!1,N.open||N.showModal()):(u.current.forEach(I=>clearTimeout(I)),u.current.clear(),N.open&&N.close()))},[e]),p.useEffect(()=>()=>{o.current.forEach(N=>clearInterval(N)),u.current.forEach(N=>clearTimeout(N))},[]);function te(N,I,H,U,W=null){if(o.current.has(I))return;const ce=setInterval(async()=>{try{const J=await xd(U,I);if(J.status==="completed"){clearInterval(o.current.get(I)),o.current.delete(I),w(Q=>Q.map(Y=>Y.id===N?{...Y,status:"completed"}:Y)),setTimeout(()=>{w(Q=>{const Y=Q.filter(de=>de.id!==N);return Y.length===0?[er()]:Y})},1400),m.current();try{const Q=J.notes_json?JSON.parse(J.notes_json):null;if(Q!=null&&Q.ublock_skipped||Q!=null&&Q.cookie_ext_skipped){const de=Q.ublock_skipped&&Q.cookie_ext_skipped?"Captured without ad-blocking or cookie-consent extension. Check ARCHIVR_UBLOCK_EXT and ARCHIVR_COOKIE_EXT in your server config.":Q.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(de,H,"warning"),ee(W,"warning",H)}else W||f.current(null,H,"success"),ee(W,"archived")}catch{W||f.current(null,H,"success"),ee(W,"archived")}}else if(J.status==="failed"){clearInterval(o.current.get(I)),o.current.delete(I);const Q=J.error_text||"Capture failed.";w(Y=>Y.map(de=>de.id===N?{...de,status:"failed",error:Q}:de)),f.current(Q,H),ee(W,"failed",H)}}catch(J){clearInterval(o.current.get(I)),o.current.delete(I);const Q=J.message||"Network error";w(Y=>Y.map(de=>de.id===N?{...de,status:"failed",error:Q}:de)),f.current(Q,H),ee(W,"failed",H)}},500);o.current.set(I,ce)}function ee(N,I,H=null){if(!N)return;const U=c.current.get(N);if(!U||(I==="archived"||I==="warning"?(U.archived++,I==="warning"&&(U.warnings++,H&&U.warningLocators.push(H))):(U.failed++,H&&U.failedLocators.push(H)),U.archived+U.failed0?`${W} archived (${ce} with warnings)`:`${W} archived`;de=J>0?`${xe}, ${J} failed`:xe}const R=W===0?"error":J>0||ce>0?"warning":"success",V=[];Q.length>0&&V.push(`Failed: -${Q.map(xe=>` ${xe}`).join(` -`)}`),Y.length>0&&V.push(`With warnings: -${Y.map(xe=>` ${xe}`).join(` -`)}`);const Ee=V.length>0?V.join(` -`):null;f.current(Ee,null,R,de)}async function ve(N,I=null){if(!N.locator.trim())return;const H=t,U=N.locator.trim(),W=N.quality||"best";w(ce=>ce.map(J=>J.id===N.id?{...J,status:"submitting",error:null}:J));try{const J=await vh(H,U,W,{ublock_enabled:D,reader_mode:$,cookie_ext_enabled:j,modal_closer_enabled:T});w(Q=>Q.map(Y=>Y.id===N.id?{...Y,status:"running",jobUid:J.job_uid,archiveId:H}:Y)),te(N.id,J.job_uid,U,H,I)}catch(ce){const J=ce.message||"Submission failed.";w(Q=>Q.map(Y=>Y.id===N.id?{...Y,status:"failed",error:J}:Y)),f.current(J,U),ee(I,"failed",U)}}function ke(){var H,U;const N=k.filter(W=>W.status==="idle"&&W.locator.trim());if(N.length===0)return;const I=N.length>1?((H=crypto.randomUUID)==null?void 0:H.call(crypto))??`batch-${Date.now()}`:null;I&&c.current.set(I,{total:N.length,archived:0,warnings:0,failed:0,failedLocators:[],warningLocators:[]}),N.forEach(W=>ve(W,I)),(U=i.current)==null||U.close()}function ye(){w(N=>[...N,er()])}function se(N){clearTimeout(u.current.get(N)),u.current.delete(N),w(I=>{const H=I.filter(U=>U.id!==N);return H.length===0?[er()]:H})}function z(N){w(I=>I.map(H=>H.id===N?{...H,status:"idle",error:null}:H))}function E(N,I){if(clearTimeout(u.current.get(N)),w(U=>U.map(W=>W.id===N?{...W,locator:I,probeState:"idle",probeQualities:null,probeHasAudio:!1,quality:"best"}:W)),!jd(I))return;const H=setTimeout(async()=>{u.current.delete(N),w(U=>U.map(W=>W.id===N?{...W,probeState:"probing"}:W));try{const U=await yh(g.current,I.trim());w(W=>W.map(ce=>{if(ce.id!==N||ce.locator!==I)return ce;const J=U.qualities??[],Q=U.has_audio??!1,Y=J.length===0&&Q?"audio":"best";return{...ce,probeState:"done",probeQualities:J,probeHasAudio:Q,quality:Y}}))}catch{w(U=>U.map(W=>W.id===N?{...W,probeState:"idle",probeQualities:null}:W))}},600);u.current.set(N,H)}function F(N,I){w(H=>H.map(U=>U.id===N?{...U,quality:I}:U))}const X=k.filter(N=>N.status==="idle"&&N.locator.trim()).length,B=Yo(k);return s.jsx("dialog",{ref:i,className:"capture-dialog",children:s.jsxs("div",{className:"capture-dialog-inner",children:[s.jsxs("div",{className:"capture-dialog-header",children:[s.jsx("h2",{className:"capture-dialog-title",children:"Capture"}),s.jsx("button",{type:"button",className:"capture-dialog-close",onClick:()=>{var N;return(N=i.current)==null?void 0:N.close()},"aria-label":"Close",children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),s.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),s.jsx("div",{className:"capture-rows",children:k.map((N,I)=>s.jsx(Zh,{item:N,autoFocus:I===k.length-1&&N.status==="idle",onLocatorChange:H=>E(N.id,H),onQualityChange:H=>F(N.id,H),onRemove:()=>se(N.id),onReset:()=>z(N.id),onSubmit:ke},N.id))}),s.jsxs("button",{type:"button",className:"capture-add-row",onClick:ye,children:[s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"14"}),s.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"})]}),"Add another"]}),s.jsxs("div",{className:"capture-advanced",children:[s.jsxs("button",{type:"button",className:"capture-advanced-toggle",onClick:()=>_(N=>!N),"aria-expanded":y,children:[s.jsx("svg",{className:`capture-chevron${y?" capture-chevron--open":""}`,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"4 6 8 10 12 6"})}),"Advanced options"]}),y&&s.jsxs("div",{className:"capture-advanced-panel",children:[s.jsxs("label",{className:"capture-ext-row",children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"uBlock Origin Lite"}),s.jsx("span",{className:"capture-ext-desc",children:"Block ads during this capture"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":D,className:`ext-toggle ext-toggle--sm${D?" ext-toggle--on":""}`,onClick:()=>d(N=>N===null?!D:!N),"aria-label":"Toggle uBlock for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]}),s.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"Block cookie banners"}),s.jsx("span",{className:"capture-ext-desc",children:"Dismiss cookie consent banners during this capture"}),!(v!=null&&v.cookie_ext_available)&&s.jsxs("span",{className:"capture-ext-hint",children:["Not configured — set ",s.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})]})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":j,className:`ext-toggle ext-toggle--sm${j?" ext-toggle--on":""}`,onClick:()=>C(N=>!N),"aria-label":"Toggle cookie banner blocking for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]}),s.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"Reader mode"}),s.jsx("span",{className:"capture-ext-desc",children:"Distil to article text via Readability (off by default)"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":$,className:`ext-toggle ext-toggle--sm${$?" ext-toggle--on":""}`,onClick:()=>G(N=>!N),"aria-label":"Toggle reader mode for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]}),s.jsxs("label",{className:"capture-ext-row",style:{marginTop:8},children:[s.jsxs("span",{className:"capture-ext-label",children:[s.jsx("span",{className:"capture-ext-name",children:"Close modals and dialogs"}),s.jsx("span",{className:"capture-ext-desc",children:"Auto-dismiss cookie banners and overlays during this capture"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":T,className:`ext-toggle ext-toggle--sm${T?" ext-toggle--on":""}`,onClick:()=>S(N=>!N),"aria-label":"Toggle modal closer for this capture",children:s.jsx("span",{className:"ext-toggle-knob"})})]})]})]}),s.jsxs("div",{className:"capture-actions",children:[s.jsx("button",{type:"button",className:"capture-submit",onClick:ke,disabled:X===0,children:X>1?`Archive ${X}`:"Archive"}),s.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var N;return(N=i.current)==null?void 0:N.close()},children:B?"Close":"Cancel"})]})]})})}function Zh({item:e,autoFocus:t,onLocatorChange:n,onQualityChange:r,onRemove:l,onReset:i,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||!jd(e.locator))return null;if(e.probeState==="probing")return s.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?s.jsx("span",{className:"capture-quality-hint",children:"No media detected"}):g.length===0&&m?s.jsx("select",{className:"capture-quality",value:"audio",onChange:f=>r(f.target.value),"aria-label":"Video quality",children:s.jsx("option",{value:"audio",children:"Audio only"})}):s.jsxs("select",{className:"capture-quality",value:e.quality||"best",onChange:f=>r(f.target.value),"aria-label":"Video quality",children:[s.jsx("option",{value:"best",children:"Best quality"}),g.map(f=>s.jsx("option",{value:f,children:f},f)),m&&s.jsx("option",{value:"audio",children:"Audio only"})]})}return null})();return s.jsxs("div",{className:`capture-row capture-row--${e.status}`,children:[s.jsxs("div",{className:"capture-row-main",children:[s.jsx(em,{status:e.status}),s.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"&&s.jsx("button",{type:"button",className:"capture-row-action",onClick:i,title:"Retry",children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M13 2.5A7 7 0 1 1 6.5 1"}),s.jsx("polyline",{points:"6.5 1 4 3.5 6.5 6"})]})}),!u&&e.status!=="completed"&&e.status!=="failed"&&s.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:l,"aria-label":"Remove",children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),s.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),e.error&&s.jsx("p",{className:"capture-row-error",children:e.error})]})}function em({status:e}){return e==="submitting"||e==="running"?s.jsx("span",{className:"cap-dot cap-dot--running","aria-label":"Running",children:s.jsx("span",{className:"cap-spinner"})}):e==="completed"?s.jsx("span",{className:"cap-dot cap-dot--ok","aria-label":"Done",children:"✓"}):e==="failed"?s.jsx("span",{className:"cap-dot cap-dot--err","aria-label":"Failed",children:"✕"}):s.jsx("span",{className:"cap-dot cap-dot--idle","aria-hidden":"true"})}function Bi(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 Zt(e){return tm(e)??""}function Sd(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 Zo={youtube:'',youtube_music:'',spotify:'',x:'',instagram:'',facebook:'',tiktok:'',reddit:'',snapchat:'',local:'',web:'',other:'?'};function Oa(e){return Zo[e]??Zo.other}function Nd(e){return e.split("/").map(t=>t?t.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):"").join("/")}function nm({entry:e,archiveId:t,isSelected:n,isMultiSelected:r,onRowClick:l}){const[i,a]=p.useState(!1),u=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!i?s.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>a(!0),style:{objectFit:"contain"}}):s.jsx("span",{dangerouslySetInnerHTML:{__html:Oa(e.source_kind)}}),c=n||r;function g(m){m.stopPropagation(),l(e,{ctrlKey:!0,metaKey:!1,shiftKey:!1,preventDefault(){}})}return s.jsxs("div",{className:[n&&"is-selected",r&&"is-multi-selected"].filter(Boolean).join(" ")||void 0,tabIndex:0,"data-entry-uid":e.entry_uid,onMouseDown:m=>{m.shiftKey&&m.preventDefault()},onClick:m=>l(e,m),onKeyDown:m=>{m.key==="Enter"&&l(e,m)},children:[s.jsx("div",{className:"col-check",children:s.jsx("button",{type:"button",className:`row-checkbox${c?" is-checked":""}`,"aria-pressed":c,"aria-label":c?"Deselect entry":"Select entry",onClick:g,onKeyDown:m=>m.stopPropagation()})}),s.jsx("div",{className:"col-added",children:Sd(e.archived_at)}),s.jsxs("div",{className:"col-title",children:[s.jsx("span",{className:"source-icon",children:u}),s.jsx("span",{className:"entry-title",children:Zt(e.title)||Zt(e.entry_uid)})]}),s.jsx("div",{className:"col-type",children:s.jsx("span",{className:"type-pill",children:Zt(e.entity_kind)})}),s.jsxs("div",{className:"col-size",children:[s.jsx("span",{className:"size-total",children:Bi(e.total_artifact_bytes)}),e.cached_bytes>0&&e.total_artifact_bytes>0&&s.jsxs("span",{className:"size-cached-pct",title:`${Bi(e.cached_bytes)} already on disk from an earlier entry`,children:[Math.round(e.cached_bytes/e.total_artifact_bytes*100),"% cached"]})]}),s.jsx("div",{className:"url-cell col-url",children:Zt(e.original_url)})]})}function rm({entries:e,selectedUids:t,onRowClick:n,archiveId:r}){return s.jsx("section",{id:"archive-view",className:"view is-active",children:s.jsxs("div",{className:"entry-table",children:[s.jsxs("div",{className:"entry-header-row",children:[s.jsx("div",{className:"col-check","aria-hidden":"true"}),s.jsx("div",{className:"col-added",children:"Added"}),s.jsx("div",{className:"col-title",children:"Title"}),s.jsx("div",{className:"col-type",children:"Type"}),s.jsx("div",{className:"col-size",children:"Size"}),s.jsx("div",{className:"col-url",children:"Original URL"})]}),s.jsx("div",{id:"entries-body",children:e.map(l=>s.jsx(nm,{entry:l,archiveId:r,isSelected:t.size===1&&t.has(l.entry_uid),isMultiSelected:t.size>=2&&t.has(l.entry_uid),onRowClick:n},l.entry_uid))})]})})}function lm(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 sm({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 s.jsx("span",{className:`run-status ${t}`,children:n})}function im({runs:e}){const[t,n]=p.useState(null);function r(l){n(i=>i===l?null:l)}return s.jsx("section",{id:"runs-view",className:"view is-active",children:s.jsxs("table",{className:"entry-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Started"}),s.jsx("th",{children:"Status"}),s.jsx("th",{children:"Requested"}),s.jsx("th",{children:"Completed"}),s.jsx("th",{children:"Failed"})]})}),s.jsx("tbody",{children:e.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,style:{color:"var(--muted)",padding:"24px 16px",textAlign:"center"},children:"No runs yet."})}):e.map(l=>{const i=l.status==="failed"&&l.error_summary,a=t===l.run_uid;return[s.jsxs("tr",{className:i?"run-row run-row--failed":"run-row",onClick:i?()=>r(l.run_uid):void 0,title:i?a?"Click to hide error":"Click to view error":void 0,children:[s.jsx("td",{children:lm(l.started_at)}),s.jsxs("td",{children:[s.jsx(sm,{status:l.status}),i&&s.jsx("span",{className:"run-expand-hint","aria-hidden":"true",children:a?"▴":"▾"})]}),s.jsx("td",{children:l.requested_count??"—"}),s.jsx("td",{children:l.completed_count??"—"}),s.jsx("td",{children:l.failed_count??"—"})]},l.run_uid),i&&a&&s.jsx("tr",{className:"run-error-row",children:s.jsx("td",{colSpan:5,children:s.jsx("pre",{className:"run-error-detail",children:l.error_summary})})},`${l.run_uid}-detail`)]})})]})})}const am=4;function om({archives:e}){const{currentUser:t}=p.useContext(as)??{},n=t&&(t.role_bits&am)!==0,[r,l]=p.useState("users"),[i,a]=p.useState([]),[o,u]=p.useState([]),[c,g]=p.useState(!1),[m,f]=p.useState(null),[k,w]=p.useState(""),[y,_]=p.useState(""),[h,d]=p.useState(""),[v,x]=p.useState(null),[j,C]=p.useState(!1),[T,S]=p.useState(""),[D,$]=p.useState(""),[G,te]=p.useState(null),[ee,ve]=p.useState(!1),ke=p.useCallback(async()=>{if(n){g(!0),f(null);try{const[E,F]=await Promise.all([Lh(),bh()]);a(E),u(F)}catch(E){f(E.message)}finally{g(!1)}}},[n]);p.useEffect(()=>{ke()},[ke]);async function ye(E){const F=E.status==="active"?"disabled":"active";try{await Rh(E.user_uid,F),a(X=>X.map(B=>B.user_uid===E.user_uid?{...B,status:F}:B))}catch(X){f(X.message)}}async function se(E){if(E.preventDefault(),!k.trim()||!y){x("Username and password required");return}C(!0),x(null);try{await zh(k.trim(),y,h.trim()||void 0),w(""),_(""),d(""),await ke()}catch(F){x(F.message)}finally{C(!1)}}async function z(E){if(E.preventDefault(),!T.trim()||!D.trim()){te("Slug and name required");return}ve(!0),te(null);try{await Dh(T.trim(),D.trim()),S(""),$(""),await ke()}catch(F){te(F.message)}finally{ve(!1)}}return n?s.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[s.jsx("h1",{children:"Admin"}),s.jsxs("div",{className:"view-tabs",children:[s.jsx("button",{className:`view-tab${r==="users"?" is-active":""}`,onClick:()=>l("users"),children:"Users"}),s.jsx("button",{className:`view-tab${r==="roles"?" is-active":""}`,onClick:()=>l("roles"),children:"Roles"}),s.jsx("button",{className:`view-tab${r==="archives"?" is-active":""}`,onClick:()=>l("archives"),children:"Archives"})]}),m&&s.jsx("div",{className:"form-msg form-msg--err",children:m}),r==="users"&&s.jsxs("div",{className:"admin-section",children:[s.jsx("h2",{children:"Users"}),c?s.jsx("p",{className:"muted",children:"Loading…"}):s.jsxs("table",{className:"admin-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Username"}),s.jsx("th",{children:"Email"}),s.jsx("th",{children:"Roles"}),s.jsx("th",{children:"Status"}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:i.map(E=>s.jsxs("tr",{className:E.status==="disabled"?"admin-row-disabled":"",children:[s.jsx("td",{children:E.username}),s.jsx("td",{className:"muted",children:E.email||"—"}),s.jsx("td",{children:E.role_slugs.join(", ")||"—"}),s.jsx("td",{children:s.jsx("span",{className:`status-badge status-${E.status}`,children:E.status})}),s.jsx("td",{children:s.jsx("button",{className:"admin-action-btn",onClick:()=>ye(E),children:E.status==="active"?"Ban":"Unban"})})]},E.user_uid))})]}),s.jsx("h3",{children:"Create User"}),s.jsxs("form",{className:"admin-form",onSubmit:se,children:[s.jsx("input",{className:"admin-input",placeholder:"Username",value:k,onChange:E=>w(E.target.value),required:!0}),s.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:y,onChange:E=>_(E.target.value),required:!0}),s.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:h,onChange:E=>d(E.target.value)}),v&&s.jsx("div",{className:"form-msg form-msg--err",children:v}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:j,children:j?"Creating…":"Create User"})]})]}),r==="roles"&&s.jsxs("div",{className:"admin-section",children:[s.jsx("h2",{children:"Roles"}),c?s.jsx("p",{className:"muted",children:"Loading…"}):s.jsxs("table",{className:"admin-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Slug"}),s.jsx("th",{children:"Name"}),s.jsx("th",{children:"Level"}),s.jsx("th",{children:"Bit"}),s.jsx("th",{children:"Built-in"})]})}),s.jsx("tbody",{children:o.map(E=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:E.slug})}),s.jsx("td",{children:E.name}),s.jsx("td",{children:E.level}),s.jsx("td",{children:E.bit_position}),s.jsx("td",{children:E.is_builtin?"✓":""})]},E.role_uid))})]}),s.jsx("h3",{children:"Create Custom Role"}),s.jsxs("form",{className:"admin-form",onSubmit:z,children:[s.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:T,onChange:E=>S(E.target.value),required:!0}),s.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:D,onChange:E=>$(E.target.value),required:!0}),G&&s.jsx("div",{className:"form-msg form-msg--err",children:G}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:ee,children:ee?"Creating…":"Create Role"})]})]}),r==="archives"&&s.jsxs("div",{className:"admin-section",children:[s.jsx("h2",{children:"Mounted Archives"}),s.jsx("div",{className:"admin-list",children:e.map(E=>s.jsxs("div",{className:"admin-archive",children:[s.jsx("strong",{children:E.label}),s.jsx("div",{className:"muted",children:E.archive_path})]},E.id))})]})]}):s.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[s.jsx("h1",{children:"Admin"}),s.jsx("p",{className:"muted",children:"You need admin privileges to access this panel."}),s.jsx("h2",{children:"Mounted Archives"}),s.jsx("div",{className:"admin-list",children:e.map(E=>s.jsxs("div",{className:"admin-archive",children:[s.jsx("strong",{children:E.label}),s.jsx("div",{className:"muted",children:E.archive_path})]},E.id))})]})}function _d({node:e,archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){var x;const c=n===e.tag.full_path,[g,m]=p.useState(!1),[f,k]=p.useState(""),w=p.useRef(!1);function y(){if(g)return;const j=c?null:e.tag.full_path;r(j),l("archive")}function _(j){j.stopPropagation(),k(e.tag.slug),m(!0)}async function h(){const j=f.trim();if(!j||j===e.tag.slug){m(!1);return}try{const C=await mh(t,e.tag.tag_uid,j);i(e.tag.full_path,C.full_path),o()}catch{}finally{m(!1)}}async function d(j){var T;j.stopPropagation();const C=((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(C))try{await gh(t,e.tag.tag_uid),a(e.tag.full_path),o()}catch{}}const v={archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u};return s.jsxs("li",{children:[s.jsxs("div",{className:"tag-node-row",children:[g?s.jsx("input",{className:"tag-rename-input",autoFocus:!0,value:f,onChange:j=>k(j.target.value),onKeyDown:j=>{j.key==="Enter"&&j.currentTarget.blur(),j.key==="Escape"&&(w.current=!0,j.currentTarget.blur())},onBlur:()=>{w.current?(w.current=!1,m(!1)):h()}}):s.jsxs("button",{className:`tag-node-btn${c?" is-active":""}`,title:e.tag.full_path,onClick:y,onDoubleClick:_,children:[u?e.tag.name:e.tag.slug,s.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:j=>{j.stopPropagation(),_(j)},children:s.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),s.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:"×"})]}),((x=e.children)==null?void 0:x.length)>0&&s.jsx("div",{className:"tag-children",children:s.jsx("ul",{className:"tag-tree-list",children:e.children.map(j=>s.jsx(_d,{node:j,...v},j.tag.tag_uid))})})]})}function um({archiveId:e,tagNodes:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){return s.jsx("section",{id:"tags-view",className:"view is-active",children:s.jsxs("div",{className:"tag-tree",children:[s.jsxs("div",{className:"tag-tree-header",children:[s.jsx("span",{className:"tag-tree-title",children:"Tags"}),n&&s.jsxs("span",{className:"tag-tree-active",children:["Filtering: ",n]})]}),t.length===0?s.jsx("p",{className:"muted",style:{padding:"8px 0"},children:"No tags yet."}):s.jsx("ul",{className:"tag-tree-list",children:t.map(c=>s.jsx(_d,{node:c,archiveId:e,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u},c.tag.tag_uid))})]})})}const ir=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],cm=e=>{var t;return((t=ir.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function dm({archiveId:e}){const[t,n]=p.useState([]),[r,l]=p.useState(!1),[i,a]=p.useState(null),[o,u]=p.useState(null),[c,g]=p.useState(null),[m,f]=p.useState(!1),[k,w]=p.useState(null),[y,_]=p.useState(""),[h,d]=p.useState(""),[v,x]=p.useState(2),[j,C]=p.useState(!1),[T,S]=p.useState(null),[D,$]=p.useState(""),[G,te]=p.useState(2),[ee,ve]=p.useState(!1),[ke,ye]=p.useState(null),[se,z]=p.useState(!1),[E,F]=p.useState(""),X=p.useRef(null),B=t.find(R=>R.collection_uid===o)??null,N=(B==null?void 0:B.slug)==="_default_",I=p.useCallback(async()=>{if(e){l(!0),a(null);try{const R=await wd(e);n(R)}catch(R){a(R.message)}finally{l(!1)}}},[e]),H=p.useCallback(async R=>{if(!R){g(null);return}f(!0),w(null);try{const V=await Ih(e,R);g(V)}catch(V){w(V.message)}finally{f(!1)}},[e]);p.useEffect(()=>{I()},[I]),p.useEffect(()=>{H(o)},[o,H]),p.useEffect(()=>{se&&X.current&&X.current.focus()},[se]);async function U(R){R.preventDefault();const V=y.trim(),Ee=h.trim();if(!(!V||!Ee)){C(!0),S(null);try{const xe=await $h(e,V,Ee,v);_(""),d(""),x(2),await I(),u(xe.collection_uid)}catch(xe){S(xe.message)}finally{C(!1)}}}async function W(){const R=E.trim();if(!R||!B){z(!1);return}try{await Go(e,B.collection_uid,{name:R}),await I(),g(V=>V&&{...V,name:R})}catch(V){a(V.message)}finally{z(!1)}}async function ce(R){if(B)try{await Go(e,B.collection_uid,{default_visibility_bits:R}),await I(),g(V=>V&&{...V,default_visibility_bits:R})}catch(V){a(V.message)}}async function J(){if(B&&window.confirm(`Delete collection "${B.name}"? Entries will not be deleted.`))try{await Fh(e,B.collection_uid),u(null),g(null),await I()}catch(R){a(R.message)}}async function Q(R){R.preventDefault();const V=D.trim();if(!(!V||!B)){ve(!0),ye(null);try{await kd(e,B.collection_uid,V,G),$(""),await H(B.collection_uid)}catch(Ee){ye(Ee.message)}finally{ve(!1)}}}async function Y(R){if(B)try{await Oh(e,B.collection_uid,R),await H(B.collection_uid)}catch(V){w(V.message)}}async function de(R,V){if(B)try{await Ah(e,B.collection_uid,R,V),g(Ee=>Ee&&{...Ee,entries:Ee.entries.map(xe=>xe.entry_uid===R?{...xe,collection_visibility_bits:V}:xe)})}catch(Ee){w(Ee.message)}}return e?s.jsxs("div",{className:"collections-view",children:[s.jsx("h2",{className:"collections-heading",children:"Collections"}),r&&s.jsx("div",{className:"muted",children:"Loading…"}),i&&s.jsxs("div",{className:"collections-error",children:[i," ",s.jsx("button",{onClick:()=>a(null),className:"coll-dismiss",children:"×"})]}),s.jsxs("div",{className:"collections-layout",children:[s.jsxs("div",{className:"collections-sidebar",children:[t.map(R=>s.jsxs("button",{className:`coll-sidebar-row${o===R.collection_uid?" is-active":""}`,onClick:()=>u(R.collection_uid),children:[s.jsx("span",{className:"coll-row-name",children:R.name}),s.jsx("span",{className:"coll-row-meta",children:cm(R.default_visibility_bits)})]},R.collection_uid)),t.length===0&&!r&&s.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),B?s.jsxs("div",{className:"coll-detail",children:[s.jsxs("div",{className:"coll-detail-header",children:[se?s.jsx("input",{ref:X,className:"coll-rename-input",value:E,onChange:R=>F(R.target.value),onBlur:W,onKeyDown:R=>{R.key==="Enter"&&W(),R.key==="Escape"&&z(!1)}}):s.jsxs("h3",{className:`coll-detail-name${N?"":" coll-detail-name--editable"}`,title:N?void 0:"Click to rename",onClick:()=>{N||(F(B.name),z(!0))},children:[(c==null?void 0:c.name)??B.name,!N&&s.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!N&&s.jsx("button",{className:"coll-delete-btn",onClick:J,title:"Delete collection",children:"Delete"})]}),s.jsxs("div",{className:"coll-detail-vis",children:[s.jsx("span",{className:"coll-vis-label",children:"Default visibility"}),s.jsx("select",{className:"coll-vis-select",value:(c==null?void 0:c.default_visibility_bits)??B.default_visibility_bits,onChange:R=>ce(Number(R.target.value)),disabled:N,children:ir.map(R=>s.jsx("option",{value:R.value,children:R.label},R.value))})]}),s.jsxs("div",{className:"coll-entries-section",children:[s.jsx("div",{className:"coll-section-heading",children:"Entries"}),m&&s.jsx("div",{className:"muted",children:"Loading…"}),k&&s.jsx("div",{className:"collections-error",children:k}),!m&&c&&(c.entries.length===0?s.jsx("div",{className:"muted",children:"No entries in this collection."}):s.jsx("ul",{className:"coll-entries-list",children:c.entries.map(R=>s.jsxs("li",{className:"coll-entry-row",children:[s.jsxs("div",{className:"coll-entry-info",children:[s.jsx("span",{className:"coll-entry-title",children:R.title||R.entry_uid}),s.jsx("span",{className:"coll-entry-kind muted",children:R.source_kind})]}),s.jsxs("div",{className:"coll-entry-actions",children:[s.jsx("select",{className:"coll-entry-vis-select",value:R.collection_visibility_bits,onChange:V=>de(R.entry_uid,Number(V.target.value)),children:ir.map(V=>s.jsx("option",{value:V.value,children:V.label},V.value))}),!N&&s.jsx("button",{className:"coll-entry-remove",onClick:()=>Y(R.entry_uid),title:"Remove from collection",children:"×"})]})]},R.entry_uid))}))]}),!N&&s.jsxs("form",{className:"coll-add-entry-form",onSubmit:Q,children:[s.jsx("div",{className:"coll-section-heading",children:"Add entry"}),s.jsxs("div",{className:"coll-add-entry-row",children:[s.jsx("input",{className:"coll-add-entry-input",type:"text",value:D,onChange:R=>$(R.target.value),placeholder:"entry_uid",required:!0}),s.jsx("select",{className:"coll-vis-select",value:G,onChange:R=>te(Number(R.target.value)),children:ir.map(R=>s.jsx("option",{value:R.value,children:R.label},R.value))}),s.jsx("button",{className:"coll-add-btn",type:"submit",disabled:ee,children:ee?"…":"Add"})]}),ke&&s.jsx("div",{className:"collections-error",style:{marginTop:4},children:ke})]})]}):s.jsx("div",{className:"coll-detail coll-detail--empty",children:s.jsx("div",{className:"muted",children:"Select a collection to view details."})})]}),s.jsxs("details",{className:"coll-create-details",children:[s.jsx("summary",{children:"+ Create collection"}),s.jsxs("form",{className:"coll-create-form",onSubmit:U,children:[s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"coll-name",children:"Name"}),s.jsx("input",{className:"capture-input",id:"coll-name",type:"text",value:y,onChange:R=>{_(R.target.value),h||d(R.target.value.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"My Collection",required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"coll-slug",children:"Slug"}),s.jsx("input",{className:"capture-input",id:"coll-slug",type:"text",value:h,onChange:R=>d(R.target.value),placeholder:"my-collection",required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"coll-vis",children:"Default visibility"}),s.jsx("select",{className:"capture-input",id:"coll-vis",style:{height:42},value:v,onChange:R=>x(Number(R.target.value)),children:ir.map(R=>s.jsx("option",{value:R.value,children:R.label},R.value))})]}),T&&s.jsx("div",{className:"collections-error",children:T}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:j,children:j?"Creating…":"Create collection"})]})]})]}):s.jsx("div",{className:"view-placeholder",children:"Select an archive."})}const fm=4;function pm({tab:e,onTabChange:t,archiveId:n}){const{currentUser:r,setCurrentUser:l}=p.useContext(as)??{},i=r&&(r.role_bits&fm)!==0,a=["profile","tokens",...i?["instance","cookies","extensions","storage"]:[]],o={profile:"Profile",tokens:"API Tokens",instance:"Instance",cookies:"Cookies",extensions:"Extensions",storage:"Storage"};return s.jsxs("section",{className:"admin-view",children:[s.jsx("h1",{children:"Settings"}),s.jsx("div",{className:"view-tabs",children:a.map(u=>s.jsx("button",{className:`view-tab${e===u?" is-active":""}`,onClick:()=>t(u),children:o[u]},u))}),e==="profile"&&s.jsx(hm,{currentUser:r,setCurrentUser:l}),e==="tokens"&&s.jsx(mm,{}),e==="instance"&&i&&s.jsx(gm,{}),e==="cookies"&&i&&s.jsx(ym,{}),e==="extensions"&&i&&s.jsx(xm,{}),e==="storage"&&i&&s.jsx(vm,{archiveId:n})]})}function hm({currentUser:e,setCurrentUser:t}){const[n,r]=p.useState((e==null?void 0:e.display_name)??""),[l,i]=p.useState(!1),[a,o]=p.useState(null),[u,c]=p.useState(""),[g,m]=p.useState(""),[f,k]=p.useState(""),[w,y]=p.useState(!1),[_,h]=p.useState(null);async function d(x){x.preventDefault(),i(!0),o(null);try{await Nh(n),t(j=>({...j,display_name:n||null})),o({ok:!0,text:"Saved."})}catch(j){o({ok:!1,text:j.message})}finally{i(!1)}}async function v(x){if(x.preventDefault(),g!==f){h({ok:!1,text:"Passwords do not match."});return}y(!0),h(null);try{await Ch(u,g),c(""),m(""),k(""),h({ok:!0,text:"Password changed."})}catch(j){h({ok:!1,text:j.message})}finally{y(!1)}}return s.jsxs("div",{style:{maxWidth:440},children:[s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Display Name"}),s.jsxs("form",{onSubmit:d,children:[s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"display-name",children:"Name shown in the UI"}),s.jsx("input",{className:"field-input",id:"display-name",placeholder:(e==null?void 0:e.username)??"",value:n,onChange:x=>r(x.target.value)})]}),a&&s.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:l,children:l?"Saving…":"Save"})]})]}),s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Display Preferences"}),s.jsxs("label",{className:"checkbox-row",children:[s.jsx("input",{type:"checkbox",checked:(e==null?void 0:e.humanize_slugs)??!1,onChange:async x=>{const j=x.target.checked;try{await _h({humanize_slugs:j}),t(C=>({...C,humanize_slugs:j}))}catch{}}}),s.jsx("span",{className:"form-label",style:{margin:0},children:"Humanize tag display"})]}),s.jsx("p",{className:"muted",style:{fontSize:13,margin:"4px 0 0"},children:'When on, tag paths show as "X / Articles" instead of "x/articles".'})]}),s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Change Password"}),s.jsxs("form",{onSubmit:v,children:[s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"cur-pw",children:"Current password"}),s.jsx("input",{className:"field-input",id:"cur-pw",type:"password",value:u,onChange:x=>c(x.target.value),required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"new-pw",children:"New password"}),s.jsx("input",{className:"field-input",id:"new-pw",type:"password",value:g,onChange:x=>m(x.target.value),required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"confirm-pw",children:"Confirm new password"}),s.jsx("input",{className:"field-input",id:"confirm-pw",type:"password",value:f,onChange:x=>k(x.target.value),required:!0})]}),_&&s.jsx("div",{className:`form-msg form-msg--${_.ok?"ok":"err"}`,children:_.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:w,children:w?"Changing…":"Change Password"})]})]})]})}function mm(){const[e,t]=p.useState([]),[n,r]=p.useState(!0),[l,i]=p.useState(null),[a,o]=p.useState(""),[u,c]=p.useState(!1),[g,m]=p.useState(null),f=p.useCallback(async()=>{r(!0),i(null);try{t(await Eh())}catch(y){i(y.message)}finally{r(!1)}},[]);p.useEffect(()=>{f()},[f]);async function k(y){if(y.preventDefault(),!!a.trim()){c(!0);try{const _=await Th(a.trim());m(_),o(""),f()}catch(_){i(_.message)}finally{c(!1)}}}async function w(y){try{await Ph(y),t(_=>_.filter(h=>h.token_uid!==y))}catch(_){i(_.message)}}return s.jsx("div",{style:{maxWidth:600},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"API Tokens"}),g&&s.jsxs("div",{className:"token-banner",children:[s.jsx("strong",{children:"Token created."})," Copy it now — it won't be shown again.",s.jsx("code",{children:g.raw_token}),s.jsx("button",{className:"token-dismiss",onClick:()=>m(null),children:"Dismiss"})]}),s.jsxs("form",{className:"token-create-row",onSubmit:k,children:[s.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:a,onChange:y=>o(y.target.value),required:!0}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:u,children:u?"Creating…":"Create token"})]}),l&&s.jsx("div",{className:"form-msg form-msg--err",children:l}),n?s.jsx("div",{className:"muted",children:"Loading…"}):s.jsxs("div",{children:[e.length===0&&s.jsx("div",{className:"muted",children:"No tokens yet."}),e.map(y=>s.jsxs("div",{className:"token-row",children:[s.jsxs("div",{className:"token-row-info",children:[s.jsx("strong",{children:y.name}),s.jsxs("div",{className:"muted",children:["Created ",y.created_at.slice(0,10),y.last_used_at&&` · Last used ${y.last_used_at.slice(0,10)}`]})]}),s.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>w(y.token_uid),children:"Revoke"})]},y.token_uid))]})]})})}function gm(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,i]=p.useState(null),[a,o]=p.useState(!1),[u,c]=p.useState(null);p.useEffect(()=>{(async()=>{try{t(await Ia())}catch(m){i(m.message)}finally{r(!1)}})()},[]);async function g(m){m.preventDefault(),o(!0),c(null);try{await xl(e),c({ok:!0,text:"Saved."})}catch(f){c({ok:!1,text:f.message})}finally{o(!1)}}return n?s.jsx("div",{className:"muted",children:"Loading…"}):l?s.jsx("div",{className:"form-msg form-msg--err",children:l}):e?s.jsx("div",{style:{maxWidth:440},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Instance Settings"}),s.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])=>s.jsxs("label",{className:"checkbox-row",children:[s.jsx("input",{type:"checkbox",checked:!!e[m],onChange:k=>t(w=>({...w,[m]:k.target.checked}))}),f]},m)),s.jsxs("div",{className:"form-field",style:{marginTop:4},children:[s.jsx("label",{className:"form-label",children:"Default entry visibility"}),s.jsxs("select",{className:"field-input",value:e.default_entry_visibility,onChange:m=>t(f=>({...f,default_entry_visibility:Number(m.target.value)})),children:[s.jsx("option",{value:0,children:"Private"}),s.jsx("option",{value:2,children:"Unlisted"}),s.jsx("option",{value:3,children:"Public"})]})]}),u&&s.jsx("div",{className:`form-msg form-msg--${u.ok?"ok":"err"}`,children:u.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:a,children:a?"Saving…":"Save Settings"})]})]})}):null}function Vs(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 vm({archiveId:e}){const[t,n]=p.useState("idle"),[r,l]=p.useState(null),[i,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 k=await Bh(e);l(k),n("scanned")}catch(k){u(k.message),n("error")}}async function m(){n("deleting"),u(null);try{const k=await Uh(e);a(k),n("done")}catch(k){u(k.message),n("error")}}const f=r&&r.deletable_files===0&&r.orphaned_blob_rows===0;return s.jsx("div",{style:{maxWidth:440},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Orphan Cleanup"}),s.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."," ",s.jsx("strong",{children:"Cleanup is blocked while captures are running."})]}),!e&&s.jsx("div",{className:"muted",children:"No archive selected."}),e&&t==="idle"&&s.jsx("button",{className:"btn-ghost",onClick:g,children:"Scan for orphaned blobs"}),t==="scanning"&&s.jsx("div",{className:"muted",children:"Scanning…"}),t==="scanned"&&r&&f&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"form-msg form-msg--ok",children:"Archive is clean — nothing to remove."}),s.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Done"})]}),t==="scanned"&&r&&!f&&s.jsxs("div",{children:[s.jsxs("div",{style:{marginBottom:14,lineHeight:1.6},children:["Found ",s.jsx("strong",{children:r.deletable_files})," unreferenced file",r.deletable_files!==1?"s":""," ","and ",s.jsx("strong",{children:r.orphaned_blob_rows})," orphaned DB record",r.orphaned_blob_rows!==1?"s":""," ","— ",s.jsx("strong",{children:Vs(r.total_bytes)})," recoverable."]}),s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsxs("button",{className:"btn-danger",onClick:m,children:["Delete (",Vs(r.total_bytes),")"]}),s.jsx("button",{className:"btn-ghost",onClick:c,children:"Cancel"})]})]}),t==="deleting"&&s.jsx("div",{className:"muted",children:"Deleting…"}),t==="done"&&i&&s.jsxs("div",{children:[s.jsxs("div",{className:"form-msg form-msg--ok",children:["Freed ",s.jsx("strong",{children:Vs(i.freed_bytes)})," ","— removed ",i.deleted_files," file",i.deleted_files!==1?"s":""," ","and ",i.deleted_blob_rows," DB record",i.deleted_blob_rows!==1?"s":"","."]}),i.errors&&i.errors.length>0&&s.jsxs("div",{className:"form-msg form-msg--err",style:{marginTop:6},children:[i.errors.length," file",i.errors.length!==1?"s":""," could not be deleted."]}),s.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Scan again"})]}),t==="error"&&s.jsxs("div",{children:[s.jsx("div",{className:"form-msg form-msg--err",children:o}),s.jsx("button",{className:"btn-ghost",style:{marginTop:10},onClick:c,children:"Try again"})]})]})})}function ym(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,i]=p.useState(null),[a,o]=p.useState("global"),[u,c]=p.useState(""),[g,m]=p.useState("{}"),[f,k]=p.useState(null),[w,y]=p.useState(!1),[_,h]=p.useState({});p.useEffect(()=>{d()},[]);async function d(){r(!0),i(null);try{t(await Wh())}catch(S){i(S.message)}finally{r(!1)}}async function v(S){S.preventDefault();try{JSON.parse(g)}catch{k({ok:!1,text:'cookies must be valid JSON, e.g. {"session": "abc"}'});return}y(!0),k(null);try{await Vh(a==="global"?null:u.trim(),a,g),c(""),m("{}"),o("global"),k({ok:!0,text:"Rule added."}),await d()}catch(D){k({ok:!1,text:D.message})}finally{y(!1)}}async function x(S){try{await Kh(S),await d()}catch(D){i(D.message)}}function j(S){h(D=>({...D,[S.rule_uid]:{cookiesInput:S.cookies_json,saving:!1,msg:null}}))}function C(S){h(D=>{const $={...D};return delete $[S],$})}async function T(S){const D=_[S.rule_uid];try{JSON.parse(D.cookiesInput)}catch{h($=>({...$,[S.rule_uid]:{...$[S.rule_uid],msg:{ok:!1,text:"Invalid JSON"}}}));return}h($=>({...$,[S.rule_uid]:{...$[S.rule_uid],saving:!0,msg:null}}));try{await Qh(S.rule_uid,{cookies_json:D.cookiesInput}),C(S.rule_uid),await d()}catch($){h(G=>({...G,[S.rule_uid]:{...G[S.rule_uid],saving:!1,msg:{ok:!1,text:$.message}}}))}}return n?s.jsx("div",{className:"muted",children:"Loading…"}):l?s.jsx("div",{className:"form-msg form-msg--err",children:l}):s.jsx("div",{style:{maxWidth:560},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Cookie Rules"}),s.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?s.jsxs("table",{className:"data-table",style:{width:"100%",marginBottom:16},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Pattern"}),s.jsx("th",{children:"Cookies"}),s.jsx("th",{style:{width:100},children:"Actions"})]})}),s.jsx("tbody",{children:e.map(S=>{const D=_[S.rule_uid],$=S.url_pattern?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"muted",children:[S.pattern_kind,":"]})," ",s.jsx("code",{children:S.url_pattern})]}):s.jsx("span",{className:"muted",children:"global (all URLs)"});return s.jsxs("tr",{children:[s.jsx("td",{children:$}),s.jsx("td",{children:D?s.jsxs(s.Fragment,{children:[s.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:12,width:"100%",minHeight:60},value:D.cookiesInput,onChange:G=>h(te=>({...te,[S.rule_uid]:{...te[S.rule_uid],cookiesInput:G.target.value}}))}),D.msg&&s.jsx("div",{className:`form-msg form-msg--${D.msg.ok?"ok":"err"}`,children:D.msg.text}),s.jsxs("div",{style:{display:"flex",gap:8,marginTop:4},children:[s.jsx("button",{className:"btn-primary",style:{fontSize:12,padding:"2px 8px"},disabled:D.saving,onClick:()=>T(S),children:D.saving?"Saving…":"Save"}),s.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>C(S.rule_uid),children:"Cancel"})]})]}):s.jsx("code",{style:{fontSize:12,wordBreak:"break-all"},children:S.cookies_json})}),s.jsx("td",{children:!D&&s.jsxs("div",{style:{display:"flex",gap:6},children:[s.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>j(S),children:"Edit"}),s.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"2px 8px"},onClick:()=>x(S.rule_uid),children:"Del"})]})})]},S.rule_uid)})})]}):s.jsx("p",{className:"muted",style:{marginBottom:16},children:"No cookie rules defined."}),s.jsx("h3",{style:{marginBottom:8},children:"Add Rule"}),s.jsxs("form",{onSubmit:v,children:[s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",children:"Pattern type"}),s.jsxs("select",{className:"field-input",value:a,onChange:S=>o(S.target.value),children:[s.jsx("option",{value:"global",children:"Global (all URLs)"}),s.jsx("option",{value:"wildcard",children:"Wildcard (e.g. *.youtube.com)"}),s.jsx("option",{value:"regex",children:"Regex (matched against full URL)"})]})]}),a!=="global"&&s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",children:a==="wildcard"?"URL/hostname pattern":"Regex pattern"}),s.jsx("input",{className:"field-input",type:"text",value:u,onChange:S=>c(S.target.value),placeholder:a==="wildcard"?"*.youtube.com or https://example.com/*":".*\\.youtube\\.com.*",required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",children:"Cookies (JSON object)"}),s.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:13,minHeight:70},value:g,onChange:S=>m(S.target.value),placeholder:'{"SESSION": "abc123", "token": "xyz"}',required:!0})]}),f&&s.jsx("div",{className:`form-msg form-msg--${f.ok?"ok":"err"}`,children:f.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:w,children:w?"Adding…":"Add Rule"})]})]})})}function xm(){const[e,t]=p.useState(null),[n,r]=p.useState(!0),[l,i]=p.useState(!1),[a,o]=p.useState(null);p.useEffect(()=>{(async()=>{try{t(await Ia())}catch(_){o({ok:!1,text:_.message})}finally{r(!1)}})()},[]);async function u(_){i(!0),o(null);try{await xl({ublock_enabled:_}),t(h=>({...h,ublock_enabled:_})),o({ok:!0,text:"Saved."})}catch(h){o({ok:!1,text:h.message})}finally{i(!1)}}async function c(_){i(!0),o(null);try{await xl({cookie_ext_enabled:_}),t(h=>({...h,cookie_ext_enabled:_})),o({ok:!0,text:"Saved."})}catch(h){o({ok:!1,text:h.message})}finally{i(!1)}}async function g(_){i(!0),o(null);try{await xl({modal_closer_enabled:_}),t(h=>({...h,modal_closer_enabled:_})),o({ok:!0,text:"Saved."})}catch(h){o({ok:!1,text:h.message})}finally{i(!1)}}if(n)return s.jsx("div",{className:"muted",children:"Loading\\u2026"});const m=(e==null?void 0:e.ublock_ext_available)??!1,f=(e==null?void 0:e.ublock_enabled)??!0,k=(e==null?void 0:e.cookie_ext_available)??!1,w=(e==null?void 0:e.cookie_ext_enabled)??!0,y=(e==null?void 0:e.modal_closer_enabled)??!0;return s.jsx("div",{children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Extensions"}),s.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."}),s.jsxs("div",{className:"ext-grid",children:[s.jsx("div",{className:"ext-card",children:s.jsxs("div",{className:"ext-card-header",children:[s.jsxs("div",{className:"ext-card-info",children:[s.jsx("span",{className:"ext-card-name",children:"uBlock Origin Lite"}),s.jsx("span",{className:"ext-card-desc",children:"Blocks ads, trackers, and other page clutter during archiving via Chrome’s declarativeNetRequest API (Manifest V3)."}),!m&&s.jsxs("span",{className:"ext-card-hint",children:["Not configured — set ",s.jsx("code",{children:"ARCHIVR_UBLOCK_EXT"})," to the unpacked extension directory to enable."]})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":f,className:`ext-toggle${f?" ext-toggle--on":""}`,onClick:()=>u(!f),disabled:l,"aria-label":"Toggle uBlock Origin Lite",children:s.jsx("span",{className:"ext-toggle-knob"})})]})}),s.jsx("div",{className:"ext-card",children:s.jsxs("div",{className:"ext-card-header",children:[s.jsxs("div",{className:"ext-card-info",children:[s.jsx("span",{className:"ext-card-name",children:"I Still Don’t Care About Cookies"}),s.jsx("span",{className:"ext-card-desc",children:"Dismiss cookie consent banners during archiving."}),!k&&s.jsxs("span",{className:"ext-card-hint",children:["Not configured — set ",s.jsx("code",{children:"ARCHIVR_COOKIE_EXT"})," to the unpacked extension directory to enable."]})]}),s.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:s.jsx("span",{className:"ext-toggle-knob"})})]})}),s.jsx("div",{className:"ext-card",children:s.jsxs("div",{className:"ext-card-header",children:[s.jsxs("div",{className:"ext-card-info",children:[s.jsx("span",{className:"ext-card-name",children:"Modal & Dialog Closer"}),s.jsx("span",{className:"ext-card-desc",children:"Auto-dismiss cookie banners, consent overlays, and other modal dialogs before a WebPage capture is taken. Implemented as an injected browser script; no external extension required."})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":y,className:`ext-toggle${y?" ext-toggle--on":""}`,onClick:()=>g(!y),disabled:l,"aria-label":"Toggle Modal and Dialog Closer",children:s.jsx("span",{className:"ext-toggle-knob"})})]})})]}),a&&s.jsx("div",{className:`form-msg form-msg--${a.ok?"ok":"err"}`,children:a.text})]})})}const eu={0:"Private",1:"Public",2:"Users only",3:"Public"},wm=()=>s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M7 17 17 7M9 7h8v8"})});function km({archiveId:e,selectedEntry:t,selectedUids:n,selectedEntries:r,detail:l,onTagFilterSet:i,tagNodes:a,onTagsRefresh:o,onEntryTitleChange:u,onEntryDeleted:c,onBulkDeleted:g,humanizeTags:m,onDetailRefresh:f,onOpenPreview:k,onPlay:w}){const[y,_]=p.useState([]),[h,d]=p.useState(""),[v,x]=p.useState([]),[j,C]=p.useState(""),T=p.useRef(0),S=p.useRef(!1),[D,$]=p.useState(!1),[G,te]=p.useState(""),[ee,ve]=p.useState("idle"),[ke,ye]=p.useState(""),se=p.useRef(null),z=(n==null?void 0:n.size)>=2,[E,F]=p.useState(""),[X,B]=p.useState("idle"),[N,I]=p.useState(""),[H,U]=p.useState([]),[W,ce]=p.useState(""),[J,Q]=p.useState("idle"),[Y,de]=p.useState(""),[R,V]=p.useState("idle");p.useEffect(()=>{const b=++T.current;if(se.current&&(clearInterval(se.current),se.current=null),ve("idle"),ye(""),!t||!e){_([]),x([]);return}$(!1),te(""),S.current=!1,_([]),Promise.all([sl(e,t.entry_uid),Mh(e,t.entry_uid)]).then(([ne,$e])=>{b===T.current&&(_(ne),x($e))}).catch(()=>{})},[t,e]),p.useEffect(()=>()=>{clearInterval(se.current)},[]),p.useEffect(()=>{if(!z||!e){U([]);return}wd(e).then(U).catch(()=>U([]))},[z,e]),p.useEffect(()=>{F(""),B("idle"),I(""),ce(""),Q("idle"),de(""),V("idle")},[n]);async function Ee(){const b=n.size;if(!window.confirm(`Delete ${b} entr${b===1?"y":"ies"}? This cannot be undone.`))return;V("running");const ne=new Set;for(const $e of n)try{await qo(e,$e),ne.add($e)}catch{}V("idle"),g==null||g(ne)}async function xe(){const b=E.trim();if(b){B("running"),I("");try{for(const ne of n)await Jo(e,ne,b);F(""),B("done"),o==null||o(),setTimeout(()=>B("idle"),1800)}catch(ne){I(ne.message),B("error")}}}async function os(){if(!W)return;Q("running"),de("");const b=[];for(const ne of n)try{await kd(e,W,ne)}catch{b.push(ne)}b.length>0?(de(`Failed for ${b.length} entr${b.length===1?"y":"ies"}.`),Q("error")):(Q("done"),setTimeout(()=>Q("idle"),1800))}async function Ar(){const b=G.trim()||null;try{await ph(e,t.entry_uid,b),u==null||u(t.entry_uid,b)}catch{}finally{$(!1)}}async function Mr(){const b=h.trim();if(!(!b||!t))try{await Jo(e,t.entry_uid,b),d(""),C("");const ne=await sl(e,t.entry_uid);_(ne),o()}catch(ne){C(ne.message)}}async function us(b){try{await hh(e,t.entry_uid,b);const ne=await sl(e,t.entry_uid);_(ne),o()}catch{}}async function cs(){if(!(!t||!e)&&window.confirm("Delete this entry? This cannot be undone."))try{await qo(e,t.entry_uid),c==null||c(t.entry_uid)}catch{}}async function ds(){if(!t||!e||ee==="running")return;const b=T.current,ne=t.entry_uid;ve("running"),ye("");try{const{job_uid:$e}=await Hh(e,ne);if(T.current!==b)return;se.current=setInterval(async()=>{try{const fn=await xd(e,$e);if(fn.status==="completed"){if(clearInterval(se.current),se.current=null,T.current!==b)return;ve("done");const vs=await sl(e,ne);if(T.current!==b)return;_(vs),f==null||f()}else if(fn.status==="failed"){if(clearInterval(se.current),se.current=null,T.current!==b)return;ve("error"),ye(fn.error_text||"Re-archive failed.")}}catch{if(clearInterval(se.current),se.current=null,T.current!==b)return;ve("error"),ye("Network error while polling.")}},500)}catch($e){if(T.current!==b)return;ve("error"),ye($e.message||"Failed to start re-archive.")}}const fs=l?[["Added",Sd(l.summary.archived_at)],["Source",l.summary.source_kind],["Type",l.summary.entity_kind],["Visibility",eu[l.summary.visibility]??l.summary.visibility],["Root",l.structured_root_relpath]]:[],ps=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),hs=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv","pdf","html","htm","jpg","jpeg","png","gif","webp","avif","svg","bmp"]),cn=l?l.artifacts.findIndex(b=>b.artifact_role==="primary_media"):-1,dn=cn>=0?l.artifacts[cn]:null,Fr=dn?dn.relpath.split(".").pop().toLowerCase():"",Br=dn&&ps.has(Fr),ms=cn>=0&&t?`/api/archives/${e}/entries/${t.entry_uid}/artifacts/${cn}`:null,gs=l&&!Br&&(l.summary.entity_kind==="tweet"||l.summary.entity_kind==="tweet_thread"||dn&&hs.has(Fr));return s.jsxs("aside",{className:"context-rail",children:[s.jsx("div",{className:"rail-eyebrow",children:"Context"}),z?s.jsxs("div",{className:"bulk-panel",children:[s.jsxs("p",{className:"bulk-count",children:[s.jsx("span",{className:"bulk-count-num",children:n.size})," entries selected"]}),s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Assign tag"}),N&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:N}),s.jsxs("div",{className:"tag-input-wrap",children:[s.jsx("span",{className:"hash",children:"/"}),s.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:E,onChange:b=>F(b.target.value),onKeyDown:b=>{b.key==="Enter"&&xe()}}),s.jsx("button",{className:"tag-add-btn",onClick:xe,disabled:X==="running"||!E.trim(),children:X==="running"?"…":X==="done"?"✓":"Add"})]})]}),H.length>0&&s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Add to collection"}),s.jsxs("div",{className:"bulk-coll-row",children:[s.jsxs("select",{className:"bulk-coll-select",value:W,onChange:b=>ce(b.target.value),children:[s.jsx("option",{value:"",children:"Pick a collection…"}),H.map(b=>s.jsx("option",{value:b.collection_uid,children:b.name},b.collection_uid))]}),s.jsx("button",{className:"tag-add-btn",onClick:os,disabled:!W||J==="running",children:J==="running"?"…":J==="done"?"✓":J==="error"?"!":"Add"})]}),Y&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"6px 0 0"},children:Y})]}),s.jsx("div",{className:"rail-delete-zone",children:s.jsx("button",{className:"rail-delete-btn",onClick:Ee,disabled:R==="running",children:R==="running"?"Deleting…":`Delete ${n.size} entr${n.size===1?"y":"ies"}`})})]}):t?l?s.jsxs(s.Fragment,{children:[D?s.jsx("input",{className:"rail-title-input",autoFocus:!0,value:G,onChange:b=>te(b.target.value),onKeyDown:b=>{b.key==="Enter"&&b.currentTarget.blur(),b.key==="Escape"&&(S.current=!0,b.currentTarget.blur())},onBlur:()=>{S.current?$(!1):Ar(),S.current=!1}}):s.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{te(l.summary.title??""),$(!0)},children:[Zt(l.summary.title)||Zt(l.summary.entry_uid),s.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:s.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),l.summary.original_url&&s.jsxs("a",{className:"url-tile",href:l.summary.original_url,target:"_blank",rel:"noopener noreferrer",children:[s.jsx("span",{className:"ico",dangerouslySetInnerHTML:{__html:Oa(l.summary.source_kind)}}),s.jsx("span",{className:"u-text",children:l.summary.original_url}),s.jsx("span",{className:"ext",children:s.jsx(wm,{})})]}),Br&&w&&s.jsx("button",{className:"rail-preview-btn",onClick:()=>w(ms,t),children:"▶ Play"}),gs&&k&&s.jsx("button",{className:"rail-preview-btn",onClick:k,children:"Preview"}),s.jsx("div",{className:"meta-list",children:fs.filter(([,b])=>b!=null&&b!=="").map(([b,ne])=>s.jsxs("div",{className:"meta-item",children:[s.jsx("span",{className:"meta-k",children:b}),s.jsx("span",{className:`meta-v${b==="Root"?" mono":""}`,children:Zt(ne)})]},b))}),l.artifacts.length>0&&s.jsxs("div",{className:"rail-section",children:[s.jsxs("div",{className:"rail-section-heading",children:["Artifacts ",s.jsx("span",{className:"num",children:l.artifacts.length})]}),s.jsx("ul",{className:"artifact-list",children:l.artifacts.map((b,ne)=>s.jsx("li",{children:s.jsxs("a",{href:`/api/archives/${e}/entries/${l.summary.entry_uid}/artifacts/${ne}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[s.jsx("span",{className:"artifact-name",children:b.artifact_role.replace(/_/g," ")}),s.jsx("span",{className:"artifact-size",children:b.byte_size!=null?Bi(b.byte_size):"—"})]})},ne))})]})]}):s.jsx("p",{className:"tags-empty",children:"Loading\\u2026"}):s.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&!z&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Tags"}),y.length===0?s.jsx("p",{className:"tags-empty",children:"No tags yet."}):s.jsx("div",{className:"tags-wrap",children:y.map(b=>s.jsxs("span",{className:"tag-pill",title:b.full_path,children:[m?Nd(b.full_path):b.full_path,s.jsx("button",{className:"remove",title:`Remove tag ${b.full_path}`,onClick:()=>us(b.tag_uid),children:"×"})]},b.tag_uid))}),j&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:j}),s.jsxs("div",{className:"tag-input-wrap",children:[s.jsx("span",{className:"hash",children:"/"}),s.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:h,onChange:b=>d(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Mr()}}),s.jsx("button",{className:"tag-add-btn",onClick:Mr,children:"Add"})]})]}),v.length>0&&s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Collections"}),v.map(b=>s.jsxs("div",{className:"coll-row",children:[s.jsx("span",{className:"coll-name",children:b.collection_uid}),s.jsx("span",{className:"vis-badge",children:eu[b.visibility_bits]??`bits:${b.visibility_bits}`})]},b.collection_uid))]}),l&&(l.summary.entity_kind==="tweet"||l.summary.entity_kind==="tweet_thread")&&s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Actions"}),s.jsx("button",{className:"rail-rearchive-btn",onClick:ds,disabled:ee==="running",children:ee==="running"?"Re-archiving…":"Re-archive"}),ee==="done"&&s.jsx("p",{className:"form-msg form-msg--ok",style:{marginTop:"6px"},children:"Re-archived successfully."}),ee==="error"&&s.jsx("p",{className:"form-msg form-msg--err",style:{marginTop:"6px"},children:ke})]}),s.jsx("div",{className:"rail-delete-zone",children:s.jsx("button",{className:"rail-delete-btn",onClick:cs,children:"Delete entry"})})]})]})}function jm({src:e}){const t=p.useRef(null);return p.useEffect(()=>{t.current&&t.current.load()},[e]),s.jsx("div",{className:"preview-video-wrap",style:{background:"#111",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:"240px"},children:e?s.jsxs("video",{ref:t,controls:!0,autoPlay:!1,style:{width:"100%",maxHeight:"100%",display:"block"},children:[s.jsx("source",{src:e}),"Your browser does not support the video element."]}):s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No video available"})})}function tu({src:e,type:t,title:n,originalUrl:r}){const l=r||e,i=n||null;return s.jsxs("div",{className:"preview-iframe-wrap",style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[s.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:[i&&s.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--ink)",fontFamily:"var(--sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[s.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.78rem",color:"var(--muted)",fontFamily:"var(--sans)"},children:l}),s.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 ↗"})]})]}),s.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:i||(t==="pdf"?"PDF preview":"Page preview")})]})}function Sm({src:e,alt:t}){return s.jsx("div",{className:"preview-image-wrap",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",background:"var(--paper-2)",overflow:"hidden"},children:s.jsx("a",{href:e,target:"_blank",rel:"noreferrer noopener",style:{display:"contents"},children:s.jsx("img",{src:e,alt:t||"",style:{objectFit:"contain",maxHeight:"100%",maxWidth:"100%",display:"block",cursor:"pointer"}})})})}function Cd(e){return e?new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(e*1e3)):""}function nu(e){return!e||!e.includes("&")?e:e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}const O={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 Nm(e,t,n){const r={};return n&&n.forEach((l,i)=>{l.relpath&&(r[l.relpath]=`/api/archives/${e}/entries/${t}/artifacts/${i}`)}),r}function bn(e,t,n){return e&&n[e]?n[e]:t||null}function Ed(){return s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",style:{flexShrink:0,color:"var(--ink)"},children:s.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 Aa(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 i=t.indexOf(l);if(i!==-1)return{s:i,e:i+l.length}}return null}function Td(e,t){const n=e.expanded_url||e.url||e.text||"",r=e.display_url||e.expanded_url||e.url||e.text||"",l=Aa(e,t,e.url,e.text,e.display_url,e.expanded_url);return!l||!n?null:{...l,kind:"url",href:n,display:r}}function Pd(e,t){const n=e.screen_name||e.name||e.text||"",r=n?`@${n}`:null,l=Aa(e,t,r);return!l||!n?null:{...l,kind:"mention",screen_name:n}}const ru=/https?:\/\/[^\s<>"'\])]+/g,_m=/[.,;:!?)()]+$/;function Wl(e,t){const n=[];let r=0,l;for(ru.lastIndex=0;(l=ru.exec(e))!==null;){l.index>r&&n.push(e.slice(r,l.index));let i=l[0].replace(_m,"");n.push(s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",style:t,children:i},l.index));const a=l[0].slice(i.length);a&&n.push(a),r=l.index+l[0].length}return r===0?e:(rTd(o,e)).filter(Boolean),...(t.user_mentions||[]).map(o=>Pd(o,e)).filter(Boolean)];if(r.length===0&&n.length===0)return Wl(nu(e),O.link);const l=new Set([0,e.length]);for(const o of r)o.s>=0&&o.s<=e.length&&l.add(o.s),o.e>=0&&o.e<=e.length&&l.add(o.e);for(const[o,u]of n)o>=0&&o<=e.length&&l.add(o),u>=0&&u<=e.length&&l.add(u);const i=(o,u)=>n.some(([c,g])=>c<=o&&g>=u),a=[...l].sort((o,u)=>o-u);return a.slice(0,-1).map((o,u)=>{const c=a[u+1];if(i(o,c))return null;const g=e.slice(o,c),m=r.filter(w=>w.s<=o&&w.e>=c),f=m.find(w=>w.kind==="url");if(f)return s.jsx("a",{href:f.href,target:"_blank",rel:"noopener noreferrer",style:O.link,children:f.display||g},u);const k=m.find(w=>w.kind==="mention");return k?s.jsx("a",{href:`https://x.com/${k.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:O.link,children:g},u):s.jsx("span",{children:Wl(nu(g),O.link)},u)}).filter(o=>o!==null)}function Em(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=Td(o,e);u&&l.push(u)}for(const o of r){const u=Pd(o,e);u&&l.push(u)}if(l.length===0)return Wl(e,O.link);const i=new Set([0,e.length]);for(const o of l)o.s>=0&&o.s<=e.length&&i.add(o.s),o.e>=0&&o.e<=e.length&&i.add(o.e);const a=[...i].sort((o,u)=>o-u);return a.slice(0,-1).map((o,u)=>{const c=a[u+1],g=l.filter(y=>y.s<=o&&y.e>=c),m=e.slice(o,c);let f;if(m.includes(` -`)){const y=m.split(` -`);f=y.flatMap((_,h)=>hy.kind==="style"&&y.style==="Code")&&(f=s.jsx("code",{style:O.iCode,children:f})),g.some(y=>y.kind==="style"&&y.style==="Bold")&&(f=s.jsx("strong",{children:f})),g.some(y=>y.kind==="style"&&y.style==="Italic")&&(f=s.jsx("em",{children:f})),g.some(y=>y.kind==="style"&&y.style==="Underline")&&(f=s.jsx("u",{children:f})),g.some(y=>y.kind==="style"&&y.style==="Strikethrough")&&(f=s.jsx("s",{children:f}));const k=g.find(y=>y.kind==="url");if(k){const y=/^https?:\/\/t\.co\//i.test(f);f=s.jsx("a",{href:k.href,target:"_blank",rel:"noopener noreferrer",style:O.link,children:y?k.display:f})}const w=g.find(y=>y.kind==="mention");return w&&(f=s.jsx("a",{href:`https://x.com/${w.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:O.link,children:f})),s.jsx("span",{children:typeof f=="string"?Wl(f,O.link):f},u)})}function Tm(e,t,n){const r=e.resolved_entities||[];return r.length===0?null:r.map((l,i)=>{var a;switch(l.type){case"divider":return s.jsx("hr",{style:O.bHr},i);case"media":{const o=bn(l.local_path,l.url,t);return o?s.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:s.jsx("img",{src:o,style:O.bImg,loading:"lazy",alt:""})},i):null}case"tweet":return l.tweet_id?s.jsxs("a",{href:`https://x.com/i/status/${l.tweet_id}`,target:"_blank",rel:"noopener noreferrer",style:O.bTweet,children:[s.jsx(Ed,{}),"View post on X"]},i):null;case"link":return l.url?s.jsx("p",{style:O.bP,children:s.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",style:O.link,children:l.url})},i):null;case"markdown":{const o=l.markdown??((a=l.data)==null?void 0:a.markdown)??"";return s.jsx("pre",{style:O.bMdPre,children:s.jsx("code",{style:O.bMdCode,children:o})},i)}case"emoji":return l.url?s.jsx("img",{src:l.url,alt:"",style:{height:"1.2em",verticalAlign:"middle",margin:"0 1px"}},i):null;default:return null}})}function Qs(e,t,n,r){const l=e.type||"",i=e.text||"",a=e.inline_style_ranges||[],o=e.data||{},u=Em(i,a,o.urls||[],o.mentions||[]);switch(l){case"header-one":return s.jsx("h1",{style:O.bH1,children:u},t);case"header-two":{const c=i.match(/(?:x\.com|twitter\.com)\/i\/status\/(\d+)/);return c?s.jsxs("a",{href:`https://x.com/i/status/${c[1]}`,target:"_blank",rel:"noopener noreferrer",style:O.bTweet,children:[s.jsx(Ed,{}),"View post on X"]},t):s.jsx("h2",{style:O.bH2,children:u},t)}case"unstyled":return i.trim()?s.jsx("p",{style:O.bP,children:u},t):s.jsx("span",{style:O.bSpacer},t);case"blockquote":return s.jsx("blockquote",{style:O.bQuote,children:u},t);case"unordered-list-item":case"ordered-list-item":return s.jsx("li",{style:O.bLi,children:u},t);case"atomic":return s.jsx("span",{children:Tm(e,n,r)},t);default:return i?s.jsx("p",{style:O.bP,children:u},t):null}}function Pm(e,t,n){const r=[];let l=0;for(;ll(null)}),g&&s.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:s.jsx("img",{src:g,style:O.aCover,alt:"Article cover"})}),s.jsxs("div",{style:O.aMeta,children:[e.title&&s.jsx("div",{style:O.aTweetTitle,children:e.title}),s.jsxs("div",{style:O.aAuthorRow,children:[m?s.jsx("img",{src:m,style:O.aAvatar,alt:a.name||""}):s.jsx("div",{style:O.aAvatarPh}),s.jsxs("div",{children:[s.jsx("div",{style:O.aAuthorName,children:a.name||a.screen_name||"Unknown"}),c&&s.jsx("div",{style:O.aAuthorSub,children:c})]})]})]}),s.jsx("hr",{style:O.aDivider}),s.jsx("div",{style:O.aBody,children:Pm(e.blocks||[],n,{onImgClick:l})})]})}function zm({photos:e,onOpen:t}){const n=e.length;if(n===0)return null;if(n===1)return s.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:s.jsx("img",{src:e[0].src,alt:e[0].alt||"",style:O.mediaImg,loading:"lazy"})});const r=n<=2?"180px":"140px";return s.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gridTemplateRows:n===2?r:`${r} ${r}`,gap:"2px"},children:e.map((l,i)=>s.jsx("a",{href:l.src,target:"_blank",rel:"noopener noreferrer",style:{display:"block",overflow:"hidden",gridRow:n===3&&i===0?"span 2":void 0},onClick:a=>{!a.metaKey&&!a.ctrlKey&&(a.preventDefault(),t(i))},children:s.jsx("img",{src:l.src,alt:l.alt||"",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})},i))})}function Ld({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 i=e[r];return s.jsx("div",{style:O.lightboxBackdrop,onClick:n,children:s.jsxs("div",{style:O.lightboxContent,onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{style:O.lightboxToolbar,children:[e.length>1&&s.jsxs("span",{style:O.lightboxCounter,children:[r+1," / ",e.length]}),s.jsx("a",{href:i.src,target:"_blank",rel:"noopener noreferrer",style:O.lightboxLink,title:"Open in new tab",children:"↗"}),s.jsx("button",{style:O.lightboxBtn,onClick:n,"aria-label":"Close",children:"×"})]}),s.jsx("img",{src:i.src,alt:i.alt||"",style:O.lightboxImg}),e.length>1&&s.jsxs("div",{style:O.lightboxNav,children:[s.jsx("button",{style:O.lightboxNavBtn,onClick:()=>l(a=>Math.max(a-1,0)),disabled:r===0,children:"‹"}),s.jsx("button",{style:O.lightboxNavBtn,onClick:()=>l(a=>Math.min(a+1,e.length-1)),disabled:r===e.length-1,children:"›"})]})]})})}function lu({tweet:e,isInThread:t,isLast:n,artifactMap:r}){var d,v;const[l,i]=p.useState(null),a=e.author||{},o=e.created_at_secs?Cd(e.created_at_secs):"",u=e.entities||{},c=bn(a.avatar_local_path,a.avatar_url,r),g=t&&!n,m=e.is_quote_status===!0,f=t?O.tweetRowThread:O.tweetRow,k=e.full_text||"",w=((v=(d=e.extended_entities)==null?void 0:d.media)!=null&&v.length?e.extended_entities.media:u.media)||[],y=[],_=[];for(const x of w)if(x.type==="photo"){const j=bn(x.local_path,x.media_url_https,r);j&&y.push({kind:"photo",src:j,alt:x.alt_text||""})}else if(x.type==="video"||x.type==="animated_gif"){const j=x.local_path&&r[x.local_path]||(()=>{var T,S;return(S=(((T=x.video_info)==null?void 0:T.variants)||[]).filter(D=>D.content_type==="video/mp4").sort((D,$)=>($.bitrate||0)-(D.bitrate||0))[0])==null?void 0:S.url})();j&&_.push({kind:x.type==="animated_gif"?"gif":"video",src:j})}const h=[];for(const x of w){if(!x.url||!(x.type==="photo"?y.some(T=>T.src===bn(x.local_path,x.media_url_https,r)):_.length>0))continue;const C=Aa(x,k,x.url);C&&h.push([C.s,C.e])}return s.jsxs(s.Fragment,{children:[l!==null&&s.jsx(Ld,{items:y,startIndex:l,onClose:()=>i(null)}),s.jsxs("div",{style:f,children:[s.jsxs("div",{style:O.leftCol,children:[c?s.jsx("img",{src:c,style:O.avatar,alt:a.name||""}):s.jsx("div",{style:O.avatarPh}),g&&s.jsx("div",{style:O.threadLine})]}),s.jsxs("div",{style:O.rightCol,children:[s.jsxs("div",{style:O.authorRow,children:[s.jsx("span",{style:O.authorName,children:a.name||a.screen_name||"Unknown"}),a.screen_name&&s.jsxs("span",{style:O.authorHandle,children:["@",a.screen_name]}),o&&s.jsxs("span",{style:O.datePart,children:["· ",o]}),m&&s.jsx("span",{style:O.qtBadge,title:"Quote tweet",children:"↻ QT"})]}),s.jsx("div",{style:O.tweetText,children:Cm(k,u,h)}),y.length>0&&s.jsx("div",{style:O.mediaGrid,children:s.jsx(zm,{photos:y,onOpen:x=>i(x)})}),_.map((x,j)=>s.jsx("div",{style:O.mediaGrid,children:s.jsx("video",{src:x.src,style:O.mediaVideo,controls:!0,loop:x.kind==="gif",muted:x.kind==="gif",autoPlay:x.kind==="gif"})},j)),(e.retweet_count>0||e.favorite_count>0)&&s.jsxs("div",{style:O.stats,children:[e.favorite_count>0&&s.jsxs("span",{children:["❤️ ",e.favorite_count.toLocaleString()]}),e.retweet_count>0&&s.jsxs("span",{children:["🔁 ",e.retweet_count.toLocaleString()]})]})]})]})]})}function Rm({archiveId:e,entryUid:t,artifacts:n,entityKind:r}){const[l,i]=p.useState(!0),[a,o]=p.useState(null),[u,c]=p.useState([]);if(p.useEffect(()=>{if(i(!0),o(null),c([]),!n||!e||!t){i(!1);return}const f=n.map((w,y)=>({...w,index:y})).filter(w=>w.artifact_role==="raw_tweet_json");if(f.length===0){o("No tweet data found."),i(!1);return}let k=!1;return dh(e,t,f.map(w=>w.index)).then(async w=>{if(k)return;const y=/https?:\/\/t\.co\/[A-Za-z0-9]+/g,_=j=>{var T;const C=j.full_text||"";return(((T=j.entities)==null?void 0:T.urls)||[]).map(S=>{var D;if(S.fromIndex!=null&&S.toIndex!=null)return[S.fromIndex,S.toIndex];if(((D=S.indices)==null?void 0:D.length)===2)return[S.indices[0],S.indices[1]];if(S.url){const $=C.indexOf(S.url);if($!==-1)return[$,$+S.url.length]}return null}).filter(Boolean)},h=(j,C,T)=>j.some(([S,D])=>S<=C&&D>=T),d=new Set;for(const j of w){const C=j.full_text||"",T=_(j);let S;for(y.lastIndex=0;(S=y.exec(C))!==null;)h(T,S.index,S.index+S[0].length)||d.add(S[0])}const v=d.size>0?await fh([...d]).catch(()=>({})):{},x=w.map(j=>{var $;const C=j.full_text||"",T=_(j),S=[];let D;for(y.lastIndex=0;(D=y.exec(C))!==null;){const G=D[0],te=v[G];te&&te!==G&&!h(T,D.index,D.index+G.length)&&S.push({url:G,expanded_url:te,display_url:(()=>{try{const ee=new URL(te);return ee.hostname+(ee.pathname.length>1?"/…":"")}catch{return te}})(),fromIndex:D.index,toIndex:D.index+G.length})}return S.length===0?j:{...j,entities:{...j.entities||{},urls:[...(($=j.entities)==null?void 0:$.urls)||[],...S]}}});k||c(x)}).catch(w=>{k||o(w.message||"Failed to load tweet.")}).finally(()=>{k||i(!1)}),()=>{k=!0}},[e,t,n]),l)return s.jsx("div",{style:O.loading,children:"Loading…"});if(a)return s.jsxs("div",{style:O.error,children:["Error: ",a]});if(u.length===0)return null;const g=Nm(e,t,n);if(r==="tweet_thread")return s.jsx("div",{style:O.threadOuter,children:u.map((f,k)=>s.jsx(lu,{tweet:f,isInThread:!0,isLast:k===u.length-1,artifactMap:g},f.id||k))});const m=u[0];return m.is_article&&m.article?s.jsx(Lm,{article:m.article,tweetAuthor:m.author,artifactMap:g}):s.jsx("div",{style:O.card,children:s.jsx(lu,{tweet:m,isInThread:!1,isLast:!0,artifactMap:g})})}const bm=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv"]),Dm=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),$m=new Set(["jpg","jpeg","png","gif","webp","avif","svg","bmp"]);function zd({archiveId:e,entry:t,detail:n}){if(!t)return s.jsx("div",{className:"preview-panel preview-panel--empty",children:s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Select an entry to preview"})});if(!n)return s.jsx("div",{className:"preview-panel preview-panel--loading",children:s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"Loading…"})});const{summary:r,artifacts:l}=n,i=r.entry_uid,a=r.entity_kind;if(a==="tweet"||a==="tweet_thread")return s.jsx("div",{className:"preview-tweet-wrap",children:s.jsx(Rm,{archiveId:e,entryUid:i,artifacts:l,entityKind:a})});const o=l.findIndex(m=>m.artifact_role==="primary_media");if(o===-1)return s.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),l.length>0&&s.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:l.map((m,f)=>s.jsxs("li",{children:[m.artifact_role,": ",m.relpath]},f))})]});const u=l[o],c=`/api/archives/${e}/entries/${i}/artifacts/${o}`,g=u.relpath.split(".").pop().toLowerCase();return bm.has(g)?s.jsx("div",{className:"preview-panel",children:s.jsx(jm,{src:c})}):Dm.has(g)?s.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:[s.jsx("span",{style:{fontSize:"2rem"},children:"🎵"}),s.jsx("span",{style:{color:"var(--ink)",fontSize:"0.95rem",fontWeight:600},children:r.title||i}),s.jsx("audio",{src:c,controls:!0,style:{marginTop:"8px",width:"100%",maxWidth:"400px"}})]}):g==="pdf"?s.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:s.jsx(tu,{src:c,type:"pdf",title:r.title,originalUrl:r.original_url})}):g==="html"||g==="htm"?s.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:s.jsx(tu,{src:c,type:"page",title:r.title,originalUrl:r.original_url})}):$m.has(g)?s.jsx("div",{className:"preview-panel",style:{height:"100%"},children:s.jsx(Sm,{src:c,alt:r.title||"Image"})}):s.jsxs("div",{className:"preview-panel preview-panel--no-preview",children:[s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No preview available"}),s.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:l.map((m,f)=>s.jsxs("li",{children:[m.artifact_role,": ",m.relpath]},f))})]})}function Im({archiveId:e,entry:t,detail:n,onClose:r}){var l,i;return p.useEffect(()=>{const a=o=>{o.key==="Escape"&&r()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),s.jsx("div",{className:"preview-modal-backdrop",onClick:r,children:s.jsxs("div",{className:`preview-modal${((l=n==null?void 0:n.summary)==null?void 0:l.entity_kind)==="tweet"||((i=n==null?void 0:n.summary)==null?void 0:i.entity_kind)==="tweet_thread"?"":" preview-modal--full"}`,onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"preview-modal-header",children:[s.jsx("span",{className:"preview-modal-title",children:(t==null?void 0:t.title)||(t==null?void 0:t.entry_uid)||"Preview"}),s.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:"↗"}),s.jsx("button",{className:"preview-modal-close",onClick:r,"aria-label":"Close preview",children:"×"})]}),s.jsx("div",{className:"preview-modal-body",children:s.jsx(zd,{archiveId:e,entry:t,detail:n})})]})})}function su(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 Om({entry:e,src:t,archiveId:n,onClose:r}){const l=p.useRef(null),[i,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 k(){const d=l.current;d&&(i?d.pause():d.play().catch(()=>{}))}function w(d){const v=l.current;if(!v||!isFinite(c))return;const x=Number(d.target.value);v.currentTime=x,u(x)}function y(d){f(Number(d.target.value))}const _=(e==null?void 0:e.title)||(e==null?void 0:e.entry_uid)||"Unknown",h=(e==null?void 0:e.source_kind)||"other";return s.jsxs(s.Fragment,{children:[s.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"}}),s.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:[s.jsxs("div",{className:"audio-bar-info",style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0,flex:"0 1 220px",overflow:"hidden"},children:[s.jsx("span",{className:"source-icon",style:{flexShrink:0,width:"18px",height:"18px",display:"flex",alignItems:"center"},dangerouslySetInnerHTML:{__html:Oa(h)}}),s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.85rem",color:"var(--ink)"},title:_,children:_})]}),s.jsxs("div",{className:"audio-bar-controls",style:{display:"flex",alignItems:"center",gap:"10px",flex:"1 1 0",minWidth:0},children:[s.jsx("button",{onClick:k,"aria-label":i?"Pause":"Play",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"var(--ink)",flexShrink:0,fontSize:"1.2rem",lineHeight:1},children:i?"⏸":"▶"}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:su(o)}),s.jsx("input",{type:"range",min:0,max:isFinite(c)?c:0,step:.1,value:isFinite(o)?o:0,onChange:w,"aria-label":"Seek",style:{flex:1,minWidth:0,accentColor:"var(--accent)"}}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--muted)",whiteSpace:"nowrap",flexShrink:0},children:su(c)})]}),s.jsxs("div",{className:"audio-bar-right",style:{display:"flex",alignItems:"center",gap:"8px",flex:"0 1 160px"},children:[s.jsx("span",{style:{fontSize:"0.85rem",color:"var(--muted)",flexShrink:0},children:"🔊"}),s.jsx("input",{type:"range",min:0,max:1,step:.01,value:m,onChange:y,"aria-label":"Volume",style:{width:"80px",accentColor:"var(--accent)"}}),s.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 Am({archiveId:e,entryUid:t}){var g,m;const[n,r]=p.useState(null),[l,i]=p.useState(!0),[a,o]=p.useState(null);p.useEffect(()=>{Mi(e,t).then(f=>{r(f),i(!1)}).catch(f=>{o((f==null?void 0:f.message)||"Failed to load entry"),i(!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 s.jsxs("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column",background:"var(--paper)",fontFamily:"var(--sans)"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 16px",borderBottom:"1px solid var(--line)",flexShrink:0,background:"var(--paper-2)"},children:[s.jsx("a",{href:"/",style:{color:"var(--accent)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"← Archive"}),s.jsx("span",{style:{flex:1,fontSize:"14px",fontWeight:600,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),c&&s.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--muted)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"Original ↗"})]}),s.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",display:"flex",flexDirection:"column"},children:[l&&s.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--muted)",fontSize:"14px"},children:"Loading…"}),a&&s.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--alert)",fontSize:"14px"},children:a}),n&&s.jsx(zd,{archiveId:e,entry:n.summary,detail:n})]})]})}const Mm=7e3;function Fm({toasts:e,onDismiss:t,onIgnoreUblock:n}){return e.length?s.jsx("div",{className:"toast-stack",role:"log","aria-live":"polite","aria-label":"Notifications",children:e.map(r=>s.jsx(Um,{toast:r,onDismiss:t,onIgnoreUblock:n},r.id))}):null}function Bm(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),i=(l[l.length-1]??"")+r,a=i?`${t}/…/${i}`:t;return a.length<=56?a:a.slice(0,53)+"…"}catch{return"…"+e.slice(-51)}}function Um({toast:e,onDismiss:t,onIgnoreUblock:n}){const[r,l]=p.useState(!1),i=e.type==="warning",a=e.type==="success";p.useEffect(()=>{if(r)return;const u=setTimeout(()=>t(e.id),Mm);return()=>clearTimeout(u)},[r,e.id,t]);const o=Bm(e.locator);return a?s.jsx("div",{className:"toast toast--success",role:"alert","aria-atomic":"true",children:s.jsxs("div",{className:"toast-top",children:[s.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"✓"}),s.jsxs("div",{className:"toast-body",children:[s.jsx("span",{className:"toast-headline",children:e.headline||"Archived"}),o&&s.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),s.jsx("div",{className:"toast-btns",children:s.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})})]})}):i?s.jsxs("div",{className:"toast toast--warning",role:"alert","aria-atomic":"true",children:[s.jsxs("div",{className:"toast-top",children:[s.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"⚠"}),s.jsxs("div",{className:"toast-body",children:[s.jsx("span",{className:"toast-headline",children:e.headline||"Archived with warnings"}),o&&s.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),s.jsxs("div",{className:"toast-btns",children:[e.text&&s.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),"aria-expanded":r,children:r?"Hide":"Details"}),e.locator&&s.jsx("button",{type:"button",className:"toast-view-btn toast-ignore-btn",onClick:()=>{n==null||n(),t(e.id)},children:"Ignore"}),s.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})]})]}),r&&s.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."})]}):s.jsxs("div",{className:"toast toast--error",role:"alert","aria-atomic":"true",children:[s.jsxs("div",{className:"toast-top",children:[s.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"✕"}),s.jsxs("div",{className:"toast-body",children:[s.jsx("span",{className:"toast-headline",children:e.headline||"Capture failed"}),o&&s.jsx("span",{className:"toast-locator",title:e.locator,children:o})]}),s.jsxs("div",{className:"toast-btns",children:[e.text&&s.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>l(u=>!u),children:r?"Hide":"View error"}),s.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})]})]}),r&&e.text&&s.jsx("pre",{className:"toast-error-detail",children:e.text})]})}const as=p.createContext(null),tr=(()=>{const e=window.location.pathname.match(/^\/preview\/([^/]+)\/([^/]+)/);return e?{archiveId:e[1],entryUid:e[2]}:null})(),Hm=["archive","tags","collections","runs","admin","settings"],Wm=["profile","tokens","instance","cookies","extensions","storage"];function Kt(){const e=window.location.pathname.split("/").filter(Boolean),t=Hm.includes(e[0])?e[0]:"archive",n=t==="settings"&&Wm.includes(e[1])?e[1]:"profile",r=new URLSearchParams(window.location.search),l=r.get("q")??"",i=t==="archive"?r.get("tag")??null:null,a=t==="archive"?r.get("entry")??null:null;return{view:t,settingsTab:n,q:l,tag:i,entry:a}}function Vm(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function Qm(){const[e,t]=p.useState("loading"),[n,r]=p.useState(null);p.useEffect(()=>{(async()=>{if(await xh()){t("setup");return}const M=await Sh();if(!M){t("login");return}r(M),t("authenticated")})()},[]),p.useEffect(()=>{const P=()=>{r(null),t("login")};return window.addEventListener("auth:expired",P),()=>window.removeEventListener("auth:expired",P)},[]),p.useEffect(()=>{const P=()=>{const{view:M,settingsTab:K,q:le,tag:rt,entry:gt}=Kt();v(M),j(K),T(le),h(rt),m(gt),k(null),y(gt?new Set([gt]):new Set)};return window.addEventListener("popstate",P),()=>window.removeEventListener("popstate",P)},[]);const[l,i]=p.useState([]),[a,o]=p.useState(null),[u,c]=p.useState([]),[g,m]=p.useState(()=>Kt().entry),[f,k]=p.useState(null),[w,y]=p.useState(()=>{const P=Kt().entry;return P?new Set([P]):new Set}),[_,h]=p.useState(()=>Kt().tag),[d,v]=p.useState(()=>Kt().view),[x,j]=p.useState(()=>Kt().settingsTab),[C,T]=p.useState(()=>Kt().q),[S,D]=p.useState(""),[$,G]=p.useState(!1),[te,ee]=p.useState([]),[ve,ke]=p.useState([]),[ye,se]=p.useState(()=>sessionStorage.getItem("captureDialogOpen")==="true"),[z,E]=p.useState([]),F=p.useRef(0),[X,B]=p.useState(()=>sessionStorage.getItem("ublockWarningIgnored")==="true"),[N,I]=p.useState(null),H=p.useRef(0),U=p.useRef(null),W=p.useRef(!1),ce=p.useRef(!0),J=p.useRef(null),Q=(n==null?void 0:n.humanize_slugs)??!1;p.useEffect(()=>{const P=++H.current;I(null),!(!f||!a)&&Mi(a,f.entry_uid).then(M=>{P===H.current&&I(M)}).catch(()=>{})},[f,a]),p.useEffect(()=>{sessionStorage.setItem("captureDialogOpen",ye)},[ye]);const Y=p.useCallback(async(P,M,K)=>{if(P){G(!0);try{let le;M||K?le=await ch(P,M,K):le=await uh(P),c(le),y(rt=>{if(rt.size<2)return rt;const gt=new Set(le.map(pn=>pn.entry_uid)),Wn=new Set([...rt].filter(pn=>gt.has(pn)));return Wn.size===rt.size?rt:Wn}),D(le.length===0?"No results":`${le.length} result${le.length===1?"":"s"}`)}catch{c([]),D("Search failed. Try again.")}finally{G(!1)}}},[]);p.useEffect(()=>{e==="authenticated"&&oh().then(P=>{if(i(P),P.length>0){const M=P[0].id;o(M)}})},[e]),p.useEffect(()=>{if(a){if(ce.current){ce.current=!1,Promise.all([Ws(a).then(ee),il(a).then(ke)]);return}h(null),k(null),m(null),y(new Set),Promise.all([Y(a,"",null),Ws(a).then(ee),il(a).then(ke)])}},[a]),p.useEffect(()=>{if(a===null)return;const P=setTimeout(()=>{Y(a,C,_)},300);return()=>clearTimeout(P)},[C,a]),p.useEffect(()=>{a!==null&&(_!==null&&v("archive"),Y(a,C,_))},[_,a]);const de=p.useCallback(P=>{o(P)},[]),R=p.useCallback(P=>{v(P),P==="tags"&&a&&il(a).then(ke)},[a]);p.useEffect(()=>{if(tr)return;const P=Vm(d,x);window.location.pathname!==P&&history.pushState(null,"",P+window.location.search)},[d,x]);const V=p.useCallback(P=>{m(P?P.entry_uid:null),k(P)},[]),Ee=p.useCallback((P,M)=>{if(M.shiftKey&&J.current!==null){M.preventDefault();const K=u.findIndex(Vn=>Vn.entry_uid===J.current),le=u.findIndex(Vn=>Vn.entry_uid===P.entry_uid);if(K===-1||le===-1){J.current=P.entry_uid,y(new Set([P.entry_uid])),V(P);return}const rt=Math.min(K,le),gt=Math.max(K,le),Wn=u.slice(rt,gt+1),pn=new Set(Wn.map(Vn=>Vn.entry_uid));y(pn),pn.size===1&&V(Wn[0])}else M.ctrlKey||M.metaKey?(J.current=P.entry_uid,y(K=>{const le=new Set(K);return le.has(P.entry_uid)?le.delete(P.entry_uid):le.add(P.entry_uid),le})):(J.current=P.entry_uid,y(new Set([P.entry_uid])),V(P))},[u,V]),xe=p.useCallback(P=>{h(P)},[]),os=p.useCallback(()=>{h(null)},[]),Ar=p.useCallback(()=>{a&&il(a).then(ke)},[a]),Mr=p.useCallback((P,M)=>{_===P?h(M):_!=null&&_.startsWith(P+"/")&&h(M+_.slice(P.length))},[_]),us=p.useCallback(P=>{(_===P||_!=null&&_.startsWith(P+"/"))&&h(null)},[_]),cs=p.useCallback((P,M)=>{c(K=>K.map(le=>le.entry_uid===P?{...le,title:M}:le)),k(K=>K&&K.entry_uid===P?{...K,title:M}:K),I(K=>K&&K.summary.entry_uid===P?{...K,summary:{...K.summary,title:M}}:K)},[]),ds=p.useCallback(()=>{if(!a||!f)return;const P=++H.current;Mi(a,f.entry_uid).then(M=>{P===H.current&&I(M)}).catch(()=>{})},[a,f]),fs=p.useCallback(P=>{c(M=>M.filter(K=>K.entry_uid!==P)),k(M=>(M==null?void 0:M.entry_uid)===P?null:M),m(M=>M===P?null:M),y(M=>{const K=new Set(M);return K.delete(P),K})},[]),ps=p.useCallback(P=>{c(M=>M.filter(K=>!P.has(K.entry_uid))),y(new Set),k(null),m(null)},[]);p.useEffect(()=>{if(w.size>=2)m(null),k(null);else if(w.size===1){const[P]=w;m(P)}else m(null),k(null)},[w]);const hs=p.useMemo(()=>u.filter(P=>w.has(P.entry_uid)),[u,w]);p.useEffect(()=>{if(!g||f)return;const P=u.find(M=>M.entry_uid===g);P&&k(P)},[u,g,f]),p.useEffect(()=>{if(tr)return;const P=new URLSearchParams;C&&P.set("q",C),d==="archive"&&_&&P.set("tag",_),d==="archive"&&g&&P.set("entry",g);const M=P.toString(),K=window.location.pathname+(M?"?"+M:"");window.location.pathname+window.location.search!==K&&history.replaceState(null,"",K)},[C,_,g,d]),p.useEffect(()=>{const P=M=>{var K,le;(M.metaKey||M.ctrlKey)&&M.key==="k"&&(M.preventDefault(),d==="archive"?((K=U.current)==null||K.focus(),(le=U.current)==null||le.select()):(W.current=!0,v("archive")))};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[d]),p.useEffect(()=>{d==="archive"&&W.current&&(W.current=!1,requestAnimationFrame(()=>{var P,M;(P=U.current)==null||P.focus(),(M=U.current)==null||M.select()}))},[d]);const cn=p.useCallback(()=>{se(!0)},[]),dn=p.useCallback(()=>{se(!1)},[]),Fr=p.useCallback(()=>{a&&Promise.all([Y(a,C,_),Ws(a).then(ee)])},[a,C,_,Y]),Br=p.useCallback((P,M,K="error",le=null)=>{if(K==="warning"&&X&&M)return;const rt=++F.current;E(gt=>[...gt,{id:rt,text:P,locator:M,type:K,headline:le}])},[X]),ms=p.useCallback(P=>{E(M=>M.filter(K=>K.id!==P))},[]),gs=p.useCallback(()=>{sessionStorage.setItem("ublockWarningIgnored","true"),B(!0),E(P=>P.filter(M=>!(M.type==="warning"&&M.locator)))},[]),[b,ne]=p.useState(null),[$e,fn]=p.useState(null),vs=p.useCallback(()=>{f&&ne(f.entry_uid)},[f]),Rd=p.useCallback(()=>ne(null),[]),bd=p.useCallback((P,M)=>{fn({src:P,entry:M})},[]),Dd=p.useCallback(()=>fn(null),[]);return p.useEffect(()=>{ne(null)},[f]),p.useEffect(()=>(document.body.classList.toggle("has-audio-bar",!!$e),()=>document.body.classList.remove("has-audio-bar")),[$e]),e==="loading"?s.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?s.jsx(qh,{onComplete:()=>t("login")}):e==="login"?s.jsx(Jh,{onLogin:P=>{r(P),t("authenticated")}}):tr?s.jsx(Am,{archiveId:tr.archiveId,entryUid:tr.entryUid}):s.jsx(as.Provider,{value:{currentUser:n,setCurrentUser:r},children:s.jsxs(s.Fragment,{children:[s.jsx(Gh,{archives:l,archiveId:a,onArchiveChange:de,view:d,onViewChange:R,onCaptureClick:cn}),s.jsxs("main",{className:"app-shell",children:[s.jsxs("div",{className:"workspace",children:[d==="archive"&&s.jsxs("div",{className:"toolbar",children:[s.jsxs("div",{className:"search-field",children:[s.jsx("span",{className:"ico","aria-hidden":"true",children:s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"7"}),s.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}),s.jsx("input",{ref:U,className:"search-input",type:"search","aria-label":"Search archive","aria-busy":$,placeholder:"Search titles, URLs, types, tags…",value:C,onChange:P=>T(P.target.value)}),s.jsx("span",{className:"kbd",children:"⌘K"})]}),s.jsxs("span",{className:"result-count",children:[S&&s.jsxs(s.Fragment,{children:[s.jsx("b",{children:S.split(" ")[0]})," ",S.split(" ").slice(1).join(" ")]}),_&&s.jsxs("button",{className:"tag-filter-badge",onClick:os,children:["× ",Q?Nd(_):_]})]})]}),d==="archive"&&s.jsx(rm,{entries:u,selectedUids:w,onRowClick:Ee,archiveId:a}),d==="runs"&&s.jsx(im,{runs:te}),d==="admin"&&s.jsx(om,{archives:l}),d==="tags"&&s.jsx(um,{archiveId:a,tagNodes:ve,tagFilter:_,onTagFilterSet:xe,onViewChange:R,onTagRenamed:Mr,onTagDeleted:us,onTagsRefresh:Ar,humanizeTags:Q}),d==="collections"&&s.jsx(dm,{archiveId:a}),d==="settings"&&s.jsx(pm,{tab:x,onTabChange:j,archiveId:a})]}),s.jsx(km,{archiveId:a,selectedEntry:f,selectedUids:w,selectedEntries:hs,detail:N,onTagFilterSet:xe,tagNodes:ve,onTagsRefresh:Ar,onEntryTitleChange:cs,onEntryDeleted:fs,onBulkDeleted:ps,humanizeTags:Q,onDetailRefresh:ds,onOpenPreview:vs,onPlay:bd})]}),b&&f&&f.entry_uid===b&&s.jsx(Im,{archiveId:a,entry:f,detail:N,onClose:Rd}),$e&&s.jsx(Om,{entry:$e.entry,src:$e.src,archiveId:a,onClose:Dd}),s.jsx(Yh,{open:ye,archiveId:a,onClose:dn,onCaptured:Fr,onToast:Br}),s.jsx(Fm,{toasts:z,onDismiss:ms,onIgnoreUblock:gs})]})})}yd(document.getElementById("root")).render(s.jsx(p.StrictMode,{children:s.jsx(Qm,{})})); diff --git a/crates/archivr-server/static/assets/index-CVmaVy6J.js b/crates/archivr-server/static/assets/index-CVmaVy6J.js new file mode 100644 index 0000000..8fc0df3 --- /dev/null +++ b/crates/archivr-server/static/assets/index-CVmaVy6J.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 ou={exports:{}},Ql={},uu={exports:{}},G={};/** + * @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 Dr=Symbol.for("react.element"),Od=Symbol.for("react.portal"),Ad=Symbol.for("react.fragment"),Fd=Symbol.for("react.strict_mode"),Md=Symbol.for("react.profiler"),Bd=Symbol.for("react.provider"),Hd=Symbol.for("react.context"),Ud=Symbol.for("react.forward_ref"),Wd=Symbol.for("react.suspense"),Vd=Symbol.for("react.memo"),Qd=Symbol.for("react.lazy"),Ba=Symbol.iterator;function Kd(e){return e===null||typeof e!="object"?null:(e=Ba&&e[Ba]||e["@@iterator"],typeof e=="function"?e:null)}var cu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},du=Object.assign,fu={};function Hn(e,t,n){this.props=e,this.context=t,this.refs=fu,this.updater=n||cu}Hn.prototype.isReactComponent={};Hn.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")};Hn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function pu(){}pu.prototype=Hn.prototype;function Wi(e,t,n){this.props=e,this.context=t,this.refs=fu,this.updater=n||cu}var Vi=Wi.prototype=new pu;Vi.constructor=Wi;du(Vi,Hn.prototype);Vi.isPureReactComponent=!0;var Ha=Array.isArray,hu=Object.prototype.hasOwnProperty,Qi={current:null},mu={key:!0,ref:!0,__self:!0,__source:!0};function gu(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)hu.call(t,r)&&!mu.hasOwnProperty(r)&&(l[r]=t[r]);var o=arguments.length-2;if(o===1)l.children=n;else if(1>>1,M=z[J];if(0>>1;Jl(H,F))Bl(U,H)?(z[J]=U,z[B]=F,J=B):(z[J]=H,z[I]=F,J=I);else if(Bl(U,F))z[J]=U,z[B]=F,J=B;else break e}}return E}function l(z,E){var F=z.sortIndex-E.sortIndex;return F!==0?F:z.id-E.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,h=3,y=!1,x=!1,k=!1,j=typeof setTimeout=="function"?setTimeout:null,p=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(z){for(var E=n(c);E!==null;){if(E.callback===null)r(c);else if(E.startTime<=z)r(c),E.sortIndex=E.expirationTime,t(u,E);else break;E=n(c)}}function w(z){if(k=!1,v(z),!x)if(n(u)!==null)x=!0,xe(S);else{var E=n(c);E!==null&&ie(w,E.startTime-z)}}function S(z,E){x=!1,k&&(k=!1,p(_),_=-1),y=!0;var F=h;try{for(v(E),m=n(u);m!==null&&(!(m.expirationTime>E)||z&&!V());){var J=m.callback;if(typeof J=="function"){m.callback=null,h=m.priorityLevel;var M=J(m.expirationTime<=E);E=e.unstable_now(),typeof M=="function"?m.callback=M:m===n(u)&&r(u),v(E)}else r(u);m=n(u)}if(m!==null)var N=!0;else{var I=n(c);I!==null&&ie(w,I.startTime-E),N=!1}return N}finally{m=null,h=F,y=!1}}var P=!1,C=null,_=-1,$=5,L=-1;function V(){return!(e.unstable_now()-L<$)}function te(){if(C!==null){var z=e.unstable_now();L=z;var E=!0;try{E=C(!0,z)}finally{E?Z():(P=!1,C=null)}}else P=!1}var Z;if(typeof d=="function")Z=function(){d(te)};else if(typeof MessageChannel<"u"){var se=new MessageChannel,de=se.port2;se.port1.onmessage=te,Z=function(){de.postMessage(null)}}else Z=function(){j(te,0)};function xe(z){C=z,P||(P=!0,Z())}function ie(z,E){_=j(function(){z(e.unstable_now())},E)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_continueExecution=function(){x||y||(x=!0,xe(S))},e.unstable_forceFrameRate=function(z){0>z||125J?(z.sortIndex=F,t(c,z),n(u)===null&&z===n(c)&&(k?(p(_),_=-1):k=!0,ie(w,F-J))):(z.sortIndex=M,t(u,z),x||y||(x=!0,xe(S))),z},e.unstable_shouldYield=V,e.unstable_wrapCallback=function(z){var E=h;return function(){var F=h;h=E;try{return z.apply(this,arguments)}finally{h=F}}}})(ku);wu.exports=ku;var lf=wu.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 sf=f,Je=lf;function b(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,af=/^[: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]*$/,Wa={},Va={};function of(e){return Js.call(Va,e)?!0:Js.call(Wa,e)?!1:af.test(e)?Va[e]=!0:(Wa[e]=!0,!1)}function uf(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 cf(e,t,n,r){if(t===null||typeof t>"u"||uf(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 Me(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 Le={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Le[e]=new Me(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Le[t]=new Me(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Le[e]=new Me(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Le[e]=new Me(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){Le[e]=new Me(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Le[e]=new Me(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Le[e]=new Me(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Le[e]=new Me(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Le[e]=new Me(e,5,!1,e.toLowerCase(),null,!1,!1)});var Xi=/[\-:]([a-z])/g;function Ji(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(Xi,Ji);Le[t]=new Me(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(Xi,Ji);Le[t]=new Me(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(Xi,Ji);Le[t]=new Me(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Le[e]=new Me(e,1,!1,e.toLowerCase(),null,!1,!1)});Le.xlinkHref=new Me("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Le[e]=new Me(e,1,!1,e.toLowerCase(),null,!0,!0)});function qi(e,t,n,r){var l=Le.hasOwnProperty(t)?Le[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{ks=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?rr(e):""}function df(e){switch(e.tag){case 5:return rr(e.type);case 16:return rr("Lazy");case 13:return rr("Suspense");case 19:return rr("SuspenseList");case 0:case 2:case 15:return e=js(e.type,!1),e;case 11:return e=js(e.type.render,!1),e;case 1:return e=js(e.type,!0),e;default:return""}}function Zs(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 vn:return"Fragment";case gn:return"Portal";case qs:return"Profiler";case Gi:return"StrictMode";case Gs:return"Suspense";case Ys:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Nu:return(e.displayName||"Context")+".Consumer";case Su:return(e._context.displayName||"Context")+".Provider";case Yi:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Zi:return t=e.displayName||null,t!==null?t:Zs(e.type)||"Memo";case Pt:t=e._payload,e=e._init;try{return Zs(e(t))}catch{}}return null}function ff(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 Zs(t);case 8:return t===Gi?"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 Ut(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Cu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function pf(e){var t=Cu(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 Vr(e){e._valueTracker||(e._valueTracker=pf(e))}function Eu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Cu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function kl(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 ei(e,t){var n=t.checked;return ge({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Ka(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Ut(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 Tu(e,t){t=t.checked,t!=null&&qi(e,"checked",t,!1)}function ti(e,t){Tu(e,t);var n=Ut(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")?ni(e,t.type,n):t.hasOwnProperty("defaultValue")&&ni(e,t.type,Ut(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Xa(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 ni(e,t,n){(t!=="number"||kl(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var lr=Array.isArray;function Tn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Qr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function yr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var or={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},hf=["Webkit","ms","Moz","O"];Object.keys(or).forEach(function(e){hf.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),or[t]=or[e]})});function zu(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||or.hasOwnProperty(e)&&or[e]?(""+t).trim():t+"px"}function Ru(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=zu(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var mf=ge({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 si(e,t){if(t){if(mf[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(b(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(b(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(b(61))}if(t.style!=null&&typeof t.style!="object")throw Error(b(62))}}function ii(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ai=null;function ea(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var oi=null,Pn=null,bn=null;function Ga(e){if(e=Or(e)){if(typeof oi!="function")throw Error(b(280));var t=e.stateNode;t&&(t=Gl(t),oi(e.stateNode,e.type,t))}}function Du(e){Pn?bn?bn.push(e):bn=[e]:Pn=e}function $u(){if(Pn){var e=Pn,t=bn;if(bn=Pn=null,Ga(e),t)for(e=0;e>>=0,e===0?32:31-(Cf(e)/Ef|0)|0}var Kr=64,Xr=4194304;function sr(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 _l(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=sr(o):(s&=a,s!==0&&(r=sr(s)))}else a=n&~l,a!==0?r=sr(a):s!==0&&(r=sr(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 $r(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-ut(t),e[t]=n}function Lf(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=cr),io=" ",ao=!1;function tc(e,t){switch(e){case"keyup":return sp.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function nc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var yn=!1;function ap(e,t){switch(e){case"compositionend":return nc(t);case"keypress":return t.which!==32?null:(ao=!0,io);case"textInput":return e=t.data,e===io&&ao?null:e;default:return null}}function op(e,t){if(yn)return e==="compositionend"||!oa&&tc(e,t)?(e=Zu(),dl=sa=Rt=null,yn=!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=fo(n)}}function ic(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ic(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ac(){for(var e=window,t=kl();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=kl(e.document)}return t}function ua(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 vp(e){var t=ac(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&ic(n.ownerDocument.documentElement,n)){if(r!==null&&ua(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=po(n,s);var a=po(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,xn=null,hi=null,fr=null,mi=!1;function ho(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;mi||xn==null||xn!==kl(r)||(r=xn,"selectionStart"in r&&ua(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}),fr&&Nr(fr,r)||(fr=r,r=Tl(hi,"onSelect"),0jn||(e.current=ki[jn],ki[jn]=null,jn--)}function ae(e,t){jn++,ki[jn]=e.current,e.current=t}var Wt={},$e=Qt(Wt),Ue=Qt(!1),rn=Wt;function In(e,t){var n=e.type.contextTypes;if(!n)return Wt;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 We(e){return e=e.childContextTypes,e!=null}function bl(){ue(Ue),ue($e)}function ko(e,t,n){if($e.current!==Wt)throw Error(b(168));ae($e,t),ae(Ue,n)}function gc(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(b(108,ff(e)||"Unknown",l));return ge({},n,r)}function Ll(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Wt,rn=$e.current,ae($e,e),ae(Ue,Ue.current),!0}function jo(e,t,n){var r=e.stateNode;if(!r)throw Error(b(169));n?(e=gc(e,t,rn),r.__reactInternalMemoizedMergedChildContext=e,ue(Ue),ue($e),ae($e,e)):ue(Ue),ae(Ue,n)}var xt=null,Yl=!1,Is=!1;function vc(e){xt===null?xt=[e]:xt.push(e)}function Pp(e){Yl=!0,vc(e)}function Kt(){if(!Is&&xt!==null){Is=!0;var e=0,t=re;try{var n=xt;for(re=1;e>=a,l-=a,wt=1<<32-ut(t)+l|n<_?($=C,C=null):$=C.sibling;var L=h(p,C,v[_],w);if(L===null){C===null&&(C=$);break}e&&C&&L.alternate===null&&t(p,C),d=s(L,d,_),P===null?S=L:P.sibling=L,P=L,C=$}if(_===v.length)return n(p,C),ce&&Jt(p,_),S;if(C===null){for(;__?($=C,C=null):$=C.sibling;var V=h(p,C,L.value,w);if(V===null){C===null&&(C=$);break}e&&C&&V.alternate===null&&t(p,C),d=s(V,d,_),P===null?S=V:P.sibling=V,P=V,C=$}if(L.done)return n(p,C),ce&&Jt(p,_),S;if(C===null){for(;!L.done;_++,L=v.next())L=m(p,L.value,w),L!==null&&(d=s(L,d,_),P===null?S=L:P.sibling=L,P=L);return ce&&Jt(p,_),S}for(C=r(p,C);!L.done;_++,L=v.next())L=y(C,p,_,L.value,w),L!==null&&(e&&L.alternate!==null&&C.delete(L.key===null?_:L.key),d=s(L,d,_),P===null?S=L:P.sibling=L,P=L);return e&&C.forEach(function(te){return t(p,te)}),ce&&Jt(p,_),S}function j(p,d,v,w){if(typeof v=="object"&&v!==null&&v.type===vn&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case Wr:e:{for(var S=v.key,P=d;P!==null;){if(P.key===S){if(S=v.type,S===vn){if(P.tag===7){n(p,P.sibling),d=l(P,v.props.children),d.return=p,p=d;break e}}else if(P.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Pt&&_o(S)===P.type){n(p,P.sibling),d=l(P,v.props),d.ref=Yn(p,P,v),d.return=p,p=d;break e}n(p,P);break}else t(p,P);P=P.sibling}v.type===vn?(d=nn(v.props.children,p.mode,w,v.key),d.return=p,p=d):(w=xl(v.type,v.key,v.props,null,p.mode,w),w.ref=Yn(p,d,v),w.return=p,p=w)}return a(p);case gn: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(p,d.sibling),d=l(d,v.children||[]),d.return=p,p=d;break e}else{n(p,d);break}else t(p,d);d=d.sibling}d=Ws(v,p.mode,w),d.return=p,p=d}return a(p);case Pt:return P=v._init,j(p,d,P(v._payload),w)}if(lr(v))return x(p,d,v,w);if(Kn(v))return k(p,d,v,w);tl(p,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,d!==null&&d.tag===6?(n(p,d.sibling),d=l(d,v),d.return=p,p=d):(n(p,d),d=Us(v,p.mode,w),d.return=p,p=d),a(p)):n(p,d)}return j}var An=kc(!0),jc=kc(!1),Dl=Qt(null),$l=null,_n=null,pa=null;function ha(){pa=_n=$l=null}function ma(e){var t=Dl.current;ue(Dl),e._currentValue=t}function Ni(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function zn(e,t){$l=e,pa=_n=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(He=!0),e.firstContext=null)}function nt(e){var t=e._currentValue;if(pa!==e)if(e={context:e,memoizedValue:t,next:null},_n===null){if($l===null)throw Error(b(308));_n=e,$l.dependencies={lanes:0,firstContext:e}}else _n=_n.next=e;return t}var Yt=null;function ga(e){Yt===null?Yt=[e]:Yt.push(e)}function Sc(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,ga(t)):(n.next=l.next,l.next=n),t.interleaved=n,_t(e,r)}function _t(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 bt=!1;function va(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Nc(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 jt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Ft(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ee&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,_t(e,n)}return l=r.interleaved,l===null?(t.next=t,ga(r)):(t.next=l.next,l.next=t),r.interleaved=t,_t(e,n)}function pl(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,na(e,n)}}function Co(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 Il(e,t,n,r){var l=e.updateQueue;bt=!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 h=o.lane,y=o.eventTime;if((r&h)===h){g!==null&&(g=g.next={eventTime:y,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var x=e,k=o;switch(h=t,y=n,k.tag){case 1:if(x=k.payload,typeof x=="function"){m=x.call(y,m,h);break e}m=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=k.payload,h=typeof x=="function"?x.call(y,m,h):x,h==null)break e;m=ge({},m,h);break e;case 2:bt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,h=l.effects,h===null?l.effects=[o]:h.push(o))}else y={eventTime:y,lane:h,tag:o.tag,payload:o.payload,callback:o.callback,next:null},g===null?(c=g=y,u=m):g=g.next=y,a|=h;if(o=o.next,o===null){if(o=l.shared.pending,o===null)break;h=o,o=h.next,h.next=null,l.lastBaseUpdate=h,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);an|=a,e.lanes=a,e.memoizedState=m}}function Eo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=As.transition;As.transition={};try{e(!1),t()}finally{re=n,As.transition=r}}function Bc(){return rt().memoizedState}function Rp(e,t,n){var r=Bt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Hc(e))Uc(t,n);else if(n=Sc(e,t,n,r),n!==null){var l=Ae();ct(n,e,r,l),Wc(n,t,r)}}function Dp(e,t,n){var r=Bt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Hc(e))Uc(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,dt(o,a)){var u=t.interleaved;u===null?(l.next=l,ga(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=Sc(e,t,l,r),n!==null&&(l=Ae(),ct(n,e,r,l),Wc(n,t,r))}}function Hc(e){var t=e.alternate;return e===me||t!==null&&t===me}function Uc(e,t){pr=Al=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Wc(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,na(e,n)}}var Fl={readContext:nt,useCallback:ze,useContext:ze,useEffect:ze,useImperativeHandle:ze,useInsertionEffect:ze,useLayoutEffect:ze,useMemo:ze,useReducer:ze,useRef:ze,useState:ze,useDebugValue:ze,useDeferredValue:ze,useTransition:ze,useMutableSource:ze,useSyncExternalStore:ze,useId:ze,unstable_isNewReconciler:!1},$p={readContext:nt,useCallback:function(e,t){return pt().memoizedState=[e,t===void 0?null:t],e},useContext:nt,useEffect:Po,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ml(4194308,4,Ic.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ml(4194308,4,e,t)},useInsertionEffect:function(e,t){return ml(4,2,e,t)},useMemo:function(e,t){var n=pt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=pt();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=Rp.bind(null,me,e),[r.memoizedState,e]},useRef:function(e){var t=pt();return e={current:e},t.memoizedState=e},useState:To,useDebugValue:_a,useDeferredValue:function(e){return pt().memoizedState=e},useTransition:function(){var e=To(!1),t=e[0];return e=zp.bind(null,e[1]),pt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=me,l=pt();if(ce){if(n===void 0)throw Error(b(407));n=n()}else{if(n=t(),Ee===null)throw Error(b(349));sn&30||Tc(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,Po(bc.bind(null,r,s,e),[e]),r.flags|=2048,zr(9,Pc.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=pt(),t=Ee.identifierPrefix;if(ce){var n=kt,r=wt;n=(r&~(1<<32-ut(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=br++,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[ht]=t,e[Er]=r,ed(e,t,!1,!1),t.stateNode=e;e:{switch(a=ii(n,r),n){case"dialog":oe("cancel",e),oe("close",e),l=r;break;case"iframe":case"object":case"embed":oe("load",e),l=r;break;case"video":case"audio":for(l=0;lBn&&(t.flags|=128,r=!0,Zn(s,!1),t.lanes=4194304)}else{if(!r)if(e=Ol(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Zn(s,!0),s.tail===null&&s.tailMode==="hidden"&&!a.alternate&&!ce)return Re(t),null}else 2*ye()-s.renderingStartTime>Bn&&n!==1073741824&&(t.flags|=128,r=!0,Zn(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=ye(),t.sibling=null,n=he.current,ae(he,r?n&1|2:n&1),t):(Re(t),null);case 22:case 23:return La(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Qe&1073741824&&(Re(t),t.subtreeFlags&6&&(t.flags|=8192)):Re(t),null;case 24:return null;case 25:return null}throw Error(b(156,t.tag))}function Up(e,t){switch(da(t),t.tag){case 1:return We(t.type)&&bl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Fn(),ue(Ue),ue($e),wa(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return xa(t),null;case 13:if(ue(he),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(b(340));On()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ue(he),null;case 4:return Fn(),null;case 10:return ma(t.type._context),null;case 22:case 23:return La(),null;case 24:return null;default:return null}}var rl=!1,De=!1,Wp=typeof WeakSet=="function"?WeakSet:Set,O=null;function Cn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ve(e,t,r)}else n.current=null}function Ri(e,t,n){try{n()}catch(r){ve(e,t,r)}}var Mo=!1;function Vp(e,t){if(gi=Cl,e=ac(),ua(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,h=null;t:for(;;){for(var y;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),(y=m.firstChild)!==null;)h=m,m=y;for(;;){if(m===e)break t;if(h===n&&++c===l&&(o=a),h===s&&++g===r&&(u=a),(y=m.nextSibling)!==null)break;m=h,h=m.parentNode}m=y}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(vi={focusedElem:e,selectionRange:n},Cl=!1,O=t;O!==null;)if(t=O,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,O=e;else for(;O!==null;){t=O;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var k=x.memoizedProps,j=x.memoizedState,p=t.stateNode,d=p.getSnapshotBeforeUpdate(t.elementType===t.type?k:it(t.type,k),j);p.__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(b(163))}}catch(w){ve(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,O=e;break}O=t.return}return x=Mo,Mo=!1,x}function hr(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&&Ri(t,n,s)}l=l.next}while(l!==r)}}function ts(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Di(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function rd(e){var t=e.alternate;t!==null&&(e.alternate=null,rd(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ht],delete t[Er],delete t[wi],delete t[Ep],delete t[Tp])),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 ld(e){return e.tag===5||e.tag===3||e.tag===4}function Bo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ld(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 $i(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=Pl));else if(r!==4&&(e=e.child,e!==null))for($i(e,t,n),e=e.sibling;e!==null;)$i(e,t,n),e=e.sibling}function Ii(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(Ii(e,t,n),e=e.sibling;e!==null;)Ii(e,t,n),e=e.sibling}var Pe=null,at=!1;function Tt(e,t,n){for(n=n.child;n!==null;)sd(e,t,n),n=n.sibling}function sd(e,t,n){if(mt&&typeof mt.onCommitFiberUnmount=="function")try{mt.onCommitFiberUnmount(Kl,n)}catch{}switch(n.tag){case 5:De||Cn(n,t);case 6:var r=Pe,l=at;Pe=null,Tt(e,t,n),Pe=r,at=l,Pe!==null&&(at?(e=Pe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pe.removeChild(n.stateNode));break;case 18:Pe!==null&&(at?(e=Pe,n=n.stateNode,e.nodeType===8?$s(e.parentNode,n):e.nodeType===1&&$s(e,n),jr(e)):$s(Pe,n.stateNode));break;case 4:r=Pe,l=at,Pe=n.stateNode.containerInfo,at=!0,Tt(e,t,n),Pe=r,at=l;break;case 0:case 11:case 14:case 15:if(!De&&(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)&&Ri(n,t,a),l=l.next}while(l!==r)}Tt(e,t,n);break;case 1:if(!De&&(Cn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ve(n,t,o)}Tt(e,t,n);break;case 21:Tt(e,t,n);break;case 22:n.mode&1?(De=(r=De)||n.memoizedState!==null,Tt(e,t,n),De=r):Tt(e,t,n);break;default:Tt(e,t,n)}}function Ho(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Wp),t.forEach(function(r){var l=eh.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function st(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=a),r&=~s}if(r=l,r=ye()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Kp(r/1960))-r,10e?16:e,Dt===null)var r=!1;else{if(e=Dt,Dt=null,Hl=0,ee&6)throw Error(b(331));var l=ee;for(ee|=4,O=e.current;O!==null;){var s=O,a=s.child;if(O.flags&16){var o=s.deletions;if(o!==null){for(var u=0;uye()-Pa?tn(e,0):Ta|=n),Ve(e,t)}function pd(e,t){t===0&&(e.mode&1?(t=Xr,Xr<<=1,!(Xr&130023424)&&(Xr=4194304)):t=1);var n=Ae();e=_t(e,t),e!==null&&($r(e,t,n),Ve(e,n))}function Zp(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),pd(e,n)}function eh(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(b(314))}r!==null&&r.delete(t),pd(e,n)}var hd;hd=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ue.current)He=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return He=!1,Bp(e,t,n);He=!!(e.flags&131072)}else He=!1,ce&&t.flags&1048576&&yc(t,Rl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;gl(e,t),e=t.pendingProps;var l=In(t,$e.current);zn(t,n),l=ja(null,t,r,e,l,n);var s=Sa();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,We(r)?(s=!0,Ll(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,va(t),l.updater=es,t.stateNode=l,l._reactInternals=t,Ci(t,r,e,n),t=Pi(null,t,r,!0,s,n)):(t.tag=0,ce&&s&&ca(t),Oe(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(gl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=nh(r),e=it(r,e),l){case 0:t=Ti(null,t,r,e,n);break e;case 1:t=Oo(null,t,r,e,n);break e;case 11:t=$o(null,t,r,e,n);break e;case 14:t=Io(null,t,r,it(r.type,e),n);break e}throw Error(b(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:it(r,l),Ti(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:it(r,l),Oo(e,t,r,l,n);case 3:e:{if(Gc(t),e===null)throw Error(b(387));r=t.pendingProps,s=t.memoizedState,l=s.element,Nc(e,t),Il(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=Mn(Error(b(423)),t),t=Ao(e,t,r,n,l);break e}else if(r!==l){l=Mn(Error(b(424)),t),t=Ao(e,t,r,n,l);break e}else for(Ke=At(t.stateNode.containerInfo.firstChild),Xe=t,ce=!0,ot=null,n=jc(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(On(),r===l){t=Ct(e,t,n);break e}Oe(e,t,r,n)}t=t.child}return t;case 5:return _c(t),e===null&&Si(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,a=l.children,yi(r,l)?a=null:s!==null&&yi(r,s)&&(t.flags|=32),qc(e,t),Oe(e,t,a,n),t.child;case 6:return e===null&&Si(t),null;case 13:return Yc(e,t,n);case 4:return ya(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=An(t,null,r,n):Oe(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:it(r,l),$o(e,t,r,l,n);case 7:return Oe(e,t,t.pendingProps,n),t.child;case 8:return Oe(e,t,t.pendingProps.children,n),t.child;case 12:return Oe(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,ae(Dl,r._currentValue),r._currentValue=a,s!==null)if(dt(s.value,a)){if(s.children===l.children&&!Ue.current){t=Ct(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=jt(-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),Ni(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(b(341));a.lanes|=n,o=a.alternate,o!==null&&(o.lanes|=n),Ni(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}Oe(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,zn(t,n),l=nt(l),r=r(l),t.flags|=1,Oe(e,t,r,n),t.child;case 14:return r=t.type,l=it(r,t.pendingProps),l=it(r.type,l),Io(e,t,r,l,n);case 15:return Xc(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:it(r,l),gl(e,t),t.tag=1,We(r)?(e=!0,Ll(t)):e=!1,zn(t,n),Vc(t,r,l),Ci(t,r,l,n),Pi(null,t,r,!0,e,n);case 19:return Zc(e,t,n);case 22:return Jc(e,t,n)}throw Error(b(156,t.tag))};function md(e,t){return Hu(e,t)}function th(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 et(e,t,n,r){return new th(e,t,n,r)}function Ra(e){return e=e.prototype,!(!e||!e.isReactComponent)}function nh(e){if(typeof e=="function")return Ra(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Yi)return 11;if(e===Zi)return 14}return 2}function Ht(e,t){var n=e.alternate;return n===null?(n=et(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 xl(e,t,n,r,l,s){var a=2;if(r=e,typeof e=="function")Ra(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case vn:return nn(n.children,l,s,t);case Gi:a=8,l|=8;break;case qs:return e=et(12,n,t,l|2),e.elementType=qs,e.lanes=s,e;case Gs:return e=et(13,n,t,l),e.elementType=Gs,e.lanes=s,e;case Ys:return e=et(19,n,t,l),e.elementType=Ys,e.lanes=s,e;case _u:return rs(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Su:a=10;break e;case Nu:a=9;break e;case Yi:a=11;break e;case Zi:a=14;break e;case Pt:a=16,r=null;break e}throw Error(b(130,e==null?e:typeof e,""))}return t=et(a,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function nn(e,t,n,r){return e=et(7,e,r,t),e.lanes=n,e}function rs(e,t,n,r){return e=et(22,e,r,t),e.elementType=_u,e.lanes=n,e.stateNode={isHidden:!1},e}function Us(e,t,n){return e=et(6,e,null,t),e.lanes=n,e}function Ws(e,t,n){return t=et(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function rh(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=Ns(0),this.expirationTimes=Ns(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ns(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Da(e,t,n,r,l,s,a,o,u){return e=new rh(e,t,n,o,u),t===1?(t=1,s===!0&&(t|=8)):t=0,s=et(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},va(s),e}function lh(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(xd)}catch(e){console.error(e)}}xd(),xu.exports=qe;var uh=xu.exports,wd,qo=uh;wd=qo.createRoot,qo.hydrateRoot;async function _e(e){const t=await fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.json()}async function ch(){return _e("/api/archives")}async function dh(e){return _e(`/api/archives/${e}/entries`)}async function fh(e,t,n){const r=new URLSearchParams;return t&&r.set("q",t),n&&r.set("tag",n),_e(`/api/archives/${e}/entries/search?${r}`)}async function Bi(e,t){return _e(`/api/archives/${e}/entries/${t}`)}function ph(e,t,n){return Promise.all(n.map(r=>_e(`/api/archives/${e}/entries/${t}/artifacts/${r}`)))}async function hh(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 mh(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 il(e,t){return _e(`/api/archives/${e}/entries/${t}/tags`)}async function Go(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 gh(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/tags/${n}`,{method:"DELETE"});if(!r.ok)throw new Error(`Remove failed (${r.status})`)}async function Yo(e,t){const n=await fetch(`/api/archives/${e}/entries/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`Delete failed (${n.status})`)}async function vh(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 yh(e,t){const n=await fetch(`/api/archives/${e}/tags/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(await n.text())}async function Vs(e){return _e(`/api/archives/${e}/runs`)}async function al(e){return _e(`/api/archives/${e}/tags`)}async function xh(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),typeof r.modal_closer_enabled=="boolean"&&(l.modal_closer_enabled=r.modal_closer_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 wh(e,t){return _e(`/api/archives/${e}/captures/probe?locator=${encodeURIComponent(t)}`)}async function kd(e,t){return _e(`/api/archives/${e}/capture_jobs/${t}`)}async function kh(){return(await(await fetch("/api/auth/setup")).json()).setup_required===!0}async function jh(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 Sh(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 Nh(){await fetch("/api/auth/logout",{method:"POST"})}async function _h(){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 Eh(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 Th(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 _e("/api/auth/tokens")}async function bh(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 Lh(e){const t=await fetch(`/api/auth/tokens/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(await t.text())}async function Aa(){return _e("/api/admin/instance-settings")}async function wl(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 zh(){return _e("/api/admin/users")}async function Rh(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 Dh(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 $h(){return _e("/api/admin/roles")}async function Ih(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 jd(e){return _e(`/api/archives/${e}/collections`)}async function Oh(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 Ah(e,t){return _e(`/api/archives/${e}/collections/${t}`)}async function Sd(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 Fh(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 Mh(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 Bh(e,t){return _e(`/api/archives/${e}/entries/${t}/collections`)}async function Zo(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 Hh(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 Uh(e){return _e(`/api/archives/${e}/blob-cleanup`)}async function Wh(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 Vh(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 Qh(){return _e("/api/admin/cookie-rules")}async function Kh(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 Xh(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 Jh(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 qh=window.fetch;window.fetch=async(...e)=>{var n;const t=await qh(...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 Gh({onLogin:e}){const[t,n]=f.useState(""),[r,l]=f.useState(""),[s,a]=f.useState(null),[o,u]=f.useState(!1);async function c(g){g.preventDefault(),a(null),u(!0);try{const m=await Sh(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 Yh({onComplete:e}){const[t,n]=f.useState(""),[r,l]=f.useState(""),[s,a]=f.useState(""),[o,u]=f.useState(null),[c,g]=f.useState(!1);async function m(h){if(h.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 jh(t,r),e()}catch(y){u(y.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:h=>n(h.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:h=>l(h.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:h=>a(h.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 Zh({archives:e,archiveId:t,onArchiveChange:n,view:r,onViewChange:l,onCaptureClick:s}){const{currentUser:a,setCurrentUser:o}=f.useContext(os)??{},[u,c]=f.useState(!1);async function g(){c(!0),await Nh(),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 Hi=1;function Nd(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 tr(e=""){return{id:Hi++,locator:e,quality:"best",probeState:"idle",probeQualities:null,probeHasAudio:!1,status:"idle",error:null,jobUid:null,archiveId:null}}function eu(e){return e.some(t=>t.status==="submitting"||t.status==="running")}function em({open:e,archiveId:t,onClose:n,onCaptured:r,onToast:l}){const s=f.useRef(null),a=f.useRef(!0),o=f.useRef(new Map),u=f.useRef(new Map),c=f.useRef(new Map),g=f.useRef(t);f.useEffect(()=>{g.current=t},[t]);const m=f.useRef(r),h=f.useRef(l);f.useEffect(()=>{m.current=r},[r]),f.useEffect(()=>{h.current=l},[l]);const[y,x]=f.useState(()=>{try{const N=JSON.parse(sessionStorage.getItem("captureItems")||"null");if(Array.isArray(N)&&N.length>0)return N.forEach(I=>{I.id>=Hi&&(Hi=I.id+1)}),N}catch{}return[tr()]});f.useEffect(()=>{sessionStorage.setItem("captureItems",JSON.stringify(y))},[y]);const[k,j]=f.useState(!1),[p,d]=f.useState(null),[v,w]=f.useState(null),[S,P]=f.useState(!0),[C,_]=f.useState(!0);f.useEffect(()=>{Aa().then(N=>{w(N),P(N.cookie_ext_enabled??!0),_(N.modal_closer_enabled??!0)}).catch(()=>w({}))},[]);const $=p!==null?p:(v==null?void 0:v.ublock_enabled)??!0,[L,V]=f.useState(!1);f.useEffect(()=>{["captureDialogLocator","captureDialogError","captureDialogBusy","captureDialogJobStatus","captureDialogJobUid"].forEach(N=>sessionStorage.removeItem(N)),x(N=>N.map(I=>I.status==="submitting"?{...I,status:"idle",error:null}:I)),y.forEach(N=>{N.status==="running"&&N.jobUid&&N.archiveId&&!o.current.has(N.jobUid)&&te(N.id,N.jobUid,N.locator,N.archiveId)})},[]),f.useEffect(()=>{const N=s.current;if(!N)return;const I=()=>{u.current.forEach(H=>clearTimeout(H)),u.current.clear(),n()};return N.addEventListener("close",I),()=>N.removeEventListener("close",I)},[n]),f.useEffect(()=>{const N=s.current;N&&(e?(!a.current&&!eu(y)&&x([tr()]),a.current=!1,N.open||N.showModal()):(u.current.forEach(I=>clearTimeout(I)),u.current.clear(),N.open&&N.close()))},[e]),f.useEffect(()=>()=>{o.current.forEach(N=>clearInterval(N)),u.current.forEach(N=>clearTimeout(N))},[]);function te(N,I,H,B,U=null){if(o.current.has(I))return;const fe=setInterval(async()=>{try{const q=await kd(B,I);if(q.status==="completed"){clearInterval(o.current.get(I)),o.current.delete(I),x(K=>K.map(Y=>Y.id===N?{...Y,status:"completed"}:Y)),setTimeout(()=>{x(K=>{const Y=K.filter(pe=>pe.id!==N);return Y.length===0?[tr()]:Y})},1400),m.current();try{const K=q.notes_json?JSON.parse(q.notes_json):null;if(K!=null&&K.ublock_skipped||K!=null&&K.cookie_ext_skipped){const pe=K.ublock_skipped&&K.cookie_ext_skipped?"Captured without ad-blocking or cookie-consent extension. Check ARCHIVR_UBLOCK_EXT and ARCHIVR_COOKIE_EXT in your server config.":K.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.";h.current(pe,H,"warning"),Z(U,"warning",H)}else U||h.current(null,H,"success"),Z(U,"archived")}catch{U||h.current(null,H,"success"),Z(U,"archived")}}else if(q.status==="failed"){clearInterval(o.current.get(I)),o.current.delete(I);const K=q.error_text||"Capture failed.";x(Y=>Y.map(pe=>pe.id===N?{...pe,status:"failed",error:K}:pe)),h.current(K,H),Z(U,"failed",H)}}catch(q){clearInterval(o.current.get(I)),o.current.delete(I);const K=q.message||"Network error";x(Y=>Y.map(pe=>pe.id===N?{...pe,status:"failed",error:K}:pe)),h.current(K,H),Z(U,"failed",H)}},500);o.current.set(I,fe)}function Z(N,I,H=null){if(!N)return;const B=c.current.get(N);if(!B||(I==="archived"||I==="warning"?(B.archived++,I==="warning"&&(B.warnings++,H&&B.warningLocators.push(H))):(B.failed++,H&&B.failedLocators.push(H)),B.archived+B.failed0?`${U} archived (${fe} with warnings)`:`${U} archived`;pe=q>0?`${we}, ${q} failed`:we}const R=U===0?"error":q>0||fe>0?"warning":"success",W=[];K.length>0&&W.push(`Failed: +${K.map(we=>` ${we}`).join(` +`)}`),Y.length>0&&W.push(`With warnings: +${Y.map(we=>` ${we}`).join(` +`)}`);const Te=W.length>0?W.join(` +`):null;h.current(Te,null,R,pe)}async function se(N,I=null){if(!N.locator.trim())return;const H=t,B=N.locator.trim(),U=N.quality||"best";x(fe=>fe.map(q=>q.id===N.id?{...q,status:"submitting",error:null}:q));try{const q=await xh(H,B,U,{ublock_enabled:$,reader_mode:L,cookie_ext_enabled:S,modal_closer_enabled:C});x(K=>K.map(Y=>Y.id===N.id?{...Y,status:"running",jobUid:q.job_uid,archiveId:H}:Y)),te(N.id,q.job_uid,B,H,I)}catch(fe){const q=fe.message||"Submission failed.";x(K=>K.map(Y=>Y.id===N.id?{...Y,status:"failed",error:q}:Y)),h.current(q,B),Z(I,"failed",B)}}function de(){var H,B;const N=y.filter(U=>U.status==="idle"&&U.locator.trim());if(N.length===0)return;const I=N.length>1?((H=crypto.randomUUID)==null?void 0:H.call(crypto))??`batch-${Date.now()}`:null;I&&c.current.set(I,{total:N.length,archived:0,warnings:0,failed:0,failedLocators:[],warningLocators:[]}),N.forEach(U=>se(U,I)),(B=s.current)==null||B.close()}function xe(){x(N=>[...N,tr()])}function ie(N){clearTimeout(u.current.get(N)),u.current.delete(N),x(I=>{const H=I.filter(B=>B.id!==N);return H.length===0?[tr()]:H})}function z(N){x(I=>I.map(H=>H.id===N?{...H,status:"idle",error:null}:H))}function E(N,I){if(clearTimeout(u.current.get(N)),x(B=>B.map(U=>U.id===N?{...U,locator:I,probeState:"idle",probeQualities:null,probeHasAudio:!1,quality:"best"}:U)),!Nd(I))return;const H=setTimeout(async()=>{u.current.delete(N),x(B=>B.map(U=>U.id===N?{...U,probeState:"probing"}:U));try{const B=await wh(g.current,I.trim());x(U=>U.map(fe=>{if(fe.id!==N||fe.locator!==I)return fe;const q=B.qualities??[],K=B.has_audio??!1,Y=q.length===0&&K?"audio":"best";return{...fe,probeState:"done",probeQualities:q,probeHasAudio:K,quality:Y}}))}catch{x(B=>B.map(U=>U.id===N?{...U,probeState:"idle",probeQualities:null}:U))}},600);u.current.set(N,H)}function F(N,I){x(H=>H.map(B=>B.id===N?{...B,quality:I}:B))}const J=y.filter(N=>N.status==="idle"&&N.locator.trim()).length,M=eu(y);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 N;return(N=s.current)==null?void 0:N.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:y.map((N,I)=>i.jsx(tm,{item:N,autoFocus:I===y.length-1&&N.status==="idle",onLocatorChange:H=>E(N.id,H),onQualityChange:H=>F(N.id,H),onRemove:()=>ie(N.id),onReset:()=>z(N.id),onSubmit:de},N.id))}),i.jsxs("button",{type:"button",className:"capture-add-row",onClick:xe,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:()=>j(N=>!N),"aria-expanded":k,children:[i.jsx("svg",{className:`capture-chevron${k?" 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"]}),k&&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":$,className:`ext-toggle ext-toggle--sm${$?" ext-toggle--on":""}`,onClick:()=>d(N=>N===null?!$:!N),"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(N=>!N),"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":L,className:`ext-toggle ext-toggle--sm${L?" ext-toggle--on":""}`,onClick:()=>V(N=>!N),"aria-label":"Toggle reader mode 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:"Close modals and dialogs"}),i.jsx("span",{className:"capture-ext-desc",children:"Auto-dismiss cookie banners and overlays during this capture"})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":C,className:`ext-toggle ext-toggle--sm${C?" ext-toggle--on":""}`,onClick:()=>_(N=>!N),"aria-label":"Toggle modal closer 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:de,disabled:J===0,children:J>1?`Archive ${J}`:"Archive"}),i.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var N;return(N=s.current)==null?void 0:N.close()},children:M?"Close":"Cancel"})]})]})})}function tm({item:e,autoFocus:t,onLocatorChange:n,onQualityChange:r,onRemove:l,onReset:s,onSubmit:a}){const o=f.useRef(null),u=e.status==="submitting"||e.status==="running";f.useEffect(()=>{var g;t&&e.status==="idle"&&((g=o.current)==null||g.focus())},[t]);const c=(()=>{if(e.status==="completed"||u||!Nd(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:h=>r(h.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:h=>r(h.target.value),"aria-label":"Video quality",children:[i.jsx("option",{value:"best",children:"Best quality"}),g.map(h=>i.jsx("option",{value:h,children:h},h)),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(nm,{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 nm({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 Ui(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 en(e){return rm(e)??""}function _d(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 tu={youtube:'',youtube_music:'',spotify:'',x:'',instagram:'',facebook:'',tiktok:'',reddit:'',snapchat:'',local:'',web:'',other:'?'};function Fa(e){return tu[e]??tu.other}function Cd(e){return e.split("/").map(t=>t?t.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):"").join("/")}function lm({entry:e,archiveId:t,isSelected:n,isMultiSelected:r,onRowClick:l}){const[s,a]=f.useState(!1),u=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!s?i.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>a(!0),style:{objectFit:"contain"}}):i.jsx("span",{dangerouslySetInnerHTML:{__html:Fa(e.source_kind)}}),c=n||r;function g(m){m.stopPropagation(),l(e,{ctrlKey:!0,metaKey:!1,shiftKey:!1,preventDefault(){}})}return i.jsxs("div",{className:[n&&"is-selected",r&&"is-multi-selected"].filter(Boolean).join(" ")||void 0,tabIndex:0,"data-entry-uid":e.entry_uid,onMouseDown:m=>{m.shiftKey&&m.preventDefault()},onClick:m=>l(e,m),onKeyDown:m=>{m.key==="Enter"&&l(e,m)},children:[i.jsx("div",{className:"col-check",children:i.jsx("button",{type:"button",className:`row-checkbox${c?" is-checked":""}`,"aria-pressed":c,"aria-label":c?"Deselect entry":"Select entry",onClick:g,onKeyDown:m=>m.stopPropagation()})}),i.jsx("div",{className:"col-added",children:_d(e.archived_at)}),i.jsxs("div",{className:"col-title",children:[i.jsx("span",{className:"source-icon",children:u}),i.jsx("span",{className:"entry-title",children:en(e.title)||en(e.entry_uid)})]}),i.jsx("div",{className:"col-type",children:i.jsx("span",{className:"type-pill",children:en(e.entity_kind)})}),i.jsxs("div",{className:"col-size",children:[i.jsx("span",{className:"size-total",children:Ui(e.total_artifact_bytes)}),e.cached_bytes>0&&e.total_artifact_bytes>0&&i.jsxs("span",{className:"size-cached-pct",title:`${Ui(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:en(e.original_url)})]})}function sm({entries:e,selectedUids:t,onRowClick: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-check","aria-hidden":"true"}),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(lm,{entry:l,archiveId:r,isSelected:t.size===1&&t.has(l.entry_uid),isMultiSelected:t.size>=2&&t.has(l.entry_uid),onRowClick:n},l.entry_uid))})]})})}function im(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 am({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 om({runs:e}){const[t,n]=f.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:im(l.started_at)}),i.jsxs("td",{children:[i.jsx(am,{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 um=4;function cm({archives:e}){const{currentUser:t}=f.useContext(os)??{},n=t&&(t.role_bits&um)!==0,[r,l]=f.useState("users"),[s,a]=f.useState([]),[o,u]=f.useState([]),[c,g]=f.useState(!1),[m,h]=f.useState(null),[y,x]=f.useState(""),[k,j]=f.useState(""),[p,d]=f.useState(""),[v,w]=f.useState(null),[S,P]=f.useState(!1),[C,_]=f.useState(""),[$,L]=f.useState(""),[V,te]=f.useState(null),[Z,se]=f.useState(!1),de=f.useCallback(async()=>{if(n){g(!0),h(null);try{const[E,F]=await Promise.all([zh(),$h()]);a(E),u(F)}catch(E){h(E.message)}finally{g(!1)}}},[n]);f.useEffect(()=>{de()},[de]);async function xe(E){const F=E.status==="active"?"disabled":"active";try{await Dh(E.user_uid,F),a(J=>J.map(M=>M.user_uid===E.user_uid?{...M,status:F}:M))}catch(J){h(J.message)}}async function ie(E){if(E.preventDefault(),!y.trim()||!k){w("Username and password required");return}P(!0),w(null);try{await Rh(y.trim(),k,p.trim()||void 0),x(""),j(""),d(""),await de()}catch(F){w(F.message)}finally{P(!1)}}async function z(E){if(E.preventDefault(),!C.trim()||!$.trim()){te("Slug and name required");return}se(!0),te(null);try{await Ih(C.trim(),$.trim()),_(""),L(""),await de()}catch(F){te(F.message)}finally{se(!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(E=>i.jsxs("tr",{className:E.status==="disabled"?"admin-row-disabled":"",children:[i.jsx("td",{children:E.username}),i.jsx("td",{className:"muted",children:E.email||"—"}),i.jsx("td",{children:E.role_slugs.join(", ")||"—"}),i.jsx("td",{children:i.jsx("span",{className:`status-badge status-${E.status}`,children:E.status})}),i.jsx("td",{children:i.jsx("button",{className:"admin-action-btn",onClick:()=>xe(E),children:E.status==="active"?"Ban":"Unban"})})]},E.user_uid))})]}),i.jsx("h3",{children:"Create User"}),i.jsxs("form",{className:"admin-form",onSubmit:ie,children:[i.jsx("input",{className:"admin-input",placeholder:"Username",value:y,onChange:E=>x(E.target.value),required:!0}),i.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:k,onChange:E=>j(E.target.value),required:!0}),i.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:p,onChange:E=>d(E.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(E=>i.jsxs("tr",{children:[i.jsx("td",{children:i.jsx("code",{children:E.slug})}),i.jsx("td",{children:E.name}),i.jsx("td",{children:E.level}),i.jsx("td",{children:E.bit_position}),i.jsx("td",{children:E.is_builtin?"✓":""})]},E.role_uid))})]}),i.jsx("h3",{children:"Create Custom Role"}),i.jsxs("form",{className:"admin-form",onSubmit:z,children:[i.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:C,onChange:E=>_(E.target.value),required:!0}),i.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:$,onChange:E=>L(E.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: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(E=>i.jsxs("div",{className:"admin-archive",children:[i.jsx("strong",{children:E.label}),i.jsx("div",{className:"muted",children:E.archive_path})]},E.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(E=>i.jsxs("div",{className:"admin-archive",children:[i.jsx("strong",{children:E.label}),i.jsx("div",{className:"muted",children:E.archive_path})]},E.id))})]})}function Ed({node:e,archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){var w;const c=n===e.tag.full_path,[g,m]=f.useState(!1),[h,y]=f.useState(""),x=f.useRef(!1);function k(){if(g)return;const S=c?null:e.tag.full_path;r(S),l("archive")}function j(S){S.stopPropagation(),y(e.tag.slug),m(!0)}async function p(){const S=h.trim();if(!S||S===e.tag.slug){m(!1);return}try{const P=await vh(t,e.tag.tag_uid,S);s(e.tag.full_path,P.full_path),o()}catch{}finally{m(!1)}}async function d(S){var C;S.stopPropagation();const P=((C=e.children)==null?void 0:C.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 yh(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:h,onChange:S=>y(S.target.value),onKeyDown:S=>{S.key==="Enter"&&S.currentTarget.blur(),S.key==="Escape"&&(x.current=!0,S.currentTarget.blur())},onBlur:()=>{x.current?(x.current=!1,m(!1)):p()}}):i.jsxs("button",{className:`tag-node-btn${c?" is-active":""}`,title:e.tag.full_path,onClick:k,onDoubleClick:j,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(),j(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:"×"})]}),((w=e.children)==null?void 0:w.length)>0&&i.jsx("div",{className:"tag-children",children:i.jsx("ul",{className:"tag-tree-list",children:e.children.map(S=>i.jsx(Ed,{node:S,...v},S.tag.tag_uid))})})]})}function dm({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(Ed,{node:c,archiveId:e,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:s,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u},c.tag.tag_uid))})]})})}const ar=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],fm=e=>{var t;return((t=ar.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function pm({archiveId:e}){const[t,n]=f.useState([]),[r,l]=f.useState(!1),[s,a]=f.useState(null),[o,u]=f.useState(null),[c,g]=f.useState(null),[m,h]=f.useState(!1),[y,x]=f.useState(null),[k,j]=f.useState(""),[p,d]=f.useState(""),[v,w]=f.useState(2),[S,P]=f.useState(!1),[C,_]=f.useState(null),[$,L]=f.useState(""),[V,te]=f.useState(2),[Z,se]=f.useState(!1),[de,xe]=f.useState(null),[ie,z]=f.useState(!1),[E,F]=f.useState(""),J=f.useRef(null),M=t.find(R=>R.collection_uid===o)??null,N=(M==null?void 0:M.slug)==="_default_",I=f.useCallback(async()=>{if(e){l(!0),a(null);try{const R=await jd(e);n(R)}catch(R){a(R.message)}finally{l(!1)}}},[e]),H=f.useCallback(async R=>{if(!R){g(null);return}h(!0),x(null);try{const W=await Ah(e,R);g(W)}catch(W){x(W.message)}finally{h(!1)}},[e]);f.useEffect(()=>{I()},[I]),f.useEffect(()=>{H(o)},[o,H]),f.useEffect(()=>{ie&&J.current&&J.current.focus()},[ie]);async function B(R){R.preventDefault();const W=k.trim(),Te=p.trim();if(!(!W||!Te)){P(!0),_(null);try{const we=await Oh(e,W,Te,v);j(""),d(""),w(2),await I(),u(we.collection_uid)}catch(we){_(we.message)}finally{P(!1)}}}async function U(){const R=E.trim();if(!R||!M){z(!1);return}try{await Zo(e,M.collection_uid,{name:R}),await I(),g(W=>W&&{...W,name:R})}catch(W){a(W.message)}finally{z(!1)}}async function fe(R){if(M)try{await Zo(e,M.collection_uid,{default_visibility_bits:R}),await I(),g(W=>W&&{...W,default_visibility_bits:R})}catch(W){a(W.message)}}async function q(){if(M&&window.confirm(`Delete collection "${M.name}"? Entries will not be deleted.`))try{await Hh(e,M.collection_uid),u(null),g(null),await I()}catch(R){a(R.message)}}async function K(R){R.preventDefault();const W=$.trim();if(!(!W||!M)){se(!0),xe(null);try{await Sd(e,M.collection_uid,W,V),L(""),await H(M.collection_uid)}catch(Te){xe(Te.message)}finally{se(!1)}}}async function Y(R){if(M)try{await Fh(e,M.collection_uid,R),await H(M.collection_uid)}catch(W){x(W.message)}}async function pe(R,W){if(M)try{await Mh(e,M.collection_uid,R,W),g(Te=>Te&&{...Te,entries:Te.entries.map(we=>we.entry_uid===R?{...we,collection_visibility_bits:W}:we)})}catch(Te){x(Te.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(R=>i.jsxs("button",{className:`coll-sidebar-row${o===R.collection_uid?" is-active":""}`,onClick:()=>u(R.collection_uid),children:[i.jsx("span",{className:"coll-row-name",children:R.name}),i.jsx("span",{className:"coll-row-meta",children:fm(R.default_visibility_bits)})]},R.collection_uid)),t.length===0&&!r&&i.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),M?i.jsxs("div",{className:"coll-detail",children:[i.jsxs("div",{className:"coll-detail-header",children:[ie?i.jsx("input",{ref:J,className:"coll-rename-input",value:E,onChange:R=>F(R.target.value),onBlur:U,onKeyDown:R=>{R.key==="Enter"&&U(),R.key==="Escape"&&z(!1)}}):i.jsxs("h3",{className:`coll-detail-name${N?"":" coll-detail-name--editable"}`,title:N?void 0:"Click to rename",onClick:()=>{N||(F(M.name),z(!0))},children:[(c==null?void 0:c.name)??M.name,!N&&i.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!N&&i.jsx("button",{className:"coll-delete-btn",onClick:q,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)??M.default_visibility_bits,onChange:R=>fe(Number(R.target.value)),disabled:N,children:ar.map(R=>i.jsx("option",{value:R.value,children:R.label},R.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…"}),y&&i.jsx("div",{className:"collections-error",children:y}),!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(R=>i.jsxs("li",{className:"coll-entry-row",children:[i.jsxs("div",{className:"coll-entry-info",children:[i.jsx("span",{className:"coll-entry-title",children:R.title||R.entry_uid}),i.jsx("span",{className:"coll-entry-kind muted",children:R.source_kind})]}),i.jsxs("div",{className:"coll-entry-actions",children:[i.jsx("select",{className:"coll-entry-vis-select",value:R.collection_visibility_bits,onChange:W=>pe(R.entry_uid,Number(W.target.value)),children:ar.map(W=>i.jsx("option",{value:W.value,children:W.label},W.value))}),!N&&i.jsx("button",{className:"coll-entry-remove",onClick:()=>Y(R.entry_uid),title:"Remove from collection",children:"×"})]})]},R.entry_uid))}))]}),!N&&i.jsxs("form",{className:"coll-add-entry-form",onSubmit:K,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:$,onChange:R=>L(R.target.value),placeholder:"entry_uid",required:!0}),i.jsx("select",{className:"coll-vis-select",value:V,onChange:R=>te(Number(R.target.value)),children:ar.map(R=>i.jsx("option",{value:R.value,children:R.label},R.value))}),i.jsx("button",{className:"coll-add-btn",type:"submit",disabled:Z,children:Z?"…":"Add"})]}),de&&i.jsx("div",{className:"collections-error",style:{marginTop:4},children:de})]})]}):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:B,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:k,onChange:R=>{j(R.target.value),p||d(R.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:p,onChange:R=>d(R.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:R=>w(Number(R.target.value)),children:ar.map(R=>i.jsx("option",{value:R.value,children:R.label},R.value))})]}),C&&i.jsx("div",{className:"collections-error",children:C}),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 hm=4;function mm({tab:e,onTabChange:t,archiveId:n}){const{currentUser:r,setCurrentUser:l}=f.useContext(os)??{},s=r&&(r.role_bits&hm)!==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(gm,{currentUser:r,setCurrentUser:l}),e==="tokens"&&i.jsx(vm,{}),e==="instance"&&s&&i.jsx(ym,{}),e==="cookies"&&s&&i.jsx(wm,{}),e==="extensions"&&s&&i.jsx(km,{}),e==="storage"&&s&&i.jsx(xm,{archiveId:n})]})}function gm({currentUser:e,setCurrentUser:t}){const[n,r]=f.useState((e==null?void 0:e.display_name)??""),[l,s]=f.useState(!1),[a,o]=f.useState(null),[u,c]=f.useState(""),[g,m]=f.useState(""),[h,y]=f.useState(""),[x,k]=f.useState(!1),[j,p]=f.useState(null);async function d(w){w.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(w){if(w.preventDefault(),g!==h){p({ok:!1,text:"Passwords do not match."});return}k(!0),p(null);try{await Th(u,g),c(""),m(""),y(""),p({ok:!0,text:"Password changed."})}catch(S){p({ok:!1,text:S.message})}finally{k(!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:w=>r(w.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 w=>{const S=w.target.checked;try{await Eh({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:w=>c(w.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:w=>m(w.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:h,onChange:w=>y(w.target.value),required:!0})]}),j&&i.jsx("div",{className:`form-msg form-msg--${j.ok?"ok":"err"}`,children:j.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:x,children:x?"Changing…":"Change Password"})]})]})]})}function vm(){const[e,t]=f.useState([]),[n,r]=f.useState(!0),[l,s]=f.useState(null),[a,o]=f.useState(""),[u,c]=f.useState(!1),[g,m]=f.useState(null),h=f.useCallback(async()=>{r(!0),s(null);try{t(await Ph())}catch(k){s(k.message)}finally{r(!1)}},[]);f.useEffect(()=>{h()},[h]);async function y(k){if(k.preventDefault(),!!a.trim()){c(!0);try{const j=await bh(a.trim());m(j),o(""),h()}catch(j){s(j.message)}finally{c(!1)}}}async function x(k){try{await Lh(k),t(j=>j.filter(p=>p.token_uid!==k))}catch(j){s(j.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:y,children:[i.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:a,onChange:k=>o(k.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(k=>i.jsxs("div",{className:"token-row",children:[i.jsxs("div",{className:"token-row-info",children:[i.jsx("strong",{children:k.name}),i.jsxs("div",{className:"muted",children:["Created ",k.created_at.slice(0,10),k.last_used_at&&` · Last used ${k.last_used_at.slice(0,10)}`]})]}),i.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>x(k.token_uid),children:"Revoke"})]},k.token_uid))]})]})})}function ym(){const[e,t]=f.useState(null),[n,r]=f.useState(!0),[l,s]=f.useState(null),[a,o]=f.useState(!1),[u,c]=f.useState(null);f.useEffect(()=>{(async()=>{try{t(await Aa())}catch(m){s(m.message)}finally{r(!1)}})()},[]);async function g(m){m.preventDefault(),o(!0),c(null);try{await wl(e),c({ok:!0,text:"Saved."})}catch(h){c({ok:!1,text:h.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,h])=>i.jsxs("label",{className:"checkbox-row",children:[i.jsx("input",{type:"checkbox",checked:!!e[m],onChange:y=>t(x=>({...x,[m]:y.target.checked}))}),h]},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(h=>({...h,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 Qs(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 xm({archiveId:e}){const[t,n]=f.useState("idle"),[r,l]=f.useState(null),[s,a]=f.useState(null),[o,u]=f.useState(null);function c(){n("idle"),l(null),a(null),u(null)}async function g(){n("scanning"),u(null),l(null);try{const y=await Uh(e);l(y),n("scanned")}catch(y){u(y.message),n("error")}}async function m(){n("deleting"),u(null);try{const y=await Wh(e);a(y),n("done")}catch(y){u(y.message),n("error")}}const h=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&&h&&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&&!h&&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:Qs(r.total_bytes)})," recoverable."]}),i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsxs("button",{className:"btn-danger",onClick:m,children:["Delete (",Qs(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:Qs(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 wm(){const[e,t]=f.useState(null),[n,r]=f.useState(!0),[l,s]=f.useState(null),[a,o]=f.useState("global"),[u,c]=f.useState(""),[g,m]=f.useState("{}"),[h,y]=f.useState(null),[x,k]=f.useState(!1),[j,p]=f.useState({});f.useEffect(()=>{d()},[]);async function d(){r(!0),s(null);try{t(await Qh())}catch(_){s(_.message)}finally{r(!1)}}async function v(_){_.preventDefault();try{JSON.parse(g)}catch{y({ok:!1,text:'cookies must be valid JSON, e.g. {"session": "abc"}'});return}k(!0),y(null);try{await Kh(a==="global"?null:u.trim(),a,g),c(""),m("{}"),o("global"),y({ok:!0,text:"Rule added."}),await d()}catch($){y({ok:!1,text:$.message})}finally{k(!1)}}async function w(_){try{await Jh(_),await d()}catch($){s($.message)}}function S(_){p($=>({...$,[_.rule_uid]:{cookiesInput:_.cookies_json,saving:!1,msg:null}}))}function P(_){p($=>{const L={...$};return delete L[_],L})}async function C(_){const $=j[_.rule_uid];try{JSON.parse($.cookiesInput)}catch{p(L=>({...L,[_.rule_uid]:{...L[_.rule_uid],msg:{ok:!1,text:"Invalid JSON"}}}));return}p(L=>({...L,[_.rule_uid]:{...L[_.rule_uid],saving:!0,msg:null}}));try{await Xh(_.rule_uid,{cookies_json:$.cookiesInput}),P(_.rule_uid),await d()}catch(L){p(V=>({...V,[_.rule_uid]:{...V[_.rule_uid],saving:!1,msg:{ok:!1,text:L.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(_=>{const $=j[_.rule_uid],L=_.url_pattern?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"muted",children:[_.pattern_kind,":"]})," ",i.jsx("code",{children:_.url_pattern})]}):i.jsx("span",{className:"muted",children:"global (all URLs)"});return i.jsxs("tr",{children:[i.jsx("td",{children:L}),i.jsx("td",{children:$?i.jsxs(i.Fragment,{children:[i.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:12,width:"100%",minHeight:60},value:$.cookiesInput,onChange:V=>p(te=>({...te,[_.rule_uid]:{...te[_.rule_uid],cookiesInput:V.target.value}}))}),$.msg&&i.jsx("div",{className:`form-msg form-msg--${$.msg.ok?"ok":"err"}`,children:$.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:$.saving,onClick:()=>C(_),children:$.saving?"Saving…":"Save"}),i.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>P(_.rule_uid),children:"Cancel"})]})]}):i.jsx("code",{style:{fontSize:12,wordBreak:"break-all"},children:_.cookies_json})}),i.jsx("td",{children:!$&&i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>S(_),children:"Edit"}),i.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"2px 8px"},onClick:()=>w(_.rule_uid),children:"Del"})]})})]},_.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:_=>o(_.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:_=>c(_.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:_=>m(_.target.value),placeholder:'{"SESSION": "abc123", "token": "xyz"}',required:!0})]}),h&&i.jsx("div",{className:`form-msg form-msg--${h.ok?"ok":"err"}`,children:h.text}),i.jsx("button",{className:"btn-primary",type:"submit",disabled:x,children:x?"Adding…":"Add Rule"})]})]})})}function km(){const[e,t]=f.useState(null),[n,r]=f.useState(!0),[l,s]=f.useState(!1),[a,o]=f.useState(null);f.useEffect(()=>{(async()=>{try{t(await Aa())}catch(j){o({ok:!1,text:j.message})}finally{r(!1)}})()},[]);async function u(j){s(!0),o(null);try{await wl({ublock_enabled:j}),t(p=>({...p,ublock_enabled:j})),o({ok:!0,text:"Saved."})}catch(p){o({ok:!1,text:p.message})}finally{s(!1)}}async function c(j){s(!0),o(null);try{await wl({cookie_ext_enabled:j}),t(p=>({...p,cookie_ext_enabled:j})),o({ok:!0,text:"Saved."})}catch(p){o({ok:!1,text:p.message})}finally{s(!1)}}async function g(j){s(!0),o(null);try{await wl({modal_closer_enabled:j}),t(p=>({...p,modal_closer_enabled:j})),o({ok:!0,text:"Saved."})}catch(p){o({ok:!1,text:p.message})}finally{s(!1)}}if(n)return i.jsx("div",{className:"muted",children:"Loading\\u2026"});const m=(e==null?void 0:e.ublock_ext_available)??!1,h=(e==null?void 0:e.ublock_enabled)??!0,y=(e==null?void 0:e.cookie_ext_available)??!1,x=(e==null?void 0:e.cookie_ext_enabled)??!0,k=(e==null?void 0:e.modal_closer_enabled)??!0;return i.jsx("div",{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.jsxs("div",{className:"ext-grid",children:[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)."}),!m&&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."}),!y&&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":x,className:`ext-toggle${x?" ext-toggle--on":""}`,onClick:()=>c(!x),disabled:l,"aria-label":"Toggle I Still Don't Care About Cookies",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:"Modal & Dialog Closer"}),i.jsx("span",{className:"ext-card-desc",children:"Auto-dismiss cookie banners, consent overlays, and other modal dialogs before a WebPage capture is taken. Implemented as an injected browser script; no external extension required."})]}),i.jsx("button",{type:"button",role:"switch","aria-checked":k,className:`ext-toggle${k?" ext-toggle--on":""}`,onClick:()=>g(!k),disabled:l,"aria-label":"Toggle Modal and Dialog Closer",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 nu={0:"Private",1:"Public",2:"Users only",3:"Public"},jm=()=>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 Sm({archiveId:e,selectedEntry:t,selectedUids:n,selectedEntries:r,detail:l,onTagFilterSet:s,tagNodes:a,onTagsRefresh:o,onEntryTitleChange:u,onEntryDeleted:c,onBulkDeleted:g,humanizeTags:m,onDetailRefresh:h,onOpenPreview:y,onPlay:x}){const[k,j]=f.useState([]),[p,d]=f.useState(""),[v,w]=f.useState([]),[S,P]=f.useState(""),C=f.useRef(0),_=f.useRef(!1),[$,L]=f.useState(!1),[V,te]=f.useState(""),[Z,se]=f.useState("idle"),[de,xe]=f.useState(""),ie=f.useRef(null),z=(n==null?void 0:n.size)>=2,[E,F]=f.useState(""),[J,M]=f.useState("idle"),[N,I]=f.useState(""),[H,B]=f.useState([]),[U,fe]=f.useState(""),[q,K]=f.useState("idle"),[Y,pe]=f.useState(""),[R,W]=f.useState("idle");f.useEffect(()=>{const D=++C.current;if(ie.current&&(clearInterval(ie.current),ie.current=null),se("idle"),xe(""),!t||!e){j([]),w([]);return}L(!1),te(""),_.current=!1,j([]),Promise.all([il(e,t.entry_uid),Bh(e,t.entry_uid)]).then(([ne,Ie])=>{D===C.current&&(j(ne),w(Ie))}).catch(()=>{})},[t,e]),f.useEffect(()=>()=>{clearInterval(ie.current)},[]),f.useEffect(()=>{if(!z||!e){B([]);return}jd(e).then(B).catch(()=>B([]))},[z,e]),f.useEffect(()=>{F(""),M("idle"),I(""),fe(""),K("idle"),pe(""),W("idle")},[n]);async function Te(){const D=n.size;if(!window.confirm(`Delete ${D} entr${D===1?"y":"ies"}? This cannot be undone.`))return;W("running");const ne=new Set;for(const Ie of n)try{await Yo(e,Ie),ne.add(Ie)}catch{}W("idle"),g==null||g(ne)}async function we(){const D=E.trim();if(D){M("running"),I("");try{for(const ne of n)await Go(e,ne,D);F(""),M("done"),o==null||o(),setTimeout(()=>M("idle"),1800)}catch(ne){I(ne.message),M("error")}}}async function us(){if(!U)return;K("running"),pe("");const D=[];for(const ne of n)try{await Sd(e,U,ne)}catch{D.push(ne)}D.length>0?(pe(`Failed for ${D.length} entr${D.length===1?"y":"ies"}.`),K("error")):(K("done"),setTimeout(()=>K("idle"),1800))}async function Fr(){const D=V.trim()||null;try{await mh(e,t.entry_uid,D),u==null||u(t.entry_uid,D)}catch{}finally{L(!1)}}async function Mr(){const D=p.trim();if(!(!D||!t))try{await Go(e,t.entry_uid,D),d(""),P("");const ne=await il(e,t.entry_uid);j(ne),o()}catch(ne){P(ne.message)}}async function cs(D){try{await gh(e,t.entry_uid,D);const ne=await il(e,t.entry_uid);j(ne),o()}catch{}}async function ds(){if(!(!t||!e)&&window.confirm("Delete this entry? This cannot be undone."))try{await Yo(e,t.entry_uid),c==null||c(t.entry_uid)}catch{}}async function fs(){if(!t||!e||Z==="running")return;const D=C.current,ne=t.entry_uid;se("running"),xe("");try{const{job_uid:Ie}=await Vh(e,ne);if(C.current!==D)return;ie.current=setInterval(async()=>{try{const pn=await kd(e,Ie);if(pn.status==="completed"){if(clearInterval(ie.current),ie.current=null,C.current!==D)return;se("done");const ys=await il(e,ne);if(C.current!==D)return;j(ys),h==null||h()}else if(pn.status==="failed"){if(clearInterval(ie.current),ie.current=null,C.current!==D)return;se("error"),xe(pn.error_text||"Re-archive failed.")}}catch{if(clearInterval(ie.current),ie.current=null,C.current!==D)return;se("error"),xe("Network error while polling.")}},500)}catch(Ie){if(C.current!==D)return;se("error"),xe(Ie.message||"Failed to start re-archive.")}}const ps=l?[["Added",_d(l.summary.archived_at)],["Source",l.summary.source_kind],["Type",l.summary.entity_kind],["Visibility",nu[l.summary.visibility]??l.summary.visibility],["Root",l.structured_root_relpath]]:[],hs=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),ms=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv","pdf","html","htm","jpg","jpeg","png","gif","webp","avif","svg","bmp"]),dn=l?l.artifacts.findIndex(D=>D.artifact_role==="primary_media"):-1,fn=dn>=0?l.artifacts[dn]:null,Br=fn?fn.relpath.split(".").pop().toLowerCase():"",Hr=fn&&hs.has(Br),gs=dn>=0&&t?`/api/archives/${e}/entries/${t.entry_uid}/artifacts/${dn}`:null,vs=l&&!Hr&&(l.summary.entity_kind==="tweet"||l.summary.entity_kind==="tweet_thread"||fn&&ms.has(Br));return i.jsxs("aside",{className:"context-rail",children:[i.jsx("div",{className:"rail-eyebrow",children:"Context"}),z?i.jsxs("div",{className:"bulk-panel",children:[i.jsxs("p",{className:"bulk-count",children:[i.jsx("span",{className:"bulk-count-num",children:n.size})," entries selected"]}),i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Assign tag"}),N&&i.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:N}),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:E,onChange:D=>F(D.target.value),onKeyDown:D=>{D.key==="Enter"&&we()}}),i.jsx("button",{className:"tag-add-btn",onClick:we,disabled:J==="running"||!E.trim(),children:J==="running"?"…":J==="done"?"✓":"Add"})]})]}),H.length>0&&i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Add to collection"}),i.jsxs("div",{className:"bulk-coll-row",children:[i.jsxs("select",{className:"bulk-coll-select",value:U,onChange:D=>fe(D.target.value),children:[i.jsx("option",{value:"",children:"Pick a collection…"}),H.map(D=>i.jsx("option",{value:D.collection_uid,children:D.name},D.collection_uid))]}),i.jsx("button",{className:"tag-add-btn",onClick:us,disabled:!U||q==="running",children:q==="running"?"…":q==="done"?"✓":q==="error"?"!":"Add"})]}),Y&&i.jsx("p",{className:"form-msg form-msg--err",style:{margin:"6px 0 0"},children:Y})]}),i.jsx("div",{className:"rail-delete-zone",children:i.jsx("button",{className:"rail-delete-btn",onClick:Te,disabled:R==="running",children:R==="running"?"Deleting…":`Delete ${n.size} entr${n.size===1?"y":"ies"}`})})]}):t?l?i.jsxs(i.Fragment,{children:[$?i.jsx("input",{className:"rail-title-input",autoFocus:!0,value:V,onChange:D=>te(D.target.value),onKeyDown:D=>{D.key==="Enter"&&D.currentTarget.blur(),D.key==="Escape"&&(_.current=!0,D.currentTarget.blur())},onBlur:()=>{_.current?L(!1):Fr(),_.current=!1}}):i.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{te(l.summary.title??""),L(!0)},children:[en(l.summary.title)||en(l.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"})})]}),l.summary.original_url&&i.jsxs("a",{className:"url-tile",href:l.summary.original_url,target:"_blank",rel:"noopener noreferrer",children:[i.jsx("span",{className:"ico",dangerouslySetInnerHTML:{__html:Fa(l.summary.source_kind)}}),i.jsx("span",{className:"u-text",children:l.summary.original_url}),i.jsx("span",{className:"ext",children:i.jsx(jm,{})})]}),Hr&&x&&i.jsx("button",{className:"rail-preview-btn",onClick:()=>x(gs,t),children:"▶ Play"}),vs&&y&&i.jsx("button",{className:"rail-preview-btn",onClick:y,children:"Preview"}),i.jsx("div",{className:"meta-list",children:ps.filter(([,D])=>D!=null&&D!=="").map(([D,ne])=>i.jsxs("div",{className:"meta-item",children:[i.jsx("span",{className:"meta-k",children:D}),i.jsx("span",{className:`meta-v${D==="Root"?" mono":""}`,children:en(ne)})]},D))}),l.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:l.artifacts.length})]}),i.jsx("ul",{className:"artifact-list",children:l.artifacts.map((D,ne)=>i.jsx("li",{children:i.jsxs("a",{href:`/api/archives/${e}/entries/${l.summary.entry_uid}/artifacts/${ne}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[i.jsx("span",{className:"artifact-name",children:D.artifact_role.replace(/_/g," ")}),i.jsx("span",{className:"artifact-size",children:D.byte_size!=null?Ui(D.byte_size):"—"})]})},ne))})]})]}):i.jsx("p",{className:"tags-empty",children:"Loading\\u2026"}):i.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&!z&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Tags"}),k.length===0?i.jsx("p",{className:"tags-empty",children:"No tags yet."}):i.jsx("div",{className:"tags-wrap",children:k.map(D=>i.jsxs("span",{className:"tag-pill",title:D.full_path,children:[m?Cd(D.full_path):D.full_path,i.jsx("button",{className:"remove",title:`Remove tag ${D.full_path}`,onClick:()=>cs(D.tag_uid),children:"×"})]},D.tag_uid))}),S&&i.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:S}),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:p,onChange:D=>d(D.target.value),onKeyDown:D=>{D.key==="Enter"&&Mr()}}),i.jsx("button",{className:"tag-add-btn",onClick:Mr,children:"Add"})]})]}),v.length>0&&i.jsxs("div",{className:"rail-section",children:[i.jsx("div",{className:"rail-section-heading",children:"Collections"}),v.map(D=>i.jsxs("div",{className:"coll-row",children:[i.jsx("span",{className:"coll-name",children:D.collection_uid}),i.jsx("span",{className:"vis-badge",children:nu[D.visibility_bits]??`bits:${D.visibility_bits}`})]},D.collection_uid))]}),l&&(l.summary.entity_kind==="tweet"||l.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:fs,disabled:Z==="running",children:Z==="running"?"Re-archiving…":"Re-archive"}),Z==="done"&&i.jsx("p",{className:"form-msg form-msg--ok",style:{marginTop:"6px"},children:"Re-archived successfully."}),Z==="error"&&i.jsx("p",{className:"form-msg form-msg--err",style:{marginTop:"6px"},children:de})]}),i.jsx("div",{className:"rail-delete-zone",children:i.jsx("button",{className:"rail-delete-btn",onClick:ds,children:"Delete entry"})})]})]})}function Nm({src:e}){const t=f.useRef(null);return f.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 ru({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 _m({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 Td(e){return e?new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(e*1e3)):""}function lu(e){return!e||!e.includes("&")?e:e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}const Q={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"}},je={bg:"#000000",border:"#2f3336",text:"#e7e9ea",dim:"#71767b",accent:"#1d9bf0",codeBg:"#16181c"},Ks={article:{background:je.bg,color:je.text,minHeight:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'},articleInner:{maxWidth:"598px",margin:"0 auto",paddingBottom:"80px"},aCover:{width:"100%",display:"block",objectFit:"cover",maxHeight:"420px"},aMeta:{padding:"20px 16px 0"},aTweetTitle:{fontSize:"34px",fontWeight:"800",letterSpacing:"-0.5px",color:je.text,lineHeight:"44px",marginBottom:"16px"},aAuthorRow:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px"},aAvatar:{width:"40px",height:"40px",borderRadius:"50%",objectFit:"cover",flexShrink:0,display:"block"},aAvatarPh:{width:"40px",height:"40px",borderRadius:"50%",background:je.border,flexShrink:0},aAuthorName:{fontSize:"15px",fontWeight:"700",color:je.text,lineHeight:"1.3"},aAuthorSub:{fontSize:"15px",color:je.dim,lineHeight:"1.3"},aDivider:{border:"none",borderTop:`1px solid ${je.border}`,margin:"0"},aBody:{padding:"4px 16px 0"},bH1:{fontSize:"26px",fontWeight:"800",letterSpacing:"-0.4px",color:je.text,lineHeight:"36px",margin:"24px 0 10px"},bH2:{fontSize:"26px",fontWeight:"800",letterSpacing:"-0.4px",color:je.text,lineHeight:"36px",margin:"24px 0 10px"},bP:{fontSize:"17px",color:je.text,lineHeight:"1.5",marginBottom:"16px",marginTop:"0"},bSpacer:{height:"6px",display:"block"},bQuote:{borderLeft:`3px solid ${je.border}`,padding:"2px 14px",margin:"14px 0",color:je.dim,fontSize:"17px",lineHeight:"1.5"},bHr:{border:"none",borderTop:`1px solid ${je.border}`,margin:"28px 0"},bImg:{width:"100%",display:"block",borderRadius:"12px",margin:"16px 0"},bUl:{margin:"10px 0 16px",paddingLeft:"28px"},bOl:{margin:"10px 0 16px",paddingLeft:"28px"},bLi:{fontSize:"17px",color:je.text,lineHeight:"1.5",marginBottom:"6px"},bTweet:{display:"flex",alignItems:"center",gap:"12px",border:`1px solid ${je.border}`,borderRadius:"12px",padding:"14px 16px",margin:"14px 0",color:je.dim,fontSize:"15px",textDecoration:"none"},bMdPre:{borderRadius:"12px",margin:"12px 0",overflow:"auto",background:"#1e2029"},bMdCode:{fontFamily:"ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, Consolas, monospace",fontSize:"13px",lineHeight:"1.65",padding:"18px 20px",display:"block",color:je.text,background:"transparent"},iCode:{fontFamily:"ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace",fontSize:"0.875em",background:je.codeBg,padding:"2px 6px",borderRadius:"4px",color:"#e6edf3"},link:{color:je.accent,textDecoration:"none"}};function Cm(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 Dn(e,t,n){return e&&n[e]?n[e]:t||null}function Pd(){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 Ma(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 bd(e,t){const n=e.expanded_url||e.url||e.text||"",r=e.display_url||e.expanded_url||e.url||e.text||"",l=Ma(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=Ma(e,t,r);return!l||!n?null:{...l,kind:"mention",screen_name:n}}const su=/https?:\/\/[^\s<>"'\])]+/g,Em=/[.,;:!?)()]+$/;function Vl(e,t){const n=[];let r=0,l;for(su.lastIndex=0;(l=su.exec(e))!==null;){l.index>r&&n.push(e.slice(r,l.index));let s=l[0].replace(Em,"");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:(rbd(o,e)).filter(Boolean),...(t.user_mentions||[]).map(o=>Ld(o,e)).filter(Boolean)];if(r.length===0&&n.length===0)return Vl(lu(e),Q.link);const l=new Set([0,e.length]);for(const o of r)o.s>=0&&o.s<=e.length&&l.add(o.s),o.e>=0&&o.e<=e.length&&l.add(o.e);for(const[o,u]of n)o>=0&&o<=e.length&&l.add(o),u>=0&&u<=e.length&&l.add(u);const s=(o,u)=>n.some(([c,g])=>c<=o&&g>=u),a=[...l].sort((o,u)=>o-u);return a.slice(0,-1).map((o,u)=>{const c=a[u+1];if(s(o,c))return null;const g=e.slice(o,c),m=r.filter(x=>x.s<=o&&x.e>=c),h=m.find(x=>x.kind==="url");if(h)return i.jsx("a",{href:h.href,target:"_blank",rel:"noopener noreferrer",style:Q.link,children:h.display||g},u);const y=m.find(x=>x.kind==="mention");return y?i.jsx("a",{href:`https://x.com/${y.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:Q.link,children:g},u):i.jsx("span",{children:Vl(lu(g),Q.link)},u)}).filter(o=>o!==null)}function Pm(e,t,n,r,l=Q){if(!e)return null;t=t||[],n=n||[],r=r||[];const s=[];for(const u of t)u.length>0&&s.push({s:u.offset,e:u.offset+u.length,kind:"style",style:u.style});for(const u of n){const c=bd(u,e);c&&s.push(c)}for(const u of r){const c=Ld(u,e);c&&s.push(c)}if(s.length===0)return Vl(e,l.link);const a=new Set([0,e.length]);for(const u of s)u.s>=0&&u.s<=e.length&&a.add(u.s),u.e>=0&&u.e<=e.length&&a.add(u.e);const o=[...a].sort((u,c)=>u-c);return o.slice(0,-1).map((u,c)=>{const g=o[c+1],m=s.filter(j=>j.s<=u&&j.e>=g),h=e.slice(u,g);let y;if(h.includes(` +`)){const j=h.split(` +`);y=j.flatMap((p,d)=>dj.kind==="style"&&j.style==="Code")&&(y=i.jsx("code",{style:l.iCode,children:y})),m.some(j=>j.kind==="style"&&j.style==="Bold")&&(y=i.jsx("strong",{children:y})),m.some(j=>j.kind==="style"&&j.style==="Italic")&&(y=i.jsx("em",{children:y})),m.some(j=>j.kind==="style"&&j.style==="Underline")&&(y=i.jsx("u",{children:y})),m.some(j=>j.kind==="style"&&j.style==="Strikethrough")&&(y=i.jsx("s",{children:y}));const x=m.find(j=>j.kind==="url");if(x){const j=/^https?:\/\/t\.co\//i.test(y);y=i.jsx("a",{href:x.href,target:"_blank",rel:"noopener noreferrer",style:l.link,children:j?x.display:y})}const k=m.find(j=>j.kind==="mention");return k&&(y=i.jsx("a",{href:`https://x.com/${k.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:l.link,children:y})),i.jsx("span",{children:typeof y=="string"?Vl(y,l.link):y},c)})}function bm(e,t,n){const r=(n==null?void 0:n.st)||Q,l=e.resolved_entities||[];return l.length===0?null:l.map((s,a)=>{var o;switch(s.type){case"divider":return i.jsx("hr",{style:r.bHr},a);case"media":{const u=Dn(s.local_path,s.url,t);return u?i.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:c=>{var g;!c.metaKey&&!c.ctrlKey&&(c.preventDefault(),(g=n==null?void 0:n.onImgClick)==null||g.call(n,u))},children:i.jsx("img",{src:u,style:r.bImg,loading:"lazy",alt:""})},a):null}case"tweet":return s.tweet_id?i.jsxs("a",{href:`https://x.com/i/status/${s.tweet_id}`,target:"_blank",rel:"noopener noreferrer",style:r.bTweet,children:[i.jsx(Pd,{}),"View post on X"]},a):null;case"link":return s.url?i.jsx("p",{style:r.bP,children:i.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",style:r.link,children:s.url})},a):null;case"markdown":{const u=s.markdown??((o=s.data)==null?void 0:o.markdown)??"";return i.jsx("pre",{style:r.bMdPre,children:i.jsx("code",{style:r.bMdCode,children:u})},a)}case"emoji":return s.url?i.jsx("img",{src:s.url,alt:"",style:{height:"1.2em",verticalAlign:"middle",margin:"0 1px"}},a):null;default:return null}})}function Xs(e,t,n,r){const l=(r==null?void 0:r.st)||Q,s=e.type||"",a=e.text||"",o=e.inline_style_ranges||[],u=e.data||{},c=Pm(a,o,u.urls||[],u.mentions||[],l);switch(s){case"header-one":return i.jsx("h1",{style:l.bH1,children:c},t);case"header-two":{const g=a.match(/(?:x\.com|twitter\.com)\/i\/status\/(\d+)/);return g?i.jsxs("a",{href:`https://x.com/i/status/${g[1]}`,target:"_blank",rel:"noopener noreferrer",style:l.bTweet,children:[i.jsx(Pd,{}),"View post on X"]},t):i.jsx("h2",{style:l.bH2,children:c},t)}case"unstyled":return a.trim()?i.jsx("p",{style:l.bP,children:c},t):i.jsx("span",{style:l.bSpacer},t);case"blockquote":return i.jsx("blockquote",{style:l.bQuote,children:c},t);case"unordered-list-item":case"ordered-list-item":return i.jsx("li",{style:l.bLi,children:c},t);case"atomic":return i.jsx("span",{children:bm(e,n,r)},t);default:return a?i.jsx("p",{style:l.bP,children:c},t):null}}function Lm(e,t,n){const r=(n==null?void 0:n.st)||Q,l=[];let s=0;for(;s{r&&(l==null||l(!0))},[r,l]);const o=r?Ks:Q,u=e.cover_media||{},c=e.author||t||{},g=e.first_published_at_secs?Td(e.first_published_at_secs):"",h=[c.screen_name?`@${c.screen_name}`:"",g].filter(Boolean).join(" · "),y=Dn(u.local_path,u.url,n),x=Dn(c.avatar_local_path,c.avatar_url,n),k=i.jsxs(i.Fragment,{children:[s&&i.jsx(zd,{items:[{src:s,alt:""}],startIndex:0,onClose:()=>a(null)}),y&&i.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:j=>{!j.metaKey&&!j.ctrlKey&&(j.preventDefault(),a(y))},children:i.jsx("img",{src:y,style:o.aCover,alt:"Article cover"})}),i.jsxs("div",{style:o.aMeta,children:[e.title&&i.jsx("div",{style:o.aTweetTitle,children:e.title}),i.jsxs("div",{style:o.aAuthorRow,children:[x?i.jsx("img",{src:x,style:o.aAvatar,alt:c.name||""}):i.jsx("div",{style:o.aAvatarPh}),i.jsxs("div",{children:[i.jsx("div",{style:o.aAuthorName,children:c.name||c.screen_name||"Unknown"}),h&&i.jsx("div",{style:o.aAuthorSub,children:h})]})]})]}),i.jsx("hr",{style:o.aDivider}),i.jsx("div",{style:o.aBody,children:Lm(e.blocks||[],n,{onImgClick:a,st:o})})]});return r?i.jsx("div",{style:Ks.article,children:i.jsx("div",{style:Ks.articleInner,children:k})}):i.jsx("div",{style:Q.article,children:k})}function Rm({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:Q.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 zd({items:e,startIndex:t,onClose:n}){const[r,l]=f.useState(t);f.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:Q.lightboxBackdrop,onClick:n,children:i.jsxs("div",{style:Q.lightboxContent,onClick:a=>a.stopPropagation(),children:[i.jsxs("div",{style:Q.lightboxToolbar,children:[e.length>1&&i.jsxs("span",{style:Q.lightboxCounter,children:[r+1," / ",e.length]}),i.jsx("a",{href:s.src,target:"_blank",rel:"noopener noreferrer",style:Q.lightboxLink,title:"Open in new tab",children:"↗"}),i.jsx("button",{style:Q.lightboxBtn,onClick:n,"aria-label":"Close",children:"×"})]}),i.jsx("img",{src:s.src,alt:s.alt||"",style:Q.lightboxImg}),e.length>1&&i.jsxs("div",{style:Q.lightboxNav,children:[i.jsx("button",{style:Q.lightboxNavBtn,onClick:()=>l(a=>Math.max(a-1,0)),disabled:r===0,children:"‹"}),i.jsx("button",{style:Q.lightboxNavBtn,onClick:()=>l(a=>Math.min(a+1,e.length-1)),disabled:r===e.length-1,children:"›"})]})]})})}function iu({tweet:e,isInThread:t,isLast:n,artifactMap:r}){var d,v;const[l,s]=f.useState(null),a=e.author||{},o=e.created_at_secs?Td(e.created_at_secs):"",u=e.entities||{},c=Dn(a.avatar_local_path,a.avatar_url,r),g=t&&!n,m=e.is_quote_status===!0,h=t?Q.tweetRowThread:Q.tweetRow,y=e.full_text||"",x=((v=(d=e.extended_entities)==null?void 0:d.media)!=null&&v.length?e.extended_entities.media:u.media)||[],k=[],j=[];for(const w of x)if(w.type==="photo"){const S=Dn(w.local_path,w.media_url_https,r);S&&k.push({kind:"photo",src:S,alt:w.alt_text||""})}else if(w.type==="video"||w.type==="animated_gif"){const S=w.local_path&&r[w.local_path]||(()=>{var C,_;return(_=(((C=w.video_info)==null?void 0:C.variants)||[]).filter($=>$.content_type==="video/mp4").sort(($,L)=>(L.bitrate||0)-($.bitrate||0))[0])==null?void 0:_.url})();S&&j.push({kind:w.type==="animated_gif"?"gif":"video",src:S})}const p=[];for(const w of x){if(!w.url||!(w.type==="photo"?k.some(C=>C.src===Dn(w.local_path,w.media_url_https,r)):j.length>0))continue;const P=Ma(w,y,w.url);P&&p.push([P.s,P.e])}return i.jsxs(i.Fragment,{children:[l!==null&&i.jsx(zd,{items:k,startIndex:l,onClose:()=>s(null)}),i.jsxs("div",{style:h,children:[i.jsxs("div",{style:Q.leftCol,children:[c?i.jsx("img",{src:c,style:Q.avatar,alt:a.name||""}):i.jsx("div",{style:Q.avatarPh}),g&&i.jsx("div",{style:Q.threadLine})]}),i.jsxs("div",{style:Q.rightCol,children:[i.jsxs("div",{style:Q.authorRow,children:[i.jsx("span",{style:Q.authorName,children:a.name||a.screen_name||"Unknown"}),a.screen_name&&i.jsxs("span",{style:Q.authorHandle,children:["@",a.screen_name]}),o&&i.jsxs("span",{style:Q.datePart,children:["· ",o]}),m&&i.jsx("span",{style:Q.qtBadge,title:"Quote tweet",children:"↻ QT"})]}),i.jsx("div",{style:Q.tweetText,children:Tm(y,u,p)}),k.length>0&&i.jsx("div",{style:Q.mediaGrid,children:i.jsx(Rm,{photos:k,onOpen:w=>s(w)})}),j.map((w,S)=>i.jsx("div",{style:Q.mediaGrid,children:i.jsx("video",{src:w.src,style:Q.mediaVideo,controls:!0,loop:w.kind==="gif",muted:w.kind==="gif",autoPlay:w.kind==="gif"})},S)),(e.retweet_count>0||e.favorite_count>0)&&i.jsxs("div",{style:Q.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 Dm({archiveId:e,entryUid:t,artifacts:n,entityKind:r,fullPage:l,onXArticle:s}){const[a,o]=f.useState(!0),[u,c]=f.useState(null),[g,m]=f.useState([]);if(f.useEffect(()=>{if(o(!0),c(null),m([]),!n||!e||!t){o(!1);return}const x=n.map((j,p)=>({...j,index:p})).filter(j=>j.artifact_role==="raw_tweet_json");if(x.length===0){c("No tweet data found."),o(!1);return}let k=!1;return ph(e,t,x.map(j=>j.index)).then(async j=>{if(k)return;const p=/https?:\/\/t\.co\/[A-Za-z0-9]+/g,d=C=>{var $;const _=C.full_text||"";return((($=C.entities)==null?void 0:$.urls)||[]).map(L=>{var V;if(L.fromIndex!=null&&L.toIndex!=null)return[L.fromIndex,L.toIndex];if(((V=L.indices)==null?void 0:V.length)===2)return[L.indices[0],L.indices[1]];if(L.url){const te=_.indexOf(L.url);if(te!==-1)return[te,te+L.url.length]}return null}).filter(Boolean)},v=(C,_,$)=>C.some(([L,V])=>L<=_&&V>=$),w=new Set;for(const C of j){const _=C.full_text||"",$=d(C);let L;for(p.lastIndex=0;(L=p.exec(_))!==null;)v($,L.index,L.index+L[0].length)||w.add(L[0])}const S=w.size>0?await hh([...w]).catch(()=>({})):{},P=j.map(C=>{var te;const _=C.full_text||"",$=d(C),L=[];let V;for(p.lastIndex=0;(V=p.exec(_))!==null;){const Z=V[0],se=S[Z];se&&se!==Z&&!v($,V.index,V.index+Z.length)&&L.push({url:Z,expanded_url:se,display_url:(()=>{try{const de=new URL(se);return de.hostname+(de.pathname.length>1?"/…":"")}catch{return se}})(),fromIndex:V.index,toIndex:V.index+Z.length})}return L.length===0?C:{...C,entities:{...C.entities||{},urls:[...((te=C.entities)==null?void 0:te.urls)||[],...L]}}});k||m(P)}).catch(j=>{k||c(j.message||"Failed to load tweet.")}).finally(()=>{k||o(!1)}),()=>{k=!0}},[e,t,n]),a)return i.jsx("div",{style:Q.loading,children:"Loading…"});if(u)return i.jsxs("div",{style:Q.error,children:["Error: ",u]});if(g.length===0)return null;const h=Cm(e,t,n);if(r==="tweet_thread")return i.jsx("div",{style:Q.threadOuter,children:g.map((x,k)=>i.jsx(iu,{tweet:x,isInThread:!0,isLast:k===g.length-1,artifactMap:h},x.id||k))});const y=g[0];return y.is_article&&y.article?i.jsx(zm,{article:y.article,tweetAuthor:y.author,artifactMap:h,fullPage:l,onXArticle:s}):i.jsx("div",{style:Q.card,children:i.jsx(iu,{tweet:y,isInThread:!1,isLast:!0,artifactMap:h})})}const $m=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv"]),Im=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),Om=new Set(["jpg","jpeg","png","gif","webp","avif","svg","bmp"]);function Rd({archiveId:e,entry:t,detail:n,fullPage:r,onXArticle:l}){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:s,artifacts:a}=n,o=s.entry_uid,u=s.entity_kind;if(u==="tweet"||u==="tweet_thread"){const y=i.jsx(Dm,{archiveId:e,entryUid:o,artifacts:a,entityKind:u,fullPage:r,onXArticle:l});return r?y:i.jsx("div",{className:"preview-tweet-wrap",children:y})}const c=a.findIndex(y=>y.artifact_role==="primary_media");if(c===-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"}),a.length>0&&i.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:a.map((y,x)=>i.jsxs("li",{children:[y.artifact_role,": ",y.relpath]},x))})]});const g=a[c],m=`/api/archives/${e}/entries/${o}/artifacts/${c}`,h=g.relpath.split(".").pop().toLowerCase();return $m.has(h)?i.jsx("div",{className:"preview-panel",children:i.jsx(Nm,{src:m})}):Im.has(h)?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:s.title||o}),i.jsx("audio",{src:m,controls:!0,style:{marginTop:"8px",width:"100%",maxWidth:"400px"}})]}):h==="pdf"?i.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:i.jsx(ru,{src:m,type:"pdf",title:s.title,originalUrl:s.original_url})}):h==="html"||h==="htm"?i.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:i.jsx(ru,{src:m,type:"page",title:s.title,originalUrl:s.original_url})}):Om.has(h)?i.jsx("div",{className:"preview-panel",style:{height:"100%"},children:i.jsx(_m,{src:m,alt:s.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:a.map((y,x)=>i.jsxs("li",{children:[y.artifact_role,": ",y.relpath]},x))})]})}function Am({archiveId:e,entry:t,detail:n,onClose:r}){var l,s;return f.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(Rd,{archiveId:e,entry:t,detail:n})})]})})}function au(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 Fm({entry:e,src:t,archiveId:n,onClose:r}){const l=f.useRef(null),[s,a]=f.useState(!1),[o,u]=f.useState(0),[c,g]=f.useState(NaN),[m,h]=f.useState(1);f.useEffect(()=>{!l.current||!t||(l.current.load(),u(0),g(NaN),a(!1))},[t]),f.useEffect(()=>{l.current&&(l.current.volume=m)},[m]);function y(){const d=l.current;d&&(s?d.pause():d.play().catch(()=>{}))}function x(d){const v=l.current;if(!v||!isFinite(c))return;const w=Number(d.target.value);v.currentTime=w,u(w)}function k(d){h(Number(d.target.value))}const j=(e==null?void 0:e.title)||(e==null?void 0:e.entry_uid)||"Unknown",p=(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:Fa(p)}}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.85rem",color:"var(--ink)"},title:j,children:j})]}),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:y,"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:au(o)}),i.jsx("input",{type:"range",min:0,max:isFinite(c)?c:0,step:.1,value:isFinite(o)?o:0,onChange:x,"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:au(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:k,"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 Mm({archiveId:e,entryUid:t}){var h,y;const[n,r]=f.useState(null),[l,s]=f.useState(!0),[a,o]=f.useState(null),[u,c]=f.useState(!1);f.useEffect(()=>{if(!u)return;const x=document.documentElement,k=document.body,j=x.style.colorScheme,p=k.style.background;return x.style.colorScheme="dark",k.style.background="#000",()=>{x.style.colorScheme=j,k.style.background=p}},[u]),f.useEffect(()=>{c(!1),Bi(e,t).then(x=>{r(x),s(!1)}).catch(x=>{o((x==null?void 0:x.message)||"Failed to load entry"),s(!1)})},[e,t]);const g=((h=n==null?void 0:n.summary)==null?void 0:h.title)||t,m=(y=n==null?void 0:n.summary)==null?void 0:y.original_url;return i.jsxs("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column",background:u?"#000":"var(--paper)",fontFamily:"var(--sans)"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:u?"8px 12px":"10px 16px",borderBottom:u?"none":"1px solid var(--line)",flexShrink:0,position:u?"sticky":"relative",top:0,zIndex:20,background:u?"rgba(0,0,0,0.82)":"var(--paper-2)",backdropFilter:u?"blur(12px)":"none",WebkitBackdropFilter:u?"blur(12px)":"none"},children:[i.jsx("a",{href:"/",style:{color:u?"#1d9bf0":"var(--accent)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"← Archive"}),i.jsx("span",{style:{flex:1,fontSize:"14px",fontWeight:600,color:u?"#e7e9ea":"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g}),m&&i.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",style:{color:u?"#71767b":"var(--muted)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"Original ↗"})]}),i.jsxs("div",{style:u?{flex:1}:{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(Rd,{archiveId:e,entry:n.summary,detail:n,fullPage:!0,onXArticle:c})]})]})}const Bm=7e3;function Hm({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(Wm,{toast:r,onDismiss:t,onIgnoreUblock:n},r.id))}):null}function Um(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 Wm({toast:e,onDismiss:t,onIgnoreUblock:n}){const[r,l]=f.useState(!1),s=e.type==="warning",a=e.type==="success";f.useEffect(()=>{if(r)return;const u=setTimeout(()=>t(e.id),Bm);return()=>clearTimeout(u)},[r,e.id,t]);const o=Um(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 os=f.createContext(null),nr=(()=>{const e=window.location.pathname.match(/^\/preview\/([^/]+)\/([^/]+)/);return e?{archiveId:e[1],entryUid:e[2]}:null})(),Vm=["archive","tags","collections","runs","admin","settings"],Qm=["profile","tokens","instance","cookies","extensions","storage"];function Xt(){const e=window.location.pathname.split("/").filter(Boolean),t=Vm.includes(e[0])?e[0]:"archive",n=t==="settings"&&Qm.includes(e[1])?e[1]:"profile",r=new URLSearchParams(window.location.search),l=r.get("q")??"",s=t==="archive"?r.get("tag")??null:null,a=t==="archive"?r.get("entry")??null:null;return{view:t,settingsTab:n,q:l,tag:s,entry:a}}function Km(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function Xm(){const[e,t]=f.useState("loading"),[n,r]=f.useState(null);f.useEffect(()=>{(async()=>{if(await kh()){t("setup");return}const A=await _h();if(!A){t("login");return}r(A),t("authenticated")})()},[]),f.useEffect(()=>{const T=()=>{r(null),t("login")};return window.addEventListener("auth:expired",T),()=>window.removeEventListener("auth:expired",T)},[]),f.useEffect(()=>{const T=()=>{const{view:A,settingsTab:X,q:le,tag:lt,entry:vt}=Xt();v(A),S(X),C(le),p(lt),m(vt),y(null),k(vt?new Set([vt]):new Set)};return window.addEventListener("popstate",T),()=>window.removeEventListener("popstate",T)},[]);const[l,s]=f.useState([]),[a,o]=f.useState(null),[u,c]=f.useState([]),[g,m]=f.useState(()=>Xt().entry),[h,y]=f.useState(null),[x,k]=f.useState(()=>{const T=Xt().entry;return T?new Set([T]):new Set}),[j,p]=f.useState(()=>Xt().tag),[d,v]=f.useState(()=>Xt().view),[w,S]=f.useState(()=>Xt().settingsTab),[P,C]=f.useState(()=>Xt().q),[_,$]=f.useState(""),[L,V]=f.useState(!1),[te,Z]=f.useState([]),[se,de]=f.useState([]),[xe,ie]=f.useState(()=>sessionStorage.getItem("captureDialogOpen")==="true"),[z,E]=f.useState([]),F=f.useRef(0),[J,M]=f.useState(()=>sessionStorage.getItem("ublockWarningIgnored")==="true"),[N,I]=f.useState(null),H=f.useRef(0),B=f.useRef(null),U=f.useRef(!1),fe=f.useRef(!0),q=f.useRef(null),K=(n==null?void 0:n.humanize_slugs)??!1;f.useEffect(()=>{const T=++H.current;I(null),!(!h||!a)&&Bi(a,h.entry_uid).then(A=>{T===H.current&&I(A)}).catch(()=>{})},[h,a]),f.useEffect(()=>{sessionStorage.setItem("captureDialogOpen",xe)},[xe]);const Y=f.useCallback(async(T,A,X)=>{if(T){V(!0);try{let le;A||X?le=await fh(T,A,X):le=await dh(T),c(le),k(lt=>{if(lt.size<2)return lt;const vt=new Set(le.map(hn=>hn.entry_uid)),Vn=new Set([...lt].filter(hn=>vt.has(hn)));return Vn.size===lt.size?lt:Vn}),$(le.length===0?"No results":`${le.length} result${le.length===1?"":"s"}`)}catch{c([]),$("Search failed. Try again.")}finally{V(!1)}}},[]);f.useEffect(()=>{e==="authenticated"&&ch().then(T=>{if(s(T),T.length>0){const A=T[0].id;o(A)}})},[e]),f.useEffect(()=>{if(a){if(fe.current){fe.current=!1,Promise.all([Vs(a).then(Z),al(a).then(de)]);return}p(null),y(null),m(null),k(new Set),Promise.all([Y(a,"",null),Vs(a).then(Z),al(a).then(de)])}},[a]),f.useEffect(()=>{if(a===null)return;const T=setTimeout(()=>{Y(a,P,j)},300);return()=>clearTimeout(T)},[P,a]),f.useEffect(()=>{a!==null&&(j!==null&&v("archive"),Y(a,P,j))},[j,a]);const pe=f.useCallback(T=>{o(T)},[]),R=f.useCallback(T=>{v(T),T==="tags"&&a&&al(a).then(de)},[a]);f.useEffect(()=>{if(nr)return;const T=Km(d,w);window.location.pathname!==T&&history.pushState(null,"",T+window.location.search)},[d,w]);const W=f.useCallback(T=>{m(T?T.entry_uid:null),y(T)},[]),Te=f.useCallback((T,A)=>{if(A.shiftKey&&q.current!==null){A.preventDefault();const X=u.findIndex(Qn=>Qn.entry_uid===q.current),le=u.findIndex(Qn=>Qn.entry_uid===T.entry_uid);if(X===-1||le===-1){q.current=T.entry_uid,k(new Set([T.entry_uid])),W(T);return}const lt=Math.min(X,le),vt=Math.max(X,le),Vn=u.slice(lt,vt+1),hn=new Set(Vn.map(Qn=>Qn.entry_uid));k(hn),hn.size===1&&W(Vn[0])}else A.ctrlKey||A.metaKey?(q.current=T.entry_uid,k(X=>{const le=new Set(X);return le.has(T.entry_uid)?le.delete(T.entry_uid):le.add(T.entry_uid),le})):(q.current=T.entry_uid,k(new Set([T.entry_uid])),W(T))},[u,W]),we=f.useCallback(T=>{p(T)},[]),us=f.useCallback(()=>{p(null)},[]),Fr=f.useCallback(()=>{a&&al(a).then(de)},[a]),Mr=f.useCallback((T,A)=>{j===T?p(A):j!=null&&j.startsWith(T+"/")&&p(A+j.slice(T.length))},[j]),cs=f.useCallback(T=>{(j===T||j!=null&&j.startsWith(T+"/"))&&p(null)},[j]),ds=f.useCallback((T,A)=>{c(X=>X.map(le=>le.entry_uid===T?{...le,title:A}:le)),y(X=>X&&X.entry_uid===T?{...X,title:A}:X),I(X=>X&&X.summary.entry_uid===T?{...X,summary:{...X.summary,title:A}}:X)},[]),fs=f.useCallback(()=>{if(!a||!h)return;const T=++H.current;Bi(a,h.entry_uid).then(A=>{T===H.current&&I(A)}).catch(()=>{})},[a,h]),ps=f.useCallback(T=>{c(A=>A.filter(X=>X.entry_uid!==T)),y(A=>(A==null?void 0:A.entry_uid)===T?null:A),m(A=>A===T?null:A),k(A=>{const X=new Set(A);return X.delete(T),X})},[]),hs=f.useCallback(T=>{c(A=>A.filter(X=>!T.has(X.entry_uid))),k(new Set),y(null),m(null)},[]);f.useEffect(()=>{if(x.size>=2)m(null),y(null);else if(x.size===1){const[T]=x;m(T)}else m(null),y(null)},[x]);const ms=f.useMemo(()=>u.filter(T=>x.has(T.entry_uid)),[u,x]);f.useEffect(()=>{if(!g||h)return;const T=u.find(A=>A.entry_uid===g);T&&y(T)},[u,g,h]),f.useEffect(()=>{if(nr)return;const T=new URLSearchParams;P&&T.set("q",P),d==="archive"&&j&&T.set("tag",j),d==="archive"&&g&&T.set("entry",g);const A=T.toString(),X=window.location.pathname+(A?"?"+A:"");window.location.pathname+window.location.search!==X&&history.replaceState(null,"",X)},[P,j,g,d]),f.useEffect(()=>{const T=A=>{var X,le;(A.metaKey||A.ctrlKey)&&A.key==="k"&&(A.preventDefault(),d==="archive"?((X=B.current)==null||X.focus(),(le=B.current)==null||le.select()):(U.current=!0,v("archive")))};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[d]),f.useEffect(()=>{d==="archive"&&U.current&&(U.current=!1,requestAnimationFrame(()=>{var T,A;(T=B.current)==null||T.focus(),(A=B.current)==null||A.select()}))},[d]);const dn=f.useCallback(()=>{ie(!0)},[]),fn=f.useCallback(()=>{ie(!1)},[]),Br=f.useCallback(()=>{a&&Promise.all([Y(a,P,j),Vs(a).then(Z)])},[a,P,j,Y]),Hr=f.useCallback((T,A,X="error",le=null)=>{if(X==="warning"&&J&&A)return;const lt=++F.current;E(vt=>[...vt,{id:lt,text:T,locator:A,type:X,headline:le}])},[J]),gs=f.useCallback(T=>{E(A=>A.filter(X=>X.id!==T))},[]),vs=f.useCallback(()=>{sessionStorage.setItem("ublockWarningIgnored","true"),M(!0),E(T=>T.filter(A=>!(A.type==="warning"&&A.locator)))},[]),[D,ne]=f.useState(null),[Ie,pn]=f.useState(null),ys=f.useCallback(()=>{h&&ne(h.entry_uid)},[h]),Dd=f.useCallback(()=>ne(null),[]),$d=f.useCallback((T,A)=>{pn({src:T,entry:A})},[]),Id=f.useCallback(()=>pn(null),[]);return f.useEffect(()=>{ne(null)},[h]),f.useEffect(()=>(document.body.classList.toggle("has-audio-bar",!!Ie),()=>document.body.classList.remove("has-audio-bar")),[Ie]),e==="loading"?i.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?i.jsx(Yh,{onComplete:()=>t("login")}):e==="login"?i.jsx(Gh,{onLogin:T=>{r(T),t("authenticated")}}):nr?i.jsx(Mm,{archiveId:nr.archiveId,entryUid:nr.entryUid}):i.jsx(os.Provider,{value:{currentUser:n,setCurrentUser:r},children:i.jsxs(i.Fragment,{children:[i.jsx(Zh,{archives:l,archiveId:a,onArchiveChange:pe,view:d,onViewChange:R,onCaptureClick:dn}),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",{ref:B,className:"search-input",type:"search","aria-label":"Search archive","aria-busy":L,placeholder:"Search titles, URLs, types, tags…",value:P,onChange:T=>C(T.target.value)}),i.jsx("span",{className:"kbd",children:"⌘K"})]}),i.jsxs("span",{className:"result-count",children:[_&&i.jsxs(i.Fragment,{children:[i.jsx("b",{children:_.split(" ")[0]})," ",_.split(" ").slice(1).join(" ")]}),j&&i.jsxs("button",{className:"tag-filter-badge",onClick:us,children:["× ",K?Cd(j):j]})]})]}),d==="archive"&&i.jsx(sm,{entries:u,selectedUids:x,onRowClick:Te,archiveId:a}),d==="runs"&&i.jsx(om,{runs:te}),d==="admin"&&i.jsx(cm,{archives:l}),d==="tags"&&i.jsx(dm,{archiveId:a,tagNodes:se,tagFilter:j,onTagFilterSet:we,onViewChange:R,onTagRenamed:Mr,onTagDeleted:cs,onTagsRefresh:Fr,humanizeTags:K}),d==="collections"&&i.jsx(pm,{archiveId:a}),d==="settings"&&i.jsx(mm,{tab:w,onTabChange:S,archiveId:a})]}),i.jsx(Sm,{archiveId:a,selectedEntry:h,selectedUids:x,selectedEntries:ms,detail:N,onTagFilterSet:we,tagNodes:se,onTagsRefresh:Fr,onEntryTitleChange:ds,onEntryDeleted:ps,onBulkDeleted:hs,humanizeTags:K,onDetailRefresh:fs,onOpenPreview:ys,onPlay:$d})]}),D&&h&&h.entry_uid===D&&i.jsx(Am,{archiveId:a,entry:h,detail:N,onClose:Dd}),Ie&&i.jsx(Fm,{entry:Ie.entry,src:Ie.src,archiveId:a,onClose:Id}),i.jsx(em,{open:xe,archiveId:a,onClose:fn,onCaptured:Br,onToast:Hr}),i.jsx(Hm,{toasts:z,onDismiss:gs,onIgnoreUblock:vs})]})})}wd(document.getElementById("root")).render(i.jsx(f.StrictMode,{children:i.jsx(Xm,{})})); diff --git a/crates/archivr-server/static/index.html b/crates/archivr-server/static/index.html index 131937b..9a2ae4a 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/components/PreviewPage.jsx b/frontend/src/components/PreviewPage.jsx index 480aebc..7bf9d56 100644 --- a/frontend/src/components/PreviewPage.jsx +++ b/frontend/src/components/PreviewPage.jsx @@ -9,8 +9,28 @@ export default function PreviewPage({ archiveId, entryUid }) { const [detail, setDetail] = useState(null) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) + // Set to true by ArticleRenderer when the entry turns out to be an X article, + // triggering the X dark palette on the page shell. + const [xArticle, setXArticle] = useState(false) + + // When displaying an X article, make the document scroll (not an inner div) + // and apply color-scheme:dark so native scrollbars match the dark palette. + useEffect(() => { + if (!xArticle) return + const html = document.documentElement + const body = document.body + const prevScheme = html.style.colorScheme + const prevBg = body.style.background + html.style.colorScheme = 'dark' + body.style.background = '#000' + return () => { + html.style.colorScheme = prevScheme + body.style.background = prevBg + } + }, [xArticle]) useEffect(() => { + setXArticle(false) fetchEntryDetail(archiveId, entryUid) .then(d => { setDetail(d); setLoading(false) }) .catch(e => { setError(e?.message || 'Failed to load entry'); setLoading(false) }) @@ -24,28 +44,33 @@ export default function PreviewPage({ archiveId, entryUid }) { minHeight: '100vh', display: 'flex', flexDirection: 'column', - background: 'var(--paper)', + background: xArticle ? '#000' : 'var(--paper)', fontFamily: 'var(--sans)', }}> - {/* Minimal topbar */} + {/* Topbar — sticky + blur when showing an X article, matching a-topbar in the renderer */}
← Archive Original ↗ )}
{/* Content */} -
+
{loading && (
Loading… @@ -77,6 +104,8 @@ export default function PreviewPage({ archiveId, entryUid }) { archiveId={archiveId} entry={detail.summary} detail={detail} + fullPage + onXArticle={setXArticle} /> )}
diff --git a/frontend/src/components/PreviewPanel.jsx b/frontend/src/components/PreviewPanel.jsx index 381e6c7..a7c2711 100644 --- a/frontend/src/components/PreviewPanel.jsx +++ b/frontend/src/components/PreviewPanel.jsx @@ -7,7 +7,7 @@ const VIDEO_EXTS = new Set(['mp4', 'webm', 'mov', 'mkv', 'avi', 'm4v', 'ogv']); const AUDIO_EXTS = new Set(['mp3', 'ogg', 'm4a', 'opus', 'wav', 'flac', 'aac']); const IMAGE_EXTS = new Set(['jpg', 'jpeg', 'png', 'gif', 'webp', 'avif', 'svg', 'bmp']); -export default function PreviewPanel({ archiveId, entry, detail }) { +export default function PreviewPanel({ archiveId, entry, detail, fullPage, onXArticle }) { if (!entry) { return ( @@ -35,16 +35,20 @@ export default function PreviewPanel({ archiveId, entry, detail }) { // 1. Tweet / tweet thread if (entityKind === 'tweet' || entityKind === 'tweet_thread') { - return ( -
- -
+ const tweetPreview = ( + ); + // In fullPage mode the parent (PreviewPage) is the scroll container; + // skip preview-tweet-wrap to avoid nested overflow/scroll. + if (fullPage) return tweetPreview; + return
{tweetPreview}
; } // 2. Find primary_media artifact diff --git a/frontend/src/components/TweetPreview.jsx b/frontend/src/components/TweetPreview.jsx index be3c0e3..eb2f404 100644 --- a/frontend/src/components/TweetPreview.jsx +++ b/frontend/src/components/TweetPreview.jsx @@ -415,6 +415,84 @@ const S = { }, }; +// ── X dark palette (mirroring x-article-renderer) ────────────────────────────── +const X = { + bg: '#000000', + border: '#2f3336', + text: '#e7e9ea', + dim: '#71767b', + accent: '#1d9bf0', + codeBg: '#16181c', +}; + +// ── Full-page X article styles (mirrors x-article-renderer CSS) ────────────────── +// Used only when ArticleRenderer is rendered from PreviewPage (fullPage=true). +// Colors are hard-coded to X's dark palette; layout matches the standalone renderer. +const SF = { + // Article container — fills the scrollable page area, dark bg + article: { + background: X.bg, + color: X.text, + minHeight: '100%', + fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif', + }, + // Inner content — constrained to 598px, matches #article-content in renderer + articleInner: { + maxWidth: '598px', + margin: '0 auto', + paddingBottom: '80px', + }, + aCover: { width: '100%', display: 'block', objectFit: 'cover', maxHeight: '420px' }, + aMeta: { padding: '20px 16px 0' }, + aTweetTitle: { + fontSize: '34px', fontWeight: '800', letterSpacing: '-0.5px', + color: X.text, lineHeight: '44px', marginBottom: '16px', + }, + aAuthorRow: { display: 'flex', alignItems: 'center', gap: '12px', marginBottom: '16px' }, + aAvatar: { width: '40px', height: '40px', borderRadius: '50%', objectFit: 'cover', flexShrink: 0, display: 'block' }, + aAvatarPh: { width: '40px', height: '40px', borderRadius: '50%', background: X.border, flexShrink: 0 }, + aAuthorName: { fontSize: '15px', fontWeight: '700', color: X.text, lineHeight: '1.3' }, + aAuthorSub: { fontSize: '15px', color: X.dim, lineHeight: '1.3' }, + aDivider: { border: 'none', borderTop: `1px solid ${X.border}`, margin: '0' }, + aBody: { padding: '4px 16px 0' }, + // Block styles + bH1: { + fontSize: '26px', fontWeight: '800', letterSpacing: '-0.4px', + color: X.text, lineHeight: '36px', margin: '24px 0 10px', + }, + bH2: { + fontSize: '26px', fontWeight: '800', letterSpacing: '-0.4px', + color: X.text, lineHeight: '36px', margin: '24px 0 10px', + }, + bP: { fontSize: '17px', color: X.text, lineHeight: '1.5', marginBottom: '16px', marginTop: '0' }, + bSpacer: { height: '6px', display: 'block' }, + bQuote: { borderLeft: `3px solid ${X.border}`, padding: '2px 14px', margin: '14px 0', color: X.dim, fontSize: '17px', lineHeight: '1.5' }, + bHr: { border: 'none', borderTop: `1px solid ${X.border}`, margin: '28px 0' }, + bImg: { width: '100%', display: 'block', borderRadius: '12px', margin: '16px 0' }, + bUl: { margin: '10px 0 16px', paddingLeft: '28px' }, + bOl: { margin: '10px 0 16px', paddingLeft: '28px' }, + bLi: { fontSize: '17px', color: X.text, lineHeight: '1.5', marginBottom: '6px' }, + bTweet: { + display: 'flex', alignItems: 'center', gap: '12px', + border: `1px solid ${X.border}`, borderRadius: '12px', + padding: '14px 16px', margin: '14px 0', + color: X.dim, fontSize: '15px', textDecoration: 'none', + }, + bMdPre: { borderRadius: '12px', margin: '12px 0', overflow: 'auto', background: '#1e2029' }, + bMdCode: { + fontFamily: "ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, Consolas, monospace", + fontSize: '13px', lineHeight: '1.65', + padding: '18px 20px', display: 'block', + color: X.text, background: 'transparent', + }, + iCode: { + fontFamily: "ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace", + fontSize: '0.875em', background: X.codeBg, + padding: '2px 6px', borderRadius: '4px', color: '#e6edf3', + }, + link: { color: X.accent, textDecoration: 'none' }, +}; + // ── Artifact URL helpers ──────────────────────────────────────────────────────── // Build relpath → artifact API URL map from the artifacts array so archived // copies are preferred over CDN URLs (avatars, media, cover images). @@ -590,7 +668,7 @@ function renderTweetTextJSX(fullText, entities, skipSpans = []) { // Splits block text at style-range, URL, and mention boundaries, returning // an array of React nodes with the appropriate wrappers applied. -function renderInlineJSX(text, styleRanges, urls, mentions) { +function renderInlineJSX(text, styleRanges, urls, mentions, st = S) { if (!text) return null; styleRanges = styleRanges || []; urls = urls || []; @@ -610,7 +688,7 @@ function renderInlineJSX(text, styleRanges, urls, mentions) { if (ann) anns.push(ann); } - if (anns.length === 0) return linkifyText(text, S.link); + if (anns.length === 0) return linkifyText(text, st.link); const pts = new Set([0, text.length]); for (const a of anns) { @@ -637,7 +715,7 @@ function renderInlineJSX(text, styleRanges, urls, mentions) { // Apply inline styles innermost first (matching Draft.js precedence). if (active.some(a => a.kind === 'style' && a.style === 'Code')) - content = {content}; + content = {content}; if (active.some(a => a.kind === 'style' && a.style === 'Bold')) content = {content}; if (active.some(a => a.kind === 'style' && a.style === 'Italic')) @@ -654,7 +732,7 @@ function renderInlineJSX(text, styleRanges, urls, mentions) { // human-readable display URL; otherwise keep the styled anchor text. const isTco = /^https?:\/\/t\.co\//i.test(content); content = ( - + {isTco ? url.display : content} ); @@ -667,14 +745,14 @@ function renderInlineJSX(text, styleRanges, urls, mentions) { href={`https://x.com/${mention.screen_name}`} target="_blank" rel="noopener noreferrer" - style={S.link} + style={st.link} > {content} ); } - return {typeof content === 'string' ? linkifyText(content, S.link) : content}; + return {typeof content === 'string' ? linkifyText(content, st.link) : content}; }); } @@ -682,13 +760,14 @@ function renderInlineJSX(text, styleRanges, urls, mentions) { // Port of renderAtomic() from x-article-renderer. function renderAtomicJSX(block, artifactMap, opts) { + const st = opts?.st || S; const entities = block.resolved_entities || []; if (entities.length === 0) return null; return entities.map((e, i) => { switch (e.type) { case 'divider': - return
; + return
; case 'media': { const src = resolveUrl(e.local_path, e.url, artifactMap); @@ -707,7 +786,7 @@ function renderAtomicJSX(block, artifactMap, opts) { } }} > - + ); } @@ -719,7 +798,7 @@ function renderAtomicJSX(block, artifactMap, opts) { href={`https://x.com/i/status/${e.tweet_id}`} target="_blank" rel="noopener noreferrer" - style={S.bTweet} + style={st.bTweet} > View post on X @@ -728,8 +807,8 @@ function renderAtomicJSX(block, artifactMap, opts) { case 'link': return e.url ? ( -

- +

+ {e.url}

@@ -738,8 +817,8 @@ function renderAtomicJSX(block, artifactMap, opts) { case 'markdown': { const md = e.markdown ?? e.data?.markdown ?? ''; return ( -
-            {md}
+          
+            {md}
           
); } @@ -764,15 +843,16 @@ function renderAtomicJSX(block, artifactMap, opts) { // Port of renderBlock() from x-article-renderer. function renderBlockJSX(block, key, artifactMap, opts) { + const st = opts?.st || S; const type = block.type || ''; const text = block.text || ''; const styleRanges = block.inline_style_ranges || []; const data = block.data || {}; - const inner = renderInlineJSX(text, styleRanges, data.urls || [], data.mentions || []); + const inner = renderInlineJSX(text, styleRanges, data.urls || [], data.mentions || [], st); switch (type) { case 'header-one': - return

{inner}

; + return

{inner}

; case 'header-two': { const m = text.match(/(?:x\.com|twitter\.com)\/i\/status\/(\d+)/); @@ -783,32 +863,32 @@ function renderBlockJSX(block, key, artifactMap, opts) { href={`https://x.com/i/status/${m[1]}`} target="_blank" rel="noopener noreferrer" - style={S.bTweet} + style={st.bTweet} > View post on X ); } - return

{inner}

; + return

{inner}

; } case 'unstyled': - if (!text.trim()) return ; - return

{inner}

; + if (!text.trim()) return ; + return

{inner}

; case 'blockquote': - return
{inner}
; + return
{inner}
; case 'unordered-list-item': case 'ordered-list-item': - return
  • {inner}
  • ; + return
  • {inner}
  • ; case 'atomic': return {renderAtomicJSX(block, artifactMap, opts)}; default: - return text ?

    {inner}

    : null; + return text ?

    {inner}

    : null; } } @@ -817,6 +897,7 @@ function renderBlockJSX(block, key, artifactMap, opts) { // Groups consecutive same-type list items into a single ul/ol. function renderBlocksJSX(blocks, artifactMap, opts) { + const st = opts?.st || S; const items = []; let i = 0; @@ -830,7 +911,7 @@ function renderBlocksJSX(blocks, artifactMap, opts) { listItems.push(renderBlockJSX(blocks[i], i, artifactMap, opts)); i++; } - items.push(
      {listItems}
    ); + items.push(
      {listItems}
    ); } else if (b.type === 'ordered-list-item') { const startIdx = i; const listItems = []; @@ -838,7 +919,7 @@ function renderBlocksJSX(blocks, artifactMap, opts) { listItems.push(renderBlockJSX(blocks[i], i, artifactMap, opts)); i++; } - items.push(
      {listItems}
    ); + items.push(
      {listItems}
    ); } else { items.push(renderBlockJSX(b, i, artifactMap, opts)); i++; @@ -850,9 +931,15 @@ function renderBlocksJSX(blocks, artifactMap, opts) { // ── Article renderer ─────────────────────────────────────────────────────────── -function ArticleRenderer({ article, tweetAuthor, artifactMap }) { +function ArticleRenderer({ article, tweetAuthor, artifactMap, fullPage, onXArticle }) { const [lightboxSrc, setLightboxSrc] = useState(null); + // Notify the page shell (PreviewPage) that it should switch to X dark palette. + useEffect(() => { + if (fullPage) onXArticle?.(true); + }, [fullPage, onXArticle]); + + const st = fullPage ? SF : S; const cover = article.cover_media || {}; const author = article.author || tweetAuthor || {}; const date = article.first_published_at_secs @@ -864,8 +951,8 @@ function ArticleRenderer({ article, tweetAuthor, artifactMap }) { const coverSrc = resolveUrl(cover.local_path, cover.url, artifactMap); const avatarSrc = resolveUrl(author.avatar_local_path, author.avatar_url, artifactMap); - return ( -
    + const body = ( + <> {lightboxSrc && ( { if (!e.metaKey && !e.ctrlKey) { e.preventDefault(); setLightboxSrc(coverSrc); } }} > - Article cover + Article cover )} -
    +
    {article.title && ( -
    {article.title}
    +
    {article.title}
    )} -
    +
    {avatarSrc - ? {author.name - :
    + ? {author.name + :
    }
    -
    +
    {author.name || author.screen_name || 'Unknown'}
    {subLine && ( -
    {subLine}
    +
    {subLine}
    )}
    -
    -
    - {renderBlocksJSX(article.blocks || [], artifactMap, { onImgClick: setLightboxSrc })} +
    +
    + {renderBlocksJSX(article.blocks || [], artifactMap, { onImgClick: setLightboxSrc, st })}
    -
    + ); + + if (fullPage) { + return ( +
    +
    {body}
    +
    + ); + } + + return
    {body}
    ; } // ── Tweet card ───────────────────────────────────────────────────────────────── @@ -1148,7 +1245,7 @@ function TweetCard({ tweet, isInThread, isLast, artifactMap }) { // ── TweetPreview ─────────────────────────────────────────────────────────────── -export default function TweetPreview({ archiveId, entryUid, artifacts, entityKind }) { +export default function TweetPreview({ archiveId, entryUid, artifacts, entityKind, fullPage, onXArticle }) { const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [tweets, setTweets] = useState([]); @@ -1258,7 +1355,7 @@ export default function TweetPreview({ archiveId, entryUid, artifacts, entityKin const tweet = tweets[0]; if (tweet.is_article && tweet.article) { - return ; + return ; } return (