1import{r as e,j as s}from"./vendor-react-BfgFmtGS.js";import{a as t}from"./useAuth-DynbexoK.js";import{B as a}from"./button-CYJdLL_L.js";import{a as i}from"./runtime-utils-GN4cODRt.js";import{r as n,M as l,e as o,f as r,E as d,a as c,g as x,h as m,c as p,i as u}from"./feedBatchMonitorDebug-BCAjn03I.js";import{loadSignedInExploreFirstPagePrefetchWarmAt as h,loadAnonymousExploreRandomPrefetchWarmAt as f,SIGNED_IN_EXPLORE_FIRST_PAGE_PREFETCH_TTL_MS as b,ANON_EXPLORE_RANDOM_PREFETCH_TTL_MS as g}from"./explorePrefetch-BjaxcGhU.js";import{r as w,F as j}from"./feedBatchMonitorVisibility-Dzs90-gC.js";import{s as v}from"./documentVisibleInterval-kwPiY7AC.js";import{a as y}from"./vendor-router-QOYqHwMx.js";import{c as N}from"./createLucideIcon-D9HkCDkl.js";import{H as k}from"./heart-CdAafllh.js";import{D as L}from"./database-iFG0pU72.js";import{E as M}from"./eye-CImpNXgw.js";import{C}from"./circle-check-DpwBxCoL.js";import{L as E}from"./loader-circle-fXsKc0TP.js";import{A as F}from"./activity-Cs2H8ktv.js";const S=N("Layers2",[["path",{d:"m16.02 12 5.48 3.13a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74L7.98 12",key:"1cuww1"}],["path",{d:"M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74Z",key:"pdlvxu"}]]),_=N("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]),A="echo:global-feed-batch-monitors-minimized";function B(e){if(!Number.isFinite(Number(e)))return"never";const s=Math.max(0,Math.round((Date.now()-Number(e))/1e3));return s<5?"just now":s<60?`${s}s ago`:`${Math.round(s/60)}m ago`}function z(e,s){return"ready"===e?C:s||"warming"===e||"loading"===e?E:F}function R(e){return"ready"===e?"border-emerald-500/30 bg-emerald-500/12 text-emerald-100":"warming"===e||"loading"===e?"border-amber-500/30 bg-amber-500/12 text-amber-100":"blocked"===e||"error"===e?"border-rose-500/30 bg-rose-500/12 text-rose-100":"border-sky-500/30 bg-sky-500/12 text-sky-100"}function P(){var N,C;const E=y(),{isAdmin:F,profile:P,user:I}=t(),[D,U]=e.useState(0),[G,V]=e.useState(()=>"undefined"!=typeof window&&"true"===window.sessionStorage.getItem(A)),[$,q]=e.useState(w);e.useEffect(()=>{const e=()=>q(w());return window.addEventListener(j,e),window.addEventListener("storage",e),()=>{window.removeEventListener(j,e),window.removeEventListener("storage",e)}},[]),e.useEffect(()=>{if($)return v(()=>U(e=>e+1),1e3,{runOnResume:!0})},[$]);const{myFeed:O,myFeedLastGood:W,explore:H,exploreFeed2:K,exploreLastGood:Y}=e.useMemo(()=>({myFeed:n(o,l),myFeedLastGood:r(u),explore:n(c,d),exploreFeed2:n(m,x),exploreLastGood:r(p)}),[D,E.pathname]),Z="/"===E.pathname,J=E.pathname.startsWith("/explore"),Q=e.useMemo(()=>Z||!W?O:O?(O.visibleRows??0)>0||O.isInitialLoading||O.isAppending?O:(W.visibleRows??0)>0?W:O:W,[Z,O,W]),T=e.useMemo(()=>{var e,s;const t=Number((null==K?void 0:K.lastUpdatedAt)||0)>=Number((null==H?void 0:H.lastUpdatedAt)||0)?K:H,a=Y??function(e){const s=e?h(e):0,t=f(),a=Math.max(s,t),i=s>0&&Date.now()-s<b,n=t>0&&Date.now()-t<g,l=i||n;return{lastUpdatedAt:a||Date.now(),monitor:{activelyLoading:!1,displayedCount:0,engine:i?"prefetched_first_page":n?"prefetched_random":"waiting_for_visit",hasMore:l,nextCursor:null,pageCount:l?1:0,readyCount:l?1:0,route:"/explore",source:l?"prefetch-manager":"explore",status:l?"ready":"idle",statusLabel:l?"Explore prefetched":"Visit Explore for live batch stats"}}}(null==I?void 0:I.id);return J||!a?t??a:t?((null==(e=t.monitor)?void 0:e.readyCount)??0)>0?t:((null==(s=a.monitor)?void 0:s.readyCount)??0)>0?a:t:a},[H,K,Y,J,null==I?void 0:I.id]);if(!F&&!(null==P?void 0:P.is_admin))return null;if(!$)return null;if(!Q&&!T)return null;const X=z(null==Q?void 0:Q.status,(null==Q?void 0:Q.isPrefetchingBufferedPage)||(null==Q?void 0:Q.isFetching)),ee=null==(N=null==T?void 0:T.monitor)?void 0:N.status,se=Boolean(null==(C=null==T?void 0:T.monitor)?void 0:C.activelyLoading),te=z(ee,se),ae=Boolean(null==Q?void 0:Q.backgroundWarmOnly)&&!Z,ie=ae?"Rendered here":"Visible",ne=(null==Q?void 0:Q.visibleRows)??0,le=(null==Q?void 0:Q.visiblePages)??0,oe=(null==Q?void 0:Q.loadedPages)??(null==Q?void 0:Q.visiblePages)??0,re=(null==Q?void 0:Q.lastPageSize)??0,de=Boolean(null==Q?void 0:Q.cursorReady),ce=Boolean(null==Q?void 0:Q.sessionExhausted),xe=Boolean(null==Q?void 0:Q.isInitialLoading)||Boolean(null==Q?void 0:Q.isAppending);
1return G?s.jsxs(a,{type:"button",variant:"ghost",className:"fixed bottom-4 right-4 z-[72] hidden h-11 rounded-full border border-white/10 bg-black/85 px-3 text-xs font-black text-white shadow-[0_14px_40px_rgba(0,0,0,0.38)] backdrop-blur-xl hover:bg-black/90 hover:text-white md:inline-flex",onClick:()=>{V(!1),window.sessionStorage.removeItem(A)},"aria-label":"Show feed batch monitors",children:[s.jsx(S,{className:"mr-2 h-3.5 w-3.5"}),oe," pages",s.jsx("span",{className:"mx-2 text-white/30",children:"|"}),xe?"loading":ce?"done":"ready"]}):s.jsxs("aside",{className:"fixed bottom-4 right-4 z-[72] hidden w-[25rem] rounded-2xl border border-white/10 bg-black/85 p-3 text-white shadow-[0_20px_60px_rgba(0,0,0,0.42)] backdrop-blur-xl md:block",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-white/45",children:"Feed monitors"}),s.jsx("p",{className:"mt-1 text-xs font-bold text-white/60",children:"My Feed and Explore batch state"})]}),s.jsx(a,{size:"icon",variant:"ghost",className:"h-8 w-8 rounded-full text-white/60 hover:bg-white/10 hover:text-white",onClick:()=>{V(!0),window.sessionStorage.setItem(A,"true")},"aria-label":"Minimize feed batch monitors",children:s.jsx(_,{className:"h-4 w-4"})})]}),Q?s.jsxs("section",{className:"mt-3 rounded-2xl border border-white/10 bg-white/[0.04] p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(k,{className:"h-3.5 w-3.5 text-rose-300"}),s.jsx("p",{className:"text-sm font-black text-white",children:"My Feed"}),Z?s.jsx("span",{className:"rounded-full bg-white/[0.08] px-2 py-0.5 text-[10px] font-bold text-white/60",children:"live"}):null,ae?s.jsx("span",{className:"rounded-full bg-white/[0.08] px-2 py-0.5 text-[10px] font-bold text-white/60",children:"off-route"}):null]}),s.jsxs("div",{className:i("mt-2 inline-flex items-center gap-2 rounded-full border px-2.5 py-1 text-xs font-black",R(Q.status)),children:[s.jsx(X,{className:i("h-3.5 w-3.5",("warming"===Q.status||"loading"===Q.status)&&"animate-spin")}),Q.statusLabel]})]}),s.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-white/40",children:B(Q.lastUpdatedAt)})]}),s.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[s.jsxs("div",{className:"rounded-xl bg-white/[0.06] px-3 py-2",children:[s.jsx("p",{className:"font-bold text-white/45",children:ie}),s.jsxs("p",{className:"mt-0.5 font-black text-white",children:[ne," echoes"]}),s.jsxs("p",{className:"text-white/45",children:[le," pages"]})]}),s.jsxs("div",{className:"rounded-xl bg-white/[0.06] px-3 py-2",children:[s.jsx("p",{className:"font-bold text-white/45",children:"Session"}),s.jsxs("p",{className:"mt-0.5 font-black text-white",children:[oe," pages loaded"]}),s.jsx("p",{className:"text-white/45",children:ce?"exhausted for this seed":re>0?`last page ${re} echoes`:"awaiting first page"})]})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5 text-[10px] font-bold text-white/55",children:[s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-white/[0.06] px-2 py-1",children:[s.jsx(L,{className:"h-3 w-3"}),Q.feedKind]}),s.jsxs("span",{className:"rounded-full bg-white/[0.06] px-2 py-1",children:["seed ",(me=Q.sessionSeed??Q.activeSeed,Number.isFinite(Number(me))?String(me).slice(2,8)||"0":"none")]}),s.jsxs("span",{className:"rounded-full bg-white/[0.06] px-2 py-1",children:["cursor ",de?"ready":"missing"]}),s.jsxs("span",{className:"rounded-full bg-white/[0.06] px-2 py-1",children:["more ",Q.hasNextPage?"yes":"no"]}),s.jsx("span",{className:"rounded-full bg-white/[0.06] px-2 py-1",children:ce?"session exhausted":xe?"request active":"session live"})]})]}):null,(null==T?void 0:T.monitor)?s.jsxs("section",{className:"mt-3 rounded-2xl border border-white/10 bg-white/[0.04] p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(M,{className:"h-3.5 w-3.5 text-cyan-300"}),s.jsx("p",{className:"text-sm font-black text-white",children:"Explore"}),J?s.jsx("span",{className:"rounded-full bg-white/[0.08] px-2 py-0.5 text-[10px] font-bold text-white/60",children:"live"}):null]}),s.jsxs("div",{className:i("mt-2 inline-flex items-center gap-2 rounded-full border px-2.5 py-1 text-xs font-black",R(ee)),children:[s.jsx(te,{className:i("h-3.5 w-3.5",
1se&&"animate-spin")}),T.monitor.statusLabel||"Explore status"]})]}),s.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-white/40",children:B(T.lastUpdatedAt)})]}),s.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[s.jsxs("div",{className:"rounded-xl bg-white/[0.06] px-3 py-2",children:[s.jsx("p",{className:"font-bold text-white/45",children:"Rendered"}),s.jsxs("p",{className:"mt-0.5 font-black text-white",children:[T.monitor.displayedCount??0," cards"]}),s.jsx("p",{className:"text-white/45",children:T.monitor.source||"explore"})]}),s.jsxs("div",{className:"rounded-xl bg-white/[0.06] px-3 py-2",children:[s.jsx("p",{className:"font-bold text-white/45",children:"Ready"}),s.jsxs("p",{className:"mt-0.5 font-black text-white",children:[T.monitor.readyCount??0," queued"]}),s.jsx("p",{className:"text-white/45",children:T.monitor.pageCount?`${T.monitor.pageCount} pages`:T.monitor.engine||"engine unknown"})]})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5 text-[10px] font-bold text-white/55",children:[s.jsxs("span",{className:"rounded-full bg-white/[0.06] px-2 py-1",children:["source ",T.monitor.source||"explore"]}),T.monitor.engine?s.jsxs("span",{className:"rounded-full bg-white/[0.06] px-2 py-1",children:["engine ",T.monitor.engine]}):null,s.jsxs("span",{className:"rounded-full bg-white/[0.06] px-2 py-1",children:["cursor ",T.monitor.nextCursor??0]}),s.jsxs("span",{className:"rounded-full bg-white/[0.06] px-2 py-1",children:["more ",T.monitor.hasMore?"yes":"no"]})]})]}):null]});var me}export{P as FeedBatchMonitors};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.