/** You: captures and their seals, followed situations, holograms, settings. */ import { icon, FAMILY_ICON } from './icons.js'; import { $, $$, esc, ago, haptic, store, applyMotionPref } from './dom.js'; import { all, get } from '../capture/db.js'; import { deviceKey } from '../capture/provenance.js'; export function createYou( view, { bindScroll, getSituations, onOpenSituation, onVerify, onCredits }, ) { let urls = []; view.addEventListener( 'scroll', () => view.classList.toggle('is-scrolled', view.scrollTop > 44), { passive: true }, ); bindScroll(view); async function render() { urls.forEach((u) => URL.revokeObjectURL(u)); urls = []; const [captures, key, sits] = await Promise.all([ all('captures').catch(() => []), deviceKey().catch(() => null), getSituations().catch(() => []), ]); captures.sort((a, b) => b.seq - a.seq); const followed = store.get('followed') || []; const fol = followed .map((id) => sits.find((s) => String(s.id) === id)) .filter(Boolean); const contacts = followed.filter((id) => id.startsWith('contact:')); const thumbs = await Promise.all( captures.slice(0, 30).map(async (c) => { const m = await get('media', c.id).catch(() => null); if (!m?.blob) return ''; const u = URL.createObjectURL(m.blob); urls.push(u); return u; }), ); const q = store.get('quality'); const rm = store.get('reduceMotion'); const radius = store.get('alertRadiusKm'); view.innerHTML = `

You

${icon('you')}
This device ${key ? `Signing key ${esc(key.keyId)} · P-256 · ${key.extractable ? 'extractable' : 'non-extractable'}` : 'Signing key unavailable (needs a secure context)'} ${captures.length} sealed capture${captures.length === 1 ? '' : 's'} · ${followed.length} followed
Captures tap to verify
${ captures.length ? `
${captures .slice(0, 30) .map( (c, i) => ``, ) .join('')}
` : `
${icon('seal')}
No sealed captures yet.
Open Capture → Witness and tap the shutter.
` }
Following
${ fol.length || contacts.length ? `
${fol .map( (s) => ``, ) .join( '', )}${contacts.map((c) => `
${icon('scope')}${esc(c.slice(8))}Contact
`).join('')}
` : '
Follow a situation from its brief and it appears here and in the tab-bar accessory.
' }
Holograms Concept
${icon('cube')}
Leave something in a placePin a 3D note to a spot on Earth for people who visit with Look. Concept placeholder in this prototype.
Settings
${icon('globe')}Globe qualityApplies on next launch
${['auto', 'high', 'battery'].map((v) => ``).join('')}
${icon('sparkles')}Reduce motionCross-fades instead of flights and morphs
${['system', 'on', 'off'].map((v) => ``).join('')}
${icon('pin')}Alert radiusSituations inside it ping you${radius.toLocaleString()} km
${icon('hand')}HapticsRibbon detents and seals only
About
${icon('lock')}ProvenancePrototype uses WebCrypto ECDSA P-256 with a non-extractable key in IndexedDB. Native builds use the Secure Enclave and C2PA.

God’s Eye mobile prototype. The window through which you see the world, and the eye through which the world sees itself.

`; $$('.segmented', view).forEach(placeThumb); } function placeThumb(seg) { const b = $('[aria-pressed="true"]', seg) || $('button', seg); const th = $('.seg-thumb', seg); if (!b || !th) return; th.style.width = `${b.offsetWidth}px`; th.style.transform = `translateX(${b.offsetLeft}px)`; } view.addEventListener('click', async (e) => { const cap = e.target.closest('[data-cap]'); if (cap) { const c = (await all('captures')).find((x) => x.id === cap.dataset.cap); if (c) onVerify(c); return; } const sit = e.target.closest('[data-sit]'); if (sit) { const s = (await getSituations()).find( (x) => String(x.id) === sit.dataset.sit, ); if (s) onOpenSituation(s); return; } const segBtn = e.target.closest('.segmented[data-set] button'); if (segBtn) { const seg = segBtn.parentElement; $$('button', seg).forEach((b) => b.setAttribute('aria-pressed', String(b === segBtn)), ); placeThumb(seg); store.set(seg.dataset.set, segBtn.dataset.v); if (seg.dataset.set === 'reduceMotion') applyMotionPref(); haptic('tick'); return; } const sw = e.target.closest('[data-switch]'); if (sw) { const on = sw.getAttribute('aria-checked') !== 'true'; sw.setAttribute('aria-checked', String(on)); store.set(sw.dataset.switch, on); haptic('tick'); return; } if (e.target.closest('[data-act="credits"]')) onCredits(); }); view.addEventListener('input', (e) => { if (!e.target.matches('.slider')) return; const v = Number(e.target.value); e.target.style.setProperty('--p', `${((v - 25) / 1975) * 100}%`); $('[data-radius]', view).textContent = `${v.toLocaleString()} km`; }); view.addEventListener('change', (e) => { if (e.target.matches('.slider')) store.set('alertRadiusKm', Number(e.target.value)); }); new ResizeObserver(() => $$('.segmented', view).forEach(placeThumb)).observe( view, ); return { render }; }