/** * GMIIE author profile loader — bio, attribution badges, articles, contact CTA. */ (function () { const root = document.getElementById('author-profile-root'); if (!root) return; const authorId = root.dataset.authorId; if (!authorId) return; const nameEl = document.getElementById('ap-name'); const roleEl = document.getElementById('ap-role'); const bioEl = document.getElementById('ap-bio'); const badgeEl = document.getElementById('ap-badge'); const statsEl = document.getElementById('ap-stats'); const articlesEl = document.getElementById('ap-articles'); let contactEl = document.getElementById('ap-contact'); function badgeFor(author) { if (author.attribution_class === 'human+ai' || author.type === 'hybrid') { return 'Human + AI · Disclosed · LPS-1'; } if (author.type === 'ai' || author.attribution_class === 'ai') { return 'AI · Model Named · LPS-1'; } return 'Human · SHA-256 · LPS-1'; } function roleLabel(author) { if (author.type === 'ai') return 'AI Writer'; if (author.type === 'hybrid') return 'System Partner'; return 'Human Author'; } function esc(s) { return String(s || '') .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"'); } function renderContact(author) { if (!contactEl) { contactEl = document.createElement('div'); contactEl.id = 'ap-contact'; contactEl.className = 'ap-contact'; contactEl.style.cssText = 'margin:20px 0;padding:16px;border:1px solid var(--rule,#d4c9a8);background:var(--paper2,#f3f0e8);'; const anchor = articlesEl || bioEl; if (anchor && anchor.parentNode) anchor.parentNode.insertBefore(contactEl, anchor.nextSibling); } const status = author.email_alias_status || 'pending_dns'; const statusLabel = status === 'live' || status === 'routed_via_legacychain' ? 'Email routing LIVE' : 'Email routing pending DNS'; contactEl.innerHTML = '

Contact & respond

' + '

' + 'Correspondence routes through LegacyChain intake. Machine agents use x402 on Apostle Chain (7332).' + '

' + '

' + '' + esc(statusLabel) + '' + (author.email_alias ? ' · ' + esc(author.email_alias) : '') + '

' + '
' + 'Email author' + 'Verify provenance' + (author.x402_rate ? 'x402 ' + esc(author.x402_rate) + ' ATP' : '') + '
'; } fetch('/api/authors/' + encodeURIComponent(authorId), { cache: 'no-store' }) .then(function (r) { return r.ok ? r.json() : null; }) .then(function (data) { if (!data || !data.author) { if (bioEl) bioEl.textContent = 'Author profile unavailable — check /api/authors'; return; } const a = data.author; if (nameEl) nameEl.textContent = a.name; if (roleEl) { roleEl.textContent = roleLabel(a) + (a.ai_model ? ' · ' + a.ai_model : ''); } if (bioEl) bioEl.textContent = a.bio || ''; if (badgeEl) badgeEl.textContent = badgeFor(a); if (statsEl) { const desks = (a.desks || []).slice(0, 4).join(', '); statsEl.innerHTML = '' + (a.follower_count || 0) + ' followers (beta)' + (desks ? ' · Desks: ' + esc(desks) : '') + (a.lps1_status ? ' · LPS-1: ' + esc(a.lps1_status) : ''); } renderContact(a); if (articlesEl && data.recent_articles) { articlesEl.innerHTML = data.recent_articles .slice(0, 8) .map(function (art) { const verifyUrl = '/api/articles/' + encodeURIComponent(art.id) + '/verify'; return ( '
' + '

' + esc(art.title) + '

' + '

' + esc((art.summary || '').slice(0, 280)) + '

' + '' + '
' ); }) .join('') || '

No recent articles in Pulse feed.

'; } }) .catch(function () { if (bioEl) bioEl.textContent = 'Could not load author profile.'; }); })();