tokentracker-cli 0.3.0 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{r as b,_ as S,m as z}from"./main-CvjKTqMk.js";const L=()=>{const h=b.useRef(null);return b.useEffect(()=>{const t=h.current;if(!t)return;const e=t.getContext("2d",{alpha:!0});if(!e)return;const g=S(window.location.search),r=!!(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches),i={scale:r?.45:.5,fps:r?3:8,baseFontSize:16,spacing:r?1.7:1.4,trailAlpha:r?.2:.12,speed:r?.5:.85,resetChance:r?.97:.985,highlightChance:.05},w="01XYZA@#$%";let s=0,a=0,f=0,o=[],c=12,u=16,d=document.visibilityState!=="hidden";const m=g?R(42):Math.random,M=()=>{t.style.width="100%",t.style.height="100%";const n=Math.max(1,Math.floor(window.innerWidth*i.scale)),l=Math.max(1,Math.floor(window.innerHeight*i.scale));t.width=n,t.height=l,c=Math.max(8,Math.round(i.baseFontSize*i.scale)),u=Math.max(10,Math.round(c*i.spacing));const E=Math.ceil(t.width/u);o=Array.from({length:E},()=>m()*-100),e.font=`${c}px monospace`,e.textBaseline="top",e.imageSmoothingEnabled=!1},x=()=>{a&&cancelAnimationFrame(a),a=requestAnimationFrame(M)},F=()=>{e.fillStyle=`rgba(5, 5, 5, ${i.trailAlpha})`,e.fillRect(0,0,t.width,t.height);for(let n=0;n<o.length;n++){const l=w.charAt(Math.floor(m()*w.length));e.fillStyle=m()<i.highlightChance?"#E8FFE9":"#00FF41",e.fillText(l,n*u,o[n]*c),o[n]*c>t.height&&m()>i.resetChance&&(o[n]=0),o[n]+=i.speed}},v=n=>{if(!d)return;const l=1e3/i.fps;n-f>=l&&(F(),f=n),s=requestAnimationFrame(v)},y=()=>{d&&(f=performance.now(),s=requestAnimationFrame(v))},p=()=>{s&&cancelAnimationFrame(s),s=0},A=()=>{d=document.visibilityState!=="hidden",d?(p(),y()):p()};return M(),g?(F(),()=>{a&&cancelAnimationFrame(a)}):(y(),window.addEventListener("resize",x),document.addEventListener("visibilitychange",A),()=>{window.removeEventListener("resize",x),document.removeEventListener("visibilitychange",A),p(),a&&cancelAnimationFrame(a)})},[]),z.jsx("canvas",{ref:h,className:"matrix-rain fixed inset-0 z-0 pointer-events-none opacity-20",style:{width:"100%",height:"100%"}})};function R(h){let t=h;return()=>{t+=1831565813;let e=Math.imul(t^t>>>15,1|t);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}export{L as MatrixRain};
1
+ import{r as b,_ as S,m as z}from"./main-C3QpHBOP.js";const L=()=>{const h=b.useRef(null);return b.useEffect(()=>{const t=h.current;if(!t)return;const e=t.getContext("2d",{alpha:!0});if(!e)return;const g=S(window.location.search),r=!!(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches),i={scale:r?.45:.5,fps:r?3:8,baseFontSize:16,spacing:r?1.7:1.4,trailAlpha:r?.2:.12,speed:r?.5:.85,resetChance:r?.97:.985,highlightChance:.05},w="01XYZA@#$%";let s=0,a=0,f=0,o=[],c=12,u=16,d=document.visibilityState!=="hidden";const m=g?R(42):Math.random,M=()=>{t.style.width="100%",t.style.height="100%";const n=Math.max(1,Math.floor(window.innerWidth*i.scale)),l=Math.max(1,Math.floor(window.innerHeight*i.scale));t.width=n,t.height=l,c=Math.max(8,Math.round(i.baseFontSize*i.scale)),u=Math.max(10,Math.round(c*i.spacing));const E=Math.ceil(t.width/u);o=Array.from({length:E},()=>m()*-100),e.font=`${c}px monospace`,e.textBaseline="top",e.imageSmoothingEnabled=!1},x=()=>{a&&cancelAnimationFrame(a),a=requestAnimationFrame(M)},F=()=>{e.fillStyle=`rgba(5, 5, 5, ${i.trailAlpha})`,e.fillRect(0,0,t.width,t.height);for(let n=0;n<o.length;n++){const l=w.charAt(Math.floor(m()*w.length));e.fillStyle=m()<i.highlightChance?"#E8FFE9":"#00FF41",e.fillText(l,n*u,o[n]*c),o[n]*c>t.height&&m()>i.resetChance&&(o[n]=0),o[n]+=i.speed}},v=n=>{if(!d)return;const l=1e3/i.fps;n-f>=l&&(F(),f=n),s=requestAnimationFrame(v)},y=()=>{d&&(f=performance.now(),s=requestAnimationFrame(v))},p=()=>{s&&cancelAnimationFrame(s),s=0},A=()=>{d=document.visibilityState!=="hidden",d?(p(),y()):p()};return M(),g?(F(),()=>{a&&cancelAnimationFrame(a)}):(y(),window.addEventListener("resize",x),document.addEventListener("visibilitychange",A),()=>{window.removeEventListener("resize",x),document.removeEventListener("visibilitychange",A),p(),a&&cancelAnimationFrame(a)})},[]),z.jsx("canvas",{ref:h,className:"matrix-rain fixed inset-0 z-0 pointer-events-none opacity-20",style:{width:"100%",height:"100%"}})};function R(h){let t=h;return()=>{t+=1831565813;let e=Math.imul(t^t>>>15,1|t);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}export{L as MatrixRain};
@@ -1 +1 @@
1
- import{m as t,r as i,d as z,_ as U,l as g}from"./main-CvjKTqMk.js";import{p as G}from"./vibeusage-api-By1xP_lg.js";import{MatrixRain as Z}from"./MatrixRain-DNvnkted.js";const S={TOP_LEFT:"┌",TOP_RIGHT:"┐",BOTTOM_LEFT:"└",BOTTOM_RIGHT:"┘",HORIZONTAL:"─",VERTICAL:"│"};function ne({title:r,subtitle:e,children:s,className:n="",bodyClassName:a=""}){return t.jsxs("div",{className:`relative flex flex-col matrix-panel ${n}`,children:[t.jsxs("div",{className:"flex items-center leading-none",children:[t.jsx("span",{className:"shrink-0 text-matrix-dim",children:S.TOP_LEFT}),t.jsx("span",{className:"mx-3 shrink-0 text-heading uppercase text-matrix-primary px-2 py-1 bg-matrix-panelStrong border border-matrix-ghost",children:r}),e?t.jsxs("span",{className:"text-caption text-matrix-muted mr-2 uppercase",children:["[",e,"]"]}):null,t.jsx("span",{className:"flex-1 overflow-hidden whitespace-nowrap text-matrix-ghost",children:S.HORIZONTAL.repeat(100)}),t.jsx("span",{className:"shrink-0 text-matrix-dim",children:S.TOP_RIGHT})]}),t.jsxs("div",{className:"flex flex-1",children:[t.jsx("div",{className:"shrink-0 w-3 flex justify-center text-matrix-ghost",children:S.VERTICAL}),t.jsx("div",{className:`flex-1 min-w-0 py-5 px-4 relative z-10 ${a}`,children:s}),t.jsx("div",{className:"shrink-0 w-3 flex justify-center text-matrix-ghost",children:S.VERTICAL})]}),t.jsxs("div",{className:"flex items-center leading-none text-matrix-ghost",children:[t.jsx("span",{className:"shrink-0",children:S.BOTTOM_LEFT}),t.jsx("span",{className:"flex-1 overflow-hidden whitespace-nowrap",children:S.HORIZONTAL.repeat(100)}),t.jsx("span",{className:"shrink-0",children:S.BOTTOM_RIGHT})]})]})}const O=12e4,B=3e5,F=1e4;function W({intervalMs:r=O,maxIntervalMs:e=B,failureRetryMs:s=F,backoffStepMs:n}={}){const a=T(r,O),c=T(e,B),f=Math.max(a,c),l=Math.max(1e3,Math.round(a*.5)),o=T(n,l),d=T(s,F),v=Math.min(a,Math.max(1e3,d));return{baseIntervalMs:a,maxIntervalMs:f,backoffStepMs:o,failureRetryMs:v}}function $(r={}){const e=W(r);let s=0,n=e.baseIntervalMs;return{onSuccess:()=>{s+=1;const o=Math.max(0,s-1);return n=L(e.baseIntervalMs+e.backoffStepMs*o,e.baseIntervalMs,e.maxIntervalMs),n},onFailure:()=>(s=0,n=L(e.failureRetryMs,1e3,e.maxIntervalMs),n),onError:()=>(s=0,n=L(e.baseIntervalMs,e.baseIntervalMs,e.maxIntervalMs),n),reset:()=>(s=0,n=e.baseIntervalMs,n),getNextDelay(){return n},getConfig(){return{...e}}}}function T(r,e){const s=Number(r);return!Number.isFinite(s)||s<=0?e:Math.floor(s)}function L(r,e,s){const n=T(r,e);return n<e?e:n>s?s:n}function X({baseUrl:r,accessToken:e,intervalMs:s=O,timeoutMs:n=2500,retryDelayMs:a=300,failureThreshold:c=2}={}){const[f,l]=i.useState("unknown"),[o,d]=i.useState(!1),[v,w]=i.useState(null),[I,k]=i.useState(null),[D,H]=i.useState(null),[V,N]=i.useState(null),_=i.useRef(!1),j=i.useRef(0),M=i.useRef($({intervalMs:s})),p=i.useRef(M.current.getNextDelay()),m=i.useRef(null),C=Number.isFinite(Number(c))?Math.max(1,Math.floor(Number(c))):2;i.useEffect(()=>{M.current=$({intervalMs:s}),p.current=M.current.getNextDelay(),m.current&&m.current(p.current)},[s]);const y=i.useCallback(x=>{const u=M.current;return u&&(x==="success"?p.current=u.onSuccess():x==="failure"?p.current=u.onFailure():p.current=u.onError()),p.current},[]),E=i.useCallback(async({reschedule:x=!0}={})=>{let u="error";if(!r){l("error"),d(!1),w(null),k(new Date().toISOString()),N("Missing baseUrl"),y(u),x&&m.current&&m.current(p.current);return}try{new URL(r)}catch{l("error"),d(!1),w(null),k(new Date().toISOString()),N("Invalid baseUrl"),y(u),x&&m.current&&m.current(p.current);return}const R=await z(e);if(!R){l("unknown"),d(!1),w(null),k(new Date().toISOString()),N(null),y(u),x&&m.current&&m.current(p.current);return}if(_.current){x&&m.current&&m.current(p.current);return}_.current=!0,d(!0),N(null);try{const b=await Y({baseUrl:r,accessToken:R,timeoutMs:n,retryDelayMs:a});if(!b.ok)throw b.error;u="success",j.current=0,w(b.status??200);const h=new Date().toISOString();k(h),l("active"),N(null),H(h)}catch(b){const h=b?.status??b?.statusCode;if(w(Number.isFinite(h)?h:null),k(new Date().toISOString()),h===401||h===403)j.current=0,l("error"),N("Unauthorized");else if(typeof h=="number"&&h<500)j.current=0,l("error"),N(`HTTP ${h}`);else{u="failure",j.current+=1;const A=j.current>=C?"down":"error";l(A),N(b?.name==="AbortError"?"Timeout":b?.message||"Fetch failed")}}finally{_.current=!1,d(!1),y(u),x&&m.current&&m.current(p.current)}},[e,y,r,a,C,n]);return i.useEffect(()=>{let x=null;const u=()=>{x!=null&&window.clearTimeout(x),x=null},R=A=>{u(),!(typeof document<"u"&&document.hidden)&&(x=window.setTimeout(()=>{E({reschedule:!0})},A))};m.current=R;const b=()=>{typeof document<"u"&&document.hidden||x||E({reschedule:!0})},h=()=>{typeof document<"u"&&document.hidden?u():b()};return b(),document?.addEventListener?.("visibilitychange",h),()=>{u(),m.current=null,document?.removeEventListener?.("visibilitychange",h)}},[E]),{status:f,checking:o,httpStatus:v,lastCheckedAt:I,lastOkAt:D,error:V,refresh:E}}async function Y({baseUrl:r,accessToken:e,timeoutMs:s,retryDelayMs:n}){const a=await P({baseUrl:r,accessToken:e,timeoutMs:s});return a.ok||!q(a.error)?a:(n>0&&await J(n),P({baseUrl:r,accessToken:e,timeoutMs:s}))}async function P({baseUrl:r,accessToken:e,timeoutMs:s}){const n=new AbortController,a=window.setTimeout(()=>n.abort(),s);try{return{ok:!0,status:(await G({baseUrl:r,accessToken:e,signal:n.signal}))?.status??200}}catch(c){return{ok:!1,error:c}}finally{window.clearTimeout(a)}}function q(r){return r?r.retryable||(r?.status??r?.statusCode)>=500?!0:r?.name==="AbortError":!1}function J(r){return!r||r<=0?Promise.resolve():new Promise(e=>setTimeout(e,r))}function K({status:r="STABLE",title:e,className:s=""}){const[n,a]=i.useState("0"),c=i.useMemo(()=>typeof window>"u"?!1:U(window.location.search),[]);i.useEffect(()=>{let o;if(r==="STABLE"){if(c){a("1");return}o=window.setInterval(()=>{a(Math.random()>.5?"1":"0")},150)}return()=>window.clearInterval(o)},[c,r]);const f={STABLE:{color:"text-matrix-primary",indicator:n},UNSTABLE:{color:"text-yellow-400",indicator:"!"},LOST:{color:"text-red-500/90",indicator:"×"}},l=f[r]||f.STABLE;return t.jsx("div",{title:e,className:["matrix-header-chip matrix-header-chip--bare font-matrix transition-all duration-700",l.color,s].filter(Boolean).join(" "),children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("span",{className:"text-caption text-matrix-dim mr-1",children:"["}),t.jsx("span",{className:"text-caption w-[10px] inline-block text-center font-black",children:l.indicator}),t.jsx("span",{className:"text-caption text-matrix-dim ml-1",children:"]"})]})})}function se({baseUrl:r,accessToken:e,statusOverride:s,titleOverride:n}){const{status:a,checking:c,httpStatus:f,lastCheckedAt:l,lastOkAt:o,error:d}=X({baseUrl:r,accessToken:e}),v=i.useMemo(()=>Q(r),[r]),w=i.useMemo(()=>s||(a==="active"?"STABLE":a==="down"?"LOST":"UNSTABLE"),[a,s]),I=i.useMemo(()=>n||[`${g("backend.meta.status_label")}=${a}`,v?`${g("backend.meta.host_label")}=${v}`:null,l?`${g("backend.meta.checked_label")}=${l}`:null,o?`${g("backend.meta.ok_label")}=${o}`:null,f!=null?`${g("backend.meta.http_label")}=${f}`:null,d?`${g("backend.meta.error_label")}=${d}`:null].filter(Boolean).join(" • "),[d,v,f,l,o,a,n]);return t.jsx(K,{status:w,title:I,className:c?"opacity-80":""})}function Q(r){try{return new URL(r).host}catch{return null}}function ae({headerRight:r,headerStatus:e,children:s,footerLeft:n,footerRight:a,contentClassName:c="",rootClassName:f="",hideHeader:l=!1}){const o=g("shell.header.title"),d=String(o||"").trim().split(/\s+/),v=d[0]||o,w=d.slice(1).join(" ");return t.jsxs("div",{className:`min-h-screen bg-matrix-dark text-matrix-primary font-matrix p-4 md:p-8 flex flex-col leading-tight text-body selection:bg-matrix-primary selection:text-black overflow-hidden ${f}`,children:[t.jsx(Z,{}),t.jsx("div",{className:"matrix-scanline-overlay pointer-events-none fixed inset-0 z-50 bg-[linear-gradient(rgba(18,16,16,0)_50%,rgba(0,0,0,0.1)_50%)] bg-[length:100%_4px]"}),t.jsxs("div",{className:`relative z-10 flex flex-col min-h-screen matrix-shell-content ${c}`,children:[l?null:t.jsx("header",{className:"border-b border-matrix-primary/20 pb-3 mb-6 shrink-0",children:t.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3 md:gap-6",children:[t.jsx("img",{src:"/icon.svg",alt:"","aria-hidden":"true",className:"w-7 h-7 sm:w-8 sm:h-8 md:w-9 md:h-9 rounded-sm bg-black border border-matrix-primary/30 shadow-[0_0_12px_rgba(0,255,65,0.35)] shrink-0"}),t.jsxs("div",{className:"flex min-w-0 items-baseline gap-2 md:gap-3 uppercase select-none",children:[t.jsx("span",{className:"text-matrix-primary font-black text-xl sm:text-2xl md:text-3xl glow-text leading-none truncate",style:{letterSpacing:"-1px"},children:v}),w?t.jsx("span",{className:"hidden sm:inline text-matrix-primary font-extralight text-xs md:text-base truncate",style:{letterSpacing:"2px"},children:w}):null]}),t.jsx("div",{className:"hidden sm:flex items-center space-x-4 text-caption text-matrix-muted uppercase font-bold shrink-0",children:e||t.jsxs("span",{className:"flex items-center",children:[t.jsx("span",{className:"w-1.5 h-1.5 bg-matrix-primary rounded-full mr-2 animate-pulse"}),g("shell.header.link_active")]})})]}),r?t.jsx("div",{className:"w-full md:w-auto md:ml-4",children:t.jsx("div",{className:"w-full md:w-auto overflow-x-auto no-scrollbar",children:r})}):null]})}),t.jsx("main",{className:"flex-1",children:s}),t.jsxs("footer",{className:"mt-6 pt-3 border-t border-matrix-ghost flex justify-between text-caption uppercase font-bold tracking-[0.3em] text-matrix-dim shrink-0",children:[t.jsx("div",{className:"flex space-x-10 items-center",children:n||t.jsx("span",{children:g("shell.footer.help")})}),t.jsx("div",{className:"flex items-center space-x-3",children:a||t.jsx("span",{className:"font-bold",children:g("shell.footer.neural_index")})})]})]})]})}export{ne as A,se as B,ae as M};
1
+ import{m as t,r as i,d as z,_ as U,l as g}from"./main-C3QpHBOP.js";import{p as G}from"./vibeusage-api-EQ444MvB.js";import{MatrixRain as Z}from"./MatrixRain-B2DIJ0ID.js";const S={TOP_LEFT:"┌",TOP_RIGHT:"┐",BOTTOM_LEFT:"└",BOTTOM_RIGHT:"┘",HORIZONTAL:"─",VERTICAL:"│"};function ne({title:r,subtitle:e,children:s,className:n="",bodyClassName:a=""}){return t.jsxs("div",{className:`relative flex flex-col matrix-panel ${n}`,children:[t.jsxs("div",{className:"flex items-center leading-none",children:[t.jsx("span",{className:"shrink-0 text-matrix-dim",children:S.TOP_LEFT}),t.jsx("span",{className:"mx-3 shrink-0 text-heading uppercase text-matrix-primary px-2 py-1 bg-matrix-panelStrong border border-matrix-ghost",children:r}),e?t.jsxs("span",{className:"text-caption text-matrix-muted mr-2 uppercase",children:["[",e,"]"]}):null,t.jsx("span",{className:"flex-1 overflow-hidden whitespace-nowrap text-matrix-ghost",children:S.HORIZONTAL.repeat(100)}),t.jsx("span",{className:"shrink-0 text-matrix-dim",children:S.TOP_RIGHT})]}),t.jsxs("div",{className:"flex flex-1",children:[t.jsx("div",{className:"shrink-0 w-3 flex justify-center text-matrix-ghost",children:S.VERTICAL}),t.jsx("div",{className:`flex-1 min-w-0 py-5 px-4 relative z-10 ${a}`,children:s}),t.jsx("div",{className:"shrink-0 w-3 flex justify-center text-matrix-ghost",children:S.VERTICAL})]}),t.jsxs("div",{className:"flex items-center leading-none text-matrix-ghost",children:[t.jsx("span",{className:"shrink-0",children:S.BOTTOM_LEFT}),t.jsx("span",{className:"flex-1 overflow-hidden whitespace-nowrap",children:S.HORIZONTAL.repeat(100)}),t.jsx("span",{className:"shrink-0",children:S.BOTTOM_RIGHT})]})]})}const O=12e4,B=3e5,F=1e4;function W({intervalMs:r=O,maxIntervalMs:e=B,failureRetryMs:s=F,backoffStepMs:n}={}){const a=T(r,O),c=T(e,B),f=Math.max(a,c),l=Math.max(1e3,Math.round(a*.5)),o=T(n,l),d=T(s,F),v=Math.min(a,Math.max(1e3,d));return{baseIntervalMs:a,maxIntervalMs:f,backoffStepMs:o,failureRetryMs:v}}function $(r={}){const e=W(r);let s=0,n=e.baseIntervalMs;return{onSuccess:()=>{s+=1;const o=Math.max(0,s-1);return n=L(e.baseIntervalMs+e.backoffStepMs*o,e.baseIntervalMs,e.maxIntervalMs),n},onFailure:()=>(s=0,n=L(e.failureRetryMs,1e3,e.maxIntervalMs),n),onError:()=>(s=0,n=L(e.baseIntervalMs,e.baseIntervalMs,e.maxIntervalMs),n),reset:()=>(s=0,n=e.baseIntervalMs,n),getNextDelay(){return n},getConfig(){return{...e}}}}function T(r,e){const s=Number(r);return!Number.isFinite(s)||s<=0?e:Math.floor(s)}function L(r,e,s){const n=T(r,e);return n<e?e:n>s?s:n}function X({baseUrl:r,accessToken:e,intervalMs:s=O,timeoutMs:n=2500,retryDelayMs:a=300,failureThreshold:c=2}={}){const[f,l]=i.useState("unknown"),[o,d]=i.useState(!1),[v,w]=i.useState(null),[I,k]=i.useState(null),[D,H]=i.useState(null),[V,N]=i.useState(null),_=i.useRef(!1),j=i.useRef(0),M=i.useRef($({intervalMs:s})),p=i.useRef(M.current.getNextDelay()),m=i.useRef(null),C=Number.isFinite(Number(c))?Math.max(1,Math.floor(Number(c))):2;i.useEffect(()=>{M.current=$({intervalMs:s}),p.current=M.current.getNextDelay(),m.current&&m.current(p.current)},[s]);const y=i.useCallback(x=>{const u=M.current;return u&&(x==="success"?p.current=u.onSuccess():x==="failure"?p.current=u.onFailure():p.current=u.onError()),p.current},[]),E=i.useCallback(async({reschedule:x=!0}={})=>{let u="error";if(!r){l("error"),d(!1),w(null),k(new Date().toISOString()),N("Missing baseUrl"),y(u),x&&m.current&&m.current(p.current);return}try{new URL(r)}catch{l("error"),d(!1),w(null),k(new Date().toISOString()),N("Invalid baseUrl"),y(u),x&&m.current&&m.current(p.current);return}const R=await z(e);if(!R){l("unknown"),d(!1),w(null),k(new Date().toISOString()),N(null),y(u),x&&m.current&&m.current(p.current);return}if(_.current){x&&m.current&&m.current(p.current);return}_.current=!0,d(!0),N(null);try{const b=await Y({baseUrl:r,accessToken:R,timeoutMs:n,retryDelayMs:a});if(!b.ok)throw b.error;u="success",j.current=0,w(b.status??200);const h=new Date().toISOString();k(h),l("active"),N(null),H(h)}catch(b){const h=b?.status??b?.statusCode;if(w(Number.isFinite(h)?h:null),k(new Date().toISOString()),h===401||h===403)j.current=0,l("error"),N("Unauthorized");else if(typeof h=="number"&&h<500)j.current=0,l("error"),N(`HTTP ${h}`);else{u="failure",j.current+=1;const A=j.current>=C?"down":"error";l(A),N(b?.name==="AbortError"?"Timeout":b?.message||"Fetch failed")}}finally{_.current=!1,d(!1),y(u),x&&m.current&&m.current(p.current)}},[e,y,r,a,C,n]);return i.useEffect(()=>{let x=null;const u=()=>{x!=null&&window.clearTimeout(x),x=null},R=A=>{u(),!(typeof document<"u"&&document.hidden)&&(x=window.setTimeout(()=>{E({reschedule:!0})},A))};m.current=R;const b=()=>{typeof document<"u"&&document.hidden||x||E({reschedule:!0})},h=()=>{typeof document<"u"&&document.hidden?u():b()};return b(),document?.addEventListener?.("visibilitychange",h),()=>{u(),m.current=null,document?.removeEventListener?.("visibilitychange",h)}},[E]),{status:f,checking:o,httpStatus:v,lastCheckedAt:I,lastOkAt:D,error:V,refresh:E}}async function Y({baseUrl:r,accessToken:e,timeoutMs:s,retryDelayMs:n}){const a=await P({baseUrl:r,accessToken:e,timeoutMs:s});return a.ok||!q(a.error)?a:(n>0&&await J(n),P({baseUrl:r,accessToken:e,timeoutMs:s}))}async function P({baseUrl:r,accessToken:e,timeoutMs:s}){const n=new AbortController,a=window.setTimeout(()=>n.abort(),s);try{return{ok:!0,status:(await G({baseUrl:r,accessToken:e,signal:n.signal}))?.status??200}}catch(c){return{ok:!1,error:c}}finally{window.clearTimeout(a)}}function q(r){return r?r.retryable||(r?.status??r?.statusCode)>=500?!0:r?.name==="AbortError":!1}function J(r){return!r||r<=0?Promise.resolve():new Promise(e=>setTimeout(e,r))}function K({status:r="STABLE",title:e,className:s=""}){const[n,a]=i.useState("0"),c=i.useMemo(()=>typeof window>"u"?!1:U(window.location.search),[]);i.useEffect(()=>{let o;if(r==="STABLE"){if(c){a("1");return}o=window.setInterval(()=>{a(Math.random()>.5?"1":"0")},150)}return()=>window.clearInterval(o)},[c,r]);const f={STABLE:{color:"text-matrix-primary",indicator:n},UNSTABLE:{color:"text-yellow-400",indicator:"!"},LOST:{color:"text-red-500/90",indicator:"×"}},l=f[r]||f.STABLE;return t.jsx("div",{title:e,className:["matrix-header-chip matrix-header-chip--bare font-matrix transition-all duration-700",l.color,s].filter(Boolean).join(" "),children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("span",{className:"text-caption text-matrix-dim mr-1",children:"["}),t.jsx("span",{className:"text-caption w-[10px] inline-block text-center font-black",children:l.indicator}),t.jsx("span",{className:"text-caption text-matrix-dim ml-1",children:"]"})]})})}function se({baseUrl:r,accessToken:e,statusOverride:s,titleOverride:n}){const{status:a,checking:c,httpStatus:f,lastCheckedAt:l,lastOkAt:o,error:d}=X({baseUrl:r,accessToken:e}),v=i.useMemo(()=>Q(r),[r]),w=i.useMemo(()=>s||(a==="active"?"STABLE":a==="down"?"LOST":"UNSTABLE"),[a,s]),I=i.useMemo(()=>n||[`${g("backend.meta.status_label")}=${a}`,v?`${g("backend.meta.host_label")}=${v}`:null,l?`${g("backend.meta.checked_label")}=${l}`:null,o?`${g("backend.meta.ok_label")}=${o}`:null,f!=null?`${g("backend.meta.http_label")}=${f}`:null,d?`${g("backend.meta.error_label")}=${d}`:null].filter(Boolean).join(" • "),[d,v,f,l,o,a,n]);return t.jsx(K,{status:w,title:I,className:c?"opacity-80":""})}function Q(r){try{return new URL(r).host}catch{return null}}function ae({headerRight:r,headerStatus:e,children:s,footerLeft:n,footerRight:a,contentClassName:c="",rootClassName:f="",hideHeader:l=!1}){const o=g("shell.header.title"),d=String(o||"").trim().split(/\s+/),v=d[0]||o,w=d.slice(1).join(" ");return t.jsxs("div",{className:`min-h-screen bg-matrix-dark text-matrix-primary font-matrix p-4 md:p-8 flex flex-col leading-tight text-body selection:bg-matrix-primary selection:text-black overflow-hidden ${f}`,children:[t.jsx(Z,{}),t.jsx("div",{className:"matrix-scanline-overlay pointer-events-none fixed inset-0 z-50 bg-[linear-gradient(rgba(18,16,16,0)_50%,rgba(0,0,0,0.1)_50%)] bg-[length:100%_4px]"}),t.jsxs("div",{className:`relative z-10 flex flex-col min-h-screen matrix-shell-content ${c}`,children:[l?null:t.jsx("header",{className:"border-b border-matrix-primary/20 pb-3 mb-6 shrink-0",children:t.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3 md:gap-6",children:[t.jsx("img",{src:"/icon.svg",alt:"","aria-hidden":"true",className:"w-7 h-7 sm:w-8 sm:h-8 md:w-9 md:h-9 rounded-sm bg-black border border-matrix-primary/30 shadow-[0_0_12px_rgba(0,255,65,0.35)] shrink-0"}),t.jsxs("div",{className:"flex min-w-0 items-baseline gap-2 md:gap-3 uppercase select-none",children:[t.jsx("span",{className:"text-matrix-primary font-black text-xl sm:text-2xl md:text-3xl glow-text leading-none truncate",style:{letterSpacing:"-1px"},children:v}),w?t.jsx("span",{className:"hidden sm:inline text-matrix-primary font-extralight text-xs md:text-base truncate",style:{letterSpacing:"2px"},children:w}):null]}),t.jsx("div",{className:"hidden sm:flex items-center space-x-4 text-caption text-matrix-muted uppercase font-bold shrink-0",children:e||t.jsxs("span",{className:"flex items-center",children:[t.jsx("span",{className:"w-1.5 h-1.5 bg-matrix-primary rounded-full mr-2 animate-pulse"}),g("shell.header.link_active")]})})]}),r?t.jsx("div",{className:"w-full md:w-auto md:ml-4",children:t.jsx("div",{className:"w-full md:w-auto overflow-x-auto no-scrollbar",children:r})}):null]})}),t.jsx("main",{className:"flex-1",children:s}),t.jsxs("footer",{className:"mt-6 pt-3 border-t border-matrix-ghost flex justify-between text-caption uppercase font-bold tracking-[0.3em] text-matrix-dim shrink-0",children:[t.jsx("div",{className:"flex space-x-10 items-center",children:n||t.jsx("span",{children:g("shell.footer.help")})}),t.jsx("div",{className:"flex items-center space-x-3",children:a||t.jsx("span",{className:"font-bold",children:g("shell.footer.neural_index")})})]})]})]})}export{ne as A,se as B,ae as M};