mirror of
https://github.com/thegeneralist01/archivr
synced 2026-10-09 12:55:00 +02:00
- Persist sibling order for child entries (archived_entries.position): backfilled to the previous archived_at order, new children appended (initial playlist order kept; sync appends after user order). - PUT /api/archives/:id/entries/:uid/children/order takes the full child UID list in one IMMEDIATE transaction (401 guest, 403 role not allowed, 404 unknown or invisible parent, 400 unless exactly the current children). - Reorder permission is a role mask in the auth instance settings (reorder_children_role_bits, default Admin|Owner). Only the Owner can change it, built-in or custom roles, never Guest. /api/auth/me and login expose can_reorder_children. Settings PATCH is now one IMMEDIATE txn. - Main page: drag handle for mouse/trackpad on viewports >640px, up/down arrows otherwise (pure CSS, arrows are the fallback), Alt+Up/Down everywhere; optimistic with revert. Settings > Instance > Permissions for the Owner (read-only for admins). - Fix: renaming a child entry now updates its row immediately. - Remove Storybook (deps, config, stories, docs).
49 lines
314 KiB
JavaScript
49 lines
314 KiB
JavaScript
(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 Xu={exports:{}},Cs={},Ju={exports:{}},oe={};/**
|
||
* @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 gl=Symbol.for("react.element"),Nf=Symbol.for("react.portal"),Cf=Symbol.for("react.fragment"),Ef=Symbol.for("react.strict_mode"),bf=Symbol.for("react.profiler"),Tf=Symbol.for("react.provider"),Pf=Symbol.for("react.context"),Lf=Symbol.for("react.forward_ref"),Rf=Symbol.for("react.suspense"),zf=Symbol.for("react.memo"),If=Symbol.for("react.lazy"),So=Symbol.iterator;function $f(e){return e===null||typeof e!="object"?null:(e=So&&e[So]||e["@@iterator"],typeof e=="function"?e:null)}var Gu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Yu=Object.assign,Zu={};function jr(e,t,n){this.props=e,this.context=t,this.refs=Zu,this.updater=n||Gu}jr.prototype.isReactComponent={};jr.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")};jr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ec(){}ec.prototype=jr.prototype;function _a(e,t,n){this.props=e,this.context=t,this.refs=Zu,this.updater=n||Gu}var Na=_a.prototype=new ec;Na.constructor=_a;Yu(Na,jr.prototype);Na.isPureReactComponent=!0;var _o=Array.isArray,tc=Object.prototype.hasOwnProperty,Ca={current:null},nc={key:!0,ref:!0,__self:!0,__source:!0};function rc(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)tc.call(t,r)&&!nc.hasOwnProperty(r)&&(l[r]=t[r]);var o=arguments.length-2;if(o===1)l.children=n;else if(1<o){for(var u=Array(o),d=0;d<o;d++)u[d]=arguments[d+2];l.children=u}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)l[r]===void 0&&(l[r]=o[r]);return{$$typeof:gl,type:e,key:i,ref:a,props:l,_owner:Ca.current}}function Df(e,t){return{$$typeof:gl,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Ea(e){return typeof e=="object"&&e!==null&&e.$$typeof===gl}function Of(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var No=/\/+/g;function Zs(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Of(""+e.key):t.toString(36)}function Ul(e,t,n,r,l){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(i){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case gl:case Nf:a=!0}}if(a)return a=e,l=l(a),e=r===""?"."+Zs(a,0):r,_o(l)?(n="",e!=null&&(n=e.replace(No,"$&/")+"/"),Ul(l,t,n,"",function(d){return d})):l!=null&&(Ea(l)&&(l=Df(l,n+(!l.key||a&&a.key===l.key?"":(""+l.key).replace(No,"$&/")+"/")+e)),t.push(l)),1;if(a=0,r=r===""?".":r+":",_o(e))for(var o=0;o<e.length;o++){i=e[o];var u=r+Zs(i,o);a+=Ul(i,t,n,u,l)}else if(u=$f(e),typeof u=="function")for(e=u.call(e),o=0;!(i=e.next()).done;)i=i.value,u=r+Zs(i,o++),a+=Ul(i,t,n,u,l);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function Sl(e,t,n){if(e==null)return e;var r=[],l=0;return Ul(e,r,"","",function(i){return t.call(n,i,l++)}),r}function Af(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var ut={current:null},Hl={transition:null},Mf={ReactCurrentDispatcher:ut,ReactCurrentBatchConfig:Hl,ReactCurrentOwner:Ca};function lc(){throw Error("act(...) is not supported in production builds of React.")}oe.Children={map:Sl,forEach:function(e,t,n){Sl(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Sl(e,function(){t++}),t},toArray:function(e){return Sl(e,function(t){return t})||[]},only:function(e){if(!Ea(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};oe.Component=jr;oe.Fragment=Cf;oe.Profiler=bf;oe.PureComponent=_a;oe.StrictMode=Ef;oe.Suspense=Rf;oe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Mf;oe.act=lc;oe.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=Yu({},e.props),l=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=Ca.current),t.key!==void 0&&(l=""+t.key),e.type&&e.type.defaultProps)var o=e.type.defaultProps;for(u in t)tc.call(t,u)&&!nc.hasOwnProperty(u)&&(r[u]=t[u]===void 0&&o!==void 0?o[u]:t[u])}var u=arguments.length-2;if(u===1)r.children=n;else if(1<u){o=Array(u);for(var d=0;d<u;d++)o[d]=arguments[d+2];r.children=o}return{$$typeof:gl,type:e.type,key:l,ref:i,props:r,_owner:a}};oe.createContext=function(e){return e={$$typeof:Pf,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Tf,_context:e},e.Consumer=e};oe.createElement=rc;oe.createFactory=function(e){var t=rc.bind(null,e);return t.type=e,t};oe.createRef=function(){return{current:null}};oe.forwardRef=function(e){return{$$typeof:Lf,render:e}};oe.isValidElement=Ea;oe.lazy=function(e){return{$$typeof:If,_payload:{_status:-1,_result:e},_init:Af}};oe.memo=function(e,t){return{$$typeof:zf,type:e,compare:t===void 0?null:t}};oe.startTransition=function(e){var t=Hl.transition;Hl.transition={};try{e()}finally{Hl.transition=t}};oe.unstable_act=lc;oe.useCallback=function(e,t){return ut.current.useCallback(e,t)};oe.useContext=function(e){return ut.current.useContext(e)};oe.useDebugValue=function(){};oe.useDeferredValue=function(e){return ut.current.useDeferredValue(e)};oe.useEffect=function(e,t){return ut.current.useEffect(e,t)};oe.useId=function(){return ut.current.useId()};oe.useImperativeHandle=function(e,t,n){return ut.current.useImperativeHandle(e,t,n)};oe.useInsertionEffect=function(e,t){return ut.current.useInsertionEffect(e,t)};oe.useLayoutEffect=function(e,t){return ut.current.useLayoutEffect(e,t)};oe.useMemo=function(e,t){return ut.current.useMemo(e,t)};oe.useReducer=function(e,t,n){return ut.current.useReducer(e,t,n)};oe.useRef=function(e){return ut.current.useRef(e)};oe.useState=function(e){return ut.current.useState(e)};oe.useSyncExternalStore=function(e,t,n){return ut.current.useSyncExternalStore(e,t,n)};oe.useTransition=function(){return ut.current.useTransition()};oe.version="18.3.1";Ju.exports=oe;var c=Ju.exports;/**
|
||
* @license React
|
||
* react-jsx-runtime.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 Ff=c,Bf=Symbol.for("react.element"),Uf=Symbol.for("react.fragment"),Hf=Object.prototype.hasOwnProperty,Wf=Ff.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Vf={key:!0,ref:!0,__self:!0,__source:!0};function sc(e,t,n){var r,l={},i=null,a=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)Hf.call(t,r)&&!Vf.hasOwnProperty(r)&&(l[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)l[r]===void 0&&(l[r]=t[r]);return{$$typeof:Bf,type:e,key:i,ref:a,props:l,_owner:Wf.current}}Cs.Fragment=Uf;Cs.jsx=sc;Cs.jsxs=sc;Xu.exports=Cs;var s=Xu.exports,ic={exports:{}},St={},ac={exports:{}},oc={};/**
|
||
* @license React
|
||
* scheduler.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.
|
||
*/(function(e){function t(I,R){var K=I.length;I.push(R);e:for(;0<K;){var ee=K-1>>>1,se=I[ee];if(0<l(se,R))I[ee]=R,I[K]=se,K=ee;else break e}}function n(I){return I.length===0?null:I[0]}function r(I){if(I.length===0)return null;var R=I[0],K=I.pop();if(K!==R){I[0]=K;e:for(var ee=0,se=I.length,ie=se>>>1;ee<ie;){var Y=2*(ee+1)-1,Ne=I[Y],pe=Y+1,U=I[pe];if(0>l(Ne,K))pe<se&&0>l(U,Ne)?(I[ee]=U,I[pe]=K,ee=pe):(I[ee]=Ne,I[Y]=K,ee=Y);else if(pe<se&&0>l(U,K))I[ee]=U,I[pe]=K,ee=pe;else break e}}return R}function l(I,R){var K=I.sortIndex-R.sortIndex;return K!==0?K:I.id-R.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=[],d=[],y=1,g=null,m=3,x=!1,w=!1,S=!1,_=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(I){for(var R=n(d);R!==null;){if(R.callback===null)r(d);else if(R.startTime<=I)r(d),R.sortIndex=R.expirationTime,t(u,R);else break;R=n(d)}}function k(I){if(S=!1,h(I),!w)if(n(u)!==null)w=!0,Le(E);else{var R=n(d);R!==null&&ve(k,R.startTime-I)}}function E(I,R){w=!1,S&&(S=!1,p(v),v=-1),x=!0;var K=m;try{for(h(R),g=n(u);g!==null&&(!(g.expirationTime>R)||I&&!X());){var ee=g.callback;if(typeof ee=="function"){g.callback=null,m=g.priorityLevel;var se=ee(g.expirationTime<=R);R=e.unstable_now(),typeof se=="function"?g.callback=se:g===n(u)&&r(u),h(R)}else r(u);g=n(u)}if(g!==null)var ie=!0;else{var Y=n(d);Y!==null&&ve(k,Y.startTime-R),ie=!1}return ie}finally{g=null,m=K,x=!1}}var P=!1,N=null,v=-1,b=5,L=-1;function X(){return!(e.unstable_now()-L<b)}function Q(){if(N!==null){var I=e.unstable_now();L=I;var R=!0;try{R=N(!0,I)}finally{R?ne():(P=!1,N=null)}}else P=!1}var ne;if(typeof f=="function")ne=function(){f(Q)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,fe=q.port2;q.port1.onmessage=Q,ne=function(){fe.postMessage(null)}}else ne=function(){_(Q,0)};function Le(I){N=I,P||(P=!0,ne())}function ve(I,R){v=_(function(){I(e.unstable_now())},R)}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(I){I.callback=null},e.unstable_continueExecution=function(){w||x||(w=!0,Le(E))},e.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):b=0<I?Math.floor(1e3/I):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(I){switch(m){case 1:case 2:case 3:var R=3;break;default:R=m}var K=m;m=R;try{return I()}finally{m=K}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(I,R){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var K=m;m=I;try{return R()}finally{m=K}},e.unstable_scheduleCallback=function(I,R,K){var ee=e.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?ee+K:ee):K=ee,I){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=K+se,I={id:y++,callback:R,priorityLevel:I,startTime:K,expirationTime:se,sortIndex:-1},K>ee?(I.sortIndex=K,t(d,I),n(u)===null&&I===n(d)&&(S?(p(v),v=-1):S=!0,ve(k,K-ee))):(I.sortIndex=se,t(u,I),w||x||(w=!0,Le(E))),I},e.unstable_shouldYield=X,e.unstable_wrapCallback=function(I){var R=m;return function(){var K=m;m=R;try{return I.apply(this,arguments)}finally{m=K}}}})(oc);ac.exports=oc;var Kf=ac.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 Qf=c,jt=Kf;function O(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var uc=new Set,Gr={};function Wn(e,t){mr(e,t),mr(e+"Capture",t)}function mr(e,t){for(Gr[e]=t,e=0;e<t.length;e++)uc.add(t[e])}var tn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Li=Object.prototype.hasOwnProperty,qf=/^[: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]*$/,Co={},Eo={};function Xf(e){return Li.call(Eo,e)?!0:Li.call(Co,e)?!1:qf.test(e)?Eo[e]=!0:(Co[e]=!0,!1)}function Jf(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 Gf(e,t,n,r){if(t===null||typeof t>"u"||Jf(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 ct(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 Ye={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ye[e]=new ct(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ye[t]=new ct(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ye[e]=new ct(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ye[e]=new ct(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){Ye[e]=new ct(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ye[e]=new ct(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ye[e]=new ct(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ye[e]=new ct(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ye[e]=new ct(e,5,!1,e.toLowerCase(),null,!1,!1)});var ba=/[\-:]([a-z])/g;function Ta(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(ba,Ta);Ye[t]=new ct(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(ba,Ta);Ye[t]=new ct(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(ba,Ta);Ye[t]=new ct(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ye[e]=new ct(e,1,!1,e.toLowerCase(),null,!1,!1)});Ye.xlinkHref=new ct("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ye[e]=new ct(e,1,!1,e.toLowerCase(),null,!0,!0)});function Pa(e,t,n,r){var l=Ye.hasOwnProperty(t)?Ye[t]:null;(l!==null?l.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Gf(t,n,l,r)&&(n=null),r||l===null?Xf(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):l.mustUseProperty?e[l.propertyName]=n===null?l.type===3?!1:"":n:(t=l.attributeName,r=l.attributeNamespace,n===null?e.removeAttribute(t):(l=l.type,n=l===3||l===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var sn=Qf.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_l=Symbol.for("react.element"),Jn=Symbol.for("react.portal"),Gn=Symbol.for("react.fragment"),La=Symbol.for("react.strict_mode"),Ri=Symbol.for("react.profiler"),cc=Symbol.for("react.provider"),dc=Symbol.for("react.context"),Ra=Symbol.for("react.forward_ref"),zi=Symbol.for("react.suspense"),Ii=Symbol.for("react.suspense_list"),za=Symbol.for("react.memo"),dn=Symbol.for("react.lazy"),fc=Symbol.for("react.offscreen"),bo=Symbol.iterator;function Cr(e){return e===null||typeof e!="object"?null:(e=bo&&e[bo]||e["@@iterator"],typeof e=="function"?e:null)}var Pe=Object.assign,ei;function $r(e){if(ei===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);ei=t&&t[1]||""}return`
|
||
`+ei+e}var ti=!1;function ni(e,t){if(!e||ti)return"";ti=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var l=d.stack.split(`
|
||
`),i=r.stack.split(`
|
||
`),a=l.length-1,o=i.length-1;1<=a&&0<=o&&l[a]!==i[o];)o--;for(;1<=a&&0<=o;a--,o--)if(l[a]!==i[o]){if(a!==1||o!==1)do if(a--,o--,0>o||l[a]!==i[o]){var u=`
|
||
`+l[a].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=a&&0<=o);break}}}finally{ti=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?$r(e):""}function Yf(e){switch(e.tag){case 5:return $r(e.type);case 16:return $r("Lazy");case 13:return $r("Suspense");case 19:return $r("SuspenseList");case 0:case 2:case 15:return e=ni(e.type,!1),e;case 11:return e=ni(e.type.render,!1),e;case 1:return e=ni(e.type,!0),e;default:return""}}function $i(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 Jn:return"Portal";case Ri:return"Profiler";case La:return"StrictMode";case zi:return"Suspense";case Ii:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case dc:return(e.displayName||"Context")+".Consumer";case cc:return(e._context.displayName||"Context")+".Provider";case Ra:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case za:return t=e.displayName||null,t!==null?t:$i(e.type)||"Memo";case dn:t=e._payload,e=e._init;try{return $i(e(t))}catch{}}return null}function Zf(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 $i(t);case 8:return t===La?"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 Nn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function pc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ep(e){var t=pc(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 Nl(e){e._valueTracker||(e._valueTracker=ep(e))}function hc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=pc(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function ts(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 Di(e,t){var n=t.checked;return Pe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function To(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Nn(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 mc(e,t){t=t.checked,t!=null&&Pa(e,"checked",t,!1)}function Oi(e,t){mc(e,t);var n=Nn(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")?Ai(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ai(e,t.type,Nn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Po(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 Ai(e,t,n){(t!=="number"||ts(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Dr=Array.isArray;function or(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l<n.length;l++)t["$"+n[l]]=!0;for(n=0;n<e.length;n++)l=t.hasOwnProperty("$"+e[n].value),e[n].selected!==l&&(e[n].selected=l),l&&r&&(e[n].defaultSelected=!0)}else{for(n=""+Nn(n),t=null,l=0;l<e.length;l++){if(e[l].value===n){e[l].selected=!0,r&&(e[l].defaultSelected=!0);return}t!==null||e[l].disabled||(t=e[l])}t!==null&&(t.selected=!0)}}function Mi(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(O(91));return Pe({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Lo(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(O(92));if(Dr(n)){if(1<n.length)throw Error(O(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Nn(n)}}function gc(e,t){var n=Nn(t.value),r=Nn(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Ro(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function yc(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Fi(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?yc(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Cl,vc=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,l){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,l)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Cl=Cl||document.createElement("div"),Cl.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Cl.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 Br={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},tp=["Webkit","ms","Moz","O"];Object.keys(Br).forEach(function(e){tp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Br[t]=Br[e]})});function xc(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Br.hasOwnProperty(e)&&Br[e]?(""+t).trim():t+"px"}function wc(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=xc(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var np=Pe({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 Bi(e,t){if(t){if(np[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(O(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(O(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(O(61))}if(t.style!=null&&typeof t.style!="object")throw Error(O(62))}}function Ui(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 Hi=null;function Ia(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Wi=null,ur=null,cr=null;function zo(e){if(e=xl(e)){if(typeof Wi!="function")throw Error(O(280));var t=e.stateNode;t&&(t=Ls(t),Wi(e.stateNode,e.type,t))}}function kc(e){ur?cr?cr.push(e):cr=[e]:ur=e}function jc(){if(ur){var e=ur,t=cr;if(cr=ur=null,zo(e),t)for(e=0;e<t.length;e++)zo(t[e])}}function Sc(e,t){return e(t)}function _c(){}var ri=!1;function Nc(e,t,n){if(ri)return e(t,n);ri=!0;try{return Sc(e,t,n)}finally{ri=!1,(ur!==null||cr!==null)&&(_c(),jc())}}function Zr(e,t){var n=e.stateNode;if(n===null)return null;var r=Ls(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(O(231,t,typeof n));return n}var Vi=!1;if(tn)try{var Er={};Object.defineProperty(Er,"passive",{get:function(){Vi=!0}}),window.addEventListener("test",Er,Er),window.removeEventListener("test",Er,Er)}catch{Vi=!1}function rp(e,t,n,r,l,i,a,o,u){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(y){this.onError(y)}}var Ur=!1,ns=null,rs=!1,Ki=null,lp={onError:function(e){Ur=!0,ns=e}};function sp(e,t,n,r,l,i,a,o,u){Ur=!1,ns=null,rp.apply(lp,arguments)}function ip(e,t,n,r,l,i,a,o,u){if(sp.apply(this,arguments),Ur){if(Ur){var d=ns;Ur=!1,ns=null}else throw Error(O(198));rs||(rs=!0,Ki=d)}}function Vn(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Cc(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Io(e){if(Vn(e)!==e)throw Error(O(188))}function ap(e){var t=e.alternate;if(!t){if(t=Vn(e),t===null)throw Error(O(188));return t!==e?null:e}for(var n=e,r=t;;){var l=n.return;if(l===null)break;var i=l.alternate;if(i===null){if(r=l.return,r!==null){n=r;continue}break}if(l.child===i.child){for(i=l.child;i;){if(i===n)return Io(l),e;if(i===r)return Io(l),t;i=i.sibling}throw Error(O(188))}if(n.return!==r.return)n=l,r=i;else{for(var a=!1,o=l.child;o;){if(o===n){a=!0,n=l,r=i;break}if(o===r){a=!0,r=l,n=i;break}o=o.sibling}if(!a){for(o=i.child;o;){if(o===n){a=!0,n=i,r=l;break}if(o===r){a=!0,r=i,n=l;break}o=o.sibling}if(!a)throw Error(O(189))}}if(n.alternate!==r)throw Error(O(190))}if(n.tag!==3)throw Error(O(188));return n.stateNode.current===n?e:t}function Ec(e){return e=ap(e),e!==null?bc(e):null}function bc(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=bc(e);if(t!==null)return t;e=e.sibling}return null}var Tc=jt.unstable_scheduleCallback,$o=jt.unstable_cancelCallback,op=jt.unstable_shouldYield,up=jt.unstable_requestPaint,De=jt.unstable_now,cp=jt.unstable_getCurrentPriorityLevel,$a=jt.unstable_ImmediatePriority,Pc=jt.unstable_UserBlockingPriority,ls=jt.unstable_NormalPriority,dp=jt.unstable_LowPriority,Lc=jt.unstable_IdlePriority,Es=null,Qt=null;function fp(e){if(Qt&&typeof Qt.onCommitFiberRoot=="function")try{Qt.onCommitFiberRoot(Es,e,void 0,(e.current.flags&128)===128)}catch{}}var Ft=Math.clz32?Math.clz32:mp,pp=Math.log,hp=Math.LN2;function mp(e){return e>>>=0,e===0?32:31-(pp(e)/hp|0)|0}var El=64,bl=4194304;function Or(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 ss(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=Or(o):(i&=a,i!==0&&(r=Or(i)))}else a=n&~l,a!==0?r=Or(a):i!==0&&(r=Or(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;0<t;)n=31-Ft(t),l=1<<n,r|=e[n],t&=~l;return r}function gp(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function yp(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,l=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Ft(i),o=1<<a,u=l[a];u===-1?(!(o&n)||o&r)&&(l[a]=gp(o,t)):u<=t&&(e.expiredLanes|=o),i&=~o}}function Qi(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Rc(){var e=El;return El<<=1,!(El&4194240)&&(El=64),e}function li(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function yl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ft(t),e[t]=n}function vp(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<n;){var l=31-Ft(n),i=1<<l;t[l]=0,r[l]=-1,e[l]=-1,n&=~i}}function Da(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ft(n),l=1<<r;l&t|e[r]&t&&(e[r]|=t),n&=~l}}var ge=0;function zc(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Ic,Oa,$c,Dc,Oc,qi=!1,Tl=[],yn=null,vn=null,xn=null,el=new Map,tl=new Map,pn=[],xp="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Do(e,t){switch(e){case"focusin":case"focusout":yn=null;break;case"dragenter":case"dragleave":vn=null;break;case"mouseover":case"mouseout":xn=null;break;case"pointerover":case"pointerout":el.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":tl.delete(t.pointerId)}}function br(e,t,n,r,l,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[l]},t!==null&&(t=xl(t),t!==null&&Oa(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,l!==null&&t.indexOf(l)===-1&&t.push(l),e)}function wp(e,t,n,r,l){switch(t){case"focusin":return yn=br(yn,e,t,n,r,l),!0;case"dragenter":return vn=br(vn,e,t,n,r,l),!0;case"mouseover":return xn=br(xn,e,t,n,r,l),!0;case"pointerover":var i=l.pointerId;return el.set(i,br(el.get(i)||null,e,t,n,r,l)),!0;case"gotpointercapture":return i=l.pointerId,tl.set(i,br(tl.get(i)||null,e,t,n,r,l)),!0}return!1}function Ac(e){var t=zn(e.target);if(t!==null){var n=Vn(t);if(n!==null){if(t=n.tag,t===13){if(t=Cc(n),t!==null){e.blockedOn=t,Oc(e.priority,function(){$c(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Wl(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Xi(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Hi=r,n.target.dispatchEvent(r),Hi=null}else return t=xl(n),t!==null&&Oa(t),e.blockedOn=n,!1;t.shift()}return!0}function Oo(e,t,n){Wl(e)&&n.delete(t)}function kp(){qi=!1,yn!==null&&Wl(yn)&&(yn=null),vn!==null&&Wl(vn)&&(vn=null),xn!==null&&Wl(xn)&&(xn=null),el.forEach(Oo),tl.forEach(Oo)}function Tr(e,t){e.blockedOn===t&&(e.blockedOn=null,qi||(qi=!0,jt.unstable_scheduleCallback(jt.unstable_NormalPriority,kp)))}function nl(e){function t(l){return Tr(l,e)}if(0<Tl.length){Tr(Tl[0],e);for(var n=1;n<Tl.length;n++){var r=Tl[n];r.blockedOn===e&&(r.blockedOn=null)}}for(yn!==null&&Tr(yn,e),vn!==null&&Tr(vn,e),xn!==null&&Tr(xn,e),el.forEach(t),tl.forEach(t),n=0;n<pn.length;n++)r=pn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<pn.length&&(n=pn[0],n.blockedOn===null);)Ac(n),n.blockedOn===null&&pn.shift()}var dr=sn.ReactCurrentBatchConfig,is=!0;function jp(e,t,n,r){var l=ge,i=dr.transition;dr.transition=null;try{ge=1,Aa(e,t,n,r)}finally{ge=l,dr.transition=i}}function Sp(e,t,n,r){var l=ge,i=dr.transition;dr.transition=null;try{ge=4,Aa(e,t,n,r)}finally{ge=l,dr.transition=i}}function Aa(e,t,n,r){if(is){var l=Xi(e,t,n,r);if(l===null)hi(e,t,r,as,n),Do(e,r);else if(wp(l,e,t,n,r))r.stopPropagation();else if(Do(e,r),t&4&&-1<xp.indexOf(e)){for(;l!==null;){var i=xl(l);if(i!==null&&Ic(i),i=Xi(e,t,n,r),i===null&&hi(e,t,r,as,n),i===l)break;l=i}l!==null&&r.stopPropagation()}else hi(e,t,r,null,n)}}var as=null;function Xi(e,t,n,r){if(as=null,e=Ia(r),e=zn(e),e!==null)if(t=Vn(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Cc(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return as=e,null}function Mc(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(cp()){case $a:return 1;case Pc:return 4;case ls:case dp:return 16;case Lc:return 536870912;default:return 16}default:return 16}}var mn=null,Ma=null,Vl=null;function Fc(){if(Vl)return Vl;var e,t=Ma,n=t.length,r,l="value"in mn?mn.value:mn.textContent,i=l.length;for(e=0;e<n&&t[e]===l[e];e++);var a=n-e;for(r=1;r<=a&&t[n-r]===l[i-r];r++);return Vl=l.slice(e,1<r?1-r:void 0)}function Kl(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Pl(){return!0}function Ao(){return!1}function _t(e){function t(n,r,l,i,a){this._reactName=n,this._targetInst=l,this.type=r,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var o in e)e.hasOwnProperty(o)&&(n=e[o],this[o]=n?n(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Pl:Ao,this.isPropagationStopped=Ao,this}return Pe(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Pl)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Pl)},persist:function(){},isPersistent:Pl}),t}var Sr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Fa=_t(Sr),vl=Pe({},Sr,{view:0,detail:0}),_p=_t(vl),si,ii,Pr,bs=Pe({},vl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ba,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Pr&&(Pr&&e.type==="mousemove"?(si=e.screenX-Pr.screenX,ii=e.screenY-Pr.screenY):ii=si=0,Pr=e),si)},movementY:function(e){return"movementY"in e?e.movementY:ii}}),Mo=_t(bs),Np=Pe({},bs,{dataTransfer:0}),Cp=_t(Np),Ep=Pe({},vl,{relatedTarget:0}),ai=_t(Ep),bp=Pe({},Sr,{animationName:0,elapsedTime:0,pseudoElement:0}),Tp=_t(bp),Pp=Pe({},Sr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Lp=_t(Pp),Rp=Pe({},Sr,{data:0}),Fo=_t(Rp),zp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ip={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},$p={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Dp(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=$p[e])?!!t[e]:!1}function Ba(){return Dp}var Op=Pe({},vl,{key:function(e){if(e.key){var t=zp[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Kl(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Ip[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ba,charCode:function(e){return e.type==="keypress"?Kl(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Kl(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Ap=_t(Op),Mp=Pe({},bs,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Bo=_t(Mp),Fp=Pe({},vl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ba}),Bp=_t(Fp),Up=Pe({},Sr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Hp=_t(Up),Wp=Pe({},bs,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Vp=_t(Wp),Kp=[9,13,27,32],Ua=tn&&"CompositionEvent"in window,Hr=null;tn&&"documentMode"in document&&(Hr=document.documentMode);var Qp=tn&&"TextEvent"in window&&!Hr,Bc=tn&&(!Ua||Hr&&8<Hr&&11>=Hr),Uo=" ",Ho=!1;function Uc(e,t){switch(e){case"keyup":return Kp.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Hc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Yn=!1;function qp(e,t){switch(e){case"compositionend":return Hc(t);case"keypress":return t.which!==32?null:(Ho=!0,Uo);case"textInput":return e=t.data,e===Uo&&Ho?null:e;default:return null}}function Xp(e,t){if(Yn)return e==="compositionend"||!Ua&&Uc(e,t)?(e=Fc(),Vl=Ma=mn=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.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Bc&&t.locale!=="ko"?null:t.data;default:return null}}var Jp={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Wo(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Jp[e.type]:t==="textarea"}function Wc(e,t,n,r){kc(r),t=os(t,"onChange"),0<t.length&&(n=new Fa("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Wr=null,rl=null;function Gp(e){td(e,0)}function Ts(e){var t=tr(e);if(hc(t))return e}function Yp(e,t){if(e==="change")return t}var Vc=!1;if(tn){var oi;if(tn){var ui="oninput"in document;if(!ui){var Vo=document.createElement("div");Vo.setAttribute("oninput","return;"),ui=typeof Vo.oninput=="function"}oi=ui}else oi=!1;Vc=oi&&(!document.documentMode||9<document.documentMode)}function Ko(){Wr&&(Wr.detachEvent("onpropertychange",Kc),rl=Wr=null)}function Kc(e){if(e.propertyName==="value"&&Ts(rl)){var t=[];Wc(t,rl,e,Ia(e)),Nc(Gp,t)}}function Zp(e,t,n){e==="focusin"?(Ko(),Wr=t,rl=n,Wr.attachEvent("onpropertychange",Kc)):e==="focusout"&&Ko()}function eh(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ts(rl)}function th(e,t){if(e==="click")return Ts(t)}function nh(e,t){if(e==="input"||e==="change")return Ts(t)}function rh(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ut=typeof Object.is=="function"?Object.is:rh;function ll(e,t){if(Ut(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var l=n[r];if(!Li.call(t,l)||!Ut(e[l],t[l]))return!1}return!0}function Qo(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function qo(e,t){var n=Qo(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=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=Qo(n)}}function Qc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Qc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qc(){for(var e=window,t=ts();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=ts(e.document)}return t}function Ha(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 lh(e){var t=qc(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Qc(n.ownerDocument.documentElement,n)){if(r!==null&&Ha(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=qo(n,i);var a=qo(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<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var sh=tn&&"documentMode"in document&&11>=document.documentMode,Zn=null,Ji=null,Vr=null,Gi=!1;function Xo(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Gi||Zn==null||Zn!==ts(r)||(r=Zn,"selectionStart"in r&&Ha(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}),Vr&&ll(Vr,r)||(Vr=r,r=os(Ji,"onSelect"),0<r.length&&(t=new Fa("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Zn)))}function Ll(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var er={animationend:Ll("Animation","AnimationEnd"),animationiteration:Ll("Animation","AnimationIteration"),animationstart:Ll("Animation","AnimationStart"),transitionend:Ll("Transition","TransitionEnd")},ci={},Xc={};tn&&(Xc=document.createElement("div").style,"AnimationEvent"in window||(delete er.animationend.animation,delete er.animationiteration.animation,delete er.animationstart.animation),"TransitionEvent"in window||delete er.transitionend.transition);function Ps(e){if(ci[e])return ci[e];if(!er[e])return e;var t=er[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Xc)return ci[e]=t[n];return e}var Jc=Ps("animationend"),Gc=Ps("animationiteration"),Yc=Ps("animationstart"),Zc=Ps("transitionend"),ed=new Map,Jo="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function En(e,t){ed.set(e,t),Wn(t,[e])}for(var di=0;di<Jo.length;di++){var fi=Jo[di],ih=fi.toLowerCase(),ah=fi[0].toUpperCase()+fi.slice(1);En(ih,"on"+ah)}En(Jc,"onAnimationEnd");En(Gc,"onAnimationIteration");En(Yc,"onAnimationStart");En("dblclick","onDoubleClick");En("focusin","onFocus");En("focusout","onBlur");En(Zc,"onTransitionEnd");mr("onMouseEnter",["mouseout","mouseover"]);mr("onMouseLeave",["mouseout","mouseover"]);mr("onPointerEnter",["pointerout","pointerover"]);mr("onPointerLeave",["pointerout","pointerover"]);Wn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Wn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Wn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Wn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Wn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Wn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ar="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),oh=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ar));function Go(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,ip(r,t,void 0,e),e.currentTarget=null}function td(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],l=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var a=r.length-1;0<=a;a--){var o=r[a],u=o.instance,d=o.currentTarget;if(o=o.listener,u!==i&&l.isPropagationStopped())break e;Go(l,o,d),i=u}else for(a=0;a<r.length;a++){if(o=r[a],u=o.instance,d=o.currentTarget,o=o.listener,u!==i&&l.isPropagationStopped())break e;Go(l,o,d),i=u}}}if(rs)throw e=Ki,rs=!1,Ki=null,e}function Se(e,t){var n=t[na];n===void 0&&(n=t[na]=new Set);var r=e+"__bubble";n.has(r)||(nd(t,e,2,!1),n.add(r))}function pi(e,t,n){var r=0;t&&(r|=4),nd(n,e,r,t)}var Rl="_reactListening"+Math.random().toString(36).slice(2);function sl(e){if(!e[Rl]){e[Rl]=!0,uc.forEach(function(n){n!=="selectionchange"&&(oh.has(n)||pi(n,!1,e),pi(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Rl]||(t[Rl]=!0,pi("selectionchange",!1,t))}}function nd(e,t,n,r){switch(Mc(t)){case 1:var l=jp;break;case 4:l=Sp;break;default:l=Aa}n=l.bind(null,t,n,e),l=void 0,!Vi||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(l=!0),r?l!==void 0?e.addEventListener(t,n,{capture:!0,passive:l}):e.addEventListener(t,n,!0):l!==void 0?e.addEventListener(t,n,{passive:l}):e.addEventListener(t,n,!1)}function hi(e,t,n,r,l){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var o=r.stateNode.containerInfo;if(o===l||o.nodeType===8&&o.parentNode===l)break;if(a===4)for(a=r.return;a!==null;){var u=a.tag;if((u===3||u===4)&&(u=a.stateNode.containerInfo,u===l||u.nodeType===8&&u.parentNode===l))return;a=a.return}for(;o!==null;){if(a=zn(o),a===null)return;if(u=a.tag,u===5||u===6){r=i=a;continue e}o=o.parentNode}}r=r.return}Nc(function(){var d=i,y=Ia(n),g=[];e:{var m=ed.get(e);if(m!==void 0){var x=Fa,w=e;switch(e){case"keypress":if(Kl(n)===0)break e;case"keydown":case"keyup":x=Ap;break;case"focusin":w="focus",x=ai;break;case"focusout":w="blur",x=ai;break;case"beforeblur":case"afterblur":x=ai;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":x=Mo;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=Cp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=Bp;break;case Jc:case Gc:case Yc:x=Tp;break;case Zc:x=Hp;break;case"scroll":x=_p;break;case"wheel":x=Vp;break;case"copy":case"cut":case"paste":x=Lp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=Bo}var S=(t&4)!==0,_=!S&&e==="scroll",p=S?m!==null?m+"Capture":null:m;S=[];for(var f=d,h;f!==null;){h=f;var k=h.stateNode;if(h.tag===5&&k!==null&&(h=k,p!==null&&(k=Zr(f,p),k!=null&&S.push(il(f,k,h)))),_)break;f=f.return}0<S.length&&(m=new x(m,w,null,n,y),g.push({event:m,listeners:S}))}}if(!(t&7)){e:{if(m=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",m&&n!==Hi&&(w=n.relatedTarget||n.fromElement)&&(zn(w)||w[nn]))break e;if((x||m)&&(m=y.window===y?y:(m=y.ownerDocument)?m.defaultView||m.parentWindow:window,x?(w=n.relatedTarget||n.toElement,x=d,w=w?zn(w):null,w!==null&&(_=Vn(w),w!==_||w.tag!==5&&w.tag!==6)&&(w=null)):(x=null,w=d),x!==w)){if(S=Mo,k="onMouseLeave",p="onMouseEnter",f="mouse",(e==="pointerout"||e==="pointerover")&&(S=Bo,k="onPointerLeave",p="onPointerEnter",f="pointer"),_=x==null?m:tr(x),h=w==null?m:tr(w),m=new S(k,f+"leave",x,n,y),m.target=_,m.relatedTarget=h,k=null,zn(y)===d&&(S=new S(p,f+"enter",w,n,y),S.target=h,S.relatedTarget=_,k=S),_=k,x&&w)t:{for(S=x,p=w,f=0,h=S;h;h=qn(h))f++;for(h=0,k=p;k;k=qn(k))h++;for(;0<f-h;)S=qn(S),f--;for(;0<h-f;)p=qn(p),h--;for(;f--;){if(S===p||p!==null&&S===p.alternate)break t;S=qn(S),p=qn(p)}S=null}else S=null;x!==null&&Yo(g,m,x,S,!1),w!==null&&_!==null&&Yo(g,_,w,S,!0)}}e:{if(m=d?tr(d):window,x=m.nodeName&&m.nodeName.toLowerCase(),x==="select"||x==="input"&&m.type==="file")var E=Yp;else if(Wo(m))if(Vc)E=nh;else{E=eh;var P=Zp}else(x=m.nodeName)&&x.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(E=th);if(E&&(E=E(e,d))){Wc(g,E,n,y);break e}P&&P(e,m,d),e==="focusout"&&(P=m._wrapperState)&&P.controlled&&m.type==="number"&&Ai(m,"number",m.value)}switch(P=d?tr(d):window,e){case"focusin":(Wo(P)||P.contentEditable==="true")&&(Zn=P,Ji=d,Vr=null);break;case"focusout":Vr=Ji=Zn=null;break;case"mousedown":Gi=!0;break;case"contextmenu":case"mouseup":case"dragend":Gi=!1,Xo(g,n,y);break;case"selectionchange":if(sh)break;case"keydown":case"keyup":Xo(g,n,y)}var N;if(Ua)e:{switch(e){case"compositionstart":var v="onCompositionStart";break e;case"compositionend":v="onCompositionEnd";break e;case"compositionupdate":v="onCompositionUpdate";break e}v=void 0}else Yn?Uc(e,n)&&(v="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(v="onCompositionStart");v&&(Bc&&n.locale!=="ko"&&(Yn||v!=="onCompositionStart"?v==="onCompositionEnd"&&Yn&&(N=Fc()):(mn=y,Ma="value"in mn?mn.value:mn.textContent,Yn=!0)),P=os(d,v),0<P.length&&(v=new Fo(v,e,null,n,y),g.push({event:v,listeners:P}),N?v.data=N:(N=Hc(n),N!==null&&(v.data=N)))),(N=Qp?qp(e,n):Xp(e,n))&&(d=os(d,"onBeforeInput"),0<d.length&&(y=new Fo("onBeforeInput","beforeinput",null,n,y),g.push({event:y,listeners:d}),y.data=N))}td(g,t)})}function il(e,t,n){return{instance:e,listener:t,currentTarget:n}}function os(e,t){for(var n=t+"Capture",r=[];e!==null;){var l=e,i=l.stateNode;l.tag===5&&i!==null&&(l=i,i=Zr(e,n),i!=null&&r.unshift(il(e,i,l)),i=Zr(e,t),i!=null&&r.push(il(e,i,l))),e=e.return}return r}function qn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Yo(e,t,n,r,l){for(var i=t._reactName,a=[];n!==null&&n!==r;){var o=n,u=o.alternate,d=o.stateNode;if(u!==null&&u===r)break;o.tag===5&&d!==null&&(o=d,l?(u=Zr(n,i),u!=null&&a.unshift(il(n,u,o))):l||(u=Zr(n,i),u!=null&&a.push(il(n,u,o)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var uh=/\r\n?/g,ch=/\u0000|\uFFFD/g;function Zo(e){return(typeof e=="string"?e:""+e).replace(uh,`
|
||
`).replace(ch,"")}function zl(e,t,n){if(t=Zo(t),Zo(e)!==t&&n)throw Error(O(425))}function us(){}var Yi=null,Zi=null;function ea(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var ta=typeof setTimeout=="function"?setTimeout:void 0,dh=typeof clearTimeout=="function"?clearTimeout:void 0,eu=typeof Promise=="function"?Promise:void 0,fh=typeof queueMicrotask=="function"?queueMicrotask:typeof eu<"u"?function(e){return eu.resolve(null).then(e).catch(ph)}:ta;function ph(e){setTimeout(function(){throw e})}function mi(e,t){var n=t,r=0;do{var l=n.nextSibling;if(e.removeChild(n),l&&l.nodeType===8)if(n=l.data,n==="/$"){if(r===0){e.removeChild(l),nl(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=l}while(n);nl(t)}function wn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function tu(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var _r=Math.random().toString(36).slice(2),Kt="__reactFiber$"+_r,al="__reactProps$"+_r,nn="__reactContainer$"+_r,na="__reactEvents$"+_r,hh="__reactListeners$"+_r,mh="__reactHandles$"+_r;function zn(e){var t=e[Kt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[nn]||n[Kt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=tu(e);e!==null;){if(n=e[Kt])return n;e=tu(e)}return t}e=n,n=e.parentNode}return null}function xl(e){return e=e[Kt]||e[nn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function tr(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(O(33))}function Ls(e){return e[al]||null}var ra=[],nr=-1;function bn(e){return{current:e}}function _e(e){0>nr||(e.current=ra[nr],ra[nr]=null,nr--)}function we(e,t){nr++,ra[nr]=e.current,e.current=t}var Cn={},lt=bn(Cn),ht=bn(!1),Mn=Cn;function gr(e,t){var n=e.type.contextTypes;if(!n)return Cn;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 mt(e){return e=e.childContextTypes,e!=null}function cs(){_e(ht),_e(lt)}function nu(e,t,n){if(lt.current!==Cn)throw Error(O(168));we(lt,t),we(ht,n)}function rd(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(O(108,Zf(e)||"Unknown",l));return Pe({},n,r)}function ds(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Cn,Mn=lt.current,we(lt,e),we(ht,ht.current),!0}function ru(e,t,n){var r=e.stateNode;if(!r)throw Error(O(169));n?(e=rd(e,t,Mn),r.__reactInternalMemoizedMergedChildContext=e,_e(ht),_e(lt),we(lt,e)):_e(ht),we(ht,n)}var Gt=null,Rs=!1,gi=!1;function ld(e){Gt===null?Gt=[e]:Gt.push(e)}function gh(e){Rs=!0,ld(e)}function Tn(){if(!gi&&Gt!==null){gi=!0;var e=0,t=ge;try{var n=Gt;for(ge=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Gt=null,Rs=!1}catch(l){throw Gt!==null&&(Gt=Gt.slice(e+1)),Tc($a,Tn),l}finally{ge=t,gi=!1}}return null}var rr=[],lr=0,fs=null,ps=0,Nt=[],Ct=0,Fn=null,Yt=1,Zt="";function Ln(e,t){rr[lr++]=ps,rr[lr++]=fs,fs=e,ps=t}function sd(e,t,n){Nt[Ct++]=Yt,Nt[Ct++]=Zt,Nt[Ct++]=Fn,Fn=e;var r=Yt;e=Zt;var l=32-Ft(r)-1;r&=~(1<<l),n+=1;var i=32-Ft(t)+l;if(30<i){var a=l-l%5;i=(r&(1<<a)-1).toString(32),r>>=a,l-=a,Yt=1<<32-Ft(t)+l|n<<l|r,Zt=i+e}else Yt=1<<i|n<<l|r,Zt=e}function Wa(e){e.return!==null&&(Ln(e,1),sd(e,1,0))}function Va(e){for(;e===fs;)fs=rr[--lr],rr[lr]=null,ps=rr[--lr],rr[lr]=null;for(;e===Fn;)Fn=Nt[--Ct],Nt[Ct]=null,Zt=Nt[--Ct],Nt[Ct]=null,Yt=Nt[--Ct],Nt[Ct]=null}var kt=null,wt=null,Ce=!1,Mt=null;function id(e,t){var n=Et(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function lu(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,kt=e,wt=wn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,kt=e,wt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Fn!==null?{id:Yt,overflow:Zt}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Et(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,kt=e,wt=null,!0):!1;default:return!1}}function la(e){return(e.mode&1)!==0&&(e.flags&128)===0}function sa(e){if(Ce){var t=wt;if(t){var n=t;if(!lu(e,t)){if(la(e))throw Error(O(418));t=wn(n.nextSibling);var r=kt;t&&lu(e,t)?id(r,n):(e.flags=e.flags&-4097|2,Ce=!1,kt=e)}}else{if(la(e))throw Error(O(418));e.flags=e.flags&-4097|2,Ce=!1,kt=e}}}function su(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;kt=e}function Il(e){if(e!==kt)return!1;if(!Ce)return su(e),Ce=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!ea(e.type,e.memoizedProps)),t&&(t=wt)){if(la(e))throw ad(),Error(O(418));for(;t;)id(e,t),t=wn(t.nextSibling)}if(su(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){wt=wn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}wt=null}}else wt=kt?wn(e.stateNode.nextSibling):null;return!0}function ad(){for(var e=wt;e;)e=wn(e.nextSibling)}function yr(){wt=kt=null,Ce=!1}function Ka(e){Mt===null?Mt=[e]:Mt.push(e)}var yh=sn.ReactCurrentBatchConfig;function Lr(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(O(309));var r=n.stateNode}if(!r)throw Error(O(147,e));var l=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(a){var o=l.refs;a===null?delete o[i]:o[i]=a},t._stringRef=i,t)}if(typeof e!="string")throw Error(O(284));if(!n._owner)throw Error(O(290,e))}return e}function $l(e,t){throw e=Object.prototype.toString.call(t),Error(O(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function iu(e){var t=e._init;return t(e._payload)}function od(e){function t(p,f){if(e){var h=p.deletions;h===null?(p.deletions=[f],p.flags|=16):h.push(f)}}function n(p,f){if(!e)return null;for(;f!==null;)t(p,f),f=f.sibling;return null}function r(p,f){for(p=new Map;f!==null;)f.key!==null?p.set(f.key,f):p.set(f.index,f),f=f.sibling;return p}function l(p,f){return p=_n(p,f),p.index=0,p.sibling=null,p}function i(p,f,h){return p.index=h,e?(h=p.alternate,h!==null?(h=h.index,h<f?(p.flags|=2,f):h):(p.flags|=2,f)):(p.flags|=1048576,f)}function a(p){return e&&p.alternate===null&&(p.flags|=2),p}function o(p,f,h,k){return f===null||f.tag!==6?(f=Si(h,p.mode,k),f.return=p,f):(f=l(f,h),f.return=p,f)}function u(p,f,h,k){var E=h.type;return E===Gn?y(p,f,h.props.children,k,h.key):f!==null&&(f.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===dn&&iu(E)===f.type)?(k=l(f,h.props),k.ref=Lr(p,f,h),k.return=p,k):(k=Zl(h.type,h.key,h.props,null,p.mode,k),k.ref=Lr(p,f,h),k.return=p,k)}function d(p,f,h,k){return f===null||f.tag!==4||f.stateNode.containerInfo!==h.containerInfo||f.stateNode.implementation!==h.implementation?(f=_i(h,p.mode,k),f.return=p,f):(f=l(f,h.children||[]),f.return=p,f)}function y(p,f,h,k,E){return f===null||f.tag!==7?(f=An(h,p.mode,k,E),f.return=p,f):(f=l(f,h),f.return=p,f)}function g(p,f,h){if(typeof f=="string"&&f!==""||typeof f=="number")return f=Si(""+f,p.mode,h),f.return=p,f;if(typeof f=="object"&&f!==null){switch(f.$$typeof){case _l:return h=Zl(f.type,f.key,f.props,null,p.mode,h),h.ref=Lr(p,null,f),h.return=p,h;case Jn:return f=_i(f,p.mode,h),f.return=p,f;case dn:var k=f._init;return g(p,k(f._payload),h)}if(Dr(f)||Cr(f))return f=An(f,p.mode,h,null),f.return=p,f;$l(p,f)}return null}function m(p,f,h,k){var E=f!==null?f.key:null;if(typeof h=="string"&&h!==""||typeof h=="number")return E!==null?null:o(p,f,""+h,k);if(typeof h=="object"&&h!==null){switch(h.$$typeof){case _l:return h.key===E?u(p,f,h,k):null;case Jn:return h.key===E?d(p,f,h,k):null;case dn:return E=h._init,m(p,f,E(h._payload),k)}if(Dr(h)||Cr(h))return E!==null?null:y(p,f,h,k,null);$l(p,h)}return null}function x(p,f,h,k,E){if(typeof k=="string"&&k!==""||typeof k=="number")return p=p.get(h)||null,o(f,p,""+k,E);if(typeof k=="object"&&k!==null){switch(k.$$typeof){case _l:return p=p.get(k.key===null?h:k.key)||null,u(f,p,k,E);case Jn:return p=p.get(k.key===null?h:k.key)||null,d(f,p,k,E);case dn:var P=k._init;return x(p,f,h,P(k._payload),E)}if(Dr(k)||Cr(k))return p=p.get(h)||null,y(f,p,k,E,null);$l(f,k)}return null}function w(p,f,h,k){for(var E=null,P=null,N=f,v=f=0,b=null;N!==null&&v<h.length;v++){N.index>v?(b=N,N=null):b=N.sibling;var L=m(p,N,h[v],k);if(L===null){N===null&&(N=b);break}e&&N&&L.alternate===null&&t(p,N),f=i(L,f,v),P===null?E=L:P.sibling=L,P=L,N=b}if(v===h.length)return n(p,N),Ce&&Ln(p,v),E;if(N===null){for(;v<h.length;v++)N=g(p,h[v],k),N!==null&&(f=i(N,f,v),P===null?E=N:P.sibling=N,P=N);return Ce&&Ln(p,v),E}for(N=r(p,N);v<h.length;v++)b=x(N,p,v,h[v],k),b!==null&&(e&&b.alternate!==null&&N.delete(b.key===null?v:b.key),f=i(b,f,v),P===null?E=b:P.sibling=b,P=b);return e&&N.forEach(function(X){return t(p,X)}),Ce&&Ln(p,v),E}function S(p,f,h,k){var E=Cr(h);if(typeof E!="function")throw Error(O(150));if(h=E.call(h),h==null)throw Error(O(151));for(var P=E=null,N=f,v=f=0,b=null,L=h.next();N!==null&&!L.done;v++,L=h.next()){N.index>v?(b=N,N=null):b=N.sibling;var X=m(p,N,L.value,k);if(X===null){N===null&&(N=b);break}e&&N&&X.alternate===null&&t(p,N),f=i(X,f,v),P===null?E=X:P.sibling=X,P=X,N=b}if(L.done)return n(p,N),Ce&&Ln(p,v),E;if(N===null){for(;!L.done;v++,L=h.next())L=g(p,L.value,k),L!==null&&(f=i(L,f,v),P===null?E=L:P.sibling=L,P=L);return Ce&&Ln(p,v),E}for(N=r(p,N);!L.done;v++,L=h.next())L=x(N,p,v,L.value,k),L!==null&&(e&&L.alternate!==null&&N.delete(L.key===null?v:L.key),f=i(L,f,v),P===null?E=L:P.sibling=L,P=L);return e&&N.forEach(function(Q){return t(p,Q)}),Ce&&Ln(p,v),E}function _(p,f,h,k){if(typeof h=="object"&&h!==null&&h.type===Gn&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case _l:e:{for(var E=h.key,P=f;P!==null;){if(P.key===E){if(E=h.type,E===Gn){if(P.tag===7){n(p,P.sibling),f=l(P,h.props.children),f.return=p,p=f;break e}}else if(P.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===dn&&iu(E)===P.type){n(p,P.sibling),f=l(P,h.props),f.ref=Lr(p,P,h),f.return=p,p=f;break e}n(p,P);break}else t(p,P);P=P.sibling}h.type===Gn?(f=An(h.props.children,p.mode,k,h.key),f.return=p,p=f):(k=Zl(h.type,h.key,h.props,null,p.mode,k),k.ref=Lr(p,f,h),k.return=p,p=k)}return a(p);case Jn:e:{for(P=h.key;f!==null;){if(f.key===P)if(f.tag===4&&f.stateNode.containerInfo===h.containerInfo&&f.stateNode.implementation===h.implementation){n(p,f.sibling),f=l(f,h.children||[]),f.return=p,p=f;break e}else{n(p,f);break}else t(p,f);f=f.sibling}f=_i(h,p.mode,k),f.return=p,p=f}return a(p);case dn:return P=h._init,_(p,f,P(h._payload),k)}if(Dr(h))return w(p,f,h,k);if(Cr(h))return S(p,f,h,k);$l(p,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,f!==null&&f.tag===6?(n(p,f.sibling),f=l(f,h),f.return=p,p=f):(n(p,f),f=Si(h,p.mode,k),f.return=p,p=f),a(p)):n(p,f)}return _}var vr=od(!0),ud=od(!1),hs=bn(null),ms=null,sr=null,Qa=null;function qa(){Qa=sr=ms=null}function Xa(e){var t=hs.current;_e(hs),e._currentValue=t}function ia(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 fr(e,t){ms=e,Qa=sr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(pt=!0),e.firstContext=null)}function Tt(e){var t=e._currentValue;if(Qa!==e)if(e={context:e,memoizedValue:t,next:null},sr===null){if(ms===null)throw Error(O(308));sr=e,ms.dependencies={lanes:0,firstContext:e}}else sr=sr.next=e;return t}var In=null;function Ja(e){In===null?In=[e]:In.push(e)}function cd(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Ja(t)):(n.next=l.next,l.next=n),t.interleaved=n,rn(e,r)}function rn(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 fn=!1;function Ga(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dd(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 en(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function kn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,de&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,rn(e,n)}return l=r.interleaved,l===null?(t.next=t,Ja(r)):(t.next=l.next,l.next=t),r.interleaved=t,rn(e,n)}function Ql(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,Da(e,n)}}function au(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 gs(e,t,n,r){var l=e.updateQueue;fn=!1;var i=l.firstBaseUpdate,a=l.lastBaseUpdate,o=l.shared.pending;if(o!==null){l.shared.pending=null;var u=o,d=u.next;u.next=null,a===null?i=d:a.next=d,a=u;var y=e.alternate;y!==null&&(y=y.updateQueue,o=y.lastBaseUpdate,o!==a&&(o===null?y.firstBaseUpdate=d:o.next=d,y.lastBaseUpdate=u))}if(i!==null){var g=l.baseState;a=0,y=d=u=null,o=i;do{var m=o.lane,x=o.eventTime;if((r&m)===m){y!==null&&(y=y.next={eventTime:x,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var w=e,S=o;switch(m=t,x=n,S.tag){case 1:if(w=S.payload,typeof w=="function"){g=w.call(x,g,m);break e}g=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=S.payload,m=typeof w=="function"?w.call(x,g,m):w,m==null)break e;g=Pe({},g,m);break e;case 2:fn=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,m=l.effects,m===null?l.effects=[o]:m.push(o))}else x={eventTime:x,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},y===null?(d=y=x,u=g):y=y.next=x,a|=m;if(o=o.next,o===null){if(o=l.shared.pending,o===null)break;m=o,o=m.next,m.next=null,l.lastBaseUpdate=m,l.shared.pending=null}}while(!0);if(y===null&&(u=g),l.baseState=u,l.firstBaseUpdate=d,l.lastBaseUpdate=y,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);Un|=a,e.lanes=a,e.memoizedState=g}}function ou(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],l=r.callback;if(l!==null){if(r.callback=null,r=n,typeof l!="function")throw Error(O(191,l));l.call(r)}}}var wl={},qt=bn(wl),ol=bn(wl),ul=bn(wl);function $n(e){if(e===wl)throw Error(O(174));return e}function Ya(e,t){switch(we(ul,t),we(ol,e),we(qt,wl),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Fi(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Fi(t,e)}_e(qt),we(qt,t)}function xr(){_e(qt),_e(ol),_e(ul)}function fd(e){$n(ul.current);var t=$n(qt.current),n=Fi(t,e.type);t!==n&&(we(ol,e),we(qt,n))}function Za(e){ol.current===e&&(_e(qt),_e(ol))}var be=bn(0);function ys(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var yi=[];function eo(){for(var e=0;e<yi.length;e++)yi[e]._workInProgressVersionPrimary=null;yi.length=0}var ql=sn.ReactCurrentDispatcher,vi=sn.ReactCurrentBatchConfig,Bn=0,Te=null,Ke=null,qe=null,vs=!1,Kr=!1,cl=0,vh=0;function tt(){throw Error(O(321))}function to(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ut(e[n],t[n]))return!1;return!0}function no(e,t,n,r,l,i){if(Bn=i,Te=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ql.current=e===null||e.memoizedState===null?jh:Sh,e=n(r,l),Kr){i=0;do{if(Kr=!1,cl=0,25<=i)throw Error(O(301));i+=1,qe=Ke=null,t.updateQueue=null,ql.current=_h,e=n(r,l)}while(Kr)}if(ql.current=xs,t=Ke!==null&&Ke.next!==null,Bn=0,qe=Ke=Te=null,vs=!1,t)throw Error(O(300));return e}function ro(){var e=cl!==0;return cl=0,e}function Vt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return qe===null?Te.memoizedState=qe=e:qe=qe.next=e,qe}function Pt(){if(Ke===null){var e=Te.alternate;e=e!==null?e.memoizedState:null}else e=Ke.next;var t=qe===null?Te.memoizedState:qe.next;if(t!==null)qe=t,Ke=e;else{if(e===null)throw Error(O(310));Ke=e,e={memoizedState:Ke.memoizedState,baseState:Ke.baseState,baseQueue:Ke.baseQueue,queue:Ke.queue,next:null},qe===null?Te.memoizedState=qe=e:qe=qe.next=e}return qe}function dl(e,t){return typeof t=="function"?t(e):t}function xi(e){var t=Pt(),n=t.queue;if(n===null)throw Error(O(311));n.lastRenderedReducer=e;var r=Ke,l=r.baseQueue,i=n.pending;if(i!==null){if(l!==null){var a=l.next;l.next=i.next,i.next=a}r.baseQueue=l=i,n.pending=null}if(l!==null){i=l.next,r=r.baseState;var o=a=null,u=null,d=i;do{var y=d.lane;if((Bn&y)===y)u!==null&&(u=u.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var g={lane:y,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};u===null?(o=u=g,a=r):u=u.next=g,Te.lanes|=y,Un|=y}d=d.next}while(d!==null&&d!==i);u===null?a=r:u.next=o,Ut(r,t.memoizedState)||(pt=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=u,n.lastRenderedState=r}if(e=n.interleaved,e!==null){l=e;do i=l.lane,Te.lanes|=i,Un|=i,l=l.next;while(l!==e)}else l===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function wi(e){var t=Pt(),n=t.queue;if(n===null)throw Error(O(311));n.lastRenderedReducer=e;var r=n.dispatch,l=n.pending,i=t.memoizedState;if(l!==null){n.pending=null;var a=l=l.next;do i=e(i,a.action),a=a.next;while(a!==l);Ut(i,t.memoizedState)||(pt=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function pd(){}function hd(e,t){var n=Te,r=Pt(),l=t(),i=!Ut(r.memoizedState,l);if(i&&(r.memoizedState=l,pt=!0),r=r.queue,lo(yd.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||qe!==null&&qe.memoizedState.tag&1){if(n.flags|=2048,fl(9,gd.bind(null,n,r,l,t),void 0,null),Xe===null)throw Error(O(349));Bn&30||md(n,t,l)}return l}function md(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Te.updateQueue,t===null?(t={lastEffect:null,stores:null},Te.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function gd(e,t,n,r){t.value=n,t.getSnapshot=r,vd(t)&&xd(e)}function yd(e,t,n){return n(function(){vd(t)&&xd(e)})}function vd(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ut(e,n)}catch{return!0}}function xd(e){var t=rn(e,1);t!==null&&Bt(t,e,1,-1)}function uu(e){var t=Vt();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:dl,lastRenderedState:e},t.queue=e,e=e.dispatch=kh.bind(null,Te,e),[t.memoizedState,e]}function fl(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Te.updateQueue,t===null?(t={lastEffect:null,stores:null},Te.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function wd(){return Pt().memoizedState}function Xl(e,t,n,r){var l=Vt();Te.flags|=e,l.memoizedState=fl(1|t,n,void 0,r===void 0?null:r)}function zs(e,t,n,r){var l=Pt();r=r===void 0?null:r;var i=void 0;if(Ke!==null){var a=Ke.memoizedState;if(i=a.destroy,r!==null&&to(r,a.deps)){l.memoizedState=fl(t,n,i,r);return}}Te.flags|=e,l.memoizedState=fl(1|t,n,i,r)}function cu(e,t){return Xl(8390656,8,e,t)}function lo(e,t){return zs(2048,8,e,t)}function kd(e,t){return zs(4,2,e,t)}function jd(e,t){return zs(4,4,e,t)}function Sd(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function _d(e,t,n){return n=n!=null?n.concat([e]):null,zs(4,4,Sd.bind(null,t,e),n)}function so(){}function Nd(e,t){var n=Pt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&to(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Cd(e,t){var n=Pt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&to(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Ed(e,t,n){return Bn&21?(Ut(n,t)||(n=Rc(),Te.lanes|=n,Un|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,pt=!0),e.memoizedState=n)}function xh(e,t){var n=ge;ge=n!==0&&4>n?n:4,e(!0);var r=vi.transition;vi.transition={};try{e(!1),t()}finally{ge=n,vi.transition=r}}function bd(){return Pt().memoizedState}function wh(e,t,n){var r=Sn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Td(e))Pd(t,n);else if(n=cd(e,t,n,r),n!==null){var l=ot();Bt(n,e,r,l),Ld(n,t,r)}}function kh(e,t,n){var r=Sn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Td(e))Pd(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,Ut(o,a)){var u=t.interleaved;u===null?(l.next=l,Ja(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=cd(e,t,l,r),n!==null&&(l=ot(),Bt(n,e,r,l),Ld(n,t,r))}}function Td(e){var t=e.alternate;return e===Te||t!==null&&t===Te}function Pd(e,t){Kr=vs=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ld(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Da(e,n)}}var xs={readContext:Tt,useCallback:tt,useContext:tt,useEffect:tt,useImperativeHandle:tt,useInsertionEffect:tt,useLayoutEffect:tt,useMemo:tt,useReducer:tt,useRef:tt,useState:tt,useDebugValue:tt,useDeferredValue:tt,useTransition:tt,useMutableSource:tt,useSyncExternalStore:tt,useId:tt,unstable_isNewReconciler:!1},jh={readContext:Tt,useCallback:function(e,t){return Vt().memoizedState=[e,t===void 0?null:t],e},useContext:Tt,useEffect:cu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Xl(4194308,4,Sd.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Xl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Xl(4,2,e,t)},useMemo:function(e,t){var n=Vt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Vt();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=wh.bind(null,Te,e),[r.memoizedState,e]},useRef:function(e){var t=Vt();return e={current:e},t.memoizedState=e},useState:uu,useDebugValue:so,useDeferredValue:function(e){return Vt().memoizedState=e},useTransition:function(){var e=uu(!1),t=e[0];return e=xh.bind(null,e[1]),Vt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Te,l=Vt();if(Ce){if(n===void 0)throw Error(O(407));n=n()}else{if(n=t(),Xe===null)throw Error(O(349));Bn&30||md(r,t,n)}l.memoizedState=n;var i={value:n,getSnapshot:t};return l.queue=i,cu(yd.bind(null,r,i,e),[e]),r.flags|=2048,fl(9,gd.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Vt(),t=Xe.identifierPrefix;if(Ce){var n=Zt,r=Yt;n=(r&~(1<<32-Ft(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=cl++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=vh++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Sh={readContext:Tt,useCallback:Nd,useContext:Tt,useEffect:lo,useImperativeHandle:_d,useInsertionEffect:kd,useLayoutEffect:jd,useMemo:Cd,useReducer:xi,useRef:wd,useState:function(){return xi(dl)},useDebugValue:so,useDeferredValue:function(e){var t=Pt();return Ed(t,Ke.memoizedState,e)},useTransition:function(){var e=xi(dl)[0],t=Pt().memoizedState;return[e,t]},useMutableSource:pd,useSyncExternalStore:hd,useId:bd,unstable_isNewReconciler:!1},_h={readContext:Tt,useCallback:Nd,useContext:Tt,useEffect:lo,useImperativeHandle:_d,useInsertionEffect:kd,useLayoutEffect:jd,useMemo:Cd,useReducer:wi,useRef:wd,useState:function(){return wi(dl)},useDebugValue:so,useDeferredValue:function(e){var t=Pt();return Ke===null?t.memoizedState=e:Ed(t,Ke.memoizedState,e)},useTransition:function(){var e=wi(dl)[0],t=Pt().memoizedState;return[e,t]},useMutableSource:pd,useSyncExternalStore:hd,useId:bd,unstable_isNewReconciler:!1};function Ot(e,t){if(e&&e.defaultProps){t=Pe({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function aa(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Pe({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Is={isMounted:function(e){return(e=e._reactInternals)?Vn(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=ot(),l=Sn(e),i=en(r,l);i.payload=t,n!=null&&(i.callback=n),t=kn(e,i,l),t!==null&&(Bt(t,e,l,r),Ql(t,e,l))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=ot(),l=Sn(e),i=en(r,l);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=kn(e,i,l),t!==null&&(Bt(t,e,l,r),Ql(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=ot(),r=Sn(e),l=en(n,r);l.tag=2,t!=null&&(l.callback=t),t=kn(e,l,r),t!==null&&(Bt(t,e,r,n),Ql(t,e,r))}};function du(e,t,n,r,l,i,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,a):t.prototype&&t.prototype.isPureReactComponent?!ll(n,r)||!ll(l,i):!0}function Rd(e,t,n){var r=!1,l=Cn,i=t.contextType;return typeof i=="object"&&i!==null?i=Tt(i):(l=mt(t)?Mn:lt.current,r=t.contextTypes,i=(r=r!=null)?gr(e,l):Cn),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Is,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=i),t}function fu(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Is.enqueueReplaceState(t,t.state,null)}function oa(e,t,n,r){var l=e.stateNode;l.props=n,l.state=e.memoizedState,l.refs={},Ga(e);var i=t.contextType;typeof i=="object"&&i!==null?l.context=Tt(i):(i=mt(t)?Mn:lt.current,l.context=gr(e,i)),l.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(aa(e,t,i,n),l.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof l.getSnapshotBeforeUpdate=="function"||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(t=l.state,typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount(),t!==l.state&&Is.enqueueReplaceState(l,l.state,null),gs(e,n,l,r),l.state=e.memoizedState),typeof l.componentDidMount=="function"&&(e.flags|=4194308)}function wr(e,t){try{var n="",r=t;do n+=Yf(r),r=r.return;while(r);var l=n}catch(i){l=`
|
||
Error generating stack: `+i.message+`
|
||
`+i.stack}return{value:e,source:t,stack:l,digest:null}}function ki(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function ua(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Nh=typeof WeakMap=="function"?WeakMap:Map;function zd(e,t,n){n=en(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){ks||(ks=!0,xa=r),ua(e,t)},n}function Id(e,t,n){n=en(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var l=t.value;n.payload=function(){return r(l)},n.callback=function(){ua(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){ua(e,t),typeof r!="function"&&(jn===null?jn=new Set([this]):jn.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function pu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Nh;var l=new Set;r.set(t,l)}else l=r.get(t),l===void 0&&(l=new Set,r.set(t,l));l.has(n)||(l.add(n),e=Mh.bind(null,e,t,n),t.then(e,e))}function hu(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function mu(e,t,n,r,l){return e.mode&1?(e.flags|=65536,e.lanes=l,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=en(-1,1),t.tag=2,kn(n,t,1))),n.lanes|=1),e)}var Ch=sn.ReactCurrentOwner,pt=!1;function at(e,t,n,r){t.child=e===null?ud(t,null,n,r):vr(t,e.child,n,r)}function gu(e,t,n,r,l){n=n.render;var i=t.ref;return fr(t,l),r=no(e,t,n,r,i,l),n=ro(),e!==null&&!pt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,ln(e,t,l)):(Ce&&n&&Wa(t),t.flags|=1,at(e,t,r,l),t.child)}function yu(e,t,n,r,l){if(e===null){var i=n.type;return typeof i=="function"&&!ho(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,$d(e,t,i,r,l)):(e=Zl(n.type,null,r,t,t.mode,l),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&l)){var a=i.memoizedProps;if(n=n.compare,n=n!==null?n:ll,n(a,r)&&e.ref===t.ref)return ln(e,t,l)}return t.flags|=1,e=_n(i,r),e.ref=t.ref,e.return=t,t.child=e}function $d(e,t,n,r,l){if(e!==null){var i=e.memoizedProps;if(ll(i,r)&&e.ref===t.ref)if(pt=!1,t.pendingProps=r=i,(e.lanes&l)!==0)e.flags&131072&&(pt=!0);else return t.lanes=e.lanes,ln(e,t,l)}return ca(e,t,n,r,l)}function Dd(e,t,n){var r=t.pendingProps,l=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},we(ar,vt),vt|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,we(ar,vt),vt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,we(ar,vt),vt|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,we(ar,vt),vt|=r;return at(e,t,l,n),t.child}function Od(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function ca(e,t,n,r,l){var i=mt(n)?Mn:lt.current;return i=gr(t,i),fr(t,l),n=no(e,t,n,r,i,l),r=ro(),e!==null&&!pt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,ln(e,t,l)):(Ce&&r&&Wa(t),t.flags|=1,at(e,t,n,l),t.child)}function vu(e,t,n,r,l){if(mt(n)){var i=!0;ds(t)}else i=!1;if(fr(t,l),t.stateNode===null)Jl(e,t),Rd(t,n,r),oa(t,n,r,l),r=!0;else if(e===null){var a=t.stateNode,o=t.memoizedProps;a.props=o;var u=a.context,d=n.contextType;typeof d=="object"&&d!==null?d=Tt(d):(d=mt(n)?Mn:lt.current,d=gr(t,d));var y=n.getDerivedStateFromProps,g=typeof y=="function"||typeof a.getSnapshotBeforeUpdate=="function";g||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(o!==r||u!==d)&&fu(t,a,r,d),fn=!1;var m=t.memoizedState;a.state=m,gs(t,r,a,l),u=t.memoizedState,o!==r||m!==u||ht.current||fn?(typeof y=="function"&&(aa(t,n,y,r),u=t.memoizedState),(o=fn||du(t,n,o,r,m,u,d))?(g||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=u),a.props=r,a.state=u,a.context=d,r=o):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,dd(e,t),o=t.memoizedProps,d=t.type===t.elementType?o:Ot(t.type,o),a.props=d,g=t.pendingProps,m=a.context,u=n.contextType,typeof u=="object"&&u!==null?u=Tt(u):(u=mt(n)?Mn:lt.current,u=gr(t,u));var x=n.getDerivedStateFromProps;(y=typeof x=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(o!==g||m!==u)&&fu(t,a,r,u),fn=!1,m=t.memoizedState,a.state=m,gs(t,r,a,l);var w=t.memoizedState;o!==g||m!==w||ht.current||fn?(typeof x=="function"&&(aa(t,n,x,r),w=t.memoizedState),(d=fn||du(t,n,d,r,m,w,u)||!1)?(y||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,w,u),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,w,u)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=w),a.props=r,a.state=w,a.context=u,r=d):(typeof a.componentDidUpdate!="function"||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return da(e,t,n,r,i,l)}function da(e,t,n,r,l,i){Od(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return l&&ru(t,n,!1),ln(e,t,i);r=t.stateNode,Ch.current=t;var o=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=vr(t,e.child,null,i),t.child=vr(t,null,o,i)):at(e,t,o,i),t.memoizedState=r.state,l&&ru(t,n,!0),t.child}function Ad(e){var t=e.stateNode;t.pendingContext?nu(e,t.pendingContext,t.pendingContext!==t.context):t.context&&nu(e,t.context,!1),Ya(e,t.containerInfo)}function xu(e,t,n,r,l){return yr(),Ka(l),t.flags|=256,at(e,t,n,r),t.child}var fa={dehydrated:null,treeContext:null,retryLane:0};function pa(e){return{baseLanes:e,cachePool:null,transitions:null}}function Md(e,t,n){var r=t.pendingProps,l=be.current,i=!1,a=(t.flags&128)!==0,o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:(l&2)!==0),o?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(l|=1),we(be,l&1),e===null)return sa(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,i?(r=t.mode,i=t.child,a={mode:"hidden",children:a},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=Os(a,r,0,null),e=An(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=pa(n),t.memoizedState=fa,e):io(t,a));if(l=e.memoizedState,l!==null&&(o=l.dehydrated,o!==null))return Eh(e,t,a,r,o,l,n);if(i){i=r.fallback,a=t.mode,l=e.child,o=l.sibling;var u={mode:"hidden",children:r.children};return!(a&1)&&t.child!==l?(r=t.child,r.childLanes=0,r.pendingProps=u,t.deletions=null):(r=_n(l,u),r.subtreeFlags=l.subtreeFlags&14680064),o!==null?i=_n(o,i):(i=An(i,a,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,a=e.child.memoizedState,a=a===null?pa(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~n,t.memoizedState=fa,r}return i=e.child,e=i.sibling,r=_n(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function io(e,t){return t=Os({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Dl(e,t,n,r){return r!==null&&Ka(r),vr(t,e.child,null,n),e=io(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Eh(e,t,n,r,l,i,a){if(n)return t.flags&256?(t.flags&=-257,r=ki(Error(O(422))),Dl(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,l=t.mode,r=Os({mode:"visible",children:r.children},l,0,null),i=An(i,l,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&vr(t,e.child,null,a),t.child.memoizedState=pa(a),t.memoizedState=fa,i);if(!(t.mode&1))return Dl(e,t,a,null);if(l.data==="$!"){if(r=l.nextSibling&&l.nextSibling.dataset,r)var o=r.dgst;return r=o,i=Error(O(419)),r=ki(i,r,void 0),Dl(e,t,a,r)}if(o=(a&e.childLanes)!==0,pt||o){if(r=Xe,r!==null){switch(a&-a){case 4:l=2;break;case 16:l=8;break;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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:l=32;break;case 536870912:l=268435456;break;default:l=0}l=l&(r.suspendedLanes|a)?0:l,l!==0&&l!==i.retryLane&&(i.retryLane=l,rn(e,l),Bt(r,e,l,-1))}return po(),r=ki(Error(O(421))),Dl(e,t,a,r)}return l.data==="$?"?(t.flags|=128,t.child=e.child,t=Fh.bind(null,e),l._reactRetry=t,null):(e=i.treeContext,wt=wn(l.nextSibling),kt=t,Ce=!0,Mt=null,e!==null&&(Nt[Ct++]=Yt,Nt[Ct++]=Zt,Nt[Ct++]=Fn,Yt=e.id,Zt=e.overflow,Fn=t),t=io(t,r.children),t.flags|=4096,t)}function wu(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ia(e.return,t,n)}function ji(e,t,n,r,l){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:l}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=l)}function Fd(e,t,n){var r=t.pendingProps,l=r.revealOrder,i=r.tail;if(at(e,t,r.children,n),r=be.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&wu(e,n,t);else if(e.tag===19)wu(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(we(be,r),!(t.mode&1))t.memoizedState=null;else switch(l){case"forwards":for(n=t.child,l=null;n!==null;)e=n.alternate,e!==null&&ys(e)===null&&(l=n),n=n.sibling;n=l,n===null?(l=t.child,t.child=null):(l=n.sibling,n.sibling=null),ji(t,!1,l,n,i);break;case"backwards":for(n=null,l=t.child,t.child=null;l!==null;){if(e=l.alternate,e!==null&&ys(e)===null){t.child=l;break}e=l.sibling,l.sibling=n,n=l,l=e}ji(t,!0,n,null,i);break;case"together":ji(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Jl(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ln(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Un|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(O(153));if(t.child!==null){for(e=t.child,n=_n(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=_n(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function bh(e,t,n){switch(t.tag){case 3:Ad(t),yr();break;case 5:fd(t);break;case 1:mt(t.type)&&ds(t);break;case 4:Ya(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,l=t.memoizedProps.value;we(hs,r._currentValue),r._currentValue=l;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(we(be,be.current&1),t.flags|=128,null):n&t.child.childLanes?Md(e,t,n):(we(be,be.current&1),e=ln(e,t,n),e!==null?e.sibling:null);we(be,be.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Fd(e,t,n);t.flags|=128}if(l=t.memoizedState,l!==null&&(l.rendering=null,l.tail=null,l.lastEffect=null),we(be,be.current),r)break;return null;case 22:case 23:return t.lanes=0,Dd(e,t,n)}return ln(e,t,n)}var Bd,ha,Ud,Hd;Bd=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};ha=function(){};Ud=function(e,t,n,r){var l=e.memoizedProps;if(l!==r){e=t.stateNode,$n(qt.current);var i=null;switch(n){case"input":l=Di(e,l),r=Di(e,r),i=[];break;case"select":l=Pe({},l,{value:void 0}),r=Pe({},r,{value:void 0}),i=[];break;case"textarea":l=Mi(e,l),r=Mi(e,r),i=[];break;default:typeof l.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=us)}Bi(n,r);var a;n=null;for(d in l)if(!r.hasOwnProperty(d)&&l.hasOwnProperty(d)&&l[d]!=null)if(d==="style"){var o=l[d];for(a in o)o.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(Gr.hasOwnProperty(d)?i||(i=[]):(i=i||[]).push(d,null));for(d in r){var u=r[d];if(o=l!=null?l[d]:void 0,r.hasOwnProperty(d)&&u!==o&&(u!=null||o!=null))if(d==="style")if(o){for(a in o)!o.hasOwnProperty(a)||u&&u.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in u)u.hasOwnProperty(a)&&o[a]!==u[a]&&(n||(n={}),n[a]=u[a])}else n||(i||(i=[]),i.push(d,n)),n=u;else d==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,o=o?o.__html:void 0,u!=null&&o!==u&&(i=i||[]).push(d,u)):d==="children"?typeof u!="string"&&typeof u!="number"||(i=i||[]).push(d,""+u):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(Gr.hasOwnProperty(d)?(u!=null&&d==="onScroll"&&Se("scroll",e),i||o===u||(i=[])):(i=i||[]).push(d,u))}n&&(i=i||[]).push("style",n);var d=i;(t.updateQueue=d)&&(t.flags|=4)}};Hd=function(e,t,n,r){n!==r&&(t.flags|=4)};function Rr(e,t){if(!Ce)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function nt(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var l=e.child;l!==null;)n|=l.lanes|l.childLanes,r|=l.subtreeFlags&14680064,r|=l.flags&14680064,l.return=e,l=l.sibling;else for(l=e.child;l!==null;)n|=l.lanes|l.childLanes,r|=l.subtreeFlags,r|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Th(e,t,n){var r=t.pendingProps;switch(Va(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return nt(t),null;case 1:return mt(t.type)&&cs(),nt(t),null;case 3:return r=t.stateNode,xr(),_e(ht),_e(lt),eo(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Il(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Mt!==null&&(ja(Mt),Mt=null))),ha(e,t),nt(t),null;case 5:Za(t);var l=$n(ul.current);if(n=t.type,e!==null&&t.stateNode!=null)Ud(e,t,n,r,l),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(O(166));return nt(t),null}if(e=$n(qt.current),Il(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Kt]=t,r[al]=i,e=(t.mode&1)!==0,n){case"dialog":Se("cancel",r),Se("close",r);break;case"iframe":case"object":case"embed":Se("load",r);break;case"video":case"audio":for(l=0;l<Ar.length;l++)Se(Ar[l],r);break;case"source":Se("error",r);break;case"img":case"image":case"link":Se("error",r),Se("load",r);break;case"details":Se("toggle",r);break;case"input":To(r,i),Se("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},Se("invalid",r);break;case"textarea":Lo(r,i),Se("invalid",r)}Bi(n,i),l=null;for(var a in i)if(i.hasOwnProperty(a)){var o=i[a];a==="children"?typeof o=="string"?r.textContent!==o&&(i.suppressHydrationWarning!==!0&&zl(r.textContent,o,e),l=["children",o]):typeof o=="number"&&r.textContent!==""+o&&(i.suppressHydrationWarning!==!0&&zl(r.textContent,o,e),l=["children",""+o]):Gr.hasOwnProperty(a)&&o!=null&&a==="onScroll"&&Se("scroll",r)}switch(n){case"input":Nl(r),Po(r,i,!0);break;case"textarea":Nl(r),Ro(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=us)}r=l,t.updateQueue=r,r!==null&&(t.flags|=4)}else{a=l.nodeType===9?l:l.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=yc(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/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[Kt]=t,e[al]=r,Bd(e,t,!1,!1),t.stateNode=e;e:{switch(a=Ui(n,r),n){case"dialog":Se("cancel",e),Se("close",e),l=r;break;case"iframe":case"object":case"embed":Se("load",e),l=r;break;case"video":case"audio":for(l=0;l<Ar.length;l++)Se(Ar[l],e);l=r;break;case"source":Se("error",e),l=r;break;case"img":case"image":case"link":Se("error",e),Se("load",e),l=r;break;case"details":Se("toggle",e),l=r;break;case"input":To(e,r),l=Di(e,r),Se("invalid",e);break;case"option":l=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},l=Pe({},r,{value:void 0}),Se("invalid",e);break;case"textarea":Lo(e,r),l=Mi(e,r),Se("invalid",e);break;default:l=r}Bi(n,l),o=l;for(i in o)if(o.hasOwnProperty(i)){var u=o[i];i==="style"?wc(e,u):i==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&vc(e,u)):i==="children"?typeof u=="string"?(n!=="textarea"||u!=="")&&Yr(e,u):typeof u=="number"&&Yr(e,""+u):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Gr.hasOwnProperty(i)?u!=null&&i==="onScroll"&&Se("scroll",e):u!=null&&Pa(e,i,u,a))}switch(n){case"input":Nl(e),Po(e,r,!1);break;case"textarea":Nl(e),Ro(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Nn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?or(e,!!r.multiple,i,!1):r.defaultValue!=null&&or(e,!!r.multiple,r.defaultValue,!0);break;default:typeof l.onClick=="function"&&(e.onclick=us)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return nt(t),null;case 6:if(e&&t.stateNode!=null)Hd(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(O(166));if(n=$n(ul.current),$n(qt.current),Il(t)){if(r=t.stateNode,n=t.memoizedProps,r[Kt]=t,(i=r.nodeValue!==n)&&(e=kt,e!==null))switch(e.tag){case 3:zl(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&zl(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Kt]=t,t.stateNode=r}return nt(t),null;case 13:if(_e(be),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ce&&wt!==null&&t.mode&1&&!(t.flags&128))ad(),yr(),t.flags|=98560,i=!1;else if(i=Il(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(O(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(O(317));i[Kt]=t}else yr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;nt(t),i=!1}else Mt!==null&&(ja(Mt),Mt=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||be.current&1?Qe===0&&(Qe=3):po())),t.updateQueue!==null&&(t.flags|=4),nt(t),null);case 4:return xr(),ha(e,t),e===null&&sl(t.stateNode.containerInfo),nt(t),null;case 10:return Xa(t.type._context),nt(t),null;case 17:return mt(t.type)&&cs(),nt(t),null;case 19:if(_e(be),i=t.memoizedState,i===null)return nt(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)Rr(i,!1);else{if(Qe!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=ys(e),a!==null){for(t.flags|=128,Rr(i,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,a=i.alternate,a===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,e=a.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return we(be,be.current&1|2),t.child}e=e.sibling}i.tail!==null&&De()>kr&&(t.flags|=128,r=!0,Rr(i,!1),t.lanes=4194304)}else{if(!r)if(e=ys(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Rr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!Ce)return nt(t),null}else 2*De()-i.renderingStartTime>kr&&n!==1073741824&&(t.flags|=128,r=!0,Rr(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=De(),t.sibling=null,n=be.current,we(be,r?n&1|2:n&1),t):(nt(t),null);case 22:case 23:return fo(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?vt&1073741824&&(nt(t),t.subtreeFlags&6&&(t.flags|=8192)):nt(t),null;case 24:return null;case 25:return null}throw Error(O(156,t.tag))}function Ph(e,t){switch(Va(t),t.tag){case 1:return mt(t.type)&&cs(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return xr(),_e(ht),_e(lt),eo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Za(t),null;case 13:if(_e(be),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(O(340));yr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return _e(be),null;case 4:return xr(),null;case 10:return Xa(t.type._context),null;case 22:case 23:return fo(),null;case 24:return null;default:return null}}var Ol=!1,rt=!1,Lh=typeof WeakSet=="function"?WeakSet:Set,V=null;function ir(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ze(e,t,r)}else n.current=null}function ma(e,t,n){try{n()}catch(r){ze(e,t,r)}}var ku=!1;function Rh(e,t){if(Yi=is,e=qc(),Ha(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,d=0,y=0,g=e,m=null;t:for(;;){for(var x;g!==n||l!==0&&g.nodeType!==3||(o=a+l),g!==i||r!==0&&g.nodeType!==3||(u=a+r),g.nodeType===3&&(a+=g.nodeValue.length),(x=g.firstChild)!==null;)m=g,g=x;for(;;){if(g===e)break t;if(m===n&&++d===l&&(o=a),m===i&&++y===r&&(u=a),(x=g.nextSibling)!==null)break;g=m,m=g.parentNode}g=x}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Zi={focusedElem:e,selectionRange:n},is=!1,V=t;V!==null;)if(t=V,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,V=e;else for(;V!==null;){t=V;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 S=w.memoizedProps,_=w.memoizedState,p=t.stateNode,f=p.getSnapshotBeforeUpdate(t.elementType===t.type?S:Ot(t.type,S),_);p.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var h=t.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(O(163))}}catch(k){ze(t,t.return,k)}if(e=t.sibling,e!==null){e.return=t.return,V=e;break}V=t.return}return w=ku,ku=!1,w}function Qr(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&&ma(t,n,i)}l=l.next}while(l!==r)}}function $s(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 ga(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 Wd(e){var t=e.alternate;t!==null&&(e.alternate=null,Wd(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Kt],delete t[al],delete t[na],delete t[hh],delete t[mh])),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 Vd(e){return e.tag===5||e.tag===3||e.tag===4}function ju(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Vd(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 ya(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=us));else if(r!==4&&(e=e.child,e!==null))for(ya(e,t,n),e=e.sibling;e!==null;)ya(e,t,n),e=e.sibling}function va(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(va(e,t,n),e=e.sibling;e!==null;)va(e,t,n),e=e.sibling}var Je=null,At=!1;function cn(e,t,n){for(n=n.child;n!==null;)Kd(e,t,n),n=n.sibling}function Kd(e,t,n){if(Qt&&typeof Qt.onCommitFiberUnmount=="function")try{Qt.onCommitFiberUnmount(Es,n)}catch{}switch(n.tag){case 5:rt||ir(n,t);case 6:var r=Je,l=At;Je=null,cn(e,t,n),Je=r,At=l,Je!==null&&(At?(e=Je,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Je.removeChild(n.stateNode));break;case 18:Je!==null&&(At?(e=Je,n=n.stateNode,e.nodeType===8?mi(e.parentNode,n):e.nodeType===1&&mi(e,n),nl(e)):mi(Je,n.stateNode));break;case 4:r=Je,l=At,Je=n.stateNode.containerInfo,At=!0,cn(e,t,n),Je=r,At=l;break;case 0:case 11:case 14:case 15:if(!rt&&(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)&&ma(n,t,a),l=l.next}while(l!==r)}cn(e,t,n);break;case 1:if(!rt&&(ir(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ze(n,t,o)}cn(e,t,n);break;case 21:cn(e,t,n);break;case 22:n.mode&1?(rt=(r=rt)||n.memoizedState!==null,cn(e,t,n),rt=r):cn(e,t,n);break;default:cn(e,t,n)}}function Su(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Lh),t.forEach(function(r){var l=Bh.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Dt(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var l=n[r];try{var i=e,a=t,o=a;e:for(;o!==null;){switch(o.tag){case 5:Je=o.stateNode,At=!1;break e;case 3:Je=o.stateNode.containerInfo,At=!0;break e;case 4:Je=o.stateNode.containerInfo,At=!0;break e}o=o.return}if(Je===null)throw Error(O(160));Kd(i,a,l),Je=null,At=!1;var u=l.alternate;u!==null&&(u.return=null),l.return=null}catch(d){ze(l,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Qd(t,e),t=t.sibling}function Qd(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Dt(t,e),Ht(e),r&4){try{Qr(3,e,e.return),$s(3,e)}catch(S){ze(e,e.return,S)}try{Qr(5,e,e.return)}catch(S){ze(e,e.return,S)}}break;case 1:Dt(t,e),Ht(e),r&512&&n!==null&&ir(n,n.return);break;case 5:if(Dt(t,e),Ht(e),r&512&&n!==null&&ir(n,n.return),e.flags&32){var l=e.stateNode;try{Yr(l,"")}catch(S){ze(e,e.return,S)}}if(r&4&&(l=e.stateNode,l!=null)){var i=e.memoizedProps,a=n!==null?n.memoizedProps:i,o=e.type,u=e.updateQueue;if(e.updateQueue=null,u!==null)try{o==="input"&&i.type==="radio"&&i.name!=null&&mc(l,i),Ui(o,a);var d=Ui(o,i);for(a=0;a<u.length;a+=2){var y=u[a],g=u[a+1];y==="style"?wc(l,g):y==="dangerouslySetInnerHTML"?vc(l,g):y==="children"?Yr(l,g):Pa(l,y,g,d)}switch(o){case"input":Oi(l,i);break;case"textarea":gc(l,i);break;case"select":var m=l._wrapperState.wasMultiple;l._wrapperState.wasMultiple=!!i.multiple;var x=i.value;x!=null?or(l,!!i.multiple,x,!1):m!==!!i.multiple&&(i.defaultValue!=null?or(l,!!i.multiple,i.defaultValue,!0):or(l,!!i.multiple,i.multiple?[]:"",!1))}l[al]=i}catch(S){ze(e,e.return,S)}}break;case 6:if(Dt(t,e),Ht(e),r&4){if(e.stateNode===null)throw Error(O(162));l=e.stateNode,i=e.memoizedProps;try{l.nodeValue=i}catch(S){ze(e,e.return,S)}}break;case 3:if(Dt(t,e),Ht(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{nl(t.containerInfo)}catch(S){ze(e,e.return,S)}break;case 4:Dt(t,e),Ht(e);break;case 13:Dt(t,e),Ht(e),l=e.child,l.flags&8192&&(i=l.memoizedState!==null,l.stateNode.isHidden=i,!i||l.alternate!==null&&l.alternate.memoizedState!==null||(uo=De())),r&4&&Su(e);break;case 22:if(y=n!==null&&n.memoizedState!==null,e.mode&1?(rt=(d=rt)||y,Dt(t,e),rt=d):Dt(t,e),Ht(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!y&&e.mode&1)for(V=e,y=e.child;y!==null;){for(g=V=y;V!==null;){switch(m=V,x=m.child,m.tag){case 0:case 11:case 14:case 15:Qr(4,m,m.return);break;case 1:ir(m,m.return);var w=m.stateNode;if(typeof w.componentWillUnmount=="function"){r=m,n=m.return;try{t=r,w.props=t.memoizedProps,w.state=t.memoizedState,w.componentWillUnmount()}catch(S){ze(r,n,S)}}break;case 5:ir(m,m.return);break;case 22:if(m.memoizedState!==null){Nu(g);continue}}x!==null?(x.return=m,V=x):Nu(g)}y=y.sibling}e:for(y=null,g=e;;){if(g.tag===5){if(y===null){y=g;try{l=g.stateNode,d?(i=l.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(o=g.stateNode,u=g.memoizedProps.style,a=u!=null&&u.hasOwnProperty("display")?u.display:null,o.style.display=xc("display",a))}catch(S){ze(e,e.return,S)}}}else if(g.tag===6){if(y===null)try{g.stateNode.nodeValue=d?"":g.memoizedProps}catch(S){ze(e,e.return,S)}}else if((g.tag!==22&&g.tag!==23||g.memoizedState===null||g===e)&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===e)break e;for(;g.sibling===null;){if(g.return===null||g.return===e)break e;y===g&&(y=null),g=g.return}y===g&&(y=null),g.sibling.return=g.return,g=g.sibling}}break;case 19:Dt(t,e),Ht(e),r&4&&Su(e);break;case 21:break;default:Dt(t,e),Ht(e)}}function Ht(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Vd(n)){var r=n;break e}n=n.return}throw Error(O(160))}switch(r.tag){case 5:var l=r.stateNode;r.flags&32&&(Yr(l,""),r.flags&=-33);var i=ju(e);va(e,i,l);break;case 3:case 4:var a=r.stateNode.containerInfo,o=ju(e);ya(e,o,a);break;default:throw Error(O(161))}}catch(u){ze(e,e.return,u)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function zh(e,t,n){V=e,qd(e)}function qd(e,t,n){for(var r=(e.mode&1)!==0;V!==null;){var l=V,i=l.child;if(l.tag===22&&r){var a=l.memoizedState!==null||Ol;if(!a){var o=l.alternate,u=o!==null&&o.memoizedState!==null||rt;o=Ol;var d=rt;if(Ol=a,(rt=u)&&!d)for(V=l;V!==null;)a=V,u=a.child,a.tag===22&&a.memoizedState!==null?Cu(l):u!==null?(u.return=a,V=u):Cu(l);for(;i!==null;)V=i,qd(i),i=i.sibling;V=l,Ol=o,rt=d}_u(e)}else l.subtreeFlags&8772&&i!==null?(i.return=l,V=i):_u(e)}}function _u(e){for(;V!==null;){var t=V;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:rt||$s(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!rt)if(n===null)r.componentDidMount();else{var l=t.elementType===t.type?n.memoizedProps:Ot(t.type,n.memoizedProps);r.componentDidUpdate(l,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&ou(t,i,r);break;case 3:var a=t.updateQueue;if(a!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}ou(t,a,n)}break;case 5:var o=t.stateNode;if(n===null&&t.flags&4){n=o;var u=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":u.autoFocus&&n.focus();break;case"img":u.src&&(n.src=u.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var y=d.memoizedState;if(y!==null){var g=y.dehydrated;g!==null&&nl(g)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(O(163))}rt||t.flags&512&&ga(t)}catch(m){ze(t,t.return,m)}}if(t===e){V=null;break}if(n=t.sibling,n!==null){n.return=t.return,V=n;break}V=t.return}}function Nu(e){for(;V!==null;){var t=V;if(t===e){V=null;break}var n=t.sibling;if(n!==null){n.return=t.return,V=n;break}V=t.return}}function Cu(e){for(;V!==null;){var t=V;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{$s(4,t)}catch(u){ze(t,n,u)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var l=t.return;try{r.componentDidMount()}catch(u){ze(t,l,u)}}var i=t.return;try{ga(t)}catch(u){ze(t,i,u)}break;case 5:var a=t.return;try{ga(t)}catch(u){ze(t,a,u)}}}catch(u){ze(t,t.return,u)}if(t===e){V=null;break}var o=t.sibling;if(o!==null){o.return=t.return,V=o;break}V=t.return}}var Ih=Math.ceil,ws=sn.ReactCurrentDispatcher,ao=sn.ReactCurrentOwner,bt=sn.ReactCurrentBatchConfig,de=0,Xe=null,Be=null,Ge=0,vt=0,ar=bn(0),Qe=0,pl=null,Un=0,Ds=0,oo=0,qr=null,ft=null,uo=0,kr=1/0,Jt=null,ks=!1,xa=null,jn=null,Al=!1,gn=null,js=0,Xr=0,wa=null,Gl=-1,Yl=0;function ot(){return de&6?De():Gl!==-1?Gl:Gl=De()}function Sn(e){return e.mode&1?de&2&&Ge!==0?Ge&-Ge:yh.transition!==null?(Yl===0&&(Yl=Rc()),Yl):(e=ge,e!==0||(e=window.event,e=e===void 0?16:Mc(e.type)),e):1}function Bt(e,t,n,r){if(50<Xr)throw Xr=0,wa=null,Error(O(185));yl(e,n,r),(!(de&2)||e!==Xe)&&(e===Xe&&(!(de&2)&&(Ds|=n),Qe===4&&hn(e,Ge)),gt(e,r),n===1&&de===0&&!(t.mode&1)&&(kr=De()+500,Rs&&Tn()))}function gt(e,t){var n=e.callbackNode;yp(e,t);var r=ss(e,e===Xe?Ge:0);if(r===0)n!==null&&$o(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&$o(n),t===1)e.tag===0?gh(Eu.bind(null,e)):ld(Eu.bind(null,e)),fh(function(){!(de&6)&&Tn()}),n=null;else{switch(zc(r)){case 1:n=$a;break;case 4:n=Pc;break;case 16:n=ls;break;case 536870912:n=Lc;break;default:n=ls}n=nf(n,Xd.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Xd(e,t){if(Gl=-1,Yl=0,de&6)throw Error(O(327));var n=e.callbackNode;if(pr()&&e.callbackNode!==n)return null;var r=ss(e,e===Xe?Ge:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Ss(e,r);else{t=r;var l=de;de|=2;var i=Gd();(Xe!==e||Ge!==t)&&(Jt=null,kr=De()+500,On(e,t));do try{Oh();break}catch(o){Jd(e,o)}while(!0);qa(),ws.current=i,de=l,Be!==null?t=0:(Xe=null,Ge=0,t=Qe)}if(t!==0){if(t===2&&(l=Qi(e),l!==0&&(r=l,t=ka(e,l))),t===1)throw n=pl,On(e,0),hn(e,r),gt(e,De()),n;if(t===6)hn(e,r);else{if(l=e.current.alternate,!(r&30)&&!$h(l)&&(t=Ss(e,r),t===2&&(i=Qi(e),i!==0&&(r=i,t=ka(e,i))),t===1))throw n=pl,On(e,0),hn(e,r),gt(e,De()),n;switch(e.finishedWork=l,e.finishedLanes=r,t){case 0:case 1:throw Error(O(345));case 2:Rn(e,ft,Jt);break;case 3:if(hn(e,r),(r&130023424)===r&&(t=uo+500-De(),10<t)){if(ss(e,0)!==0)break;if(l=e.suspendedLanes,(l&r)!==r){ot(),e.pingedLanes|=e.suspendedLanes&l;break}e.timeoutHandle=ta(Rn.bind(null,e,ft,Jt),t);break}Rn(e,ft,Jt);break;case 4:if(hn(e,r),(r&4194240)===r)break;for(t=e.eventTimes,l=-1;0<r;){var a=31-Ft(r);i=1<<a,a=t[a],a>l&&(l=a),r&=~i}if(r=l,r=De()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Ih(r/1960))-r,10<r){e.timeoutHandle=ta(Rn.bind(null,e,ft,Jt),r);break}Rn(e,ft,Jt);break;case 5:Rn(e,ft,Jt);break;default:throw Error(O(329))}}}return gt(e,De()),e.callbackNode===n?Xd.bind(null,e):null}function ka(e,t){var n=qr;return e.current.memoizedState.isDehydrated&&(On(e,t).flags|=256),e=Ss(e,t),e!==2&&(t=ft,ft=n,t!==null&&ja(t)),e}function ja(e){ft===null?ft=e:ft.push.apply(ft,e)}function $h(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var l=n[r],i=l.getSnapshot;l=l.value;try{if(!Ut(i(),l))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function hn(e,t){for(t&=~oo,t&=~Ds,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Ft(t),r=1<<n;e[n]=-1,t&=~r}}function Eu(e){if(de&6)throw Error(O(327));pr();var t=ss(e,0);if(!(t&1))return gt(e,De()),null;var n=Ss(e,t);if(e.tag!==0&&n===2){var r=Qi(e);r!==0&&(t=r,n=ka(e,r))}if(n===1)throw n=pl,On(e,0),hn(e,t),gt(e,De()),n;if(n===6)throw Error(O(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Rn(e,ft,Jt),gt(e,De()),null}function co(e,t){var n=de;de|=1;try{return e(t)}finally{de=n,de===0&&(kr=De()+500,Rs&&Tn())}}function Hn(e){gn!==null&&gn.tag===0&&!(de&6)&&pr();var t=de;de|=1;var n=bt.transition,r=ge;try{if(bt.transition=null,ge=1,e)return e()}finally{ge=r,bt.transition=n,de=t,!(de&6)&&Tn()}}function fo(){vt=ar.current,_e(ar)}function On(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,dh(n)),Be!==null)for(n=Be.return;n!==null;){var r=n;switch(Va(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&cs();break;case 3:xr(),_e(ht),_e(lt),eo();break;case 5:Za(r);break;case 4:xr();break;case 13:_e(be);break;case 19:_e(be);break;case 10:Xa(r.type._context);break;case 22:case 23:fo()}n=n.return}if(Xe=e,Be=e=_n(e.current,null),Ge=vt=t,Qe=0,pl=null,oo=Ds=Un=0,ft=qr=null,In!==null){for(t=0;t<In.length;t++)if(n=In[t],r=n.interleaved,r!==null){n.interleaved=null;var l=r.next,i=n.pending;if(i!==null){var a=i.next;i.next=l,r.next=a}n.pending=r}In=null}return e}function Jd(e,t){do{var n=Be;try{if(qa(),ql.current=xs,vs){for(var r=Te.memoizedState;r!==null;){var l=r.queue;l!==null&&(l.pending=null),r=r.next}vs=!1}if(Bn=0,qe=Ke=Te=null,Kr=!1,cl=0,ao.current=null,n===null||n.return===null){Qe=1,pl=t,Be=null;break}e:{var i=e,a=n.return,o=n,u=t;if(t=Ge,o.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){var d=u,y=o,g=y.tag;if(!(y.mode&1)&&(g===0||g===11||g===15)){var m=y.alternate;m?(y.updateQueue=m.updateQueue,y.memoizedState=m.memoizedState,y.lanes=m.lanes):(y.updateQueue=null,y.memoizedState=null)}var x=hu(a);if(x!==null){x.flags&=-257,mu(x,a,o,i,t),x.mode&1&&pu(i,d,t),t=x,u=d;var w=t.updateQueue;if(w===null){var S=new Set;S.add(u),t.updateQueue=S}else w.add(u);break e}else{if(!(t&1)){pu(i,d,t),po();break e}u=Error(O(426))}}else if(Ce&&o.mode&1){var _=hu(a);if(_!==null){!(_.flags&65536)&&(_.flags|=256),mu(_,a,o,i,t),Ka(wr(u,o));break e}}i=u=wr(u,o),Qe!==4&&(Qe=2),qr===null?qr=[i]:qr.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var p=zd(i,u,t);au(i,p);break e;case 1:o=u;var f=i.type,h=i.stateNode;if(!(i.flags&128)&&(typeof f.getDerivedStateFromError=="function"||h!==null&&typeof h.componentDidCatch=="function"&&(jn===null||!jn.has(h)))){i.flags|=65536,t&=-t,i.lanes|=t;var k=Id(i,o,t);au(i,k);break e}}i=i.return}while(i!==null)}Zd(n)}catch(E){t=E,Be===n&&n!==null&&(Be=n=n.return);continue}break}while(!0)}function Gd(){var e=ws.current;return ws.current=xs,e===null?xs:e}function po(){(Qe===0||Qe===3||Qe===2)&&(Qe=4),Xe===null||!(Un&268435455)&&!(Ds&268435455)||hn(Xe,Ge)}function Ss(e,t){var n=de;de|=2;var r=Gd();(Xe!==e||Ge!==t)&&(Jt=null,On(e,t));do try{Dh();break}catch(l){Jd(e,l)}while(!0);if(qa(),de=n,ws.current=r,Be!==null)throw Error(O(261));return Xe=null,Ge=0,Qe}function Dh(){for(;Be!==null;)Yd(Be)}function Oh(){for(;Be!==null&&!op();)Yd(Be)}function Yd(e){var t=tf(e.alternate,e,vt);e.memoizedProps=e.pendingProps,t===null?Zd(e):Be=t,ao.current=null}function Zd(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=Ph(n,t),n!==null){n.flags&=32767,Be=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Qe=6,Be=null;return}}else if(n=Th(n,t,vt),n!==null){Be=n;return}if(t=t.sibling,t!==null){Be=t;return}Be=t=e}while(t!==null);Qe===0&&(Qe=5)}function Rn(e,t,n){var r=ge,l=bt.transition;try{bt.transition=null,ge=1,Ah(e,t,n,r)}finally{bt.transition=l,ge=r}return null}function Ah(e,t,n,r){do pr();while(gn!==null);if(de&6)throw Error(O(327));n=e.finishedWork;var l=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(O(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(vp(e,i),e===Xe&&(Be=Xe=null,Ge=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Al||(Al=!0,nf(ls,function(){return pr(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=bt.transition,bt.transition=null;var a=ge;ge=1;var o=de;de|=4,ao.current=null,Rh(e,n),Qd(n,e),lh(Zi),is=!!Yi,Zi=Yi=null,e.current=n,zh(n),up(),de=o,ge=a,bt.transition=i}else e.current=n;if(Al&&(Al=!1,gn=e,js=l),i=e.pendingLanes,i===0&&(jn=null),fp(n.stateNode),gt(e,De()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)l=t[n],r(l.value,{componentStack:l.stack,digest:l.digest});if(ks)throw ks=!1,e=xa,xa=null,e;return js&1&&e.tag!==0&&pr(),i=e.pendingLanes,i&1?e===wa?Xr++:(Xr=0,wa=e):Xr=0,Tn(),null}function pr(){if(gn!==null){var e=zc(js),t=bt.transition,n=ge;try{if(bt.transition=null,ge=16>e?16:e,gn===null)var r=!1;else{if(e=gn,gn=null,js=0,de&6)throw Error(O(331));var l=de;for(de|=4,V=e.current;V!==null;){var i=V,a=i.child;if(V.flags&16){var o=i.deletions;if(o!==null){for(var u=0;u<o.length;u++){var d=o[u];for(V=d;V!==null;){var y=V;switch(y.tag){case 0:case 11:case 15:Qr(8,y,i)}var g=y.child;if(g!==null)g.return=y,V=g;else for(;V!==null;){y=V;var m=y.sibling,x=y.return;if(Wd(y),y===d){V=null;break}if(m!==null){m.return=x,V=m;break}V=x}}}var w=i.alternate;if(w!==null){var S=w.child;if(S!==null){w.child=null;do{var _=S.sibling;S.sibling=null,S=_}while(S!==null)}}V=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,V=a;else e:for(;V!==null;){if(i=V,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Qr(9,i,i.return)}var p=i.sibling;if(p!==null){p.return=i.return,V=p;break e}V=i.return}}var f=e.current;for(V=f;V!==null;){a=V;var h=a.child;if(a.subtreeFlags&2064&&h!==null)h.return=a,V=h;else e:for(a=f;V!==null;){if(o=V,o.flags&2048)try{switch(o.tag){case 0:case 11:case 15:$s(9,o)}}catch(E){ze(o,o.return,E)}if(o===a){V=null;break e}var k=o.sibling;if(k!==null){k.return=o.return,V=k;break e}V=o.return}}if(de=l,Tn(),Qt&&typeof Qt.onPostCommitFiberRoot=="function")try{Qt.onPostCommitFiberRoot(Es,e)}catch{}r=!0}return r}finally{ge=n,bt.transition=t}}return!1}function bu(e,t,n){t=wr(n,t),t=zd(e,t,1),e=kn(e,t,1),t=ot(),e!==null&&(yl(e,1,t),gt(e,t))}function ze(e,t,n){if(e.tag===3)bu(e,e,n);else for(;t!==null;){if(t.tag===3){bu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(jn===null||!jn.has(r))){e=wr(n,e),e=Id(t,e,1),t=kn(t,e,1),e=ot(),t!==null&&(yl(t,1,e),gt(t,e));break}}t=t.return}}function Mh(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=ot(),e.pingedLanes|=e.suspendedLanes&n,Xe===e&&(Ge&n)===n&&(Qe===4||Qe===3&&(Ge&130023424)===Ge&&500>De()-uo?On(e,0):oo|=n),gt(e,t)}function ef(e,t){t===0&&(e.mode&1?(t=bl,bl<<=1,!(bl&130023424)&&(bl=4194304)):t=1);var n=ot();e=rn(e,t),e!==null&&(yl(e,t,n),gt(e,n))}function Fh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ef(e,n)}function Bh(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(O(314))}r!==null&&r.delete(t),ef(e,n)}var tf;tf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ht.current)pt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return pt=!1,bh(e,t,n);pt=!!(e.flags&131072)}else pt=!1,Ce&&t.flags&1048576&&sd(t,ps,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Jl(e,t),e=t.pendingProps;var l=gr(t,lt.current);fr(t,n),l=no(null,t,r,e,l,n);var i=ro();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,mt(r)?(i=!0,ds(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Ga(t),l.updater=Is,t.stateNode=l,l._reactInternals=t,oa(t,r,e,n),t=da(null,t,r,!0,i,n)):(t.tag=0,Ce&&i&&Wa(t),at(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Jl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Hh(r),e=Ot(r,e),l){case 0:t=ca(null,t,r,e,n);break e;case 1:t=vu(null,t,r,e,n);break e;case 11:t=gu(null,t,r,e,n);break e;case 14:t=yu(null,t,r,Ot(r.type,e),n);break e}throw Error(O(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ot(r,l),ca(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ot(r,l),vu(e,t,r,l,n);case 3:e:{if(Ad(t),e===null)throw Error(O(387));r=t.pendingProps,i=t.memoizedState,l=i.element,dd(e,t),gs(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=wr(Error(O(423)),t),t=xu(e,t,r,n,l);break e}else if(r!==l){l=wr(Error(O(424)),t),t=xu(e,t,r,n,l);break e}else for(wt=wn(t.stateNode.containerInfo.firstChild),kt=t,Ce=!0,Mt=null,n=ud(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(yr(),r===l){t=ln(e,t,n);break e}at(e,t,r,n)}t=t.child}return t;case 5:return fd(t),e===null&&sa(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,a=l.children,ea(r,l)?a=null:i!==null&&ea(r,i)&&(t.flags|=32),Od(e,t),at(e,t,a,n),t.child;case 6:return e===null&&sa(t),null;case 13:return Md(e,t,n);case 4:return Ya(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=vr(t,null,r,n):at(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ot(r,l),gu(e,t,r,l,n);case 7:return at(e,t,t.pendingProps,n),t.child;case 8:return at(e,t,t.pendingProps.children,n),t.child;case 12:return at(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,we(hs,r._currentValue),r._currentValue=a,i!==null)if(Ut(i.value,a)){if(i.children===l.children&&!ht.current){t=ln(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=en(-1,n&-n),u.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var y=d.pending;y===null?u.next=u:(u.next=y.next,y.next=u),d.pending=u}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),ia(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(O(341));a.lanes|=n,o=a.alternate,o!==null&&(o.lanes|=n),ia(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}at(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,fr(t,n),l=Tt(l),r=r(l),t.flags|=1,at(e,t,r,n),t.child;case 14:return r=t.type,l=Ot(r,t.pendingProps),l=Ot(r.type,l),yu(e,t,r,l,n);case 15:return $d(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ot(r,l),Jl(e,t),t.tag=1,mt(r)?(e=!0,ds(t)):e=!1,fr(t,n),Rd(t,r,l),oa(t,r,l,n),da(null,t,r,!0,e,n);case 19:return Fd(e,t,n);case 22:return Dd(e,t,n)}throw Error(O(156,t.tag))};function nf(e,t){return Tc(e,t)}function Uh(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 Uh(e,t,n,r)}function ho(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hh(e){if(typeof e=="function")return ho(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ra)return 11;if(e===za)return 14}return 2}function _n(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 Zl(e,t,n,r,l,i){var a=2;if(r=e,typeof e=="function")ho(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Gn:return An(n.children,l,i,t);case La:a=8,l|=8;break;case Ri:return e=Et(12,n,t,l|2),e.elementType=Ri,e.lanes=i,e;case zi:return e=Et(13,n,t,l),e.elementType=zi,e.lanes=i,e;case Ii:return e=Et(19,n,t,l),e.elementType=Ii,e.lanes=i,e;case fc:return Os(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case cc:a=10;break e;case dc:a=9;break e;case Ra:a=11;break e;case za:a=14;break e;case dn:a=16,r=null;break e}throw Error(O(130,e==null?e:typeof e,""))}return t=Et(a,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function An(e,t,n,r){return e=Et(7,e,r,t),e.lanes=n,e}function Os(e,t,n,r){return e=Et(22,e,r,t),e.elementType=fc,e.lanes=n,e.stateNode={isHidden:!1},e}function Si(e,t,n){return e=Et(6,e,null,t),e.lanes=n,e}function _i(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 Wh(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=li(0),this.expirationTimes=li(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=li(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function mo(e,t,n,r,l,i,a,o,u){return e=new Wh(e,t,n,o,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Et(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ga(i),e}function Vh(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Jn,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function rf(e){if(!e)return Cn;e=e._reactInternals;e:{if(Vn(e)!==e||e.tag!==1)throw Error(O(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(mt(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(O(171))}if(e.tag===1){var n=e.type;if(mt(n))return rd(e,n,t)}return t}function lf(e,t,n,r,l,i,a,o,u){return e=mo(n,r,!0,e,l,i,a,o,u),e.context=rf(null),n=e.current,r=ot(),l=Sn(n),i=en(r,l),i.callback=t??null,kn(n,i,l),e.current.lanes=l,yl(e,l,r),gt(e,r),e}function As(e,t,n,r){var l=t.current,i=ot(),a=Sn(l);return n=rf(n),t.context===null?t.context=n:t.pendingContext=n,t=en(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=kn(l,t,a),e!==null&&(Bt(e,l,a,i),Ql(e,l,a)),a}function _s(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Tu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function go(e,t){Tu(e,t),(e=e.alternate)&&Tu(e,t)}function Kh(){return null}var sf=typeof reportError=="function"?reportError:function(e){console.error(e)};function yo(e){this._internalRoot=e}Ms.prototype.render=yo.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(O(409));As(e,t,null,null)};Ms.prototype.unmount=yo.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Hn(function(){As(null,e,null,null)}),t[nn]=null}};function Ms(e){this._internalRoot=e}Ms.prototype.unstable_scheduleHydration=function(e){if(e){var t=Dc();e={blockedOn:null,target:e,priority:t};for(var n=0;n<pn.length&&t!==0&&t<pn[n].priority;n++);pn.splice(n,0,e),n===0&&Ac(e)}};function vo(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Fs(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Pu(){}function Qh(e,t,n,r,l){if(l){if(typeof r=="function"){var i=r;r=function(){var d=_s(a);i.call(d)}}var a=lf(t,r,e,0,null,!1,!1,"",Pu);return e._reactRootContainer=a,e[nn]=a.current,sl(e.nodeType===8?e.parentNode:e),Hn(),a}for(;l=e.lastChild;)e.removeChild(l);if(typeof r=="function"){var o=r;r=function(){var d=_s(u);o.call(d)}}var u=mo(e,0,!1,null,null,!1,!1,"",Pu);return e._reactRootContainer=u,e[nn]=u.current,sl(e.nodeType===8?e.parentNode:e),Hn(function(){As(t,u,n,r)}),u}function Bs(e,t,n,r,l){var i=n._reactRootContainer;if(i){var a=i;if(typeof l=="function"){var o=l;l=function(){var u=_s(a);o.call(u)}}As(t,a,e,l)}else a=Qh(n,t,e,l,r);return _s(a)}Ic=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Or(t.pendingLanes);n!==0&&(Da(t,n|1),gt(t,De()),!(de&6)&&(kr=De()+500,Tn()))}break;case 13:Hn(function(){var r=rn(e,1);if(r!==null){var l=ot();Bt(r,e,1,l)}}),go(e,1)}};Oa=function(e){if(e.tag===13){var t=rn(e,134217728);if(t!==null){var n=ot();Bt(t,e,134217728,n)}go(e,134217728)}};$c=function(e){if(e.tag===13){var t=Sn(e),n=rn(e,t);if(n!==null){var r=ot();Bt(n,e,t,r)}go(e,t)}};Dc=function(){return ge};Oc=function(e,t){var n=ge;try{return ge=e,t()}finally{ge=n}};Wi=function(e,t,n){switch(t){case"input":if(Oi(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var l=Ls(r);if(!l)throw Error(O(90));hc(r),Oi(r,l)}}}break;case"textarea":gc(e,n);break;case"select":t=n.value,t!=null&&or(e,!!n.multiple,t,!1)}};Sc=co;_c=Hn;var qh={usingClientEntryPoint:!1,Events:[xl,tr,Ls,kc,jc,co]},zr={findFiberByHostInstance:zn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Xh={bundleType:zr.bundleType,version:zr.version,rendererPackageName:zr.rendererPackageName,rendererConfig:zr.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:sn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Ec(e),e===null?null:e.stateNode},findFiberByHostInstance:zr.findFiberByHostInstance||Kh,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ml=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ml.isDisabled&&Ml.supportsFiber)try{Es=Ml.inject(Xh),Qt=Ml}catch{}}St.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=qh;St.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!vo(t))throw Error(O(200));return Vh(e,t,null,n)};St.createRoot=function(e,t){if(!vo(e))throw Error(O(299));var n=!1,r="",l=sf;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(l=t.onRecoverableError)),t=mo(e,1,!1,null,null,n,!1,r,l),e[nn]=t.current,sl(e.nodeType===8?e.parentNode:e),new yo(t)};St.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(O(188)):(e=Object.keys(e).join(","),Error(O(268,e)));return e=Ec(t),e=e===null?null:e.stateNode,e};St.flushSync=function(e){return Hn(e)};St.hydrate=function(e,t,n){if(!Fs(t))throw Error(O(200));return Bs(null,e,t,!0,n)};St.hydrateRoot=function(e,t,n){if(!vo(e))throw Error(O(405));var r=n!=null&&n.hydratedSources||null,l=!1,i="",a=sf;if(n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=lf(t,null,e,1,n??null,l,!1,i,a),e[nn]=t.current,sl(e),r)for(e=0;e<r.length;e++)n=r[e],l=n._getVersion,l=l(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,l]:t.mutableSourceEagerHydrationData.push(n,l);return new Ms(t)};St.render=function(e,t,n){if(!Fs(t))throw Error(O(200));return Bs(null,e,t,!1,n)};St.unmountComponentAtNode=function(e){if(!Fs(e))throw Error(O(40));return e._reactRootContainer?(Hn(function(){Bs(null,null,e,!1,function(){e._reactRootContainer=null,e[nn]=null})}),!0):!1};St.unstable_batchedUpdates=co;St.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Fs(n))throw Error(O(200));if(e==null||e._reactInternals===void 0)throw Error(O(38));return Bs(e,t,n,!1,r)};St.version="18.3.1-next-f1338f8080-20240426";function af(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(af)}catch(e){console.error(e)}}af(),ic.exports=St;var Jh=ic.exports,of,Lu=Jh;of=Lu.createRoot,Lu.hydrateRoot;async function Oe(e,t){const n=await fetch(e,t);if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);return n.json()}async function Ru(){return Oe("/api/archives")}async function zu(e,t=null){const n=t?`/api/archives/${e}/entries?collection=${encodeURIComponent(t)}`:`/api/archives/${e}/entries`;return Oe(n)}async function Gh(e,t,n,r=null){const l=new URLSearchParams;return t&&l.set("q",t),n&&l.set("tag",n),r&&l.set("collection",r),Oe(`/api/archives/${e}/entries/search?${l}`)}async function Mr(e,t){return Oe(`/api/archives/${e}/entries/${t}`)}async function Yh(e,t,{signal:n}={}){return Oe(`/api/archives/${e}/entries/${t}/summary`,{signal:n})}async function Zh(e,t,{provider:n,force:r=!1,includeImages:l=!1,signal:i}={}){const a=await fetch(`/api/archives/${e}/entries/${t}/summary`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n,force:r,include_images:l}),signal:i});if(!a.ok){const o=await a.text();let u=o.trim();try{u=JSON.parse(o).error||u}catch{}throw new Error(u||`Summary request failed (${a.status})`)}return a.json()}async function em(e,{signal:t}={}){const n=await fetch(e,{credentials:"same-origin",signal:t});if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.text()}async function Iu(e,t){return Oe(`/api/archives/${e}/entries/${t}/children`)}async function tm(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/children/order`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({child_uids:n})});if(!r.ok){const l=await r.json().catch(()=>({})),i=new Error(l.error||`HTTP ${r.status}`);throw i.status=r.status,i}}function nm(e,t,n){return Promise.all(n.map(r=>Oe(`/api/archives/${e}/entries/${t}/artifacts/${r}`)))}async function rm(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 lm(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 Fl(e,t){return Oe(`/api/archives/${e}/entries/${t}/tags`)}async function $u(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 sm(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 Du(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 im(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 am(e,t){const n=await fetch(`/api/archives/${e}/tags/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(await n.text())}async function om(e,t){const n=await fetch(`/api/archives/${e}/tags`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!n.ok)throw new Error(await n.text());return n.json()}async function um(e,t,n){const r=await fetch(`/api/archives/${e}/tags/${t}/move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent_uid:n??null})});if(!r.ok)throw new Error(await r.text());return r.json()}async function Ni(e){return Oe(`/api/archives/${e}/runs`)}async function Bl(e){return Oe(`/api/archives/${e}/tags`)}async function cm(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),typeof r.via_freedium=="boolean"&&(l.via_freedium=r.via_freedium),r.per_item_quality&&typeof r.per_item_quality=="object"&&Object.keys(r.per_item_quality).length>0&&(l.per_item_quality=r.per_item_quality),r.sync===!0&&(l.sync=!0));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(()=>({})),o=new Error(a.error||`HTTP ${i.status}`);throw o.status=i.status,o}return i.json()}async function dm(e,{title:t,body:n,mime:r="text/markdown"}){const l={title:t,body:n};r&&r!=="text/markdown"&&(l.mime=r);const i=await fetch(`/api/archives/${e}/captures/text`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!i.ok){const a=await i.json().catch(()=>({})),o=new Error(a.error||`HTTP ${i.status}`);throw o.status=i.status,o}return i.json()}async function fm(e,t){return Oe(`/api/archives/${e}/captures/probe?locator=${encodeURIComponent(t)}`)}async function pm(e,t){const n=await fetch(`/api/archives/${e}/captures/probe-playlist`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locator:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function uf(e,t){return Oe(`/api/archives/${e}/capture_jobs/${t}`)}async function hm(){return(await(await fetch("/api/auth/setup")).json()).setup_required===!0}async function mm(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 gm(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 ym(){await fetch("/api/auth/logout",{method:"POST"})}async function cf(){const e=await fetch("/api/auth/me");return e.status===401?null:e.json()}async function vm(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 xm(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 wm(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 km(){return Oe("/api/auth/tokens")}async function jm(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 Sm(e){const t=await fetch(`/api/auth/tokens/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(await t.text())}async function xo(){return Oe("/api/admin/instance-settings")}async function Jr(e){const t=await fetch("/api/admin/instance-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||`HTTP ${t.status}`)}}async function _m(){return Oe("/api/admin/users")}async function Nm(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 Cm(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 df(){return Oe("/api/admin/roles")}async function Em(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 wo(e){return Oe(`/api/archives/${e}/collections`)}async function bm(e,t,n,r=2,l=!0){const i=await fetch(`/api/archives/${e}/collections`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:t,slug:n,default_visibility_bits:r,requires_auth:l})});if(!i.ok){const a=await i.json().catch(()=>({error:i.statusText}));throw new Error(a.error||i.statusText)}return i.json()}async function Tm(e,t){return Oe(`/api/archives/${e}/collections/${t}`)}async function Sa(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 Pm(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 Lm(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 Ou(e,t){return Oe(`/api/archives/${e}/entries/${t}/collections`)}async function Ci(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 Rm(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 zm(e){return Oe(`/api/archives/${e}/blob-cleanup`)}async function Im(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 $m(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 Dm(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/artifacts/${n}/media-token`,{method:"POST"});if(!r.ok)throw new Error(`media-token ${r.status}`);return r.json()}async function Om(){return Oe("/api/admin/cookie-rules")}async function Am(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 Mm(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 Fm(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}`)}}function Bm(e,t,n){let r;return{promise:new Promise((i,a)=>{const o=new FormData;o.append("file",t),r=new XMLHttpRequest,r.open("POST",`/api/archives/${e}/uploads`),r.upload.addEventListener("progress",u=>{u.lengthComputable&&n&&n(Math.round(u.loaded/u.total*100))}),r.addEventListener("load",()=>{if(r.status>=200&&r.status<300)try{i(JSON.parse(r.responseText))}catch{a(new Error("Invalid server response"))}else{let u=`Upload failed (${r.status})`;try{u=JSON.parse(r.responseText).message||u}catch{}a(new Error(u))}}),r.addEventListener("error",()=>a(new Error("Network error during upload"))),r.addEventListener("abort",()=>a(new Error("Upload cancelled"))),r.send(o)}),abort:()=>r==null?void 0:r.abort()}}async function Ei(e,t){try{await fetch(`/api/archives/${e}/uploads`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({locator:t})})}catch{}}const Um=window.fetch;window.fetch=async(...e)=>{var n;const t=await Um(...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 Hm({onLogin:e}){const[t,n]=c.useState(""),[r,l]=c.useState(""),[i,a]=c.useState(null),[o,u]=c.useState(!1);async function d(y){y.preventDefault(),a(null),u(!0);try{const g=await gm(t,r);e(g)}catch(g){a(g.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:d,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:y=>n(y.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:y=>l(y.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 Wm({onComplete:e}){const[t,n]=c.useState(""),[r,l]=c.useState(""),[i,a]=c.useState(""),[o,u]=c.useState(null),[d,y]=c.useState(!1);async function g(m){if(m.preventDefault(),r!==i){u("Passwords do not match");return}if(r.length<8){u("Password must be at least 8 characters");return}u(null),y(!0);try{await mm(t,r),e()}catch(x){u(x.message)}finally{y(!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:g,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:m=>n(m.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:m=>l(m.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:m=>a(m.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:d,children:d?"Creating account…":"Create account"})]})]})})}function Vm({archives:e,archiveId:t,onArchiveChange:n,view:r,onViewChange:l,onCaptureClick:i,collections:a,selectedCollectionUid:o,onCollectionChange:u,isPublicSession:d,onSignInClick:y}){const{currentUser:g,setCurrentUser:m}=c.useContext(Hs)??{},[x,w]=c.useState(!1);async function S(){w(!0),await ym(),m(null),window.location.reload()}const _=a.find(h=>h.slug==="_default_"),p=!d||!!_&&!_.requires_auth,f=a.filter(h=>h.slug!=="_default_").filter(h=>!d||!h.requires_auth);return s.jsxs("header",{className:"topbar",children:[s.jsx("div",{className:"brand",children:"Archivr"}),s.jsxs("div",{className:"switchers",children:[!d&&s.jsx("div",{className:"switcher",children:s.jsx("select",{"aria-label":"Select archive",value:t??"",onChange:h=>n(h.target.value),children:e.map(h=>s.jsx("option",{value:h.id,children:h.label},h.id))})}),f.length>0&&s.jsx("div",{className:"switcher",children:s.jsxs("select",{"aria-label":"Select collection",value:o??"",onChange:h=>u(h.target.value||null),children:[p&&s.jsx("option",{value:"",children:"All entries"}),f.map(h=>s.jsx("option",{value:h.collection_uid,children:h.name},h.collection_uid))]})})]}),d?s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{flex:1}}),s.jsx("button",{className:"logout-btn",onClick:y,children:"Sign in"})]}):s.jsxs(s.Fragment,{children:[s.jsx("nav",{className:"nav","aria-label":"Primary",children:["archive","tags","collections","runs","admin","settings"].map(h=>s.jsx("button",{className:`nav-link${r===h?" is-active":""}`,onClick:()=>l(h),children:h.charAt(0).toUpperCase()+h.slice(1)},h))}),s.jsx("button",{className:"capture-button",onClick:i,children:"Capture"}),g&&s.jsxs("div",{className:"user-menu",children:[s.jsx("span",{className:"user-name",children:g.display_name||g.username}),s.jsx("button",{className:"logout-btn",onClick:S,disabled:x,children:x?"Logging out…":"Log out"})]})]})]})}let hl=1;function ff(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/")||/^[a-z0-9_-]{11}$/i.test(l))}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 Dn(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("playlist/")||l.startsWith("@")||l.startsWith("channel/")||l.startsWith("c/")||l.startsWith("user/")}if(n.startsWith("ytm:"))return n.slice(4).startsWith("playlist/");if(n.startsWith("spotify:")){const r=n.slice(8);return r.startsWith("album:")||r.startsWith("playlist:")}if(n.startsWith("http://")||n.startsWith("https://"))try{const r=new URL(t),l=r.hostname;if((l==="youtube.com"||l==="www.youtube.com")&&(r.pathname==="/playlist"&&r.searchParams.has("list")||r.pathname.startsWith("/@")||r.pathname.startsWith("/channel/")||r.pathname.startsWith("/c/")||r.pathname.startsWith("/user/"))||l==="music.youtube.com"&&r.pathname==="/playlist"&&r.searchParams.has("list")||l==="open.spotify.com"&&(r.pathname.startsWith("/album/")||r.pathname.startsWith("/playlist/")))return!0}catch{}return!1}function Xn(e=""){return{id:hl++,locator:e,quality:"best",probeState:"idle",probeQualities:null,probeHasAudio:!1,status:"idle",error:null,jobUid:null,archiveId:null,playlistProbeState:"idle",playlistInfo:null,playlistItems:null,playlistQuality:null,playlistExpanded:!1,syncEnabled:!1}}function Km(e){return{id:hl++,kind:"file",filename:e,uploadProgress:0,uploadStatus:"uploading",uploadLocator:null,uploadError:null,locator:"",quality:"best",probeState:"idle",probeQualities:null,probeHasAudio:!1,playlistProbeState:"idle",playlistInfo:null,playlistItems:null,playlistQuality:null,playlistExpanded:!1,syncEnabled:!1,error:null,status:"idle"}}function Qm(){return{id:hl++,kind:"text",title:"",body:"",mime:"text/markdown",locator:"",quality:"best",probeState:"idle",probeQualities:null,probeHasAudio:!1,playlistProbeState:"idle",playlistInfo:null,playlistItems:null,playlistQuality:null,playlistExpanded:!1,syncEnabled:!1,error:null,status:"idle"}}function qm(e,t){return e==="best"?t.map(n=>({...n,quality:"best"})):e==="audio"?t.map(n=>n.has_audio?{...n,quality:"audio"}:n.quality!==null?n:{...n,quality:null}):t.map(n=>n.qualities.includes(e)?{...n,quality:e}:n.quality!==null?n:{...n,quality:null})}function Au(e){return Array.isArray(e.playlistItems)&&e.playlistItems.some(t=>t.quality===null)}function Xm({open:e,archiveId:t,onClose:n,onCaptured:r,onToast:l,onJobStarted:i,onJobSettled:a,activeJobs:o=[]}){const u=c.useRef(null),d=c.useRef(!0),y=c.useRef(new Map),g=c.useRef(new Map),m=c.useRef(new Map),x=c.useRef(t);c.useEffect(()=>{x.current=t},[t]);const w=c.useRef(null),[S,_]=c.useState(!1),p=c.useRef([]),f=c.useRef(!1),h=c.useRef(new Map),k=c.useRef(r),E=c.useRef(l);c.useEffect(()=>{k.current=r},[r]),c.useEffect(()=>{E.current=l},[l]);const P=c.useRef(i),N=c.useRef(a);c.useEffect(()=>{P.current=i},[i]),c.useEffect(()=>{N.current=a},[a]);const[v,b]=c.useState(()=>{try{const j=JSON.parse(sessionStorage.getItem("captureItems")||"null");if(Array.isArray(j)&&j.length>0){const B=j.filter(A=>!A.status||A.status==="idle");if(B.length>0)return B.forEach(A=>{A.id>=hl&&(hl=A.id+1)}),B.map(A=>({...Xn(A.locator),...A}))}}catch{}return[Xn()]});c.useEffect(()=>{sessionStorage.setItem("captureItems",JSON.stringify(v.filter(j=>j.kind!=="file")))},[v]),c.useEffect(()=>{p.current=v},[v]);const[L,X]=c.useState(!1),[Q,ne]=c.useState(null),[q,fe]=c.useState(null),[Le,ve]=c.useState(!0),[I,R]=c.useState(!0),[K,ee]=c.useState(!0);c.useEffect(()=>{xo().then(j=>{fe(j),ve(j.cookie_ext_enabled??!0),R(j.modal_closer_enabled??!0)}).catch(()=>fe({}))},[]);const se=Q!==null?Q:(q==null?void 0:q.ublock_enabled)??!0,[ie,Y]=c.useState(!1);c.useEffect(()=>{["captureDialogLocator","captureDialogError","captureDialogBusy","captureDialogJobStatus","captureDialogJobUid"].forEach(j=>sessionStorage.removeItem(j)),o.forEach(j=>{j.jobUid&&!y.current.has(j.jobUid)&&Ne(j.id,j.jobUid,j.locator,j.archiveId,null)})},[]),c.useEffect(()=>{const j=u.current;if(!j)return;const B=()=>{if(g.current.forEach(A=>clearTimeout(A)),g.current.clear(),!f.current){const A=x.current;p.current.forEach(D=>{var F;D.kind==="file"&&(D.uploadStatus==="uploading"?((F=h.current.get(D.id))==null||F(),h.current.delete(D.id)):D.uploadStatus==="done"&&D.uploadLocator&&Ei(A,D.uploadLocator).catch(()=>{}))})}f.current=!1,n()};return j.addEventListener("close",B),()=>j.removeEventListener("close",B)},[n]),c.useEffect(()=>{const j=u.current;j&&(e?(d.current||b([Xn()]),d.current=!1,j.open||j.showModal()):(g.current.forEach(B=>clearTimeout(B)),g.current.clear(),j.open&&j.close()))},[e]),c.useEffect(()=>()=>{y.current.forEach(j=>clearInterval(j)),g.current.forEach(j=>clearTimeout(j))},[]);function Ne(j,B,A,D,F=null){if(y.current.has(B))return;const H=setInterval(async()=>{var ke,he,Re,ye;try{const Fe=await uf(D,B);if(Fe.status==="completed"){clearInterval(y.current.get(B)),y.current.delete(B),await Promise.resolve((ke=k.current)==null?void 0:ke.call(k)),(he=N.current)==null||he.call(N,j);try{const ce=Fe.notes_json?JSON.parse(Fe.notes_json):null;if(ce!=null&&ce.ublock_skipped||ce!=null&&ce.cookie_ext_skipped){const dt=ce.ublock_skipped&&ce.cookie_ext_skipped?"Captured without ad-blocking or cookie-consent extension. Check ARCHIVR_UBLOCK_EXT and ARCHIVR_COOKIE_EXT in your server config.":ce.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.";E.current(dt,A,"warning"),pe(F,"warning",A)}else F||E.current(null,A,"success"),pe(F,"archived")}catch{F||E.current(null,A,"success"),pe(F,"archived")}}else if(Fe.status==="failed"){clearInterval(y.current.get(B)),y.current.delete(B),(Re=N.current)==null||Re.call(N,j);const ce=Fe.error_text||"Capture failed.";E.current(ce,A),pe(F,"failed",A)}}catch(Fe){clearInterval(y.current.get(B)),y.current.delete(B),(ye=N.current)==null||ye.call(N,j);const ce=Fe.message||"Network error";E.current(ce,A),pe(F,"failed",A)}},500);y.current.set(B,H)}function pe(j,B,A=null){if(!j)return;const D=m.current.get(j);if(!D||(B==="archived"||B==="warning"?(D.archived++,B==="warning"&&(D.warnings++,A&&D.warningLocators.push(A))):(D.failed++,A&&D.failedLocators.push(A)),D.archived+D.failed<D.total))return;m.current.delete(j);const{archived:F,warnings:H,failed:ke,failedLocators:he,warningLocators:Re}=D;let ye;if(F===0)ye=`${ke} failed`;else{const dt=H>0?`${F} archived (${H} with warnings)`:`${F} archived`;ye=ke>0?`${dt}, ${ke} failed`:dt}const Fe=F===0?"error":ke>0||H>0?"warning":"success",ce=[];he.length>0&&ce.push(`Failed:
|
||
${he.map(dt=>` ${dt}`).join(`
|
||
`)}`),Re.length>0&&ce.push(`With warnings:
|
||
${Re.map(dt=>` ${dt}`).join(`
|
||
`)}`);const it=ce.length>0?ce.join(`
|
||
`):null;E.current(it,null,Fe,ye)}async function U(j,B){var Re,ye,Fe;const A=x.current,D=((Re=crypto.randomUUID)==null?void 0:Re.call(crypto))??`job-${Date.now()}-${Math.random()}`;if(j.type==="text"){try{const ce=await dm(A,{title:j.title,body:j.body,mime:j.mime}),it=`text:${j.title}`;(ye=P.current)==null||ye.call(P,{id:D,jobUid:ce.job_uid,locator:it,archiveId:A}),Ne(D,ce.job_uid,it,A,B)}catch(ce){const it=ce.message||"Submission failed.";E.current(it,`text:${j.title}`),pe(B,"failed",`text:${j.title}`)}return}const F=j.locator,H=j.quality,ke=j.extraExtensions||{},he={ublock_enabled:se,reader_mode:ie,cookie_ext_enabled:Le,modal_closer_enabled:I,via_freedium:K,...ke};try{const ce=await cm(A,F,H,he);(Fe=P.current)==null||Fe.call(P,{id:D,jobUid:ce.job_uid,locator:F,archiveId:A}),Ne(D,ce.job_uid,F,A,B)}catch(ce){const it=ce.message||"Submission failed.";E.current(it,F),pe(B,"failed",F),F.startsWith("file://")&&ce.status&&Ei(A,F).catch(()=>{})}}function te(){var D,F;if(v.some(H=>H.kind==="file"&&H.uploadStatus==="uploading"))return;const j=v.filter(H=>H.kind==="file"?H.uploadStatus==="done"&&H.uploadLocator:H.kind==="text"?H.title.trim()&&H.body.trim():H.locator.trim());if(j.length===0||j.some(H=>H.kind!=="file"&&H.kind!=="text"&&Au(H))||j.some(H=>H.kind!=="file"&&H.kind!=="text"&&(H.probeState==="probing"||Dn(H.locator)&&H.playlistProbeState!=="done"))||j.some(H=>H.kind!=="file"&&H.kind!=="text"&&Array.isArray(H.playlistItems)&&H.playlistItems.length===0))return;const B=j.length>1?((D=crypto.randomUUID)==null?void 0:D.call(crypto))??`batch-${Date.now()}`:null;B&&m.current.set(B,{total:j.length,archived:0,warnings:0,failed:0,failedLocators:[],warningLocators:[]});const A=j.map(H=>H.kind==="file"?{type:"file",locator:H.uploadLocator,quality:"best",extraExtensions:{}}:H.kind==="text"?{type:"text",title:H.title.trim(),body:H.body,mime:H.mime}:{type:"url",locator:H.locator.trim(),quality:H.playlistItems!==null?null:H.quality||"best",extraExtensions:H.playlistItems!==null?{per_item_quality:Object.fromEntries(H.playlistItems.map(ke=>[ke.id,ke.quality])),sync:H.syncEnabled}:{}});f.current=!0,b([Xn()]),(F=u.current)==null||F.close(),A.forEach(H=>U(H,B))}function re(){b(j=>[...j,Xn()])}function Ue(j){var A;clearTimeout(g.current.get(j)),g.current.delete(j);const B=p.current.find(D=>D.id===j);(B==null?void 0:B.kind)==="file"&&(B.uploadStatus==="uploading"?((A=h.current.get(j))==null||A(),h.current.delete(j)):B.uploadStatus==="done"&&B.uploadLocator&&Ei(x.current,B.uploadLocator).catch(()=>{})),b(D=>{const F=D.filter(H=>H.id!==j);return F.length===0?[Xn()]:F})}function Lt(j,B){if(clearTimeout(g.current.get(j)),b(A=>A.map(D=>D.id===j?{...D,locator:B,probeState:"idle",probeQualities:null,probeHasAudio:!1,quality:"best",playlistProbeState:"idle",playlistInfo:null,playlistItems:null,playlistQuality:null,playlistExpanded:!1}:D)),ff(B)){const A=setTimeout(async()=>{g.current.delete(j),b(D=>D.map(F=>F.id===j?{...F,probeState:"probing"}:F));try{const D=await fm(x.current,B.trim());b(F=>F.map(H=>{if(H.id!==j||H.locator!==B)return H;const ke=D.qualities??[],he=D.has_audio??!1,Re=ke.length===0&&he?"audio":"best";return{...H,probeState:"done",probeQualities:ke,probeHasAudio:he,quality:Re}}))}catch{b(D=>D.map(F=>F.id===j?{...F,probeState:"idle",probeQualities:null}:F))}},600);g.current.set(j,A)}else if(Dn(B)){const A=setTimeout(async()=>{g.current.delete(j),b(D=>D.map(F=>F.id===j?{...F,playlistProbeState:"probing"}:F));try{const D=await pm(x.current,B.trim());b(F=>F.map(H=>H.id!==j||H.locator!==B?H:{...H,playlistProbeState:"done",playlistInfo:D,playlistItems:D.items.map(ke=>({...ke,quality:null})),playlistQuality:null}))}catch{b(D=>D.map(F=>F.id===j?{...F,playlistProbeState:"error"}:F))}},800);g.current.set(j,A)}}function yt(j,B){b(A=>A.map(D=>D.id===j?{...D,quality:B}:D))}function Ie(j,B){b(A=>A.map(D=>{if(D.id!==j)return D;const F=qm(B,D.playlistItems);return{...D,playlistQuality:B,playlistItems:F}}))}function st(j,B,A){b(D=>D.map(F=>F.id!==j?F:{...F,playlistItems:F.playlistItems.map(H=>H.id===B?{...H,quality:A}:H)}))}function Ze(j){b(B=>B.map(A=>A.id===j?{...A,playlistExpanded:!A.playlistExpanded}:A))}function $(j,B){b(A=>A.map(D=>D.id===j?{...D,syncEnabled:B}:D))}function Z(j,B){b(A=>A.map(D=>D.id!==j?D:{...D,playlistItems:D.playlistItems.filter(F=>F.id!==B)}))}function Ae(j){const B=Array.from(j);B.length!==0&&B.forEach(A=>{const D=Km(A.name);b(he=>he.length===1&&!he[0].kind&&!he[0].locator.trim()?[D]:[...he,D]);const F=x.current,{promise:H,abort:ke}=Bm(F,A,he=>{b(Re=>Re.map(ye=>ye.id===D.id?{...ye,uploadProgress:he}:ye))});h.current.set(D.id,ke),H.then(he=>{h.current.delete(D.id),b(Re=>Re.map(ye=>ye.id===D.id?{...ye,uploadStatus:"done",uploadLocator:he.locator,uploadProgress:100}:ye))}).catch(he=>{h.current.delete(D.id),he.message!=="Upload cancelled"&&b(Re=>Re.map(ye=>ye.id===D.id?{...ye,uploadStatus:"error",uploadError:he.message}:ye))})})}function Me(j){j.preventDefault(),j.stopPropagation(),j.dataTransfer.types.includes("Files")&&_(!0)}function Rt(j){j.currentTarget.contains(j.relatedTarget)||_(!1)}function zt(j){j.preventDefault(),j.stopPropagation(),_(!1),Ae(j.dataTransfer.files)}function It(j){Ae(j.target.files),j.target.value=""}const et=v.some(j=>j.kind==="file"&&j.uploadStatus==="uploading"),Xt=v.filter(j=>j.kind==="file"?j.uploadStatus==="done"&&j.uploadLocator:j.kind==="text"?j.title.trim()&&j.body.trim():j.locator.trim()).length,$t=v.some(j=>j.kind!=="file"&&j.kind!=="text"&&Au(j)),an=v.some(j=>j.kind!=="file"&&j.kind!=="text"&&Array.isArray(j.playlistItems)&&j.playlistItems.length===0),He=v.some(j=>j.kind!=="file"&&j.kind!=="text"&&(j.probeState==="probing"||Dn(j.locator)&&j.playlistProbeState!=="done"));return s.jsx("dialog",{ref:u,className:`capture-dialog${S?" capture-dialog--dragover":""}`,onDragOver:Me,onDragLeave:Rt,onDrop:zt,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 j;return(j=u.current)==null?void 0:j.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:v.map((j,B)=>j.kind==="file"?s.jsx(Gm,{item:j,onRemove:()=>Ue(j.id)},j.id):j.kind==="text"?s.jsx(Ym,{item:j,autoFocus:B===v.length-1,onTitleChange:A=>b(D=>D.map(F=>F.id===j.id?{...F,title:A}:F)),onBodyChange:A=>b(D=>D.map(F=>F.id===j.id?{...F,body:A}:F)),onMimeChange:A=>b(D=>D.map(F=>F.id===j.id?{...F,mime:A}:F)),onRemove:()=>Ue(j.id),onSubmit:te},j.id):s.jsx(Jm,{item:j,autoFocus:B===v.length-1,onLocatorChange:A=>Lt(j.id,A),onQualityChange:A=>yt(j.id,A),onRemove:()=>Ue(j.id),onSubmit:te,onPlaylistQualityChange:A=>Ie(j.id,A),onPlaylistItemQualityChange:(A,D)=>st(j.id,A,D),onPlaylistToggle:()=>Ze(j.id),onSyncChange:A=>$(j.id,A),onPlaylistItemDelete:A=>Z(j.id,A)},j.id))}),s.jsx("input",{ref:w,type:"file",multiple:!0,hidden:!0,onChange:It,"aria-hidden":"true",tabIndex:-1}),s.jsxs("div",{className:"capture-add-row-group",children:[s.jsxs("button",{type:"button",className:"capture-add-row",onClick:re,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 URL"]}),s.jsxs("button",{type:"button",className:"capture-add-row capture-add-file",onClick:()=>{var j;return(j=w.current)==null?void 0:j.click()},children:[s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"1",width:"10",height:"14",rx:"1.5"}),s.jsx("line",{x1:"5.5",y1:"5.5",x2:"10.5",y2:"5.5"}),s.jsx("line",{x1:"5.5",y1:"8",x2:"10.5",y2:"8"}),s.jsx("line",{x1:"5.5",y1:"10.5",x2:"8.5",y2:"10.5"})]}),"Upload file"]}),s.jsxs("button",{type:"button",className:"capture-add-row capture-add-text",onClick:()=>b(j=>[...j,Qm()]),children:[s.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M2 3h12M2 7h12M2 11h8"})}),"Add text"]})]}),s.jsxs("div",{className:"capture-advanced",children:[s.jsxs("button",{type:"button",className:"capture-advanced-toggle",onClick:()=>X(j=>!j),"aria-expanded":L,children:[s.jsx("svg",{className:`capture-chevron${L?" 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"]}),L&&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":se,className:`ext-toggle ext-toggle--sm${se?" ext-toggle--on":""}`,onClick:()=>ne(j=>j===null?!se:!j),"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"}),!(q!=null&&q.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":Le,className:`ext-toggle ext-toggle--sm${Le?" ext-toggle--on":""}`,onClick:()=>ve(j=>!j),"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":ie,className:`ext-toggle ext-toggle--sm${ie?" ext-toggle--on":""}`,onClick:()=>Y(j=>!j),"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":I,className:`ext-toggle ext-toggle--sm${I?" ext-toggle--on":""}`,onClick:()=>R(j=>!j),"aria-label":"Toggle modal closer 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:"Freedium mirror"}),s.jsx("span",{className:"capture-ext-desc",children:"Route paywalled articles through a Freedium mirror (Medium, NYT, WaPo, etc.)"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":K,className:`ext-toggle ext-toggle--sm${K?" ext-toggle--on":""}`,onClick:()=>ee(j=>!j),"aria-label":"Toggle Freedium mirror 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:te,disabled:Xt===0||$t||He||an||et,children:Xt>1?`Archive ${Xt}`:"Archive"}),s.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var j;return(j=u.current)==null?void 0:j.close()},children:"Cancel"})]})]})})}function Jm({item:e,autoFocus:t,onLocatorChange:n,onQualityChange:r,onRemove:l,onSubmit:i,onPlaylistQualityChange:a,onPlaylistItemQualityChange:o,onPlaylistToggle:u,onSyncChange:d,onPlaylistItemDelete:y}){const g=c.useRef(null);c.useEffect(()=>{var w;t&&((w=g.current)==null||w.focus())},[t]);const m=(()=>{if(Dn(e.locator)){if(e.playlistProbeState==="probing")return s.jsx("span",{className:"capture-quality-probing","aria-label":"Probing playlist…",children:"…"});if(e.playlistProbeState==="done"){const w=[...new Set(e.playlistItems.flatMap(p=>p.qualities.map(f=>parseInt(f))))].sort((p,f)=>f-p),S=e.playlistItems.every(p=>p.has_audio),_=e.playlistItems.filter(p=>p.quality===null).length;return s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:"capture-quality",value:e.playlistQuality??"",onChange:p=>a(p.target.value),"aria-label":"Playlist quality",children:[!e.playlistQuality&&s.jsx("option",{value:"",disabled:!0,children:"Select quality…"}),s.jsx("option",{value:"best",children:"Best quality"}),w.map(p=>s.jsxs("option",{value:`${p}p`,children:[p,"p"]},p)),S&&s.jsx("option",{value:"audio",children:"Audio only"})]}),_>0&&s.jsxs("span",{className:"capture-conflict-badge",children:[_," need selection"]})]})}return e.playlistProbeState==="error"?s.jsx("span",{className:"capture-quality-hint capture-quality-hint--error",children:"Probe failed — edit URL to retry"}):null}if(!ff(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 w=e.probeQualities??[],S=e.probeHasAudio??!1;return w.length===0&&!S?s.jsx("span",{className:"capture-quality-hint",children:"No media detected"}):w.length===0&&S?s.jsx("select",{className:"capture-quality",value:"audio",onChange:_=>r(_.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:_=>r(_.target.value),"aria-label":"Video quality",children:[s.jsx("option",{value:"best",children:"Best quality"}),w.map(_=>s.jsx("option",{value:_,children:_},_)),S&&s.jsx("option",{value:"audio",children:"Audio only"})]})}return null})(),x=Dn(e.locator)&&e.playlistProbeState==="done"?s.jsxs("label",{className:"capture-sync-row",children:[s.jsx("input",{type:"checkbox",checked:e.syncEnabled,onChange:w=>d(w.target.checked)}),s.jsx("span",{children:"Sync — skip already-archived videos"})]}):null;return s.jsxs("div",{className:"capture-row",children:[s.jsxs("div",{className:"capture-row-main",children:[Dn(e.locator)&&e.playlistProbeState==="done"?s.jsx("button",{type:"button",className:"capture-playlist-toggle capture-playlist-toggle--left",onClick:u,"aria-label":e.playlistExpanded?"Collapse video list":"Expand video list","aria-expanded":e.playlistExpanded,children:e.playlistExpanded?"▲":"▼"}):null,s.jsx("input",{ref:g,className:"capture-input",type:"text",placeholder:"https://… · yt:ID · ytm:ID · tweet:ID · x:ID",value:e.locator,onChange:w=>n(w.target.value),onKeyDown:w=>{w.key==="Enter"&&i()},autoComplete:"off",spellCheck:!1}),m,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}),Dn(e.locator)&&e.playlistProbeState==="done"&&e.playlistExpanded?s.jsxs("div",{className:"capture-playlist-items",children:[e.playlistItems.map(w=>s.jsxs("div",{className:`capture-playlist-item${w.quality===null?" capture-playlist-item--conflict":""}`,children:[s.jsx("span",{className:"capture-playlist-item-title",children:w.title||w.url}),s.jsxs("select",{className:"capture-item-quality",value:w.quality??"",onChange:S=>o(w.id,S.target.value),"aria-label":`Quality for ${w.title||w.url}`,children:[w.quality===null&&s.jsx("option",{value:"",disabled:!0,children:"Choose…"}),s.jsx("option",{value:"best",children:"Best quality"}),w.qualities.map(S=>s.jsx("option",{value:S,children:S},S)),w.has_audio&&s.jsx("option",{value:"audio",children:"Audio only"})]}),w.quality===null&&s.jsx("span",{className:"capture-playlist-conflict-badge",children:"Choose quality"}),s.jsx("button",{type:"button",className:"capture-playlist-item-remove","aria-label":`Remove ${w.title||w.url}`,onClick:()=>y(w.id),children:"×"})]},w.id)),x]}):x]})}function Gm({item:e,onRemove:t}){const n=e.uploadStatus==="uploading",r=e.uploadStatus==="done",l=e.uploadStatus==="error";return s.jsxs("div",{className:"capture-row",children:[s.jsxs("div",{className:"capture-row-main",children:[s.jsx("span",{className:"capture-file-icon","aria-hidden":"true",children:s.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",style:{width:14,height:14},children:[s.jsx("rect",{x:"3",y:"1",width:"10",height:"14",rx:"1.5"}),s.jsx("line",{x1:"5.5",y1:"5.5",x2:"10.5",y2:"5.5"}),s.jsx("line",{x1:"5.5",y1:"8",x2:"10.5",y2:"8"}),s.jsx("line",{x1:"5.5",y1:"10.5",x2:"8.5",y2:"10.5"})]})}),s.jsx("span",{className:`capture-file-name${l?" capture-file-name--error":""}`,children:e.filename}),n&&s.jsxs("span",{className:"capture-file-progress-wrap","aria-label":`Uploading ${e.uploadProgress}%`,children:[s.jsx("span",{className:"capture-file-progress-bar",children:s.jsx("span",{className:"capture-file-progress-fill",style:{width:`${e.uploadProgress}%`}})}),s.jsxs("span",{className:"capture-file-progress-pct",children:[e.uploadProgress,"%"]})]}),r&&s.jsx("span",{className:"capture-file-badge capture-file-badge--done","aria-label":"Upload complete",children:s.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{width:11,height:11},children:s.jsx("polyline",{points:"3 8.5 6.5 12 13 5"})})}),l&&s.jsx("span",{className:"capture-file-badge capture-file-badge--error",children:"!"}),s.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:t,"aria-label":"Remove",disabled:n,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"})]})})]}),l&&s.jsx("p",{className:"capture-row-error",children:e.uploadError||"Upload failed"})]})}function Ym({item:e,autoFocus:t,onTitleChange:n,onBodyChange:r,onMimeChange:l,onRemove:i,onSubmit:a}){const o=c.useRef(null);return c.useEffect(()=>{var u;t&&((u=o.current)==null||u.focus())},[t]),s.jsx("div",{className:"capture-row capture-text-row",children:s.jsxs("div",{className:"capture-row-main",children:[s.jsx("span",{className:"capture-text-icon","aria-hidden":"true",children:s.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",style:{width:14,height:14},children:s.jsx("path",{d:"M2 3h12M2 7h12M2 11h8"})})}),s.jsxs("div",{className:"capture-text-inputs",children:[s.jsx("input",{ref:o,className:"capture-text-input capture-text-title",type:"text",placeholder:"Title",value:e.title,onChange:u=>n(u.target.value),maxLength:500}),s.jsx("textarea",{className:"capture-text-input capture-text-body",placeholder:"Body (markdown or plain text)",value:e.body,onChange:u=>r(u.target.value),rows:6}),s.jsx("div",{className:"capture-text-footer",children:s.jsxs("select",{className:"capture-text-mime",value:e.mime,onChange:u=>l(u.target.value),children:[s.jsx("option",{value:"text/markdown",children:"Markdown"}),s.jsx("option",{value:"text/plain",children:"Plain text"})]})})]}),s.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:i,"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"})]})})]})})}const Zm=["list=","/playlist/","/channel/","yt:playlist:","yt:channel:","ytm:playlist:","spotify:playlist:","spotify:album:"];function eg(e){const t=e.toLowerCase();return Zm.some(n=>t.includes(n))}function tg(e){return e.length>80?`${e.slice(0,79)}…`:e}function ng({locator:e=""}){const t=String(e),n=eg(t);return s.jsxs("div",{className:"in-progress-entry-row",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"cap-spinner in-progress-entry-row__spinner","aria-hidden":"true"}),s.jsx("span",{className:"in-progress-entry-row__locator",title:t,children:tg(t)}),s.jsxs("span",{className:"in-progress-entry-row__status",children:["Archiving…",n&&s.jsx("span",{className:"in-progress-entry-row__kind",children:"(playlist)"})]})]})}function ml(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(r===0?0:1)} ${t[r]}`}function rg(e){return e&&e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}function xt(e){return rg(e)??""}function ko(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 Mu={youtube:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="#FF0000" d="M23.5 6.2a3 3 0 0 0-2.1-2.1C19.5 3.6 12 3.6 12 3.6s-7.5 0-9.4.5A3 3 0 0 0 .5 6.2C0 8.1 0 12 0 12s0 3.9.5 5.8a3 3 0 0 0 2.1 2.1c1.9.5 9.4.5 9.4.5s7.5 0 9.4-.5a3 3 0 0 0 2.1-2.1C24 15.9 24 12 24 12s0-3.9-.5-5.8z"/><polygon fill="#fff" points="9.6,15.6 15.8,12 9.6,8.4"/></svg>',youtube_music:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="12" fill="#FF0000"/><polygon fill="#fff" points="9.6,15.6 15.8,12 9.6,8.4"/></svg>',spotify:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="12" fill="#1DB954"/><path fill="#fff" d="M17.9 10.9c-3.2-1.9-8.5-2.1-11.6-1.1-.5.1-1-.2-1.1-.6-.1-.5.2-1 .6-1.1 3.5-1.1 9.4-.9 13 1.3.4.2.6.8.3 1.2-.2.5-.8.6-1.2.3zm-.1 2.9c-.2.4-.7.5-1.1.3-2.7-1.6-6.7-2.1-9.9-1.1-.4.1-.9-.1-1-.5-.1-.4.1-.9.5-1 3.6-1.1 8-.5 11.1 1.3.4.2.5.7.4 1zm-1.3 2.8c-.2.3-.6.4-.9.2-2.3-1.4-5.2-1.7-8.6-.9-.3.1-.7-.1-.8-.5-.1-.3.1-.7.4-.8 3.7-.9 7-.5 9.6 1 .4.2.5.6.3.9z"/></svg>',x:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M18.2 2h3.3l-7.2 8.2L23 22h-6.6l-5.2-6.8L5 22H1.7l7.7-8.8L1 2h6.8l4.7 6.2zm-1.1 18h1.8L6.9 3.9H5z"/></svg>',instagram:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="ig" x1="0%" y1="100%" x2="100%" y2="0%"><stop offset="0%" stop-color="#f09433"/><stop offset="25%" stop-color="#e6683c"/><stop offset="50%" stop-color="#dc2743"/><stop offset="75%" stop-color="#cc2366"/><stop offset="100%" stop-color="#bc1888"/></linearGradient></defs><rect width="24" height="24" rx="5" fill="url(#ig)"/><rect x="2.5" y="2.5" width="19" height="19" rx="4" fill="none" stroke="#fff" stroke-width="1.5"/><circle cx="12" cy="12" r="4" fill="none" stroke="#fff" stroke-width="1.5"/><circle cx="17.5" cy="6.5" r="1" fill="#fff"/></svg>',facebook:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="24" rx="4" fill="#1877F2"/><path fill="#fff" d="M16 8h-2c-.6 0-1 .4-1 1v2h3l-.4 3H13v8h-3v-8H8v-3h2V9a4 4 0 0 1 4-4h2v3z"/></svg>',tiktok:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M19.6 5.4a4.8 4.8 0 0 1-4.8-4.8h-3v14.7a2 2 0 1 1-2-2l.1-3a5 5 0 1 0 4.9 5V8.4a8 8 0 0 0 4.8 1.6V6.7a4.8 4.8 0 0 1-0-.2l0 0 .1.9z" fill="#000"/><path d="M18.6 4.4a4.8 4.8 0 0 1-4.8-4.8h-3v14.7a2 2 0 1 1-2-2l.1-3a5 5 0 1 0 4.9 5V7.4a8 8 0 0 0 4.8 1.6V5.7" fill="none" stroke="#69C9D0" stroke-width="1.5"/></svg>',reddit:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="12" fill="#FF4500"/><path fill="#fff" d="M20 12a2 2 0 0 0-2-2 2 2 0 0 0-1.3.5c-1.3-.9-3-.9-4.6-.9l.8-3.7 2.6.5a1.4 1.4 0 1 0 1.4-1.3 1.4 1.4 0 0 0-1.3.8l-2.9-.5a.3.3 0 0 0-.4.3l-.9 4.1c-1.6 0-3.1.1-4.3.9A2 2 0 0 0 4 12a2 2 0 0 0 1 1.7 3.3 3.3 0 0 0 0 .5c0 2.6 3 4.8 6.8 4.8s6.8-2.1 6.8-4.8a3.3 3.3 0 0 0 0-.5A2 2 0 0 0 20 12zm-13.6 1a1.1 1.1 0 1 1 1.1 1.1A1.1 1.1 0 0 1 6.4 13zm6.2 3.1a3.5 3.5 0 0 1-2.3.7 3.5 3.5 0 0 1-2.3-.7.3.3 0 0 1 .4-.4 3 3 0 0 0 1.9.5 3 3 0 0 0 1.9-.5.3.3 0 0 1 .4.4zm-.3-2a1.1 1.1 0 1 1 1.1-1.1A1.1 1.1 0 0 1 12.3 14.1z"/></svg>',snapchat:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="24" rx="4" fill="#FFFC00"/><path d="M12 3.5c-2.4 0-4.4 2-4.4 4.4v1.3l-.8.1c-.3 0-.5.2-.5.5s.3.5.6.6c.3.1.5.3.5.8 0 .3-.1.5-.3.7-.6.8-1.5 1.3-2.2 1.4-.1.7.7 1 1.7 1.2.1.6.3.8.8.8.6 0 1.1.4 2.7.4 1.5 0 2.1-.4 2.7-.4.5 0 .7-.2.8-.8 1-.2 1.8-.5 1.7-1.2-.7-.1-1.6-.6-2.2-1.4-.2-.2-.3-.4-.3-.7 0-.5.2-.7.5-.8.3-.1.6-.3.6-.6s-.2-.5-.5-.5l-.8-.1V7.9C16.4 5.5 14.4 3.5 12 3.5z"/></svg>',local:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="#666" stroke-width="1.5" stroke-linejoin="round" d="M4 4h7l2 2h7v14H4z"/></svg>',web:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="none" stroke="#555" stroke-width="1.5"/><ellipse cx="12" cy="12" rx="4" ry="10" fill="none" stroke="#555" stroke-width="1.5"/><line x1="2" y1="9" x2="22" y2="9" stroke="#555" stroke-width="1.5"/><line x1="2" y1="15" x2="22" y2="15" stroke="#555" stroke-width="1.5"/></svg>',other:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="none" stroke="#999" stroke-width="1.5"/><text x="12" y="16" text-anchor="middle" font-size="12" fill="#999">?</text></svg>'};function Us(e){return Mu[e]??Mu.other}function pf(e){return e.split("/").map(t=>t?t.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):"").join("/")}function lg({entry:e,index:t,onRowClick:n,selectedUids:r,isFirst:l,isLast:i,reorderDisabled:a,onMove:o,canReorder:u,isDragging:d,dropEdge:y,onHandleDragStart:g,onHandleDragEnd:m,onRowDragOver:x,onRowDrop:w}){const S=(r==null?void 0:r.size)===1&&r.has(e.entry_uid),_=(r==null?void 0:r.size)>=2&&r.has(e.entry_uid),p=xt(e.title)||xt(e.entry_uid),f=["child-entry-row",t%2===0?"child-entry-row--light":"child-entry-row--dark",S&&"is-selected",_&&"is-multi-selected",d&&"is-dragging",y==="before"&&"is-drop-before",y==="after"&&"is-drop-after"].filter(Boolean).join(" ");return s.jsxs("div",{className:f,tabIndex:0,"data-entry-uid":e.entry_uid,onMouseDown:h=>{h.shiftKey&&h.preventDefault()},onClick:h=>n(e,h),onDragOver:u?x:void 0,onDrop:u?w:void 0,"aria-keyshortcuts":u?"Alt+ArrowUp Alt+ArrowDown":void 0,onKeyDown:h=>{if(u&&h.altKey&&(h.key==="ArrowUp"||h.key==="ArrowDown")){h.preventDefault(),a||o(h.key==="ArrowUp"?-1:1);return}h.key==="Enter"&&n(e,h)},children:[s.jsx("div",{className:"col-check","aria-hidden":"true"}),s.jsx("div",{className:"col-added",children:ko(e.archived_at)}),s.jsxs("div",{className:"col-title",children:[u&&s.jsxs("span",{className:"child-reorder-controls",children:[s.jsx("span",{className:"child-drag-handle",draggable:!a,title:"Drag to reorder (or Alt+↑/↓)","aria-hidden":"true",onClick:h=>h.stopPropagation(),onDragStart:g,onDragEnd:m,children:"⋮⋮"}),s.jsx("button",{type:"button",className:"child-move-btn","aria-label":`Move ${p} up`,disabled:a||l,onClick:h=>{h.stopPropagation(),o(-1)},onKeyDown:h=>h.stopPropagation(),children:"↑"}),s.jsx("button",{type:"button",className:"child-move-btn","aria-label":`Move ${p} down`,disabled:a||i,onClick:h=>{h.stopPropagation(),o(1)},onKeyDown:h=>h.stopPropagation(),children:"↓"})]}),s.jsx("span",{className:"source-icon",children:s.jsx("span",{dangerouslySetInnerHTML:{__html:Us(e.source_kind)}})}),s.jsx("span",{className:"entry-title",children:p})]}),s.jsx("div",{className:"col-type",children:s.jsx("span",{className:"type-pill",children:xt(e.entity_kind)})}),s.jsx("div",{className:"col-size",children:s.jsx("span",{className:"size-total",children:ml(e.total_artifact_bytes)})}),s.jsx("div",{className:"url-cell col-url",children:xt(e.original_url)})]})}function sg({entry:e,archiveId:t,rowIndex:n,isSelected:r,isMultiSelected:l,onRowClick:i,selectedUids:a,deletedUids:o,renamedTitles:u,isPublicSession:d,canReorder:y=!1,onReorderError:g}){const[m,x]=c.useState(!1),[w,S]=c.useState(!1),[_,p]=c.useState(null),[f,h]=c.useState(!1),[k,E]=c.useState(!1),[P,N]=c.useState(null),[v,b]=c.useState(null),L=c.useRef(null),X=c.useRef(null),ne=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!m?s.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>x(!0),style:{objectFit:"contain"}}):s.jsx("span",{dangerouslySetInnerHTML:{__html:Us(e.source_kind)}}),q=r||l,fe=e.child_count>0&&!d;function Le(U){U.stopPropagation(),i(e,{ctrlKey:!0,metaKey:!1,shiftKey:!1,preventDefault(){}})}async function ve(U){if(U.stopPropagation(),w){S(!1);return}if(S(!0),_===null&&!f){h(!0);try{const te=await Iu(t,e.entry_uid);p(te)}catch{p([])}finally{h(!1)}}}const I=(_??[]).filter(U=>!(o!=null&&o.has(U.entry_uid))).map(U=>u!=null&&u.has(U.entry_uid)?{...U,title:u.get(U.entry_uid)}:U);async function R(U){const te=_;p(U),E(!0);try{await tm(t,e.entry_uid,U.map(re=>re.entry_uid))}catch(re){if(p(te),g==null||g(re.message),re.status===400)try{p(await Iu(t,e.entry_uid))}catch{}}finally{E(!1)}}function K(U,te){if(!y||k||U===te||te<0||te>=I.length)return;const re=I.slice(),[Ue]=re.splice(U,1);re.splice(te,0,Ue),R(re)}function ee(U,te){var re;X.current=((re=I[U])==null?void 0:re.entry_uid)??null,K(U,U+te)}c.useEffect(()=>{const U=X.current;if(!U||!L.current)return;X.current=null;const te=L.current.querySelector(`[data-entry-uid="${CSS.escape(U)}"]`);te&&!te.contains(document.activeElement)&&te.focus()},[_]);function se(U,te){te.stopPropagation(),te.dataTransfer.effectAllowed="move",te.dataTransfer.setData("text/plain",U);const re=te.currentTarget.closest(".child-entry-row");re&&te.dataTransfer.setDragImage(re,16,re.offsetHeight/2),N(U)}function ie(){N(null),b(null)}function Y(U,te){if(!P)return;te.preventDefault(),te.dataTransfer.dropEffect="move";const re=te.currentTarget.getBoundingClientRect(),Ue=te.clientY>re.top+re.height/2;((v==null?void 0:v.uid)!==U||(v==null?void 0:v.after)!==Ue)&&b({uid:U,after:Ue})}function Ne(U,te){if(!P)return;te.preventDefault();const re=I.findIndex(Ie=>Ie.entry_uid===P),Ue=I.findIndex(Ie=>Ie.entry_uid===U),Lt=(v==null?void 0:v.uid)===U?v.after:!1;if(ie(),re===-1||Ue===-1)return;let yt=Ue+(Lt?1:0);re<yt&&(yt-=1),K(re,yt)}const pe=["entry-row-outer",n%2===0?"entry-row-outer--light":"entry-row-outer--dark",r&&"is-selected",l&&"is-multi-selected"].filter(Boolean).join(" ");return s.jsxs("div",{className:pe,"data-entry-uid":e.entry_uid,children:[s.jsxs("div",{className:"entry-row-main",tabIndex:0,onMouseDown:U=>{U.shiftKey&&U.preventDefault()},onClick:U=>i(e,U),onKeyDown:U=>{U.key==="Enter"&&i(e,U)},children:[s.jsx("div",{className:"col-check",children:s.jsx("button",{type:"button",className:`row-checkbox${q?" is-checked":""}`,"aria-pressed":q,"aria-label":q?"Deselect entry":"Select entry",onClick:Le,onKeyDown:U=>U.stopPropagation()})}),s.jsx("div",{className:"col-added",children:ko(e.archived_at)}),s.jsxs("div",{className:"col-title",children:[fe&&s.jsx("button",{type:"button",className:`entry-expand-btn${w?" is-expanded":""}`,"aria-label":w?"Collapse children":`Expand ${e.child_count} items`,"aria-expanded":w,onClick:ve,onKeyDown:U=>U.stopPropagation()}),s.jsx("span",{className:"source-icon",children:ne}),s.jsx("span",{className:"entry-title",children:xt(e.title)||xt(e.entry_uid)}),fe&&s.jsx("span",{className:"child-count-badge","aria-hidden":"true",children:e.child_count})]}),s.jsx("div",{className:"col-type",children:s.jsx("span",{className:"type-pill",children:xt(e.entity_kind)})}),s.jsxs("div",{className:"col-size",children:[s.jsx("span",{className:"size-total",children:ml(e.total_artifact_bytes)}),e.cached_bytes>0&&e.cacheable_bytes>0&&s.jsxs("span",{className:"size-cached-pct",title:`${ml(e.cached_bytes)} already on disk from an earlier entry`,children:[Math.round(e.cached_bytes/e.cacheable_bytes*100),"% cached"]})]}),s.jsx("div",{className:"url-cell col-url",children:xt(e.original_url)})]}),w&&s.jsxs(s.Fragment,{children:[f&&s.jsx("div",{className:"child-entries-loading",children:"Loading…"}),s.jsx("div",{className:"child-entries",ref:L,"aria-busy":k,"aria-label":`${e.child_count} child entries`,children:I.map((U,te)=>s.jsx(lg,{entry:U,index:te,onRowClick:i,selectedUids:a,isFirst:te===0,isLast:te===I.length-1,reorderDisabled:k,canReorder:y,onMove:re=>ee(te,re),isDragging:P===U.entry_uid,dropEdge:(v==null?void 0:v.uid)===U.entry_uid&&P!==U.entry_uid?v.after?"after":"before":null,onHandleDragStart:re=>se(U.entry_uid,re),onHandleDragEnd:ie,onRowDragOver:re=>Y(U.entry_uid,re),onRowDrop:re=>Ne(U.entry_uid,re)},U.entry_uid))})]})]})}function ig({entries:e,selectedUids:t,onRowClick:n,archiveId:r,pendingCaptures:l=[],deletedUids:i,renamedTitles:a,isPublicSession:o,canReorder:u=!1,onChildReorderError:d}){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.jsxs("div",{id:"entries-body",children:[l.filter(y=>y.archiveId===r).reverse().map(y=>s.jsx(ng,{locator:y.locator},y.id)),e.map((y,g)=>s.jsx(sg,{entry:y,rowIndex:g,archiveId:r,isSelected:t.size===1&&t.has(y.entry_uid),isMultiSelected:t.size>=2&&t.has(y.entry_uid),onRowClick:n,selectedUids:t,deletedUids:i,renamedTitles:a,isPublicSession:o,canReorder:u,onReorderError:d},y.entry_uid))]})]})})}function ag(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 og({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 ug({runs:e}){const[t,n]=c.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:ag(l.started_at)}),s.jsxs("td",{children:[s.jsx(og,{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 cg=4;function dg({archives:e}){const{currentUser:t}=c.useContext(Hs)??{},n=t&&(t.role_bits&cg)!==0,[r,l]=c.useState("users"),[i,a]=c.useState([]),[o,u]=c.useState([]),[d,y]=c.useState(!1),[g,m]=c.useState(null),[x,w]=c.useState(""),[S,_]=c.useState(""),[p,f]=c.useState(""),[h,k]=c.useState(null),[E,P]=c.useState(!1),[N,v]=c.useState(""),[b,L]=c.useState(""),[X,Q]=c.useState(null),[ne,q]=c.useState(!1),fe=c.useCallback(async()=>{if(n){y(!0),m(null);try{const[R,K]=await Promise.all([_m(),df()]);a(R),u(K)}catch(R){m(R.message)}finally{y(!1)}}},[n]);c.useEffect(()=>{fe()},[fe]);async function Le(R){const K=R.status==="active"?"disabled":"active";try{await Cm(R.user_uid,K),a(ee=>ee.map(se=>se.user_uid===R.user_uid?{...se,status:K}:se))}catch(ee){m(ee.message)}}async function ve(R){if(R.preventDefault(),!x.trim()||!S){k("Username and password required");return}P(!0),k(null);try{await Nm(x.trim(),S,p.trim()||void 0),w(""),_(""),f(""),await fe()}catch(K){k(K.message)}finally{P(!1)}}async function I(R){if(R.preventDefault(),!N.trim()||!b.trim()){Q("Slug and name required");return}q(!0),Q(null);try{await Em(N.trim(),b.trim()),v(""),L(""),await fe()}catch(K){Q(K.message)}finally{q(!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"})]}),g&&s.jsx("div",{className:"form-msg form-msg--err",children:g}),r==="users"&&s.jsxs("div",{className:"admin-section",children:[s.jsx("h2",{children:"Users"}),d?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(R=>s.jsxs("tr",{className:R.status==="disabled"?"admin-row-disabled":"",children:[s.jsx("td",{children:R.username}),s.jsx("td",{className:"muted",children:R.email||"—"}),s.jsx("td",{children:R.role_slugs.join(", ")||"—"}),s.jsx("td",{children:s.jsx("span",{className:`status-badge status-${R.status}`,children:R.status})}),s.jsx("td",{children:s.jsx("button",{className:"admin-action-btn",onClick:()=>Le(R),children:R.status==="active"?"Ban":"Unban"})})]},R.user_uid))})]}),s.jsx("h3",{children:"Create User"}),s.jsxs("form",{className:"admin-form",onSubmit:ve,children:[s.jsx("input",{className:"admin-input",placeholder:"Username",value:x,onChange:R=>w(R.target.value),required:!0}),s.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:S,onChange:R=>_(R.target.value),required:!0}),s.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:p,onChange:R=>f(R.target.value)}),h&&s.jsx("div",{className:"form-msg form-msg--err",children:h}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:E,children:E?"Creating…":"Create User"})]})]}),r==="roles"&&s.jsxs("div",{className:"admin-section",children:[s.jsx("h2",{children:"Roles"}),d?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(R=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:R.slug})}),s.jsx("td",{children:R.name}),s.jsx("td",{children:R.level}),s.jsx("td",{children:R.bit_position}),s.jsx("td",{children:R.is_builtin?"✓":""})]},R.role_uid))})]}),s.jsx("h3",{children:"Create Custom Role"}),s.jsxs("form",{className:"admin-form",onSubmit:I,children:[s.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:N,onChange:R=>v(R.target.value),required:!0}),s.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:b,onChange:R=>L(R.target.value),required:!0}),X&&s.jsx("div",{className:"form-msg form-msg--err",children:X}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:ne,children:ne?"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(R=>s.jsxs("div",{className:"admin-archive",children:[s.jsx("strong",{children:R.label}),s.jsx("div",{className:"muted",children:R.archive_path})]},R.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(R=>s.jsxs("div",{className:"admin-archive",children:[s.jsx("strong",{children:R.label}),s.jsx("div",{className:"muted",children:R.archive_path})]},R.id))})]})}function hf({node:e,onPick:t}){var n;return s.jsxs("li",{children:[s.jsx("button",{className:"tag-picker-node-btn",title:e.tag.full_path,onClick:()=>t(e.tag),children:e.tag.slug}),((n=e.children)==null?void 0:n.length)>0&&s.jsx("div",{className:"tag-children",children:s.jsx("ul",{className:"tag-tree-list",children:e.children.map(r=>s.jsx(hf,{node:r,onPick:t},r.tag.tag_uid))})})]})}function Fu({title:e,tagNodes:t,excludeUid:n,onPick:r,onCancel:l}){c.useEffect(()=>{function o(u){u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),l())}return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[l]);function i(o){return o.filter(u=>u.tag.tag_uid!==n).map(u=>({...u,children:i(u.children)}))}const a=n?i(t):t;return s.jsx("div",{className:"tag-picker-backdrop",onClick:o=>{o.target===o.currentTarget&&l()},children:s.jsxs("div",{className:"tag-picker-modal",role:"dialog","aria-modal":"true",children:[s.jsxs("div",{className:"tag-picker-header",children:[s.jsx("span",{className:"tag-picker-title",children:e}),s.jsx("button",{className:"tag-picker-close",onClick:l,title:"Cancel","aria-label":"Cancel",children:"×"})]}),s.jsxs("div",{className:"tag-picker-body",children:[s.jsx("button",{className:"tag-picker-root-btn",onClick:()=>r(null),title:"Place at root level (no parent)",children:"↑ Root tag (no parent)"}),a.length>0?s.jsx("ul",{className:"tag-tree-list tag-picker-tree",children:a.map(o=>s.jsx(hf,{node:o,onPick:r},o.tag.tag_uid))}):s.jsx("p",{className:"tag-picker-empty",children:"No other tags available."})]})]})})}function mf({parentPath:e,archiveId:t,onDone:n,onCancel:r}){const[l,i]=c.useState(""),a=c.useRef(!1);async function o(){const u=l.trim();if(!u){r();return}const d=e?`${e}/${u}`:`/${u}`;try{await om(t,d),n()}catch(y){alert(y.message||"Create failed"),r()}}return s.jsx("input",{className:"tag-rename-input",autoFocus:!0,placeholder:"tag name",value:l,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&u.currentTarget.blur(),u.key==="Escape"&&(a.current=!0,u.currentTarget.blur())},onBlur:()=>{a.current?(a.current=!1,r()):o()}})}function gf({node:e,archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u,moveSelectMode:d,onMoveSourceSelect:y,pendingCreateParentUid:g,onCreateDone:m,onCreateCancel:x}){var X;const w=n===e.tag.full_path,[S,_]=c.useState(!1),[p,f]=c.useState(""),h=c.useRef(!1);function k(){if(S)return;if(d){y(e);return}const Q=w?null:e.tag.full_path;r(Q),l("archive")}function E(Q){Q.stopPropagation(),!d&&(f(e.tag.slug),_(!0))}async function P(){const Q=p.trim();if(!Q||Q===e.tag.slug){_(!1);return}try{const ne=await im(t,e.tag.tag_uid,Q);i(e.tag.full_path,ne.full_path),o()}catch{}finally{_(!1)}}async function N(Q){var q;Q.stopPropagation();const ne=((q=e.children)==null?void 0:q.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(ne))try{await am(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,moveSelectMode:d,onMoveSourceSelect:y,pendingCreateParentUid:g,onCreateDone:m,onCreateCancel:x},b=g===e.tag.tag_uid,L=((X=e.children)==null?void 0:X.length)>0;return s.jsxs("li",{children:[s.jsxs("div",{className:`tag-node-row${d?" tag-node-row--move-select":""}`,children:[S?s.jsx("input",{className:"tag-rename-input",autoFocus:!0,value:p,onChange:Q=>f(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&Q.currentTarget.blur(),Q.key==="Escape"&&(h.current=!0,Q.currentTarget.blur())},onBlur:()=>{h.current?(h.current=!1,_(!1)):P()}}):s.jsxs("button",{className:`tag-node-btn${w?" is-active":""}${d?" tag-node-btn--move-select":""}`,title:d?`Select "${e.tag.full_path}" to move`:e.tag.full_path,onClick:k,onDoubleClick:d?void 0:E,children:[s.jsx("span",{className:"tag-node-label",children:u?e.tag.name:e.tag.slug}),s.jsx("span",{className:"tag-node-count",children:e.children.length===0?`(${e.entry_count})`:`(${e.entry_count}) (${e.subtree_count} Total)`}),!d&&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",title:"Rename tag",onClick:Q=>{Q.stopPropagation(),E(Q)},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&&!d&&s.jsx("button",{className:"remove tag-node-delete",title:`Delete "${e.tag.full_path}"`,onClick:N,"aria-label":`Delete "${e.tag.full_path}"`,children:"×"})]}),(L||b)&&s.jsx("div",{className:"tag-children",children:s.jsxs("ul",{className:"tag-tree-list",children:[e.children.map(Q=>s.jsx(gf,{node:Q,...v},Q.tag.tag_uid)),b&&s.jsx("li",{children:s.jsx(mf,{parentPath:e.tag.full_path,archiveId:t,onDone:m,onCancel:x})})]})})]})}function fg({archiveId:e,tagNodes:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u}){const[d,y]=c.useState(null),[g,m]=c.useState(null);function x(){y("select-source"),m(null)}function w(){y(null),m(null)}c.useEffect(()=>{if(d!=="select-source")return;function ne(q){q.key==="Escape"&&(q.preventDefault(),q.stopPropagation(),w())}return document.addEventListener("keydown",ne),()=>document.removeEventListener("keydown",ne)},[d]);function S(ne){m(ne),y("select-dest")}async function _(ne){const q=g.tag.full_path,fe=g.tag.tag_uid,Le=(ne==null?void 0:ne.tag_uid)??null;w();try{const ve=await um(e,fe,Le);i(q,ve.full_path),o()}catch(ve){alert(ve.message||"Move failed")}}const[p,f]=c.useState(null),[h,k]=c.useState(void 0);function E(){f("select-parent"),k(void 0)}function P(){f(null),k(void 0)}function N(ne){k(ne??null),f("input")}function v(){f(null),k(void 0),o()}const b=d==="select-source",L=p==="input"?h?h.tag_uid:"__root__":void 0,X={archiveId:e,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:a,onTagsRefresh:o,humanizeTags:u,moveSelectMode:b,onMoveSourceSelect:S,pendingCreateParentUid:L,onCreateDone:v,onCreateCancel:P},Q=L==="__root__";return s.jsxs("section",{id:"tags-view",className:"view is-active",children:[s.jsxs("div",{className:"tag-tree",children:[s.jsx("div",{className:"tag-tree-header",children:b?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tag-tree-title tag-tree-title--move",children:"Select a tag to move"}),s.jsx("button",{className:"tag-tree-action-btn tag-tree-action-btn--cancel",onClick:w,children:"Cancel"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tag-tree-title",children:"Tags"}),n&&s.jsxs("span",{className:"tag-tree-active",title:n,children:["Filtering: ",n]}),s.jsxs("div",{className:"tag-tree-actions",children:[s.jsx("button",{className:"tag-tree-action-btn",onClick:E,title:"Create a new tag",disabled:!!p||!!d,children:"+ New"}),s.jsx("button",{className:"tag-tree-action-btn",onClick:x,title:"Move a tag to a different parent",disabled:!!p||!!d||t.length===0,children:"Move"})]})]})}),t.length===0&&!Q?s.jsx("p",{className:"muted",style:{padding:"8px 0"},children:"No tags yet."}):s.jsxs("ul",{className:"tag-tree-list",children:[t.map(ne=>s.jsx(gf,{node:ne,...X},ne.tag.tag_uid)),Q&&s.jsx("li",{children:s.jsx(mf,{parentPath:null,archiveId:e,onDone:v,onCancel:P})})]})]}),p==="select-parent"&&s.jsx(Fu,{title:"Create tag under…",tagNodes:t,excludeUid:null,onPick:N,onCancel:P}),d==="select-dest"&&g&&s.jsx(Fu,{title:`Move "${g.tag.slug}" under…`,tagNodes:t,excludeUid:g.tag.tag_uid,onPick:_,onCancel:w})]})}const Fr=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],pg=e=>{var t;return((t=Fr.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function hg({archiveId:e}){const[t,n]=c.useState([]),[r,l]=c.useState(!1),[i,a]=c.useState(null),[o,u]=c.useState(null),[d,y]=c.useState(null),[g,m]=c.useState(!1),[x,w]=c.useState(null),[S,_]=c.useState(""),[p,f]=c.useState(""),[h,k]=c.useState(2),[E,P]=c.useState(!1),[N,v]=c.useState(!0),[b,L]=c.useState(null),[X,Q]=c.useState(""),[ne,q]=c.useState(2),[fe,Le]=c.useState(!1),[ve,I]=c.useState(null),[R,K]=c.useState(!1),[ee,se]=c.useState(""),ie=c.useRef(null),Y=t.find($=>$.collection_uid===o)??null,Ne=(Y==null?void 0:Y.slug)==="_default_",pe=c.useCallback(async()=>{if(e){l(!0),a(null);try{const $=await wo(e);n($)}catch($){a($.message)}finally{l(!1)}}},[e]),U=c.useCallback(async $=>{if(!$){y(null);return}m(!0),w(null);try{const Z=await Tm(e,$);y(Z)}catch(Z){w(Z.message)}finally{m(!1)}},[e]);c.useEffect(()=>{pe()},[pe]),c.useEffect(()=>{U(o)},[o,U]),c.useEffect(()=>{R&&ie.current&&ie.current.focus()},[R]),c.useEffect(()=>{d!=null&&q(d.default_visibility_bits)},[d]);async function te($){$.preventDefault();const Z=S.trim(),Ae=p.trim();if(!(!Z||!Ae)){P(!0),L(null);try{const Me=await bm(e,Z,Ae,h,N);_(""),f(""),k(2),v(!0),await pe(),u(Me.collection_uid)}catch(Me){L(Me.message)}finally{P(!1)}}}async function re(){const $=ee.trim();if(!$||!Y){K(!1);return}try{await Ci(e,Y.collection_uid,{name:$}),await pe(),y(Z=>Z&&{...Z,name:$})}catch(Z){a(Z.message)}finally{K(!1)}}async function Ue($){if(Y)try{await Ci(e,Y.collection_uid,{default_visibility_bits:$}),await pe(),y(Z=>Z&&{...Z,default_visibility_bits:$})}catch(Z){a(Z.message)}}async function Lt($){if(Y)try{await Ci(e,Y.collection_uid,{requires_auth:$}),await pe(),y(Z=>Z&&{...Z,requires_auth:$})}catch(Z){a(Z.message)}}async function yt(){if(Y&&window.confirm(`Delete collection "${Y.name}"? Entries will not be deleted.`))try{await Rm(e,Y.collection_uid),u(null),y(null),await pe()}catch($){a($.message)}}async function Ie($){$.preventDefault();const Z=X.trim();if(!(!Z||!Y)){Le(!0),I(null);try{await Sa(e,Y.collection_uid,Z,ne),Q(""),await U(Y.collection_uid)}catch(Ae){I(Ae.message)}finally{Le(!1)}}}async function st($){if(Y)try{await Pm(e,Y.collection_uid,$),await U(Y.collection_uid)}catch(Z){w(Z.message)}}async function Ze($,Z){if(Y)try{await Lm(e,Y.collection_uid,$,Z),y(Ae=>Ae&&{...Ae,entries:Ae.entries.map(Me=>Me.entry_uid===$?{...Me,collection_visibility_bits:Z}:Me)})}catch(Ae){w(Ae.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($=>s.jsxs("button",{className:`coll-sidebar-row${o===$.collection_uid?" is-active":""}`,onClick:()=>u($.collection_uid),children:[s.jsx("span",{className:"coll-row-name",children:$.name}),s.jsx("span",{className:"coll-row-meta",children:pg($.default_visibility_bits)})]},$.collection_uid)),t.length===0&&!r&&s.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),Y?s.jsxs("div",{className:"coll-detail",children:[s.jsxs("div",{className:"coll-detail-header",children:[R?s.jsx("input",{ref:ie,className:"coll-rename-input",value:ee,onChange:$=>se($.target.value),onBlur:re,onKeyDown:$=>{$.key==="Enter"&&re(),$.key==="Escape"&&K(!1)}}):s.jsxs("h3",{className:`coll-detail-name${Ne?"":" coll-detail-name--editable"}`,title:Ne?void 0:"Click to rename",onClick:()=>{Ne||(se(Y.name),K(!0))},children:[(d==null?void 0:d.name)??Y.name,!Ne&&s.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!Ne&&s.jsx("button",{className:"coll-delete-btn",onClick:yt,title:"Delete collection",children:"Delete"})]}),s.jsxs("div",{className:"coll-detail-vis",children:[s.jsx("span",{className:"coll-vis-label",children:"Entries' default visibility"}),s.jsx("select",{className:"coll-vis-select",value:(d==null?void 0:d.default_visibility_bits)??Y.default_visibility_bits,onChange:$=>Ue(Number($.target.value)),children:Fr.map($=>s.jsx("option",{value:$.value,children:$.label},$.value))})]}),s.jsxs("div",{className:"coll-detail-vis",children:[s.jsx("span",{className:"coll-vis-label",children:"Collection access"}),s.jsxs("label",{className:"coll-auth-label",children:[s.jsx("input",{type:"checkbox",checked:!!((d==null?void 0:d.requires_auth)??Y.requires_auth),onChange:$=>Lt($.target.checked)})," Require authentication to view"]})]}),s.jsxs("div",{className:"coll-entries-section",children:[s.jsx("div",{className:"coll-section-heading",children:"Entries"}),g&&s.jsx("div",{className:"muted",children:"Loading…"}),x&&s.jsx("div",{className:"collections-error",children:x}),!g&&d&&(d.entries.length===0?s.jsx("div",{className:"muted",children:"No entries in this collection."}):s.jsx("ul",{className:"coll-entries-list",children:d.entries.map($=>s.jsxs("li",{className:"coll-entry-row",children:[s.jsxs("div",{className:"coll-entry-info",children:[s.jsx("span",{className:"coll-entry-title",children:$.title||$.entry_uid}),s.jsx("span",{className:"coll-entry-kind muted",children:$.source_kind})]}),s.jsxs("div",{className:"coll-entry-actions",children:[s.jsx("select",{className:"coll-entry-vis-select",value:$.collection_visibility_bits,onChange:Z=>Ze($.entry_uid,Number(Z.target.value)),children:Fr.map(Z=>s.jsx("option",{value:Z.value,children:Z.label},Z.value))}),!Ne&&s.jsx("button",{className:"coll-entry-remove",onClick:()=>st($.entry_uid),title:"Remove from collection",children:"×"})]})]},$.entry_uid))}))]}),!Ne&&s.jsxs("form",{className:"coll-add-entry-form",onSubmit:Ie,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:X,onChange:$=>Q($.target.value),placeholder:"entry_uid",required:!0}),s.jsx("select",{className:"coll-vis-select",value:ne,onChange:$=>q(Number($.target.value)),children:Fr.map($=>s.jsx("option",{value:$.value,children:$.label},$.value))}),s.jsx("button",{className:"coll-add-btn",type:"submit",disabled:fe,children:fe?"…":"Add"})]}),ve&&s.jsx("div",{className:"collections-error",style:{marginTop:4},children:ve})]})]}):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:te,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:S,onChange:$=>{_($.target.value),p||f($.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:p,onChange:$=>f($.target.value),placeholder:"my-collection",required:!0})]}),s.jsxs("div",{className:"form-field",children:[s.jsx("label",{className:"form-label",htmlFor:"coll-vis",children:"Entries' default visibility"}),s.jsx("select",{className:"capture-input",id:"coll-vis",style:{height:42},value:h,onChange:$=>k(Number($.target.value)),children:Fr.map($=>s.jsx("option",{value:$.value,children:$.label},$.value))})]}),s.jsx("div",{className:"form-field",children:s.jsxs("label",{className:"form-label",children:[s.jsx("input",{type:"checkbox",checked:N,onChange:$=>v($.target.checked)})," Require authentication to view"]})}),b&&s.jsx("div",{className:"collections-error",children:b}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:E,children:E?"Creating…":"Create collection"})]})]})]}):s.jsx("div",{className:"view-placeholder",children:"Select an archive."})}const mg=4,gg=8;function yg({tab:e,onTabChange:t,archiveId:n}){const{currentUser:r,setCurrentUser:l}=c.useContext(Hs)??{},i=r&&(r.role_bits&mg)!==0,a=!!r&&(r.role_bits&gg)!==0,o=["profile","tokens",...i?["instance","cookies","extensions","storage"]:[]],u={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:o.map(d=>s.jsx("button",{className:`view-tab${e===d?" is-active":""}`,onClick:()=>t(d),children:u[d]},d))}),e==="profile"&&s.jsx(vg,{currentUser:r,setCurrentUser:l}),e==="tokens"&&s.jsx(xg,{}),e==="instance"&&i&&s.jsx(wg,{isOwner:a,setCurrentUser:l}),e==="cookies"&&i&&s.jsx(jg,{}),e==="extensions"&&i&&s.jsx(Sg,{}),e==="storage"&&i&&s.jsx(kg,{archiveId:n})]})}function vg({currentUser:e,setCurrentUser:t}){const[n,r]=c.useState((e==null?void 0:e.display_name)??""),[l,i]=c.useState(!1),[a,o]=c.useState(null),[u,d]=c.useState(""),[y,g]=c.useState(""),[m,x]=c.useState(""),[w,S]=c.useState(!1),[_,p]=c.useState(null);async function f(k){k.preventDefault(),i(!0),o(null);try{await vm(n),t(E=>({...E,display_name:n||null})),o({ok:!0,text:"Saved."})}catch(E){o({ok:!1,text:E.message})}finally{i(!1)}}async function h(k){if(k.preventDefault(),y!==m){p({ok:!1,text:"Passwords do not match."});return}S(!0),p(null);try{await wm(u,y),d(""),g(""),x(""),p({ok:!0,text:"Password changed."})}catch(E){p({ok:!1,text:E.message})}finally{S(!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:f,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:k=>r(k.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 k=>{const E=k.target.checked;try{await xm({humanize_slugs:E}),t(P=>({...P,humanize_slugs:E}))}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:h,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:k=>d(k.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:y,onChange:k=>g(k.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:m,onChange:k=>x(k.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 xg(){const[e,t]=c.useState([]),[n,r]=c.useState(!0),[l,i]=c.useState(null),[a,o]=c.useState(""),[u,d]=c.useState(!1),[y,g]=c.useState(null),m=c.useCallback(async()=>{r(!0),i(null);try{t(await km())}catch(S){i(S.message)}finally{r(!1)}},[]);c.useEffect(()=>{m()},[m]);async function x(S){if(S.preventDefault(),!!a.trim()){d(!0);try{const _=await jm(a.trim());g(_),o(""),m()}catch(_){i(_.message)}finally{d(!1)}}}async function w(S){try{await Sm(S),t(_=>_.filter(p=>p.token_uid!==S))}catch(_){i(_.message)}}return s.jsx("div",{style:{maxWidth:600},children:s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"API Tokens"}),y&&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:y.raw_token}),s.jsx("button",{className:"token-dismiss",onClick:()=>g(null),children:"Dismiss"})]}),s.jsxs("form",{className:"token-create-row",onSubmit:x,children:[s.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:a,onChange:S=>o(S.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(S=>s.jsxs("div",{className:"token-row",children:[s.jsxs("div",{className:"token-row-info",children:[s.jsx("strong",{children:S.name}),s.jsxs("div",{className:"muted",children:["Created ",S.created_at.slice(0,10),S.last_used_at&&` · Last used ${S.last_used_at.slice(0,10)}`]})]}),s.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>w(S.token_uid),children:"Revoke"})]},S.token_uid))]})]})})}function wg({isOwner:e,setCurrentUser:t}){const[n,r]=c.useState(null),[l,i]=c.useState(!0),[a,o]=c.useState(null),[u,d]=c.useState(!1),[y,g]=c.useState(null),[m,x]=c.useState([]),[w,S]=c.useState(12),[_,p]=c.useState(!1),[f,h]=c.useState(null);c.useEffect(()=>{(async()=>{try{const[N,v]=await Promise.all([xo(),df()]);r(N),x(v.filter(b=>b.bit_position>0)),S(N.reorder_children_role_bits??12)}catch(N){o(N.message)}finally{i(!1)}})()},[]);function k(N,v){S(b=>v?(b|N)>>>0:(b&~N)>>>0)}async function E(N){N.preventDefault(),p(!0),h(null);try{await Jr({reorder_children_role_bits:w}),r(b=>({...b,reorder_children_role_bits:w}));const v=await cf();v&&(t==null||t(v)),h({ok:!0,text:"Saved."})}catch(v){h({ok:!1,text:v.message})}finally{p(!1)}}async function P(N){N.preventDefault(),d(!0),g(null);try{const{reorder_children_role_bits:v,...b}=n;await Jr(b),g({ok:!0,text:"Saved."})}catch(v){g({ok:!1,text:v.message})}finally{d(!1)}}return l?s.jsx("div",{className:"muted",children:"Loading…"}):a?s.jsx("div",{className:"form-msg form-msg--err",children:a}):n?s.jsxs("div",{style:{maxWidth:440},children:[s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Instance Settings"}),s.jsxs("form",{onSubmit:P,children:[[["public_index_enabled","Public index (unauthenticated browsing)"],["public_entry_content_enabled","Public entry content"],["open_registration_enabled","Open registration"]].map(([N,v])=>s.jsxs("label",{className:"checkbox-row",children:[s.jsx("input",{type:"checkbox",checked:!!n[N],onChange:b=>r(L=>({...L,[N]:b.target.checked}))}),v]},N)),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:n.default_entry_visibility,onChange:N=>r(v=>({...v,default_entry_visibility:Number(N.target.value)})),children:[s.jsx("option",{value:0,children:"Private"}),s.jsx("option",{value:2,children:"Unlisted"}),s.jsx("option",{value:3,children:"Public"})]})]}),y&&s.jsx("div",{className:`form-msg form-msg--${y.ok?"ok":"err"}`,children:y.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:u,children:u?"Saving…":"Save Settings"})]})]}),s.jsxs("div",{className:"form-section",children:[s.jsx("h2",{children:"Permissions"}),s.jsxs("form",{onSubmit:E,children:[s.jsx("label",{className:"form-label",children:"Reorder child entries"}),m.map(N=>{const v=1<<N.bit_position>>>0;return s.jsxs("label",{className:"checkbox-row",children:[s.jsx("input",{type:"checkbox",disabled:!e||_,checked:(w&v)!==0,onChange:b=>k(v,b.target.checked)}),N.name,!N.is_builtin&&s.jsx("span",{className:"muted",children:" (custom)"})]},N.role_uid)}),s.jsx("p",{className:"form-hint",children:"Roles are cumulative: every signed-in account also has User, and owners also have Admin. Checking User lets every signed-in account reorder."}),!e&&s.jsx("p",{className:"form-hint",children:"Only the owner can change this."}),f&&s.jsx("div",{className:`form-msg form-msg--${f.ok?"ok":"err"}`,children:f.text}),e&&s.jsx("button",{className:"btn-primary",type:"submit",disabled:_,children:_?"Saving…":"Save Permissions"})]})]})]}):null}function bi(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 kg({archiveId:e}){const[t,n]=c.useState("idle"),[r,l]=c.useState(null),[i,a]=c.useState(null),[o,u]=c.useState(null);function d(){n("idle"),l(null),a(null),u(null)}async function y(){n("scanning"),u(null),l(null);try{const x=await zm(e);l(x),n("scanned")}catch(x){u(x.message),n("error")}}async function g(){n("deleting"),u(null);try{const x=await Im(e);a(x),n("done")}catch(x){u(x.message),n("error")}}const m=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:y,children:"Scan for orphaned blobs"}),t==="scanning"&&s.jsx("div",{className:"muted",children:"Scanning…"}),t==="scanned"&&r&&m&&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:d,children:"Done"})]}),t==="scanned"&&r&&!m&&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:bi(r.total_bytes)})," recoverable."]}),s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsxs("button",{className:"btn-danger",onClick:g,children:["Delete (",bi(r.total_bytes),")"]}),s.jsx("button",{className:"btn-ghost",onClick:d,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:bi(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:d,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:d,children:"Try again"})]})]})})}function jg(){const[e,t]=c.useState(null),[n,r]=c.useState(!0),[l,i]=c.useState(null),[a,o]=c.useState("global"),[u,d]=c.useState(""),[y,g]=c.useState("{}"),[m,x]=c.useState(null),[w,S]=c.useState(!1),[_,p]=c.useState({});c.useEffect(()=>{f()},[]);async function f(){r(!0),i(null);try{t(await Om())}catch(v){i(v.message)}finally{r(!1)}}async function h(v){v.preventDefault();try{JSON.parse(y)}catch{x({ok:!1,text:'cookies must be valid JSON, e.g. {"session": "abc"}'});return}S(!0),x(null);try{await Am(a==="global"?null:u.trim(),a,y),d(""),g("{}"),o("global"),x({ok:!0,text:"Rule added."}),await f()}catch(b){x({ok:!1,text:b.message})}finally{S(!1)}}async function k(v){try{await Fm(v),await f()}catch(b){i(b.message)}}function E(v){p(b=>({...b,[v.rule_uid]:{cookiesInput:v.cookies_json,saving:!1,msg:null}}))}function P(v){p(b=>{const L={...b};return delete L[v],L})}async function N(v){const b=_[v.rule_uid];try{JSON.parse(b.cookiesInput)}catch{p(L=>({...L,[v.rule_uid]:{...L[v.rule_uid],msg:{ok:!1,text:"Invalid JSON"}}}));return}p(L=>({...L,[v.rule_uid]:{...L[v.rule_uid],saving:!0,msg:null}}));try{await Mm(v.rule_uid,{cookies_json:b.cookiesInput}),P(v.rule_uid),await f()}catch(L){p(X=>({...X,[v.rule_uid]:{...X[v.rule_uid],saving:!1,msg:{ok:!1,text:L.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(v=>{const b=_[v.rule_uid],L=v.url_pattern?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"muted",children:[v.pattern_kind,":"]})," ",s.jsx("code",{children:v.url_pattern})]}):s.jsx("span",{className:"muted",children:"global (all URLs)"});return s.jsxs("tr",{children:[s.jsx("td",{children:L}),s.jsx("td",{children:b?s.jsxs(s.Fragment,{children:[s.jsx("textarea",{className:"field-input",style:{fontFamily:"monospace",fontSize:12,width:"100%",minHeight:60},value:b.cookiesInput,onChange:X=>p(Q=>({...Q,[v.rule_uid]:{...Q[v.rule_uid],cookiesInput:X.target.value}}))}),b.msg&&s.jsx("div",{className:`form-msg form-msg--${b.msg.ok?"ok":"err"}`,children:b.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:b.saving,onClick:()=>N(v),children:b.saving?"Saving…":"Save"}),s.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>P(v.rule_uid),children:"Cancel"})]})]}):s.jsx("code",{style:{fontSize:12,wordBreak:"break-all"},children:v.cookies_json})}),s.jsx("td",{children:!b&&s.jsxs("div",{style:{display:"flex",gap:6},children:[s.jsx("button",{className:"btn-secondary",style:{fontSize:12,padding:"2px 8px"},onClick:()=>E(v),children:"Edit"}),s.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"2px 8px"},onClick:()=>k(v.rule_uid),children:"Del"})]})})]},v.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:h,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:v=>o(v.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:v=>d(v.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:y,onChange:v=>g(v.target.value),placeholder:'{"SESSION": "abc123", "token": "xyz"}',required:!0})]}),m&&s.jsx("div",{className:`form-msg form-msg--${m.ok?"ok":"err"}`,children:m.text}),s.jsx("button",{className:"btn-primary",type:"submit",disabled:w,children:w?"Adding…":"Add Rule"})]})]})})}function Sg(){const[e,t]=c.useState(null),[n,r]=c.useState(!0),[l,i]=c.useState(!1),[a,o]=c.useState(null);c.useEffect(()=>{(async()=>{try{t(await xo())}catch(_){o({ok:!1,text:_.message})}finally{r(!1)}})()},[]);async function u(_){i(!0),o(null);try{await Jr({ublock_enabled:_}),t(p=>({...p,ublock_enabled:_})),o({ok:!0,text:"Saved."})}catch(p){o({ok:!1,text:p.message})}finally{i(!1)}}async function d(_){i(!0),o(null);try{await Jr({cookie_ext_enabled:_}),t(p=>({...p,cookie_ext_enabled:_})),o({ok:!0,text:"Saved."})}catch(p){o({ok:!1,text:p.message})}finally{i(!1)}}async function y(_){i(!0),o(null);try{await Jr({modal_closer_enabled:_}),t(p=>({...p,modal_closer_enabled:_})),o({ok:!0,text:"Saved."})}catch(p){o({ok:!1,text:p.message})}finally{i(!1)}}if(n)return s.jsx("div",{className:"muted",children:"Loading\\u2026"});const g=(e==null?void 0:e.ublock_ext_available)??!1,m=(e==null?void 0:e.ublock_enabled)??!0,x=(e==null?void 0:e.cookie_ext_available)??!1,w=(e==null?void 0:e.cookie_ext_enabled)??!0,S=(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)."}),!g&&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":m,className:`ext-toggle${m?" ext-toggle--on":""}`,onClick:()=>u(!m),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."}),!x&&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:()=>d(!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":S,className:`ext-toggle${S?" ext-toggle--on":""}`,onClick:()=>y(!S),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 Bu={0:"Private",1:"Public",2:"Users only",3:"Public"},es=[{value:"anthropic_http",label:"Anthropic API"},{value:"openai_compatible",label:"OpenAI-compatible API"},{value:"claude_cli",label:"Claude CLI"},{value:"codex_cli",label:"Codex CLI"}],_g=Object.fromEntries(es.map(e=>[e.value,e.label])),Uu="archivr:summary:provider",Ng=1500,yf="This entry can’t be summarized yet.",vf="It doesn’t contain archived text that a summary provider can read. Summaries currently support text notes, web pages, X posts and threads, and X Articles. Video, audio, and image-only entries need a transcript or text source.",Hu=`${yf}
|
||
|
||
${vf}`;function Cg(e){if(!e)return null;try{const t=JSON.parse(e);if(t&&typeof t=="object")return{tldr:typeof t.tldr=="string"?t.tldr:"",summary:typeof t.summary=="string"?t.summary:"",tags:Array.isArray(t.tags)?t.tags.filter(n=>typeof n=="string"):[]}}catch{}return{tldr:"",summary:e,tags:[]}}const Eg=()=>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 bg({archiveId:e,selectedEntry:t,selectedUids:n,selectedEntries:r,detail:l,onTagFilterSet:i,tagNodes:a,onTagsRefresh:o,onEntryTitleChange:u,onEntryDeleted:d,onBulkDeleted:y,humanizeTags:g,onDetailRefresh:m,onOpenPreview:x,onPlay:w,isPublicSession:S}){var Ee,We,je;const[_,p]=c.useState([]),[f,h]=c.useState(""),[k,E]=c.useState([]),[P,N]=c.useState(""),v=c.useRef(0),b=c.useRef(!1),[L,X]=c.useState(!1),[Q,ne]=c.useState(""),[q,fe]=c.useState("idle"),[Le,ve]=c.useState(""),I=c.useRef(null),[R,K]=c.useState(!1);c.useEffect(()=>{K(!1)},[(Ee=l==null?void 0:l.summary)==null?void 0:Ee.entry_uid]);const[ee,se]=c.useState(null),[ie,Y]=c.useState(null),[Ne,pe]=c.useState(""),[U,te]=c.useState(!1),[re,Ue]=c.useState(()=>{try{return sessionStorage.getItem(Uu)||es[0].value}catch{return es[0].value}}),[Lt,yt]=c.useState(!1),Ie=c.useRef(null),st=c.useRef(null),Ze=c.useRef(null),$=c.useRef(null),Z=e&&(t!=null&&t.entry_uid)?`${e}:${t.entry_uid}`:null;$.current=Z;const Ae=(n==null?void 0:n.size)>=2,[Me,Rt]=c.useState(""),[zt,It]=c.useState("idle"),[et,Xt]=c.useState(""),[$t,an]=c.useState([]),[He,j]=c.useState(""),[B,A]=c.useState("idle"),[D,F]=c.useState(""),[H,ke]=c.useState("idle"),[he,Re]=c.useState(""),[ye,Fe]=c.useState("idle"),[ce,it]=c.useState("");c.useEffect(()=>{const T=++v.current;if(I.current&&(clearInterval(I.current),I.current=null),fe("idle"),ve(""),!t||!e){p([]),E([]);return}if(S){p([]),E([]);return}X(!1),ne(""),b.current=!1,p([]),Promise.all([Fl(e,t.entry_uid),Ou(e,t.entry_uid)]).then(([J,ae])=>{T===v.current&&(p(J),E(ae))}).catch(()=>{})},[t,e,S]),c.useEffect(()=>()=>{clearInterval(I.current)},[]),c.useLayoutEffect(()=>{var J,ae,me;clearInterval(Ie.current),Ie.current=null,(J=st.current)==null||J.abort(),st.current=null,(ae=Ze.current)==null||ae.abort(),Ze.current=null;const T=(t==null?void 0:t.entry_uid)!=null&&((me=l==null?void 0:l.summary)==null?void 0:me.entry_uid)===(t==null?void 0:t.entry_uid);se(T?l.latest_summary??null:null),Y(T?l.summary_attempt??null:null),pe(""),te(!1),yt(!1)},[e,t==null?void 0:t.entry_uid,(We=l==null?void 0:l.summary)==null?void 0:We.entry_uid]);const dt=ie==null?void 0:ie.status;c.useEffect(()=>{var on;if(clearInterval(Ie.current),Ie.current=null,dt!=="pending"&&dt!=="running"||!e||!((on=l==null?void 0:l.summary)!=null&&on.entry_uid))return;const T=l.summary.entry_uid,J=`${e}:${T}`;if(Z!==J)return;const ae=new AbortController;st.current=ae;const $e=setInterval(async()=>{var xe;try{const un=await Yh(e,T,{signal:ae.signal});if(ae.signal.aborted||$.current!==J)return;se(un.summary??null),Y(un.attempt??null);const Ys=(xe=un.attempt)==null?void 0:xe.status;Ys!=="pending"&&Ys!=="running"&&(clearInterval($e),Ie.current===$e&&(Ie.current=null),te(!1),Ys==="completed"&&$.current===J&&(m==null||m()))}catch{if(ae.signal.aborted||$.current!==J)return}},Ng);return Ie.current=$e,()=>{clearInterval($e),Ie.current===$e&&(Ie.current=null),ae.abort(),st.current===ae&&(st.current=null)}},[dt,e,t==null?void 0:t.entry_uid,(je=l==null?void 0:l.summary)==null?void 0:je.entry_uid,Z]),c.useEffect(()=>()=>{var T,J;clearInterval(Ie.current),(T=st.current)==null||T.abort(),(J=Ze.current)==null||J.abort()},[]);async function Nr(T=!1){var $e,on;if(!e||!(($e=l==null?void 0:l.summary)!=null&&$e.entry_uid)||U)return;const J=l.summary.entry_uid,ae=`${e}:${J}`;if($.current!==ae)return;const me=new AbortController;(on=Ze.current)==null||on.abort(),Ze.current=me,te(!0),pe("");try{const xe=await Zh(e,J,{provider:re,force:T,includeImages:Lt,signal:me.signal});if(me.signal.aborted||$.current!==ae)return;xe.status==="completed"?(se(xe),Y(null),te(!1),$.current===ae&&(m==null||m())):Y({...xe??{},status:"pending"})}catch(xe){if(me.signal.aborted||$.current!==ae)return;pe(xe.message||"Summary request failed"),te(!1)}finally{Ze.current===me&&(Ze.current=null)}}function Ws(T){Ue(T),T==="claude_cli"&&yt(!1);try{sessionStorage.setItem(Uu,T)}catch{}}c.useEffect(()=>{if(!e){an([]);return}wo(e).then(an).catch(()=>an([]))},[e]),c.useEffect(()=>{Rt(""),It("idle"),Xt(""),j(""),A("idle"),F(""),ke("idle"),Re(""),Fe("idle"),it("")},[n]);async function Vs(){const T=n.size;if(!window.confirm(`Delete ${T} entr${T===1?"y":"ies"}? This cannot be undone.`))return;ke("running");const J=new Set;for(const ae of n)try{await Du(e,ae),J.add(ae)}catch{}ke("idle"),y==null||y(J)}async function kl(){const T=Me.trim();if(T){It("running"),Xt("");try{for(const J of n)await $u(e,J,T);Rt(""),It("done"),o==null||o(),setTimeout(()=>It("idle"),1800)}catch(J){Xt(J.message),It("error")}}}async function Ks(){if(!He)return;A("running"),F("");const T=[],J=$t.find(ae=>ae.collection_uid===He);for(const ae of n)try{await Sa(e,He,ae,(J==null?void 0:J.default_visibility_bits)??2)}catch{T.push(ae)}T.length>0?(F(`Failed for ${T.length} entr${T.length===1?"y":"ies"}.`),A("error")):(A("done"),setTimeout(()=>A("idle"),1800))}async function Qs(){if(!he||!t)return;Fe("running"),it("");const T=$t.find(J=>J.collection_uid===he);try{await Sa(e,he,t.entry_uid,(T==null?void 0:T.default_visibility_bits)??2),Fe("done"),Re("");const J=await Ou(e,t.entry_uid);E(J),setTimeout(()=>Fe("idle"),1800)}catch(J){it(J.message),Fe("error")}}async function Kn(){const T=Q.trim()||null;try{await lm(e,t.entry_uid,T),u==null||u(t.entry_uid,T)}catch{}finally{X(!1)}}async function Qn(){const T=f.trim();if(!(!T||!t))try{await $u(e,t.entry_uid,T),h(""),N("");const J=await Fl(e,t.entry_uid);p(J),o()}catch(J){N(J.message)}}async function Pn(T){try{await sm(e,t.entry_uid,T);const J=await Fl(e,t.entry_uid);p(J),o()}catch{}}async function jl(){if(!(!t||!e)&&window.confirm("Delete this entry? This cannot be undone."))try{await Du(e,t.entry_uid),d==null||d(t.entry_uid)}catch{}}async function qs(){if(!t||!e||q==="running")return;const T=v.current,J=t.entry_uid;fe("running"),ve("");try{const{job_uid:ae}=await $m(e,J);if(v.current!==T)return;I.current=setInterval(async()=>{try{const me=await uf(e,ae);if(me.status==="completed"){if(clearInterval(I.current),I.current=null,v.current!==T)return;fe("done");const $e=await Fl(e,J);if(v.current!==T)return;p($e),m==null||m()}else if(me.status==="failed"){if(clearInterval(I.current),I.current=null,v.current!==T)return;fe("error"),ve(me.error_text||"Re-archive failed.")}}catch{if(clearInterval(I.current),I.current=null,v.current!==T)return;fe("error"),ve("Network error while polling.")}},500)}catch(ae){if(v.current!==T)return;fe("error"),ve(ae.message||"Failed to start re-archive.")}}const Xs=l?[["Added",ko(l.summary.archived_at)],["Source",l.summary.source_kind],["Type",l.summary.entity_kind],["Visibility",Bu[l.summary.visibility]??l.summary.visibility],["Root",l.structured_root_relpath]]:[],Js=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),Gs=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv","pdf","html","htm","md","markdown","txt","jpg","jpeg","png","gif","webp","avif","svg","bmp"]),C=l?l.artifacts.findIndex(T=>T.artifact_role==="primary_media"):-1,z=C>=0?l.artifacts[C]:null,M=z?z.relpath.split(".").pop().toLowerCase():"",W=z&&Js.has(M),G=C>=0&&t?`/api/archives/${e}/entries/${t.entry_uid}/artifacts/${C}`:null,ue=l&&!W&&(l.summary.entity_kind==="tweet"||l.summary.entity_kind==="tweet_thread"||z&&Gs.has(M));return s.jsxs("aside",{className:"context-rail",children:[s.jsx("div",{className:"rail-eyebrow",children:"Context"}),Ae?S?s.jsxs("p",{className:"bulk-count",children:[s.jsx("span",{className:"bulk-count-num",children:n.size})," entries selected"]}):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"}),et&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:et}),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:Me,onChange:T=>Rt(T.target.value),onKeyDown:T=>{T.key==="Enter"&&kl()}}),s.jsx("button",{className:"tag-add-btn",onClick:kl,disabled:zt==="running"||!Me.trim(),children:zt==="running"?"…":zt==="done"?"✓":"Add"})]})]}),$t.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:He,onChange:T=>j(T.target.value),children:[s.jsx("option",{value:"",children:"Pick a collection…"}),$t.filter(T=>T.slug!=="_default_").map(T=>s.jsx("option",{value:T.collection_uid,children:T.name},T.collection_uid))]}),s.jsx("button",{className:"tag-add-btn",onClick:Ks,disabled:!He||B==="running",children:B==="running"?"…":B==="done"?"✓":B==="error"?"!":"Add"})]}),D&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"6px 0 0"},children:D})]}),s.jsx("div",{className:"rail-delete-zone",children:s.jsx("button",{className:"rail-delete-btn",onClick:Vs,disabled:H==="running",children:H==="running"?"Deleting…":`Delete ${n.size} entr${n.size===1?"y":"ies"}`})})]}):t?l?s.jsxs(s.Fragment,{children:[S?s.jsx("h2",{className:"rail-title",children:xt(l.summary.title)||xt(l.summary.entry_uid)}):L?s.jsx("input",{className:"rail-title-input",autoFocus:!0,value:Q,onChange:T=>ne(T.target.value),onKeyDown:T=>{T.key==="Enter"&&T.currentTarget.blur(),T.key==="Escape"&&(b.current=!0,T.currentTarget.blur())},onBlur:()=>{b.current?X(!1):Kn(),b.current=!1}}):s.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{ne(l.summary.title??""),X(!0)},children:[xt(l.summary.title)||xt(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:Us(l.summary.source_kind)}}),s.jsx("span",{className:"u-text",children:l.summary.original_url}),s.jsx("span",{className:"ext",children:s.jsx(Eg,{})})]}),W&&w&&s.jsx("button",{className:"rail-preview-btn",onClick:()=>w(G,t),children:"▶ Play"}),ue&&x&&s.jsx("button",{className:"rail-preview-btn",onClick:x,children:"Preview"}),(()=>{const T=(ee==null?void 0:ee.status)==="completed"?Cg(ee.summary_text):null,J=(ie==null?void 0:ie.status)==="pending"||(ie==null?void 0:ie.status)==="running",ae=(ie==null?void 0:ie.status)==="failed"&&ie.error_text===Hu||Ne===Hu;return S&&!T?null:s.jsxs("div",{className:"rail-section rail-summary",children:[s.jsx("div",{className:"rail-section-heading",children:"Summary"}),T&&s.jsxs("div",{className:"rail-summary-body",children:[T.tldr&&s.jsx("p",{className:"rail-summary-tldr",children:T.tldr}),T.summary&&s.jsx("p",{className:"rail-summary-text",children:T.summary}),T.tags.length>0&&s.jsx("div",{className:"rail-summary-tags",children:T.tags.map(me=>s.jsx("span",{className:"rail-summary-tag",children:me},me))}),s.jsxs("p",{className:"rail-summary-provider",children:[_g[ee.provider_kind]||ee.provider_kind,ee.resolved_model||ee.provider_model?` · ${ee.resolved_model||ee.provider_model}`:""]})]}),J&&s.jsxs("p",{className:"rail-summary-status",children:[s.jsx("span",{className:"rail-summary-spinner","aria-hidden":"true"}),"Generating…"]}),ae&&!S&&s.jsxs("div",{className:"rail-summary-info",role:"status",children:[s.jsx("p",{className:"rail-summary-info__heading",children:yf}),s.jsx("p",{className:"rail-summary-info__detail",children:vf})]}),(ie==null?void 0:ie.status)==="failed"&&ie.error_text&&!ae&&!S&&s.jsx("p",{className:"form-msg form-msg--err rail-summary-error",children:ie.error_text}),Ne&&!ae&&s.jsx("p",{className:"form-msg form-msg--err rail-summary-error",children:Ne}),!S&&!J&&s.jsxs("div",{className:"rail-summary-controls",children:[s.jsx("select",{className:"rail-summary-select",value:re,onChange:me=>Ws(me.target.value),"aria-label":"Summary provider",children:es.map(me=>s.jsx("option",{value:me.value,children:me.label},me.value))}),s.jsxs("div",{className:`rail-summary-image-option${re==="claude_cli"?" rail-summary-image-option--disabled":""}`,children:[s.jsxs("label",{className:"rail-summary-image-option__label",children:[s.jsx("input",{type:"checkbox",checked:Lt,disabled:re==="claude_cli",onChange:me=>yt(me.target.checked)}),"Include attached images"]}),s.jsx("p",{className:"rail-summary-image-option__note",children:re==="claude_cli"?"Claude CLI cannot attach local images. Choose an HTTP provider or Codex CLI.":"Selected archived images are sent to the chosen provider. Up to 4 supported images (5 MiB each, 12 MiB total) can be attached; unsupported or oversized artifacts are skipped."})]}),s.jsx("button",{className:"rail-rearchive-btn",onClick:()=>Nr(!!T),disabled:U,children:U?"…":T?"Regenerate":"Generate"})]})]})})(),s.jsx("div",{className:"meta-list",children:Xs.filter(([,T])=>T!=null&&T!=="").map(([T,J])=>s.jsxs("div",{className:"meta-item",children:[s.jsx("span",{className:"meta-k",children:T}),s.jsx("span",{className:`meta-v${T==="Root"?" mono":""}`,children:xt(J)})]},T))}),l.artifacts.length>0&&(()=>{const T=l.artifacts.map((xe,un)=>({...xe,_idx:un})),J=T.filter(xe=>xe.artifact_role==="font"),ae=T.filter(xe=>xe.artifact_role!=="font"),me=J.reduce((xe,un)=>xe+(un.byte_size||0),0),$e=l.summary.entry_uid,on=xe=>s.jsx("li",{children:s.jsxs("a",{href:`/api/archives/${e}/entries/${$e}/artifacts/${xe._idx}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[s.jsx("span",{className:"artifact-name",children:xe.artifact_role==="font"?xe.relpath.split("/").pop():xe.artifact_role.replace(/_/g," ")}),s.jsx("span",{className:"artifact-size",children:xe.byte_size!=null?ml(xe.byte_size):"—"})]})},xe._idx);return 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.jsxs("ul",{className:"artifact-list",children:[ae.map(on),J.length>0&&s.jsxs("li",{className:"artifact-group",children:[s.jsxs("button",{type:"button",className:"artifact-group-header artifact-link","aria-expanded":R,onClick:()=>K(xe=>!xe),children:[s.jsxs("span",{className:"artifact-name",children:[s.jsx("span",{"aria-hidden":"true",className:`artifact-group-chevron${R?" open":""}`,children:"›"}),` fonts (${J.length})`]}),s.jsx("span",{className:"artifact-size",children:ml(me)})]}),R&&s.jsx("ul",{className:"artifact-list artifact-group-body",children:J.map(on)})]})]})]})})()]}):s.jsx("p",{className:"tags-empty",children:"Loading\\u2026"}):s.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&!Ae&&!S&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Tags"}),_.length===0?s.jsx("p",{className:"tags-empty",children:"No tags yet."}):s.jsx("div",{className:"tags-wrap",children:_.map(T=>s.jsxs("span",{className:"tag-pill",title:T.full_path,children:[g?pf(T.full_path):T.full_path,s.jsx("button",{className:"remove",title:`Remove tag ${T.full_path}`,onClick:()=>Pn(T.tag_uid),children:"×"})]},T.tag_uid))}),P&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:P}),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:f,onChange:T=>h(T.target.value),onKeyDown:T=>{T.key==="Enter"&&Qn()}}),s.jsx("button",{className:"tag-add-btn",onClick:Qn,children:"Add"})]})]}),(k.length>0||$t.filter(T=>T.slug!=="_default_").length>0)&&s.jsxs("div",{className:"rail-section",children:[s.jsx("div",{className:"rail-section-heading",children:"Collections"}),k.map(T=>s.jsxs("div",{className:"coll-row",children:[s.jsx("span",{className:"coll-name",children:T.name}),s.jsx("span",{className:"vis-badge",children:Bu[T.visibility_bits]??`bits:${T.visibility_bits}`})]},T.collection_uid)),$t.filter(T=>T.slug!=="_default_").length>0&&s.jsxs("div",{className:"bulk-coll-row",style:{marginTop:8},children:[s.jsxs("select",{className:"bulk-coll-select",value:he,onChange:T=>Re(T.target.value),children:[s.jsx("option",{value:"",children:"Add to collection…"}),$t.filter(T=>T.slug!=="_default_").map(T=>s.jsx("option",{value:T.collection_uid,children:T.name},T.collection_uid))]}),s.jsx("button",{className:"tag-add-btn",onClick:Qs,disabled:!he||ye==="running",children:ye==="running"?"…":ye==="done"?"✓":ye==="error"?"!":"Add"})]}),ce&&s.jsx("p",{className:"form-msg form-msg--err",style:{margin:"4px 0 0"},children:ce})]}),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:qs,disabled:q==="running",children:q==="running"?"Re-archiving…":"Re-archive"}),q==="done"&&s.jsx("p",{className:"form-msg form-msg--ok",style:{marginTop:"6px"},children:"Re-archived successfully."}),q==="error"&&s.jsx("p",{className:"form-msg form-msg--err",style:{marginTop:"6px"},children:Le})]}),s.jsx("div",{className:"rail-delete-zone",children:s.jsx("button",{className:"rail-delete-btn",onClick:jl,children:"Delete entry"})})]})]})}const Tg=/\/api\/archives\/([^/]+)\/entries\/([^/]+)\/artifacts\/(\d+)/;function Pg(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M5 17H3a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h18a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2"}),s.jsx("polygon",{points:"12 15 17 21 7 21 12 15"})]})}function Lg({src:e,contentType:t="video/mp4"}){const n=c.useRef(null),[r,l]=c.useState(null),[i,a]=c.useState(!1),[o,u]=c.useState(!1);c.useEffect(()=>{if(!e){l(null);return}const g=e.match(Tg);if(!g){l(e);return}let m=!1;return l(null),Dm(g[1],g[2],parseInt(g[3],10)).then(({url:x})=>{m||l(x)}).catch(()=>{m||l(e)}),()=>{m=!0}},[e]),c.useEffect(()=>{n.current&&n.current.load()},[r]),c.useEffect(()=>{u(typeof HTMLVideoElement<"u"&&"webkitShowPlaybackTargetPicker"in HTMLVideoElement.prototype)},[]),c.useEffect(()=>{var m;const g=x=>{if(x)try{cast.framework.CastContext.getInstance().setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a(!0)}catch{}};if((m=window.cast)!=null&&m.framework)g(!0);else if(window.__onGCastApiAvailable=g,!document.querySelector('script[src*="cast_sender"]')){const x=document.createElement("script");x.src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1",document.head.appendChild(x)}},[]),c.useEffect(()=>{if(!i||!r)return;const g=cast.framework.CastContext.getInstance(),{CastContextEventType:m,SessionState:x}=cast.framework,w=_=>{if(!_)return;const p=new chrome.cast.media.MediaInfo(window.location.origin+r,t);_.loadMedia(new chrome.cast.media.LoadRequest(p)).catch(()=>{})};w(g.getCurrentSession());const S=_=>{(_.sessionState===x.SESSION_STARTED||_.sessionState===x.SESSION_RESUMED)&&w(g.getCurrentSession())};return g.addEventListener(m.SESSION_STATE_CHANGED,S),()=>g.removeEventListener(m.SESSION_STATE_CHANGED,S)},[i,r,t]);const d=()=>{var g,m;(m=(g=n.current)==null?void 0:g.webkitShowPlaybackTargetPicker)==null||m.call(g)},y=i||o;return s.jsx("div",{className:"preview-video-wrap",style:{position:"relative"},children:e?s.jsxs(s.Fragment,{children:[r?s.jsxs("video",{ref:n,controls:!0,autoPlay:!1,playsInline:!0,"x-webkit-airplay":"allow",style:{width:"100%",maxHeight:"100%",display:"block"},children:[s.jsx("source",{src:r}),"Your browser does not support the video element."]}):s.jsx("div",{className:"video-tv-loading","aria-label":"Loading video…"}),y&&r&&s.jsxs("div",{className:"video-tv-controls",children:[o&&s.jsx("button",{className:"video-tv-btn",title:"AirPlay to device","aria-label":"AirPlay to device",onClick:d,children:s.jsx(Pg,{})}),i&&s.jsx("google-cast-launcher",{className:"video-tv-btn",title:"Cast to TV"})]})]}):s.jsx("span",{style:{color:"var(--muted)",fontFamily:"var(--sans)",fontSize:"0.9rem"},children:"No video available"})})}function Wu({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 Rg({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 xf(e){return e?new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(e*1e3)):""}function Vu(e){return!e||!e.includes("&")?e:e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}const le={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"}},Ve={bg:"#000000",border:"#2f3336",text:"#e7e9ea",dim:"#71767b",accent:"#1d9bf0",codeBg:"#16181c"},Ti={article:{background:Ve.bg,color:Ve.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:Ve.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:Ve.border,flexShrink:0},aAuthorName:{fontSize:"15px",fontWeight:"700",color:Ve.text,lineHeight:"1.3"},aAuthorSub:{fontSize:"15px",color:Ve.dim,lineHeight:"1.3"},aDivider:{border:"none",borderTop:`1px solid ${Ve.border}`,margin:"0"},aBody:{padding:"4px 16px 0"},bH1:{fontSize:"26px",fontWeight:"800",letterSpacing:"-0.4px",color:Ve.text,lineHeight:"36px",margin:"24px 0 10px"},bH2:{fontSize:"26px",fontWeight:"800",letterSpacing:"-0.4px",color:Ve.text,lineHeight:"36px",margin:"24px 0 10px"},bP:{fontSize:"17px",color:Ve.text,lineHeight:"1.5",marginBottom:"16px",marginTop:"0"},bSpacer:{height:"6px",display:"block"},bQuote:{borderLeft:`3px solid ${Ve.border}`,padding:"2px 14px",margin:"14px 0",color:Ve.dim,fontSize:"17px",lineHeight:"1.5"},bHr:{border:"none",borderTop:`1px solid ${Ve.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:Ve.text,lineHeight:"1.5",marginBottom:"6px"},bTweet:{display:"flex",alignItems:"center",gap:"12px",border:`1px solid ${Ve.border}`,borderRadius:"12px",padding:"14px 16px",margin:"14px 0",color:Ve.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:Ve.text,background:"transparent"},iCode:{fontFamily:"ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace",fontSize:"0.875em",background:Ve.codeBg,padding:"2px 6px",borderRadius:"4px",color:"#e6edf3"},link:{color:Ve.accent,textDecoration:"none"}};function zg(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 hr(e,t,n){return e&&n[e]?n[e]:t||null}function wf(){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 jo(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 kf(e,t){const n=e.expanded_url||e.url||e.text||"",r=e.display_url||e.expanded_url||e.url||e.text||"",l=jo(e,t,e.url,e.text,e.display_url,e.expanded_url);return!l||!n?null:{...l,kind:"url",href:n,display:r}}function jf(e,t){const n=e.screen_name||e.name||e.text||"",r=n?`@${n}`:null,l=jo(e,t,r);return!l||!n?null:{...l,kind:"mention",screen_name:n}}const Ku=/https?:\/\/[^\s<>"'\])]+/g,Ig=/[.,;:!?)()]+$/;function Ns(e,t){const n=[];let r=0,l;for(Ku.lastIndex=0;(l=Ku.exec(e))!==null;){l.index>r&&n.push(e.slice(r,l.index));let i=l[0].replace(Ig,"");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:(r<e.length&&n.push(e.slice(r)),n)}function $g(e,t,n=[]){if(!e)return null;const r=[...(t.urls||[]).map(o=>kf(o,e)).filter(Boolean),...(t.user_mentions||[]).map(o=>jf(o,e)).filter(Boolean)];if(r.length===0&&n.length===0)return Ns(Vu(e),le.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(([d,y])=>d<=o&&y>=u),a=[...l].sort((o,u)=>o-u);return a.slice(0,-1).map((o,u)=>{const d=a[u+1];if(i(o,d))return null;const y=e.slice(o,d),g=r.filter(w=>w.s<=o&&w.e>=d),m=g.find(w=>w.kind==="url");if(m)return s.jsx("a",{href:m.href,target:"_blank",rel:"noopener noreferrer",style:le.link,children:m.display||y},u);const x=g.find(w=>w.kind==="mention");return x?s.jsx("a",{href:`https://x.com/${x.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:le.link,children:y},u):s.jsx("span",{children:Ns(Vu(y),le.link)},u)}).filter(o=>o!==null)}function Dg(e,t,n,r,l=le){if(!e)return null;t=t||[],n=n||[],r=r||[];const i=[];for(const u of t)u.length>0&&i.push({s:u.offset,e:u.offset+u.length,kind:"style",style:u.style});for(const u of n){const d=kf(u,e);d&&i.push(d)}for(const u of r){const d=jf(u,e);d&&i.push(d)}if(i.length===0)return Ns(e,l.link);const a=new Set([0,e.length]);for(const u of i)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,d)=>u-d);return o.slice(0,-1).map((u,d)=>{const y=o[d+1],g=i.filter(_=>_.s<=u&&_.e>=y),m=e.slice(u,y);let x;if(m.includes(`
|
||
`)){const _=m.split(`
|
||
`);x=_.flatMap((p,f)=>f<_.length-1?[p,s.jsx("br",{},f)]:[p])}else x=m;g.some(_=>_.kind==="style"&&_.style==="Code")&&(x=s.jsx("code",{style:l.iCode,children:x})),g.some(_=>_.kind==="style"&&_.style==="Bold")&&(x=s.jsx("strong",{children:x})),g.some(_=>_.kind==="style"&&_.style==="Italic")&&(x=s.jsx("em",{children:x})),g.some(_=>_.kind==="style"&&_.style==="Underline")&&(x=s.jsx("u",{children:x})),g.some(_=>_.kind==="style"&&_.style==="Strikethrough")&&(x=s.jsx("s",{children:x}));const w=g.find(_=>_.kind==="url");if(w){const _=/^https?:\/\/t\.co\//i.test(x);x=s.jsx("a",{href:w.href,target:"_blank",rel:"noopener noreferrer",style:l.link,children:_?w.display:x})}const S=g.find(_=>_.kind==="mention");return S&&(x=s.jsx("a",{href:`https://x.com/${S.screen_name}`,target:"_blank",rel:"noopener noreferrer",style:l.link,children:x})),s.jsx("span",{children:typeof x=="string"?Ns(x,l.link):x},d)})}function Og(e,t,n){const r=(n==null?void 0:n.st)||le,l=e.resolved_entities||[];return l.length===0?null:l.map((i,a)=>{var o;switch(i.type){case"divider":return s.jsx("hr",{style:r.bHr},a);case"media":{const u=hr(i.local_path,i.url,t);return u?s.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:d=>{var y;!d.metaKey&&!d.ctrlKey&&(d.preventDefault(),(y=n==null?void 0:n.onImgClick)==null||y.call(n,u))},children:s.jsx("img",{src:u,style:r.bImg,loading:"lazy",alt:""})},a):null}case"tweet":return i.tweet_id?s.jsxs("a",{href:`https://x.com/i/status/${i.tweet_id}`,target:"_blank",rel:"noopener noreferrer",style:r.bTweet,children:[s.jsx(wf,{}),"View post on X"]},a):null;case"link":return i.url?s.jsx("p",{style:r.bP,children:s.jsx("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",style:r.link,children:i.url})},a):null;case"markdown":{const u=i.markdown??((o=i.data)==null?void 0:o.markdown)??"";return s.jsx("pre",{style:r.bMdPre,children:s.jsx("code",{style:r.bMdCode,children:u})},a)}case"emoji":return i.url?s.jsx("img",{src:i.url,alt:"",style:{height:"1.2em",verticalAlign:"middle",margin:"0 1px"}},a):null;default:return null}})}function Pi(e,t,n,r){const l=(r==null?void 0:r.st)||le,i=e.type||"",a=e.text||"",o=e.inline_style_ranges||[],u=e.data||{},d=Dg(a,o,u.urls||[],u.mentions||[],l);switch(i){case"header-one":return s.jsx("h1",{style:l.bH1,children:d},t);case"header-two":{const y=a.match(/(?:x\.com|twitter\.com)\/i\/status\/(\d+)/);return y?s.jsxs("a",{href:`https://x.com/i/status/${y[1]}`,target:"_blank",rel:"noopener noreferrer",style:l.bTweet,children:[s.jsx(wf,{}),"View post on X"]},t):s.jsx("h2",{style:l.bH2,children:d},t)}case"unstyled":return a.trim()?s.jsx("p",{style:l.bP,children:d},t):s.jsx("span",{style:l.bSpacer},t);case"blockquote":return s.jsx("blockquote",{style:l.bQuote,children:d},t);case"unordered-list-item":case"ordered-list-item":return s.jsx("li",{style:l.bLi,children:d},t);case"atomic":return s.jsx("span",{children:Og(e,n,r)},t);default:return a?s.jsx("p",{style:l.bP,children:d},t):null}}function Ag(e,t,n){const r=(n==null?void 0:n.st)||le,l=[];let i=0;for(;i<e.length;){const a=e[i];if(a.type==="unordered-list-item"){const o=i,u=[];for(;i<e.length&&e[i].type==="unordered-list-item";)u.push(Pi(e[i],i,t,n)),i++;l.push(s.jsx("ul",{style:r.bUl,children:u},`ul-${o}`))}else if(a.type==="ordered-list-item"){const o=i,u=[];for(;i<e.length&&e[i].type==="ordered-list-item";)u.push(Pi(e[i],i,t,n)),i++;l.push(s.jsx("ol",{style:r.bOl,children:u},`ol-${o}`))}else l.push(Pi(a,i,t,n)),i++}return l}function Mg({article:e,tweetAuthor:t,artifactMap:n,fullPage:r,onXArticle:l}){const[i,a]=c.useState(null);c.useEffect(()=>{r&&(l==null||l(!0))},[r,l]);const o=r?Ti:le,u=e.cover_media||{},d=e.author||t||{},y=e.first_published_at_secs?xf(e.first_published_at_secs):"",m=[d.screen_name?`@${d.screen_name}`:"",y].filter(Boolean).join(" · "),x=hr(u.local_path,u.url,n),w=hr(d.avatar_local_path,d.avatar_url,n),S=s.jsxs(s.Fragment,{children:[i&&s.jsx(Sf,{items:[{src:i,alt:""}],startIndex:0,onClose:()=>a(null)}),x&&s.jsx("a",{href:x,target:"_blank",rel:"noopener noreferrer",style:{display:"block",cursor:"zoom-in"},onClick:_=>{!_.metaKey&&!_.ctrlKey&&(_.preventDefault(),a(x))},children:s.jsx("img",{src:x,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:[w?s.jsx("img",{src:w,style:o.aAvatar,alt:d.name||""}):s.jsx("div",{style:o.aAvatarPh}),s.jsxs("div",{children:[s.jsx("div",{style:o.aAuthorName,children:d.name||d.screen_name||"Unknown"}),m&&s.jsx("div",{style:o.aAuthorSub,children:m})]})]})]}),s.jsx("hr",{style:o.aDivider}),s.jsx("div",{style:o.aBody,children:Ag(e.blocks||[],n,{onImgClick:a,st:o})})]});return r?s.jsx("div",{style:Ti.article,children:s.jsx("div",{style:Ti.articleInner,children:S})}):s.jsx("div",{style:le.article,children:S})}function Fg({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:le.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 Sf({items:e,startIndex:t,onClose:n}){const[r,l]=c.useState(t);c.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:le.lightboxBackdrop,onClick:n,children:s.jsxs("div",{style:le.lightboxContent,onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{style:le.lightboxToolbar,children:[e.length>1&&s.jsxs("span",{style:le.lightboxCounter,children:[r+1," / ",e.length]}),s.jsx("a",{href:i.src,target:"_blank",rel:"noopener noreferrer",style:le.lightboxLink,title:"Open in new tab",children:"↗"}),s.jsx("button",{style:le.lightboxBtn,onClick:n,"aria-label":"Close",children:"×"})]}),s.jsx("img",{src:i.src,alt:i.alt||"",style:le.lightboxImg}),e.length>1&&s.jsxs("div",{style:le.lightboxNav,children:[s.jsx("button",{style:le.lightboxNavBtn,onClick:()=>l(a=>Math.max(a-1,0)),disabled:r===0,children:"‹"}),s.jsx("button",{style:le.lightboxNavBtn,onClick:()=>l(a=>Math.min(a+1,e.length-1)),disabled:r===e.length-1,children:"›"})]})]})})}function Qu({tweet:e,isInThread:t,isLast:n,artifactMap:r}){var f,h;const[l,i]=c.useState(null),a=e.author||{},o=e.created_at_secs?xf(e.created_at_secs):"",u=e.entities||{},d=hr(a.avatar_local_path,a.avatar_url,r),y=t&&!n,g=e.is_quote_status===!0,m=t?le.tweetRowThread:le.tweetRow,x=e.full_text||"",w=((h=(f=e.extended_entities)==null?void 0:f.media)!=null&&h.length?e.extended_entities.media:u.media)||[],S=[],_=[];for(const k of w)if(k.type==="photo"){const E=hr(k.local_path,k.media_url_https,r);E&&S.push({kind:"photo",src:E,alt:k.alt_text||""})}else if(k.type==="video"||k.type==="animated_gif"){const E=k.local_path&&r[k.local_path]||(()=>{var N,v;return(v=(((N=k.video_info)==null?void 0:N.variants)||[]).filter(b=>b.content_type==="video/mp4").sort((b,L)=>(L.bitrate||0)-(b.bitrate||0))[0])==null?void 0:v.url})();E&&_.push({kind:k.type==="animated_gif"?"gif":"video",src:E})}const p=[];for(const k of w){if(!k.url||!(k.type==="photo"?S.some(N=>N.src===hr(k.local_path,k.media_url_https,r)):_.length>0))continue;const P=jo(k,x,k.url);P&&p.push([P.s,P.e])}return s.jsxs(s.Fragment,{children:[l!==null&&s.jsx(Sf,{items:S,startIndex:l,onClose:()=>i(null)}),s.jsxs("div",{style:m,children:[s.jsxs("div",{style:le.leftCol,children:[d?s.jsx("img",{src:d,style:le.avatar,alt:a.name||""}):s.jsx("div",{style:le.avatarPh}),y&&s.jsx("div",{style:le.threadLine})]}),s.jsxs("div",{style:le.rightCol,children:[s.jsxs("div",{style:le.authorRow,children:[s.jsx("span",{style:le.authorName,children:a.name||a.screen_name||"Unknown"}),a.screen_name&&s.jsxs("span",{style:le.authorHandle,children:["@",a.screen_name]}),o&&s.jsxs("span",{style:le.datePart,children:["· ",o]}),g&&s.jsx("span",{style:le.qtBadge,title:"Quote tweet",children:"↻ QT"})]}),s.jsx("div",{style:le.tweetText,children:$g(x,u,p)}),S.length>0&&s.jsx("div",{style:le.mediaGrid,children:s.jsx(Fg,{photos:S,onOpen:k=>i(k)})}),_.map((k,E)=>s.jsx("div",{style:le.mediaGrid,children:s.jsx("video",{src:k.src,style:le.mediaVideo,controls:!0,loop:k.kind==="gif",muted:k.kind==="gif",autoPlay:k.kind==="gif"})},E)),(e.retweet_count>0||e.favorite_count>0)&&s.jsxs("div",{style:le.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 Bg({archiveId:e,entryUid:t,artifacts:n,entityKind:r,fullPage:l,onXArticle:i}){const[a,o]=c.useState(!0),[u,d]=c.useState(null),[y,g]=c.useState([]);if(c.useEffect(()=>{if(o(!0),d(null),g([]),!n||!e||!t){o(!1);return}const w=n.map((_,p)=>({..._,index:p})).filter(_=>_.artifact_role==="raw_tweet_json");if(w.length===0){d("No tweet data found."),o(!1);return}let S=!1;return nm(e,t,w.map(_=>_.index)).then(async _=>{if(S)return;const p=/https?:\/\/t\.co\/[A-Za-z0-9]+/g,f=N=>{var b;const v=N.full_text||"";return(((b=N.entities)==null?void 0:b.urls)||[]).map(L=>{var X;if(L.fromIndex!=null&&L.toIndex!=null)return[L.fromIndex,L.toIndex];if(((X=L.indices)==null?void 0:X.length)===2)return[L.indices[0],L.indices[1]];if(L.url){const Q=v.indexOf(L.url);if(Q!==-1)return[Q,Q+L.url.length]}return null}).filter(Boolean)},h=(N,v,b)=>N.some(([L,X])=>L<=v&&X>=b),k=new Set;for(const N of _){const v=N.full_text||"",b=f(N);let L;for(p.lastIndex=0;(L=p.exec(v))!==null;)h(b,L.index,L.index+L[0].length)||k.add(L[0])}const E=k.size>0?await rm([...k]).catch(()=>({})):{},P=_.map(N=>{var Q;const v=N.full_text||"",b=f(N),L=[];let X;for(p.lastIndex=0;(X=p.exec(v))!==null;){const ne=X[0],q=E[ne];q&&q!==ne&&!h(b,X.index,X.index+ne.length)&&L.push({url:ne,expanded_url:q,display_url:(()=>{try{const fe=new URL(q);return fe.hostname+(fe.pathname.length>1?"/…":"")}catch{return q}})(),fromIndex:X.index,toIndex:X.index+ne.length})}return L.length===0?N:{...N,entities:{...N.entities||{},urls:[...((Q=N.entities)==null?void 0:Q.urls)||[],...L]}}});S||g(P)}).catch(_=>{S||d(_.message||"Failed to load tweet.")}).finally(()=>{S||o(!1)}),()=>{S=!0}},[e,t,n]),a)return s.jsx("div",{style:le.loading,children:"Loading…"});if(u)return s.jsxs("div",{style:le.error,children:["Error: ",u]});if(y.length===0)return null;const m=zg(e,t,n);if(r==="tweet_thread")return s.jsx("div",{style:le.threadOuter,children:y.map((w,S)=>s.jsx(Qu,{tweet:w,isInThread:!0,isLast:S===y.length-1,artifactMap:m},w.id||S))});const x=y[0];return x.is_article&&x.article?s.jsx(Mg,{article:x.article,tweetAuthor:x.author,artifactMap:m,fullPage:l,onXArticle:i}):s.jsx("div",{style:le.card,children:s.jsx(Qu,{tweet:x,isInThread:!1,isLast:!0,artifactMap:m})})}function Ug({src:e,mime:t,title:n}){const[r,l]=c.useState(null),[i,a]=c.useState(null);return c.useEffect(()=>{const o=new AbortController;return l(null),a(null),em(e,{signal:o.signal}).then(l).catch(u=>{u.name!=="AbortError"&&a(u.message||String(u))}),()=>o.abort()},[e]),i?s.jsxs("div",{className:"text-preview text-preview--error",children:["Failed to load text: ",i]}):r===null?s.jsx("div",{className:"text-preview text-preview--loading",children:"Loading…"}):s.jsxs("div",{className:"text-preview",children:[n&&s.jsx("h1",{className:"text-preview__title",children:n}),s.jsx("pre",{className:"text-preview__body",children:r}),t&&s.jsx("div",{className:"text-preview__mime",children:t})]})}const Hg=new Set(["mp4","webm","mov","mkv","avi","m4v","ogv"]),Wg=new Set(["mp3","ogg","m4a","opus","wav","flac","aac"]),Vg=new Set(["jpg","jpeg","png","gif","webp","avif","svg","bmp"]),Kg=new Set(["md","markdown","txt"]),Qg={mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",mkv:"video/x-matroska",avi:"video/x-msvideo",m4v:"video/mp4",ogv:"video/ogg"};function _f({archiveId:e,entry:t,detail:n,fullPage:r,onXArticle:l}){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:i,artifacts:a}=n,o=i.entry_uid,u=i.entity_kind;if(u==="tweet"||u==="tweet_thread"){const x=s.jsx(Bg,{archiveId:e,entryUid:o,artifacts:a,entityKind:u,fullPage:r,onXArticle:l});return r?x:s.jsx("div",{className:"preview-tweet-wrap",children:x})}const d=a.findIndex(x=>x.artifact_role==="primary_media");if(d===-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"}),a.length>0&&s.jsx("ul",{style:{marginTop:"12px",paddingLeft:"20px",fontSize:"0.8rem",color:"var(--muted-2)",fontFamily:"var(--sans)"},children:a.map((x,w)=>s.jsxs("li",{children:[x.artifact_role,": ",x.relpath]},w))})]});const y=a[d],g=`/api/archives/${e}/entries/${o}/artifacts/${d}`,m=y.relpath.split(".").pop().toLowerCase();return Hg.has(m)?s.jsx("div",{className:"preview-panel",children:s.jsx(Lg,{src:g,contentType:Qg[m]||"video/mp4"})}):Wg.has(m)?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:i.title||o}),s.jsx("audio",{src:g,controls:!0,style:{marginTop:"8px",width:"100%",maxWidth:"400px"}})]}):m==="pdf"?s.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:s.jsx(Wu,{src:g,type:"pdf",title:i.title,originalUrl:i.original_url})}):m==="html"||m==="htm"?s.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0},children:s.jsx(Wu,{src:g,type:"page",title:i.title,originalUrl:i.original_url})}):Kg.has(m)?s.jsx("div",{className:"preview-panel",style:{flex:1,minHeight:0,overflow:"auto"},children:s.jsx(Ug,{src:g,mime:y.mime_type,title:i.title})}):Vg.has(m)?s.jsx("div",{className:"preview-panel",style:{height:"100%"},children:s.jsx(Rg,{src:g,alt:i.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:a.map((x,w)=>s.jsxs("li",{children:[x.artifact_role,": ",x.relpath]},w))})]})}function qg({archiveId:e,entry:t,detail:n,onClose:r}){var l,i;return c.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(_f,{archiveId:e,entry:t,detail:n})})]})})}function qu(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 Xg({entry:e,src:t,archiveId:n,onClose:r}){const l=c.useRef(null),[i,a]=c.useState(!1),[o,u]=c.useState(0),[d,y]=c.useState(NaN),[g,m]=c.useState(1);c.useEffect(()=>{!l.current||!t||(l.current.load(),u(0),y(NaN),a(!1))},[t]),c.useEffect(()=>{l.current&&(l.current.volume=g)},[g]);function x(){const f=l.current;f&&(i?f.pause():f.play().catch(()=>{}))}function w(f){const h=l.current;if(!h||!isFinite(d))return;const k=Number(f.target.value);h.currentTime=k,u(k)}function S(f){m(Number(f.target.value))}const _=(e==null?void 0:e.title)||(e==null?void 0:e.entry_uid)||"Unknown",p=(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 f;return u(((f=l.current)==null?void 0:f.currentTime)??0)},onLoadedMetadata:()=>{var f;return y(((f=l.current)==null?void 0:f.duration)??NaN)},onDurationChange:()=>{var f;return y(((f=l.current)==null?void 0:f.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:Us(p)}}),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:x,"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:qu(o)}),s.jsx("input",{type:"range",min:0,max:isFinite(d)?d: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:qu(d)})]}),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:g,onChange:S,"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 Jg({archiveId:e,entryUid:t}){var m,x;const[n,r]=c.useState(null),[l,i]=c.useState(!0),[a,o]=c.useState(null),[u,d]=c.useState(!1);c.useEffect(()=>{if(!u)return;const w=document.documentElement,S=document.body,_=w.style.colorScheme,p=S.style.background;return w.style.colorScheme="dark",S.style.background="#000",()=>{w.style.colorScheme=_,S.style.background=p}},[u]),c.useEffect(()=>{d(!1),Mr(e,t).then(w=>{r(w),i(!1)}).catch(w=>{o((w==null?void 0:w.message)||"Failed to load entry"),i(!1)})},[e,t]);const y=((m=n==null?void 0:n.summary)==null?void 0:m.title)||t,g=(x=n==null?void 0:n.summary)==null?void 0:x.original_url;return s.jsxs("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column",background:u?"#000":"var(--paper)",fontFamily:"var(--sans)"},children:[s.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:[s.jsx("a",{href:"/",style:{color:u?"#1d9bf0":"var(--accent)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"← Archive"}),s.jsx("span",{style:{flex:1,fontSize:"14px",fontWeight:600,color:u?"#e7e9ea":"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y}),g&&s.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{color:u?"#71767b":"var(--muted)",textDecoration:"none",fontSize:"13px",flexShrink:0},children:"Original ↗"})]}),s.jsxs("div",{style:u?{flex:1}:{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(_f,{archiveId:e,entry:n.summary,detail:n,fullPage:!0,onXArticle:d})]})]})}const Gg=7e3;function Yg({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(ey,{toast:r,onDismiss:t,onIgnoreUblock:n},r.id))}):null}function Zg(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 ey({toast:e,onDismiss:t,onIgnoreUblock:n}){const[r,l]=c.useState(!1),i=e.type==="warning",a=e.type==="success";c.useEffect(()=>{if(r)return;const u=setTimeout(()=>t(e.id),Gg);return()=>clearTimeout(u)},[r,e.id,t]);const o=Zg(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 Hs=c.createContext(null),ty=["archive","tags","collections","runs","admin","settings"],ny=["profile","tokens","instance","cookies","extensions","storage"],Ir=(()=>{const e=window.location.pathname.match(/^\/preview\/([^/]+)\/([^/]+)/);return e?{archiveId:e[1],entryUid:e[2]}:null})();function Wt(){const e=window.location.pathname.split("/").filter(Boolean),t=ty.includes(e[0])?e[0]:"archive",n=t==="settings"&&ny.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,o=t==="archive"?r.get("collection")??null:null,u=o==="main"?null:o,d=r.get("archive")??null;return{view:t,settingsTab:n,q:l,tag:i,entry:a,collection:u,archive:d}}function ry(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function ly(){const[e,t]=c.useState("loading"),[n,r]=c.useState(null);c.useEffect(()=>{(async()=>{var M,W,G;if(await hm()){t("setup");return}const z=await cf();if(!z){const{collection:ue,archive:Ee}=Wt();try{const We=await Ru(),je=Ee?((M=We.find(T=>T.id===Ee))==null?void 0:M.id)??((W=We[0])==null?void 0:W.id):(G=We[0])==null?void 0:G.id;if(je){await zu(je,ue),i(We),o(je),d(ue),t("authenticated");return}}catch{}t("login");return}r(z),t("authenticated")})()},[]),c.useEffect(()=>{const C=()=>{n&&(r(null),t("login"))};return window.addEventListener("auth:expired",C),()=>window.removeEventListener("auth:expired",C)},[n]),c.useEffect(()=>{const C=()=>{const{view:z,settingsTab:M,q:W,tag:G,entry:ue,collection:Ee}=Wt();X(z),ne(M),fe(W),b(G),h(ue),E(null),N(ue?new Set([ue]):new Set),d(Ee)};return window.addEventListener("popstate",C),()=>window.removeEventListener("popstate",C)},[]);const[l,i]=c.useState([]),[a,o]=c.useState(null),[u,d]=c.useState(()=>Wt().collection),[y,g]=c.useState([]),[m,x]=c.useState([]),[w,S]=c.useState(()=>new Set),[_,p]=c.useState(()=>new Map),[f,h]=c.useState(()=>Wt().entry),[k,E]=c.useState(null),[P,N]=c.useState(()=>{const C=Wt().entry;return C?new Set([C]):new Set}),[v,b]=c.useState(()=>Wt().tag),[L,X]=c.useState(()=>Wt().view),[Q,ne]=c.useState(()=>Wt().settingsTab),[q,fe]=c.useState(()=>Wt().q),[Le,ve]=c.useState(""),[I,R]=c.useState(!1),[K,ee]=c.useState([]),[se,ie]=c.useState([]),[Y,Ne]=c.useState(()=>sessionStorage.getItem("captureDialogOpen")==="true"),[pe,U]=c.useState([]),te=c.useRef(0),[re,Ue]=c.useState(()=>{try{const C=JSON.parse(sessionStorage.getItem("pendingCaptures")||"[]");if(Array.isArray(C))return C}catch{}return[]});c.useEffect(()=>{sessionStorage.setItem("pendingCaptures",JSON.stringify(re))},[re]);const[Lt,yt]=c.useState(()=>sessionStorage.getItem("ublockWarningIgnored")==="true"),[Ie,st]=c.useState(null),Ze=c.useRef(0),$=c.useRef(null),Z=c.useRef(!1),Ae=c.useRef(!0),Me=c.useRef(null),Rt=c.useRef(0),zt=c.useRef(new Map),It=(n==null?void 0:n.humanize_slugs)??!1;c.useEffect(()=>{const C=++Ze.current;st(null),!(!k||!a)&&Mr(a,k.entry_uid).then(z=>{C===Ze.current&&st(z)}).catch(()=>{})},[k,a]),c.useEffect(()=>{sessionStorage.setItem("captureDialogOpen",Y)},[Y]);const et=c.useCallback(async(C,z,M,W)=>{if(C){R(!0);try{let G;z||M?G=await Gh(C,z,M,W):G=await zu(C,W),x(G),N(ue=>{if(ue.size<2)return ue;const Ee=new Set(G.map(je=>je.entry_uid)),We=new Set([...ue].filter(je=>Ee.has(je)));return We.size===ue.size?ue:We}),ve(G.length===0?"No results":`${G.length} result${G.length===1?"":"s"}`)}catch{x([]),ve("Search failed. Try again.")}finally{R(!1)}}},[]);c.useEffect(()=>{e==="authenticated"&&(a||Ru().then(C=>{if(i(C),C.length>0){const{archive:z}=Wt(),M=z?C.find(W=>W.id===z):null;o((M==null?void 0:M.id)??C[0].id)}}))},[e,a]),c.useEffect(()=>{if(!a)return;const C=!n;if(Ae.current){Ae.current=!1;const M=[];C||(M.push(Ni(a).then(ee)),M.push(Bl(a).then(ie))),M.length&&Promise.all(M);return}b(null),E(null),h(null),N(new Set),d(null);const z=[et(a,"",null,null)];C||(z.push(Ni(a).then(ee)),z.push(Bl(a).then(ie))),Promise.all(z)},[a,n]),c.useEffect(()=>{if(a===null)return;const C=setTimeout(()=>{et(a,q,v,u)},300);return()=>clearTimeout(C)},[q,a,u]),c.useEffect(()=>{a!==null&&(v!==null&&X("archive"),et(a,q,v,u))},[v,a,u]);const Xt=c.useCallback(C=>{o(C),d(null);const z=new URLSearchParams(window.location.search);z.set("archive",C),z.delete("collection");const M=z.toString();history.replaceState(null,"",window.location.pathname+(M?"?"+M:""))},[]);c.useEffect(()=>{if(!a){g([]);return}wo(a).then(g).catch(()=>g([]))},[a]);const $t=c.useCallback(C=>{if(!n){const W=C?y.find(G=>G.collection_uid===C):y.find(G=>G.slug==="_default_");if(W!=null&&W.requires_auth){t("login");return}}d(C),E(null),h(null),N(new Set),et(a,q,v,C);const z=new URLSearchParams(window.location.search);C?(z.set("collection",C),z.set("archive",a)):(z.delete("collection"),a&&z.set("archive",a));const M=z.toString();history.replaceState(null,"",window.location.pathname+(M?"?"+M:""))},[a,q,v,n,y,et]),an=c.useCallback(C=>{X(C),C==="tags"&&a&&Bl(a).then(ie)},[a]);c.useEffect(()=>{if(Ir)return;const C=ry(L,Q);window.location.pathname!==C&&history.pushState(null,"",C+window.location.search)},[L,Q]);const He=c.useCallback(C=>{h(C?C.entry_uid:null),E(C)},[]),j=c.useCallback((C,z)=>{if(zt.current.set(C.entry_uid,C),++Rt.current,z.shiftKey&&Me.current!==null){z.preventDefault();const M=[...document.querySelectorAll("#entries-body [data-entry-uid]")],W=M.findIndex(je=>je.dataset.entryUid===Me.current),G=M.findIndex(je=>je.dataset.entryUid===C.entry_uid);if(W===-1||G===-1){Me.current=C.entry_uid,N(new Set([C.entry_uid])),He(C);return}const ue=Math.min(W,G),Ee=Math.max(W,G),We=new Set(M.slice(ue,Ee+1).map(je=>je.dataset.entryUid));N(We),We.size===1&&He(C)}else if(z.ctrlKey||z.metaKey){Me.current=C.entry_uid;const M=new Set(P);if(M.has(C.entry_uid)?M.delete(C.entry_uid):M.add(C.entry_uid),N(M),M.size===0)He(null);else if(M.size===1){const[W]=M,G=zt.current.get(W)??m.find(ue=>ue.entry_uid===W)??null;if(G)He(G);else{const ue=++Rt.current;Mr(a,W).then(Ee=>{ue===Rt.current&&(Ee!=null&&Ee.summary)&&He(Ee.summary)}).catch(()=>{})}}else He(null)}else Me.current=C.entry_uid,N(new Set([C.entry_uid])),He(C)},[m,P,He,a]),B=c.useCallback(C=>{b(C)},[]),A=c.useCallback(()=>{b(null)},[]),D=c.useCallback(()=>{a&&Bl(a).then(ie)},[a]),F=c.useCallback((C,z)=>{v===C?b(z):v!=null&&v.startsWith(C+"/")&&b(z+v.slice(C.length))},[v]),H=c.useCallback(C=>{(v===C||v!=null&&v.startsWith(C+"/"))&&b(null)},[v]),ke=c.useCallback((C,z)=>{p(W=>new Map(W).set(C,z));const M=zt.current.get(C);M&&zt.current.set(C,{...M,title:z}),x(W=>W.map(G=>G.entry_uid===C?{...G,title:z}:G)),E(W=>W&&W.entry_uid===C?{...W,title:z}:W),st(W=>W&&W.summary.entry_uid===C?{...W,summary:{...W.summary,title:z}}:W)},[]),he=c.useCallback(()=>{if(!a||!k)return;const C=++Ze.current;Mr(a,k.entry_uid).then(z=>{C===Ze.current&&st(z)}).catch(()=>{})},[a,k]),Re=c.useCallback(C=>{const z=m.some(M=>M.entry_uid===C);S(M=>{const W=new Set(M);return W.add(C),W}),x(M=>M.filter(W=>W.entry_uid!==C)),E(M=>(M==null?void 0:M.entry_uid)===C?null:M),h(M=>M===C?null:M),N(M=>{const W=new Set(M);return W.delete(C),W}),z||et(a,q,v,u)},[m,a,q,v,u,et]),ye=c.useCallback(C=>{const z=new Set(m.map(W=>W.entry_uid)),M=[...C].some(W=>!z.has(W));S(W=>{const G=new Set(W);return C.forEach(ue=>G.add(ue)),G}),x(W=>W.filter(G=>!C.has(G.entry_uid))),N(new Set),E(null),h(null),M&&et(a,q,v,u)},[m,a,q,v,u,et]);c.useEffect(()=>{if(P.size>=2)h(null),E(null);else if(P.size===1){const[C]=P;h(C)}else h(null),E(null)},[P]);const Fe=c.useMemo(()=>m.filter(C=>P.has(C.entry_uid)),[m,P]);c.useEffect(()=>{if(!f||k)return;const C=m.find(z=>z.entry_uid===f);C&&E(C)},[m,f,k]),c.useEffect(()=>{if(Ir)return;const C=new URLSearchParams(window.location.search).get("archive"),z=new URLSearchParams;q&&z.set("q",q),L==="archive"&&v&&z.set("tag",v),L==="archive"&&f&&z.set("entry",f),L==="archive"&&u?(z.set("collection",u),a&&z.set("archive",a)):C&&a&&z.set("archive",a);const M=z.toString(),W=window.location.pathname+(M?"?"+M:"");window.location.pathname+window.location.search!==W&&history.replaceState(null,"",W)},[q,v,f,u,a,L]),c.useEffect(()=>{const C=z=>{var ue,Ee,We,je;const M=z.key==="/"&&!z.metaKey&&!z.ctrlKey&&!z.altKey,W=(z.metaKey||z.ctrlKey)&&z.key==="k";if(!M&&!W)return;const G=(ue=document.activeElement)==null?void 0:ue.tagName;M&&(G==="INPUT"||G==="TEXTAREA"||G==="SELECT")||M&&((Ee=document.activeElement)!=null&&Ee.isContentEditable)||(z.preventDefault(),L==="archive"?((We=$.current)==null||We.focus(),(je=$.current)==null||je.select()):(Z.current=!0,X("archive")))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[L]),c.useEffect(()=>{const C=z=>{var ae,me;if(z.metaKey||z.ctrlKey||z.altKey||z.key!=="j"&&z.key!=="k")return;const M=(ae=document.activeElement)==null?void 0:ae.tagName;if(M==="INPUT"||M==="TEXTAREA"||M==="SELECT"||(me=document.activeElement)!=null&&me.isContentEditable)return;const W=[...document.querySelectorAll("#entries-body [data-entry-uid]")];if(W.length===0)return;const[G]=P.size===1?P:[null],ue=G?W.findIndex($e=>$e.dataset.entryUid===G):-1,Ee=z.key==="j"?Math.min(ue+1,W.length-1):Math.max(ue-1,0);if(Ee===ue&&ue!==-1)return;const We=W[Ee<0?0:Ee],je=We.dataset.entryUid;Me.current=je;const T=++Rt.current;N(new Set([je]));const J=zt.current.get(je)??m.find($e=>$e.entry_uid===je)??null;J?He(J):Mr(a,je).then($e=>{T===Rt.current&&($e!=null&&$e.summary)&&He($e.summary)}).catch(()=>{}),We.scrollIntoView({block:"nearest"}),z.preventDefault()};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[P,m,He,a]),c.useEffect(()=>{L==="archive"&&Z.current&&(Z.current=!1,requestAnimationFrame(()=>{var C,z;(C=$.current)==null||C.focus(),(z=$.current)==null||z.select()}))},[L]);const ce=c.useCallback(()=>{Ne(!0)},[]),it=c.useCallback(()=>{Ne(!1)},[]),dt=c.useCallback(()=>{if(a)return Promise.allSettled([et(a,q,v,u),Ni(a).then(ee)])},[a,q,v,u,et]),Nr=c.useCallback((C,z,M="error",W=null)=>{if(M==="warning"&&Lt&&z)return;const G=++te.current;U(ue=>[...ue,{id:G,text:C,locator:z,type:M,headline:W}])},[Lt]),Ws=c.useCallback(C=>{U(z=>z.filter(M=>M.id!==C))},[]),Vs=c.useCallback(C=>{Nr(C,null,"error","Reorder failed")},[Nr]),kl=c.useCallback(()=>{sessionStorage.setItem("ublockWarningIgnored","true"),yt(!0),U(C=>C.filter(z=>!(z.type==="warning"&&z.locator)))},[]),Ks=c.useCallback(C=>{Ue(z=>[...z,C])},[]),Qs=c.useCallback(C=>{Ue(z=>z.filter(M=>M.id!==C))},[]),[Kn,Qn]=c.useState(null),[Pn,jl]=c.useState(null),qs=c.useCallback(()=>{k&&Qn(k.entry_uid)},[k]),Xs=c.useCallback(()=>Qn(null),[]),Js=c.useCallback((C,z)=>{jl({src:C,entry:z})},[]),Gs=c.useCallback(()=>jl(null),[]);return c.useEffect(()=>{Qn(null)},[k]),c.useEffect(()=>{const C=z=>{var W,G,ue;if(z.key!=="Escape"||Y||Kn)return;const M=(W=document.activeElement)==null?void 0:W.tagName;M==="INPUT"||M==="TEXTAREA"||M==="SELECT"||P.size>0&&(z.preventDefault(),N(new Set),(ue=(G=document.activeElement)==null?void 0:G.blur)==null||ue.call(G))};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[Y,Kn,P]),c.useEffect(()=>(document.body.classList.toggle("has-audio-bar",!!Pn),()=>document.body.classList.remove("has-audio-bar")),[Pn]),Ir?s.jsx(Jg,{archiveId:Ir.archiveId,entryUid:Ir.entryUid}):e==="loading"?s.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?s.jsx(Wm,{onComplete:()=>t("login")}):e==="login"?s.jsx(Hm,{onLogin:C=>{r(C),t("authenticated")}}):s.jsx(Hs.Provider,{value:{currentUser:n,setCurrentUser:r},children:s.jsxs(s.Fragment,{children:[s.jsx(Vm,{archives:l,archiveId:a,onArchiveChange:Xt,view:L,onViewChange:an,onCaptureClick:ce,collections:y,selectedCollectionUid:u,onCollectionChange:$t,isPublicSession:!n,onSignInClick:()=>t("login")}),s.jsxs("main",{className:"app-shell",children:[s.jsxs("div",{className:"workspace",children:[L==="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:$,className:"search-input",type:"search","aria-label":"Search archive","aria-busy":I,placeholder:"Search titles, URLs, types, tags…",value:q,onChange:C=>fe(C.target.value)}),s.jsx("span",{className:"kbd",children:"⌘K"})]}),s.jsxs("span",{className:"result-count",children:[Le&&s.jsxs(s.Fragment,{children:[s.jsx("b",{children:Le.split(" ")[0]})," ",Le.split(" ").slice(1).join(" ")]}),v&&s.jsxs("button",{className:"tag-filter-badge",onClick:A,children:["× ",It?pf(v):v]})]})]}),L==="archive"&&s.jsx(ig,{entries:m,selectedUids:P,onRowClick:j,archiveId:a,pendingCaptures:re,deletedUids:w,renamedTitles:_,isPublicSession:!n,canReorder:!!(n!=null&&n.can_reorder_children),onChildReorderError:Vs}),L==="runs"&&s.jsx(ug,{runs:K}),L==="admin"&&s.jsx(dg,{archives:l}),L==="tags"&&s.jsx(fg,{archiveId:a,tagNodes:se,tagFilter:v,onTagFilterSet:B,onViewChange:an,onTagRenamed:F,onTagDeleted:H,onTagsRefresh:D,humanizeTags:It}),L==="collections"&&s.jsx(hg,{archiveId:a}),L==="settings"&&s.jsx(yg,{tab:Q,onTabChange:ne,archiveId:a})]}),s.jsx(bg,{archiveId:a,selectedEntry:k,selectedUids:P,selectedEntries:Fe,detail:Ie,onTagFilterSet:B,tagNodes:se,onTagsRefresh:D,onEntryTitleChange:ke,onEntryDeleted:Re,onBulkDeleted:ye,humanizeTags:It,onDetailRefresh:he,onOpenPreview:qs,onPlay:Js,isPublicSession:!n})]}),Kn&&k&&k.entry_uid===Kn&&s.jsx(qg,{archiveId:a,entry:k,detail:Ie,onClose:Xs}),Pn&&s.jsx(Xg,{entry:Pn.entry,src:Pn.src,archiveId:a,onClose:Gs}),s.jsx(Xm,{open:Y,archiveId:a,onClose:it,onCaptured:dt,onToast:Nr,activeJobs:re,onJobStarted:Ks,onJobSettled:Qs}),s.jsx(Yg,{toasts:pe,onDismiss:Ws,onIgnoreUblock:kl})]})})}of(document.getElementById("root")).render(s.jsx(c.StrictMode,{children:s.jsx(ly,{})}));
|