Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435// Tiny shared helpers used across the UI modules.
// HTML-escape for string interpolation into innerHTML.export const esc = (s) => String(s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
// "just now" / "12s ago" / "3m ago" / "5h ago" / "2d ago" / "never".export function relTime(ms) { if (!ms) return 'never'; const s = Math.max(0, Math.floor((Date.now() - ms) / 1000)); if (s < 10) return 'just now'; if (s < 60) return `${s}s ago`; const m = Math.floor(s / 60); if (m < 60) return `${m}m ago`; const h = Math.floor(m / 60); if (h < 24) return `${h}h ago`; return `${Math.floor(h / 24)}d ago`;}
// Clock-style "07:31 PM" for a timestamp.export const fmtTime = (ms) => new Date(ms).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
// Truncate long text with an ellipsis.export const clip = (s, n = 240) => (s.length > n ? s.slice(0, n - 1) + '…' : s);
// First 8 chars of a plc DID, for when we can't resolve a handle.export const shortDid = (did) => did.replace(/^did:plc:/, '').slice(0, 8);
// at://did/app.bsky.feed.post/rkey -> https://bsky.app/profile/did/post/rkeyexport function postUrl(atUri) { const m = atUri?.match(/^at:\/\/([^/]+)\/app\.bsky\.feed\.post\/(.+)$/); return m ? `https://bsky.app/profile/${m[1]}/post/${m[2]}` : null;}