@phnx-labs/artifacts-cli 0.18.4 → 0.19.0

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.
@@ -0,0 +1,698 @@
1
+ import { Marked } from 'marked';
2
+ import { escapeHtml } from './html.js';
3
+ /**
4
+ * Media and social components: a post, a video or reel, a gallery, an event
5
+ * agenda and a link card. Authors supply JSON data; the renderer owns the
6
+ * markup, the palette and the lightbox. Every field is checked strictly, the
7
+ * same contract as the explorer: an unknown or misspelled field fails instead
8
+ * of silently dropping content.
9
+ */
10
+ export const CARD_NAMES = ['post', 'video', 'gallery', 'events', 'link'];
11
+ export function isCardFence(info) {
12
+ return CARD_NAMES.includes(info.trim());
13
+ }
14
+ export const POST_PLATFORMS = ['x', 'threads', 'bluesky', 'linkedin', 'reddit', 'instagram'];
15
+ const ASPECTS = ['16:9', '9:16', '1:1', '4:3'];
16
+ const EVENT_STATUSES = ['confirmed', 'tentative', 'cancelled'];
17
+ const fail = (message) => { throw new Error(message); };
18
+ const isObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
19
+ function record(value, fields, path, required = []) {
20
+ if (!isObject(value))
21
+ fail(`${path} must be an object`);
22
+ const object = value;
23
+ for (const key of Object.keys(object))
24
+ if (!Object.hasOwn(fields, key))
25
+ fail(`${path}.${key} is not supported`);
26
+ for (const key of required)
27
+ if (object[key] === undefined)
28
+ fail(`${path}.${key} is required`);
29
+ for (const [key, check] of Object.entries(fields))
30
+ if (object[key] !== undefined)
31
+ check(object[key], `${path}.${key}`);
32
+ }
33
+ const text = (value, path) => { if (typeof value !== 'string' || !value.trim())
34
+ fail(`${path} must be non-empty text`); };
35
+ const flag = (value, path) => { if (typeof value !== 'boolean')
36
+ fail(`${path} must be true or false`); };
37
+ const count = (value, path) => { if (!Number.isFinite(value) || value < 0)
38
+ fail(`${path} must be a non-negative number`); };
39
+ const oneOf = (values) => (value, path) => {
40
+ if (!values.includes(value))
41
+ fail(`${path} must be one of ${values.map((v) => JSON.stringify(v)).join(', ')}`);
42
+ };
43
+ const link = (value, path) => {
44
+ text(value, path);
45
+ let url;
46
+ try {
47
+ url = new URL(value);
48
+ }
49
+ catch {
50
+ return fail(`${path} must be an https or http URL`);
51
+ }
52
+ if (!['https:', 'http:'].includes(url.protocol))
53
+ fail(`${path} must be an https or http URL`);
54
+ };
55
+ /** A media source is an http(s) URL, an image data URI, or a path beside the Markdown that render inlines. */
56
+ const source = (value, path) => {
57
+ text(value, path);
58
+ if (/^data:(?:image|video)\//i.test(value))
59
+ return;
60
+ if (/^[a-z][a-z0-9+.-]*:/i.test(value) || value.startsWith('//'))
61
+ return link(value, path);
62
+ };
63
+ const list = (item, max) => (value, path) => {
64
+ if (!Array.isArray(value) || !value.length)
65
+ fail(`${path} must be a non-empty array`);
66
+ if (value.length > max)
67
+ fail(`${path} supports at most ${max} entries`);
68
+ value.forEach((entry, index) => item(entry, `${path}[${index}]`));
69
+ };
70
+ const metrics = (names) => (value, path) => record(value, Object.fromEntries(names.map((name) => [name, count])), path);
71
+ const author = (value, path) => record(value, { name: text, handle: text, avatar: source, verified: flag, headline: text }, path, ['name']);
72
+ const media = (value, path) => record(value, { src: source, alt: text, type: oneOf(['image', 'video']), poster: source, caption: text }, path, ['src']);
73
+ const SCHEMAS = {
74
+ post: (value, path) => {
75
+ record(value, {
76
+ platform: oneOf(POST_PLATFORMS), author, text, title: text, community: text, flair: text,
77
+ media: list(media, 10), time: text, url: link,
78
+ metrics: metrics(['replies', 'reposts', 'likes', 'views', 'bookmarks', 'comments', 'score', 'shares']),
79
+ }, path, ['platform', 'author']);
80
+ if (value.text === undefined && value.media === undefined && value.title === undefined)
81
+ fail(`${path} needs text, title or media`);
82
+ if (value.platform !== 'instagram' && value.media?.length > 4)
83
+ fail(`${path}.media supports at most 4 entries on ${value.platform}; use a gallery for more`);
84
+ },
85
+ video: (value, path) => record(value, {
86
+ src: source, title: text, caption: text, poster: source, aspect: oneOf(ASPECTS), author,
87
+ metrics: metrics(['likes', 'comments', 'shares', 'views']), duration: text, url: link, loop: flag, muted: flag,
88
+ }, path, ['src']),
89
+ gallery: (value, path) => record(value, {
90
+ title: text, caption: text, layout: oneOf(['grid', 'masonry', 'carousel']), columns: oneOf([2, 3, 4]), items: list(media, 60),
91
+ }, path, ['items']),
92
+ events: (value, path) => record(value, {
93
+ title: text, timezone: text,
94
+ events: list((event, at) => {
95
+ record(event, {
96
+ title: text, start: dateTime, end: dateTime, location: text, url: link, description: text,
97
+ status: oneOf(EVENT_STATUSES), attendees: list(text, 50), calendar: text,
98
+ }, at, ['title', 'start']);
99
+ if (event.end) {
100
+ const [start, end] = [parseDate(event.start), parseDate(event.end)];
101
+ const timed = start.minutes !== undefined && end.minutes !== undefined;
102
+ if (timed ? end.key < start.key : end.dateKey < start.dateKey)
103
+ fail(`${at}.end must not be before start`);
104
+ }
105
+ }, 200),
106
+ }, path, ['events']),
107
+ link: (value, path) => record(value, {
108
+ url: link, title: text, description: text, image: source, site: text, layout: oneOf(['compact', 'large']),
109
+ }, path, ['url', 'title']),
110
+ };
111
+ const EXAMPLES = {
112
+ post: {
113
+ platform: 'x',
114
+ author: { name: 'Ada Example', handle: 'ada', verified: true },
115
+ text: 'Shipped the new renderer today. Pages went from 25k tokens to 2.4k. #buildinpublic',
116
+ media: [{ src: 'https://picsum.photos/seed/renderer/1200/675', alt: 'Before and after token counts' }],
117
+ time: '2026-11-24T09:41',
118
+ metrics: { replies: 18, reposts: 42, likes: 1280, views: 48200 },
119
+ url: 'https://x.com/ada/status/1',
120
+ },
121
+ video: { src: 'demo.mp4', poster: 'demo.jpg', title: 'Checkout flow, end to end', caption: 'Recorded on the staging build.', aspect: '16:9', duration: '0:42' },
122
+ gallery: {
123
+ title: 'Onboarding screens', layout: 'grid', columns: 3,
124
+ items: [
125
+ { src: 'screens/welcome.png', alt: 'Welcome', caption: 'Welcome' },
126
+ { src: 'screens/connect.png', alt: 'Connect a repository', caption: 'Connect' },
127
+ { src: 'screens/done.png', alt: 'Ready to run', caption: 'Done' },
128
+ ],
129
+ },
130
+ events: {
131
+ title: 'Launch week', timezone: 'PT',
132
+ events: [
133
+ { title: 'Design review', start: '2026-11-24T09:30', end: '2026-11-24T10:00', location: 'Zoom', attendees: ['Ada', 'Lin'] },
134
+ { title: 'Launch', start: '2026-11-25', status: 'confirmed', calendar: 'Marketing' },
135
+ ],
136
+ },
137
+ link: { url: 'https://artifacts-cli.sh', title: 'Artifacts', description: 'The chat ends. The artifact stays.', site: 'artifacts-cli.sh' },
138
+ };
139
+ export const CARD_COMPONENTS = [
140
+ {
141
+ name: 'post',
142
+ purpose: 'A social post as it appears on X, Threads, Bluesky, LinkedIn, Reddit or Instagram: author, text, media and engagement. Use for a draft to review, a post being cited, or results of a launch.',
143
+ fields: {
144
+ platform: `Required: ${POST_PLATFORMS.join(', ')}. Sets the layout; colors stay the artifact palette.`,
145
+ author: 'Required {name, handle?, avatar?, verified?, headline?}. headline shows on LinkedIn. avatar is a URL or a path beside the Markdown; initials stand in without one.',
146
+ text: 'Post body. Line breaks are kept; URLs, @handles and #tags are highlighted.',
147
+ 'title, community, flair': 'Reddit: the post title, r/community and flair.',
148
+ media: 'Up to 4 {src, alt?, type?: image|video, poster?} (Instagram: 10, shown as a swipeable carousel). Images open in a lightbox.',
149
+ time: 'ISO date-time such as 2026-11-24T09:41 (shown as written, no time-zone shift) or display text such as "2h".',
150
+ metrics: 'Counts: replies, reposts, likes, views, bookmarks, comments, score, shares. Shown compact (48.2K).',
151
+ url: 'Link to the live post.',
152
+ },
153
+ },
154
+ {
155
+ name: 'video',
156
+ purpose: 'A playable video, or a vertical reel with author, caption and engagement over it. YouTube links render as a thumbnail that opens the video.',
157
+ fields: {
158
+ src: 'Required. An http(s) video URL, a YouTube link, or a file beside the Markdown (inlined, so keep it small).',
159
+ aspect: '16:9 (default), 9:16, 1:1 or 4:3. 9:16 and YouTube Shorts render as a reel.',
160
+ 'title, caption, duration': 'Text under the player; on a reel the caption sits over the video.',
161
+ poster: 'Still frame shown before playback.',
162
+ 'author, metrics': 'Reel overlay: {name, handle?, avatar?, verified?} and likes, comments, shares, views.',
163
+ 'url, loop, muted': 'Link to the original; loop and mute playback.',
164
+ },
165
+ },
166
+ {
167
+ name: 'gallery',
168
+ purpose: 'Images or clips in a grid, masonry columns or a swipeable carousel. Click any item to open it full screen; arrow keys move between items.',
169
+ fields: {
170
+ items: 'Required, up to 60 {src, alt?, caption?, type?: image|video, poster?}. Give alt text for every image a reader needs.',
171
+ layout: 'grid (default, square crops), masonry (natural heights) or carousel.',
172
+ columns: '2, 3 (default) or 4. Phones show two.',
173
+ 'title, caption': 'Optional heading and note.',
174
+ },
175
+ },
176
+ {
177
+ name: 'events',
178
+ purpose: 'A calendar agenda grouped by day: times, durations, location, attendees, status and join links.',
179
+ fields: {
180
+ events: 'Required, up to 200 {title, start, end?, location?, url?, description?, status?, attendees?, calendar?}. Sorted by start.',
181
+ 'start, end': 'ISO date (all day) or date-time, shown as written. end must not precede start.',
182
+ status: 'confirmed (default), tentative (dashed) or cancelled (struck through).',
183
+ 'url, attendees': 'Join or details link; attendee names shown as initials.',
184
+ 'title, timezone': 'Optional heading and a time-zone label such as PT.',
185
+ },
186
+ },
187
+ {
188
+ name: 'link',
189
+ purpose: 'A rich preview for one link: site, title, description and image. Use it for a source worth reading, not for every citation.',
190
+ fields: {
191
+ 'url, title': 'Required.',
192
+ 'description, image, site': 'Optional preview text, thumbnail and site name (defaults to the host).',
193
+ layout: 'compact (default, thumbnail beside the text) or large (image above).',
194
+ },
195
+ },
196
+ ].map((component) => ({ ...component, format: 'JSON', example: JSON.stringify(EXAMPLES[component.name], null, 2) }));
197
+ export function parseCard(name, raw) {
198
+ try {
199
+ if (raw.length > 200_000)
200
+ throw new Error(`${name} exceeds 200 KB`);
201
+ let data;
202
+ try {
203
+ data = JSON.parse(raw);
204
+ }
205
+ catch (error) {
206
+ throw new Error(`not valid JSON (${error instanceof Error ? error.message : String(error)})`);
207
+ }
208
+ SCHEMAS[name](data, name);
209
+ return { data };
210
+ }
211
+ catch (error) {
212
+ return { error: error instanceof Error ? error.message : String(error) };
213
+ }
214
+ }
215
+ /** Same lexer as validation, so fenced examples inside other fences are never treated as components. */
216
+ export function cardFences(markdown) {
217
+ const found = [];
218
+ const lexer = new Marked();
219
+ lexer.walkTokens(lexer.lexer(markdown), (token) => {
220
+ if (token.type === 'code' && isCardFence(token.lang ?? ''))
221
+ found.push({ name: token.lang.trim(), raw: token.raw, text: token.text });
222
+ });
223
+ return found;
224
+ }
225
+ export function renderCard(name, raw) {
226
+ const { data, error } = parseCard(name, raw);
227
+ if (!data)
228
+ return `<p class="artifact-callout artifact-callout-danger">Invalid ${name}: ${escapeHtml(error ?? '')}</p>`;
229
+ if (name === 'post')
230
+ return renderPost(data);
231
+ if (name === 'video')
232
+ return renderVideo(data);
233
+ if (name === 'gallery')
234
+ return renderGallery(data);
235
+ if (name === 'events')
236
+ return renderEvents(data);
237
+ return renderLink(data);
238
+ }
239
+ // ---------------------------------------------------------------- formatting
240
+ const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
241
+ const WEEKDAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
242
+ /** Wall-clock parse: the time is shown exactly as written, never shifted to the renderer's zone. */
243
+ function parseDate(value) {
244
+ const match = /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/.exec(value.trim());
245
+ if (!match)
246
+ return undefined;
247
+ const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
248
+ const probe = new Date(Date.UTC(year, month - 1, day));
249
+ if (probe.getUTCMonth() !== month - 1 || probe.getUTCDate() !== day)
250
+ return undefined;
251
+ const minutes = match[4] === undefined ? undefined : Number(match[4]) * 60 + Number(match[5]);
252
+ if (minutes !== undefined && (Number(match[4]) > 23 || Number(match[5]) > 59))
253
+ return undefined;
254
+ const dateKey = `${match[1]}-${match[2]}-${match[3]}`;
255
+ return { year, month, day, minutes, dateKey, key: `${dateKey}T${String(minutes ?? -1).padStart(4, '0')}` };
256
+ }
257
+ const dateTime = (value, path) => {
258
+ text(value, path);
259
+ if (!parseDate(value))
260
+ fail(`${path} must be an ISO date (2026-11-24) or date-time (2026-11-24T09:30)`);
261
+ };
262
+ function clock(minutes) {
263
+ const hours = Math.floor(minutes / 60);
264
+ return `${hours % 12 || 12}:${String(minutes % 60).padStart(2, '0')} ${hours < 12 ? 'AM' : 'PM'}`;
265
+ }
266
+ function until(start, end) {
267
+ return `until ${MONTHS[end.month - 1]} ${end.day}${end.year === start.year ? '' : `, ${end.year}`}`;
268
+ }
269
+ function displayTime(value) {
270
+ const date = parseDate(value);
271
+ if (!date)
272
+ return value;
273
+ const day = `${MONTHS[date.month - 1]} ${date.day}, ${date.year}`;
274
+ return date.minutes === undefined ? day : `${clock(date.minutes)} · ${day}`;
275
+ }
276
+ export function compactCount(value) {
277
+ if (value < 1000)
278
+ return String(Math.round(value));
279
+ const [divisor, suffix] = value < 1e6 ? [1e3, 'K'] : value < 1e9 ? [1e6, 'M'] : [1e9, 'B'];
280
+ const scaled = value / divisor;
281
+ return `${scaled >= 100 ? Math.round(scaled) : Number(scaled.toFixed(1))}${suffix}`;
282
+ }
283
+ function initials(name) {
284
+ return name.trim().split(/\s+/).slice(0, 2).map((part) => [...part][0]?.toUpperCase() ?? '').join('');
285
+ }
286
+ function avatar(person, size = 'md') {
287
+ return person.avatar
288
+ ? `<img class="card-avatar card-avatar-${size}" src="${escapeHtml(person.avatar)}" alt="" loading="lazy">`
289
+ : `<span class="card-avatar card-avatar-${size} card-avatar-initials" aria-hidden="true">${escapeHtml(initials(person.name))}</span>`;
290
+ }
291
+ function hostOf(url) {
292
+ try {
293
+ return new URL(url).hostname.replace(/^www\./, '');
294
+ }
295
+ catch {
296
+ return url;
297
+ }
298
+ }
299
+ /** Plain text in, escaped HTML out: URLs become links, @handles and #tags are highlighted. */
300
+ function richText(value) {
301
+ const pattern = /(https?:\/\/[^\s<]+[^\s<.,:;"')\]!?])|(^|[^\w])([@#][\w]+)/g;
302
+ let html = '';
303
+ let last = 0;
304
+ for (const match of value.matchAll(pattern)) {
305
+ const index = match.index ?? 0;
306
+ if (match[1]) {
307
+ html += escapeHtml(value.slice(last, index)) + `<a class="card-link" href="${escapeHtml(match[1])}">${escapeHtml(match[1].replace(/^https?:\/\/(www\.)?/, ''))}</a>`;
308
+ }
309
+ else {
310
+ const start = index + match[2].length;
311
+ html += escapeHtml(value.slice(last, start)) + `<span class="card-entity">${escapeHtml(match[3])}</span>`;
312
+ }
313
+ last = index + match[0].length;
314
+ }
315
+ return (html + escapeHtml(value.slice(last))).replace(/\r?\n/g, '<br>');
316
+ }
317
+ // ------------------------------------------------------------------- icons
318
+ const icon = (body, label = '') => `<svg class="card-icon" viewBox="0 0 24 24" ${label ? `role="img" aria-label="${escapeHtml(label)}"` : 'aria-hidden="true"'}><g fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">${body}</g></svg>`;
319
+ const ICONS = {
320
+ replies: icon('<path d="M4 5.5h16v10H9.5L5 19.5v-4H4z"/>'),
321
+ comments: icon('<path d="M4 5.5h16v10H9.5L5 19.5v-4H4z"/>'),
322
+ reposts: icon('<path d="M7 7h10v5"/><path d="m14.5 9.5 2.5 2.5 2.5-2.5"/><path d="M17 17H7v-5"/><path d="M9.5 14.5 7 12l-2.5 2.5"/>'),
323
+ shares: icon('<path d="M21 4 10.5 13.5"/><path d="M21 4l-6.5 16-4-6.5L4 9.5z"/>'),
324
+ likes: icon('<path d="M12 20s-7.5-4.6-7.5-10.2A4.3 4.3 0 0 1 12 7.2a4.3 4.3 0 0 1 7.5 2.6C19.5 15.4 12 20 12 20z"/>'),
325
+ views: icon('<path d="M5 20V12"/><path d="M10 20V5"/><path d="M15 20v-9"/><path d="M20 20V8"/>'),
326
+ bookmarks: icon('<path d="M6.5 4h11v16l-5.5-4-5.5 4z"/>'),
327
+ score: icon('<path d="m12 4 7 8h-4v8H9v-8H5z"/>'),
328
+ play: '<svg class="card-play" viewBox="0 0 64 64" aria-hidden="true"><circle cx="32" cy="32" r="30" fill="#000" fill-opacity=".55"/><path d="M26 20v24l19-12z" fill="#fff"/></svg>',
329
+ pin: icon('<path d="M12 21s-6.5-6-6.5-11a6.5 6.5 0 0 1 13 0c0 5-6.5 11-6.5 11z"/><circle cx="12" cy="10" r="2.3"/>'),
330
+ external: icon('<path d="M14 4h6v6"/><path d="M20 4l-9 9"/><path d="M18 14v6H4V6h6"/>'),
331
+ };
332
+ const VERIFIED = '<svg class="card-verified" viewBox="0 0 24 24" role="img" aria-label="Verified"><circle cx="12" cy="12" r="10" fill="var(--accent)"/><path d="m7.5 12.3 3 3 6-6.3" fill="none" stroke="var(--surface)" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
333
+ const PLATFORM_LABEL = { x: 'X', threads: 'Threads', bluesky: 'Bluesky', linkedin: 'LinkedIn', reddit: 'Reddit', instagram: 'Instagram' };
334
+ // Monochrome marks in the reader's text color; the artifact palette, not brand colors, owns the page.
335
+ const PLATFORM_MARK = {
336
+ x: '<path fill="currentColor" d="M18.24 2.25h3.31l-7.23 8.26 8.5 11.24h-6.65l-5.21-6.82-5.97 6.82H1.68l7.73-8.84L1.25 2.25h6.83l4.71 6.23zm-1.16 17.52h1.83L7.08 4.13H5.12z"/>',
337
+ threads: '<path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" d="M16.5 11.3c-.6-3-3.1-4.1-5.4-3.6-2.4.5-3.3 2.6-2.6 4.2.8 1.8 4 2 5.4.5 1.6-1.8 1.2-5.2-1.6-6.6C9 4.4 4 6.3 4 12.2 4 17 7.4 20 12 20c3.8 0 7-2.2 7-5.5 0-2.4-1.9-3.7-4.2-3.7"/>',
338
+ bluesky: '<path fill="currentColor" d="M6.3 4.2C8.6 6 11.1 9.5 12 11.4c.9-1.9 3.4-5.4 5.7-7.2 1.7-1.2 4.3-2.2 4.3.8 0 .6-.3 5-.5 5.7-.7 2.5-3.3 3.1-5.6 2.7 4 .7 5 3 2.8 5.2-4.2 4.3-6-1.1-6.5-2.5l-.2-.5-.2.5c-.5 1.4-2.3 6.8-6.5 2.5-2.2-2.2-1.2-4.5 2.8-5.2-2.3.4-4.9-.2-5.6-2.7C2.3 10 2 5.6 2 5c0-3 2.6-2 4.3-.8z"/>',
339
+ linkedin: '<path fill="currentColor" d="M20.45 20.45h-3.56v-5.57c0-1.33-.02-3.04-1.85-3.04-1.85 0-2.14 1.45-2.14 2.94v5.67H9.35V9h3.41v1.56h.05c.48-.9 1.64-1.85 3.37-1.85 3.6 0 4.27 2.37 4.27 5.46v6.28zM5.34 7.43a2.06 2.06 0 1 1 0-4.13 2.06 2.06 0 0 1 0 4.13zM7.12 20.45H3.56V9h3.56zM22.22 0H1.77C.79 0 0 .77 0 1.73v20.54C0 23.23.79 24 1.77 24h20.45c.98 0 1.78-.77 1.78-1.73V1.73C24 .77 23.2 0 22.22 0z"/>',
340
+ reddit: '<g fill="none" stroke="currentColor" stroke-width="1.8"><ellipse cx="12" cy="14.5" rx="8" ry="5.5"/><circle cx="18.5" cy="5" r="1.6"/><path d="M12 9l1.3-5.2 5.2 1.2"/></g><circle cx="9" cy="14" r="1.2" fill="currentColor"/><circle cx="15" cy="14" r="1.2" fill="currentColor"/>',
341
+ instagram: '<g fill="none" stroke="currentColor" stroke-width="1.9"><rect x="3" y="3" width="18" height="18" rx="5"/><circle cx="12" cy="12" r="4.2"/></g><circle cx="17.4" cy="6.6" r="1.2" fill="currentColor"/>',
342
+ };
343
+ function platformMark(platform) {
344
+ return `<svg class="card-platform" viewBox="0 0 24 24" role="img" aria-label="${PLATFORM_LABEL[platform]}">${PLATFORM_MARK[platform]}</svg>`;
345
+ }
346
+ function metricRow(values, order, className = 'post-metrics') {
347
+ const shown = order.filter((name) => values[name] !== undefined);
348
+ if (!shown.length)
349
+ return '';
350
+ return `<ul class="${className}">${shown.map((name) => `<li title="${escapeHtml(`${values[name].toLocaleString('en-US')} ${name}`)}">${ICONS[name] ?? ''}<span>${compactCount(values[name])}</span><span class="card-sr"> ${escapeHtml(name)}</span></li>`).join('')}</ul>`;
351
+ }
352
+ // ------------------------------------------------------------------- media
353
+ const YOUTUBE = /^https?:\/\/(?:www\.|m\.)?(?:youtube\.com\/(?:watch\?(?:[^#]*&)?v=|shorts\/|embed\/|live\/)|youtu\.be\/)([\w-]{11})/;
354
+ function mediaElement(item, className) {
355
+ if (item.type === 'video') {
356
+ return `<video class="${className}" src="${escapeHtml(item.src)}"${item.poster ? ` poster="${escapeHtml(item.poster)}"` : ''} controls playsinline preload="metadata"${item.alt ? ` aria-label="${escapeHtml(item.alt)}"` : ''}></video>`;
357
+ }
358
+ return `<img class="${className}" src="${escapeHtml(item.src)}" alt="${escapeHtml(item.alt ?? '')}" loading="lazy">`;
359
+ }
360
+ function postMedia(items, platform) {
361
+ if (!items?.length)
362
+ return '';
363
+ if (platform === 'instagram') {
364
+ return `<div class="post-carousel">${items.map((item) => `<div class="post-slide">${mediaElement(item, 'card-zoom')}</div>`).join('')}</div>`
365
+ + (items.length > 1 ? `<div class="post-dots" aria-hidden="true">${items.map(() => '<span></span>').join('')}</div>` : '');
366
+ }
367
+ return `<div class="post-media post-media-${items.length}">${items.map((item) => `<div class="post-tile">${mediaElement(item, 'card-zoom')}</div>`).join('')}</div>`;
368
+ }
369
+ // ------------------------------------------------------------------- renderers
370
+ function renderPost(post) {
371
+ const { author: person, platform } = post;
372
+ const name = `<span class="post-name">${escapeHtml(person.name)}${person.verified ? VERIFIED : ''}</span>`;
373
+ const handle = person.handle ? escapeHtml(platform === 'reddit' ? `u/${person.handle.replace(/^u\//, '')}` : `@${person.handle.replace(/^@/, '')}`) : '';
374
+ const time = post.time ? escapeHtml(displayTime(post.time)) : '';
375
+ const metric = post.metrics ?? {};
376
+ const body = post.text ? `<p class="post-text">${richText(post.text)}</p>` : '';
377
+ const open = post.url ? `<a class="card-link post-open" href="${escapeHtml(post.url)}">View on ${PLATFORM_LABEL[platform]}</a>` : '';
378
+ const label = `${PLATFORM_LABEL[platform]} post by ${person.name}`;
379
+ if (platform === 'reddit') {
380
+ const community = post.community ? `r/${post.community.replace(/^r\//, '')}` : '';
381
+ const meta = [community && `<strong>${escapeHtml(community)}</strong>`, handle, time].filter(Boolean).join('<span class="card-dot">·</span>');
382
+ return `<article class="artifact-post post-reddit" aria-label="${escapeHtml(label)}"><header class="post-head">${avatar(person, 'sm')}<span class="post-meta">${meta}</span>${platformMark(platform)}</header>`
383
+ + `${post.flair ? `<span class="post-flair">${escapeHtml(post.flair)}</span>` : ''}${post.title ? `<h4 class="post-title">${escapeHtml(post.title)}</h4>` : ''}${body}${postMedia(post.media, platform)}`
384
+ + `<footer class="post-foot">${metricRow(metric, ['score', 'comments', 'shares'], 'post-metrics post-metrics-pills')}${open}</footer></article>`;
385
+ }
386
+ if (platform === 'instagram') {
387
+ const caption = post.text ? `<p class="post-text"><strong>${escapeHtml(person.handle ?? person.name)}</strong> ${richText(post.text)}</p>` : '';
388
+ return `<article class="artifact-post post-instagram" aria-label="${escapeHtml(label)}"><header class="post-head">${avatar(person, 'sm')}<span class="post-ident"><span class="post-name">${escapeHtml(person.handle?.replace(/^@/, '') ?? person.name)}${person.verified ? VERIFIED : ''}</span>${time ? `<span class="post-sub">${time}</span>` : ''}</span>${platformMark(platform)}</header>`
389
+ + `${postMedia(post.media, platform)}<footer class="post-foot">${metricRow(metric, ['likes', 'comments', 'shares', 'views'])}${open}</footer>${caption}</article>`;
390
+ }
391
+ if (platform === 'linkedin') {
392
+ const sub = [person.headline, time].filter(Boolean).map((part) => escapeHtml(part === time ? displayTime(post.time) : part)).join('<br>');
393
+ return `<article class="artifact-post post-linkedin" aria-label="${escapeHtml(label)}"><header class="post-head">${avatar(person)}<span class="post-ident">${name}${sub ? `<span class="post-sub">${sub}</span>` : ''}</span>${platformMark(platform)}</header>`
394
+ + `${body}${postMedia(post.media, platform)}<footer class="post-foot">${metricRow(metric, ['likes', 'comments', 'reposts', 'views'])}${open}</footer></article>`;
395
+ }
396
+ const sub = [handle, time].filter(Boolean).join('<span class="card-dot">·</span>');
397
+ return `<article class="artifact-post post-${platform}" aria-label="${escapeHtml(label)}"><header class="post-head">${avatar(person)}<span class="post-ident">${name}${sub ? `<span class="post-sub">${sub}</span>` : ''}</span>${platformMark(platform)}</header>`
398
+ + `${body}${postMedia(post.media, platform)}<footer class="post-foot">${metricRow(metric, ['replies', 'reposts', 'likes', 'views', 'bookmarks'])}${open}</footer></article>`;
399
+ }
400
+ function renderVideo(video) {
401
+ const youtube = YOUTUBE.exec(video.src);
402
+ const aspect = video.aspect ?? (youtube && /\/shorts\//.test(video.src) ? '9:16' : '16:9');
403
+ const reel = aspect === '9:16';
404
+ const ratio = `video-${aspect.replace(':', 'x')}`;
405
+ const label = video.title ?? video.caption ?? 'Video';
406
+ const player = youtube
407
+ ? `<a class="card-link video-frame ${ratio} video-link" href="${escapeHtml(video.src)}" aria-label="${escapeHtml(`Play ${label} on YouTube`)}"><img src="${escapeHtml(video.poster ?? `https://i.ytimg.com/vi/${youtube[1]}/hqdefault.jpg`)}" alt="" loading="lazy">${ICONS.play}</a>`
408
+ : `<div class="video-frame ${ratio}"><video src="${escapeHtml(video.src)}"${video.poster ? ` poster="${escapeHtml(video.poster)}"` : ''} controls playsinline preload="metadata"${video.loop ? ' loop' : ''}${video.muted ? ' muted' : ''} aria-label="${escapeHtml(label)}"></video></div>`;
409
+ const metric = video.metrics ?? {};
410
+ const source = video.url ? `<a class="card-link post-open" href="${escapeHtml(video.url)}">Open original</a>` : '';
411
+ if (reel) {
412
+ const who = video.author ? `<span class="reel-author">${avatar(video.author, 'sm')}<strong>${escapeHtml(video.author.handle ? `@${video.author.handle.replace(/^@/, '')}` : video.author.name)}</strong>${video.author.verified ? VERIFIED : ''}</span>` : '';
413
+ const overlay = who || video.caption || video.title
414
+ ? `<div class="reel-overlay">${who}${video.title ? `<strong class="reel-title">${escapeHtml(video.title)}</strong>` : ''}${video.caption ? `<p>${richText(video.caption)}</p>` : ''}</div>` : '';
415
+ const rail = metricRow(metric, ['likes', 'comments', 'shares', 'views'], 'reel-rail');
416
+ return `<figure class="artifact-video video-reel" aria-label="${escapeHtml(label)}"><div class="reel-stage">${player}${youtube ? '' : ICONS.play.replace('card-play', 'card-play reel-play')}${overlay}${rail}${video.duration ? `<span class="video-duration">${escapeHtml(video.duration)}</span>` : ''}</div>${source ? `<figcaption>${source}</figcaption>` : ''}</figure>`;
417
+ }
418
+ const heading = video.title || video.duration
419
+ ? `<span class="video-heading">${video.title ? `<strong>${escapeHtml(video.title)}</strong>` : ''}${video.duration ? `<span class="video-length">${escapeHtml(video.duration)}</span>` : ''}</span>` : '';
420
+ const meta = metricRow(metric, ['views', 'likes', 'comments', 'shares']);
421
+ const caption = heading || video.caption || meta || source
422
+ ? `<figcaption>${heading}${video.caption ? `<p>${richText(video.caption)}</p>` : ''}${meta || source ? `<span class="video-foot">${meta}${source}</span>` : ''}</figcaption>` : '';
423
+ return `<figure class="artifact-video" aria-label="${escapeHtml(label)}">${player}${caption}</figure>`;
424
+ }
425
+ function renderGallery(gallery) {
426
+ const layout = gallery.layout ?? 'grid';
427
+ const columns = gallery.columns ?? 3;
428
+ const head = gallery.title || gallery.caption
429
+ ? `<figcaption>${gallery.title ? `<strong>${escapeHtml(gallery.title)}</strong>` : ''}${gallery.caption ? `<p>${escapeHtml(gallery.caption)}</p>` : ''}</figcaption>` : '';
430
+ const items = gallery.items.map((item) => `<li class="gallery-item">${mediaElement(item, 'card-zoom')}${item.caption ? `<span class="gallery-caption">${escapeHtml(item.caption)}</span>` : ''}</li>`).join('');
431
+ return `<figure class="artifact-gallery gallery-${layout} gallery-cols-${columns}" aria-label="${escapeHtml(gallery.title ?? 'Gallery')}">${head}<ul class="gallery-items">${items}</ul></figure>`;
432
+ }
433
+ function renderEvents(data) {
434
+ const events = data.events.map((event, index) => ({ event, index, start: parseDate(event.start), end: event.end ? parseDate(event.end) : undefined }))
435
+ .sort((a, b) => (a.start.key < b.start.key ? -1 : a.start.key > b.start.key ? 1 : a.index - b.index));
436
+ const days = new Map();
437
+ for (const entry of events)
438
+ days.set(entry.start.dateKey, [...(days.get(entry.start.dateKey) ?? []), entry]);
439
+ const rows = [...days.values()].map((entries) => {
440
+ const first = entries[0].start;
441
+ const weekday = WEEKDAYS[new Date(Date.UTC(first.year, first.month - 1, first.day)).getUTCDay()];
442
+ const dateBlock = `<div class="events-date"><span class="events-dow">${weekday}</span><span class="events-dom">${first.day}</span><span class="events-mon">${MONTHS[first.month - 1]}</span></div>`;
443
+ const list = entries.map(({ event, start, end }) => {
444
+ const status = event.status ?? 'confirmed';
445
+ let when = 'All day';
446
+ let length = '';
447
+ if (start.minutes !== undefined) {
448
+ when = clock(start.minutes);
449
+ if (end?.minutes !== undefined && end.dateKey === start.dateKey) {
450
+ when += `<span class="events-until">${clock(end.minutes)}</span>`;
451
+ const minutes = end.minutes - start.minutes;
452
+ length = minutes === 0 ? '' : minutes >= 60 ? `${Math.floor(minutes / 60)} h${minutes % 60 ? ` ${minutes % 60} min` : ''}` : `${minutes} min`;
453
+ }
454
+ else if (end && end.dateKey !== start.dateKey) {
455
+ length = until(start, end);
456
+ }
457
+ }
458
+ else if (end && end.dateKey !== start.dateKey) {
459
+ length = until(start, end);
460
+ }
461
+ const meta = [length, event.location && `${ICONS.pin}${escapeHtml(event.location)}`, event.calendar && escapeHtml(event.calendar), status !== 'confirmed' && `<span class="events-status">${status}</span>`]
462
+ .filter(Boolean).map((part) => `<span>${part}</span>`).join('');
463
+ const people = event.attendees?.length
464
+ ? `<span class="events-people" aria-label="${escapeHtml(`Attendees: ${event.attendees.join(', ')}`)}">${event.attendees.slice(0, 5).map((person) => `<span class="card-avatar card-avatar-xs card-avatar-initials" title="${escapeHtml(person)}">${escapeHtml(initials(person))}</span>`).join('')}${event.attendees.length > 5 ? `<span class="events-more">+${event.attendees.length - 5}</span>` : ''}</span>` : '';
465
+ const join = event.url ? `<a class="card-link events-join" href="${escapeHtml(event.url)}">${/meet\.google|zoom\.us|teams\.microsoft|whereby|around\.co/.test(event.url) ? 'Join' : 'Open'}</a>` : '';
466
+ return `<li class="events-item events-${status}"><span class="events-time">${when}</span><div class="events-body"><strong class="events-title">${escapeHtml(event.title)}</strong>${meta ? `<span class="events-meta">${meta}</span>` : ''}${event.description ? `<span class="events-desc">${escapeHtml(event.description)}</span>` : ''}${people}</div>${join}</li>`;
467
+ }).join('');
468
+ return `<li class="events-day">${dateBlock}<ul class="events-list">${list}</ul></li>`;
469
+ }).join('');
470
+ const head = data.title || data.timezone
471
+ ? `<figcaption>${data.title ? `<strong>${escapeHtml(data.title)}</strong>` : ''}${data.timezone ? `<span class="events-zone">Times in ${escapeHtml(data.timezone)}</span>` : ''}</figcaption>` : '';
472
+ return `<figure class="artifact-events" aria-label="${escapeHtml(data.title ?? 'Events')}">${head}<ul class="events-days">${rows}</ul></figure>`;
473
+ }
474
+ function renderLink(card) {
475
+ const layout = card.layout ?? 'compact';
476
+ const site = card.site ?? hostOf(card.url);
477
+ const image = card.image ? `<img class="link-image" src="${escapeHtml(card.image)}" alt="" loading="lazy">` : '';
478
+ return `<a class="card-link artifact-link-card link-${layout}${image ? '' : ' link-no-image'}" href="${escapeHtml(card.url)}">${layout === 'large' ? image : ''}<span class="link-body"><span class="link-site">${escapeHtml(site)}</span><strong class="link-title">${escapeHtml(card.title)}</strong>${card.description ? `<span class="link-desc">${escapeHtml(card.description)}</span>` : ''}<span class="link-url">${ICONS.external}${escapeHtml(hostOf(card.url))}</span></span>${layout === 'compact' ? image : ''}</a>`;
479
+ }
480
+ // ------------------------------------------------------------------- styles + behavior
481
+ /** Marks a link the renderer emits for a card. Admitted by the sanitizer but not an author class, so `artifacts check` rejects it in embedded HTML. */
482
+ export const CARD_LINK_CLASS = 'card-link';
483
+ export const CARD_CLASSES = [
484
+ 'card-avatar', 'card-avatar-sm', 'card-avatar-md', 'card-avatar-xs', 'card-avatar-initials', 'card-entity', 'card-icon', 'card-play',
485
+ 'card-verified', 'card-platform', 'card-dot', 'card-sr', 'card-zoom',
486
+ 'artifact-post', ...POST_PLATFORMS.map((platform) => `post-${platform}`), 'post-head', 'post-ident', 'post-name', 'post-sub', 'post-meta',
487
+ 'post-flair', 'post-title', 'post-text', 'post-media', 'post-media-1', 'post-media-2', 'post-media-3', 'post-media-4', 'post-tile',
488
+ 'post-carousel', 'post-slide', 'post-dots', 'post-foot', 'post-metrics', 'post-metrics-pills', 'post-open',
489
+ 'artifact-video', 'video-reel', 'video-frame', 'video-16x9', 'video-9x16', 'video-1x1', 'video-4x3', 'video-link', 'video-heading',
490
+ 'video-length', 'video-duration', 'video-foot', 'reel-stage', 'reel-play', 'reel-overlay', 'reel-author', 'reel-title', 'reel-rail',
491
+ 'artifact-gallery', 'gallery-grid', 'gallery-masonry', 'gallery-carousel', 'gallery-cols-2', 'gallery-cols-3', 'gallery-cols-4',
492
+ 'gallery-items', 'gallery-item', 'gallery-caption',
493
+ 'artifact-events', 'events-zone', 'events-days', 'events-day', 'events-date', 'events-dow', 'events-dom', 'events-mon', 'events-list',
494
+ 'events-item', 'events-confirmed', 'events-tentative', 'events-cancelled', 'events-time', 'events-until', 'events-body', 'events-title',
495
+ 'events-meta', 'events-status', 'events-desc', 'events-people', 'events-more', 'events-join',
496
+ 'artifact-link-card', 'link-compact', 'link-large', 'link-no-image', 'link-image', 'link-body', 'link-site', 'link-title', 'link-desc', 'link-url',
497
+ ];
498
+ export const CARD_CSS = `
499
+ .card-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
500
+ .card-avatar{flex:0 0 auto;border-radius:50%;object-fit:cover;background:var(--surface-alt)}
501
+ .card-avatar-md{width:42px;height:42px}.card-avatar-sm{width:30px;height:30px}.card-avatar-xs{width:24px;height:24px;font-size:9.5px!important}
502
+ .card-avatar-initials{display:inline-flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--accent) 16%,var(--surface));color:var(--accent);font:650 13px/1 var(--font-body);letter-spacing:.02em}
503
+ .card-avatar-sm.card-avatar-initials{font-size:11px}
504
+ .card-icon{width:17px;height:17px;flex:0 0 auto}
505
+ .card-verified{display:inline-block;width:16px;height:16px;margin-left:4px;vertical-align:-3px}
506
+ .card-platform{width:18px;height:18px;flex:0 0 auto;margin-left:auto;color:var(--text);opacity:.75}
507
+ .card-entity{color:var(--accent)}
508
+ .card-dot{margin:0 5px;opacity:.6}
509
+ img.card-zoom{cursor:zoom-in}
510
+ .artifact-post{max-width:560px;margin:var(--figure-spacing) 0;border:1px solid var(--line);border-radius:16px;background:var(--surface);padding:16px 18px 12px;color:var(--text);font-size:15.5px;line-height:1.5}
511
+ .post-head{display:flex;align-items:center;gap:11px;min-width:0}
512
+ .post-ident{display:flex;flex-direction:column;min-width:0;line-height:1.3}
513
+ .post-name{font-weight:700;overflow-wrap:anywhere}
514
+ .post-sub,.post-meta{color:var(--muted);font-size:13.5px;overflow-wrap:anywhere}
515
+ .post-meta strong{color:var(--text)}
516
+ .post-text{margin:12px 0 0;white-space:normal;overflow-wrap:anywhere}
517
+ .post-text a{color:var(--accent)}
518
+ .post-title{margin:8px 0 0;font-size:19px;line-height:1.3}
519
+ .post-flair{display:inline-block;margin-top:10px;padding:1px 9px;border-radius:999px;background:var(--surface-alt);border:1px solid var(--line);color:var(--muted);font-size:12px;font-weight:600}
520
+ .post-media{display:grid;gap:2px;margin-top:12px;border:1px solid var(--line);border-radius:14px;overflow:hidden;grid-template-columns:1fr 1fr}
521
+ .post-tile{position:relative;min-height:0;background:var(--surface-alt)}
522
+ .post-tile img,.post-tile video{display:block;width:100%;height:100%;object-fit:cover;margin:0}
523
+ .post-media-1{grid-template-columns:1fr}.post-media-1 .post-tile img,.post-media-1 .post-tile video{height:auto;max-height:520px}
524
+ .post-media-2{aspect-ratio:16/9}.post-media-3{aspect-ratio:16/9;grid-template-rows:1fr 1fr}.post-media-3 .post-tile:first-child{grid-row:span 2}
525
+ .post-media-4{aspect-ratio:16/9;grid-template-rows:1fr 1fr}
526
+ .post-carousel{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;margin:12px -18px 0;scrollbar-width:none;aspect-ratio:1/1;background:var(--surface-alt)}
527
+ .post-carousel::-webkit-scrollbar{display:none}
528
+ .post-slide{flex:0 0 100%;scroll-snap-align:center}
529
+ .post-slide img,.post-slide video{display:block;width:100%;height:100%;object-fit:cover;margin:0}
530
+ .post-dots{display:flex;justify-content:center;gap:5px;margin-top:9px}
531
+ .post-dots span{width:6px;height:6px;border-radius:50%;background:var(--line);transition:background .15s}
532
+ .post-dots span.is-active{background:var(--accent)}
533
+ .post-foot{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;margin-top:10px;padding-top:2px}
534
+ .post-metrics{display:flex;flex-wrap:wrap;gap:4px 22px;list-style:none;margin:0;padding:0;color:var(--muted);font-size:13.5px;font-variant-numeric:tabular-nums}
535
+ .post-metrics li{display:inline-flex;align-items:center;gap:6px;margin:0}
536
+ .post-metrics-pills{gap:8px}.post-metrics-pills li{padding:4px 11px;border-radius:999px;background:var(--surface-alt)}
537
+ .post-open{margin-left:auto;color:var(--muted);font-size:13px}
538
+ .post-open:hover{color:var(--accent)}
539
+ .post-instagram{padding-bottom:14px}.post-instagram .post-text{margin-top:8px;font-size:14.5px}
540
+ .post-linkedin{border-radius:10px}
541
+ .post-reddit{border-radius:12px}
542
+ .artifact-video{margin:var(--figure-spacing) 0;min-width:0}
543
+ .video-frame{position:relative;display:block;overflow:hidden;border-radius:var(--radius);border:1px solid var(--line);background:#000}
544
+ .video-frame video,.video-frame img{display:block;width:100%;height:100%;object-fit:contain;margin:0}
545
+ .video-link img{object-fit:cover}
546
+ .video-16x9{aspect-ratio:16/9}.video-4x3{aspect-ratio:4/3}.video-1x1{aspect-ratio:1/1;max-width:560px}.video-9x16{aspect-ratio:9/16}
547
+ .card-play{position:absolute;left:50%;top:50%;width:64px;height:64px;transform:translate(-50%,-50%);transition:transform .15s}
548
+ .video-link:hover .card-play{transform:translate(-50%,-50%) scale(1.08)}
549
+ .artifact-video figcaption{margin-top:10px;color:var(--text)}
550
+ .artifact-video figcaption p{margin:4px 0 0;color:var(--muted);font-size:14.5px}
551
+ .video-heading{display:flex;align-items:baseline;gap:10px}
552
+ .video-length{color:var(--muted);font:500 12px/1 var(--font-mono)}
553
+ .video-foot{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;margin-top:8px}
554
+ .video-reel{display:flex;flex-direction:column;align-items:center}
555
+ .reel-stage{position:relative;width:min(340px,100%)}
556
+ .reel-stage .video-frame{border-radius:22px;border:1px solid var(--line)}
557
+ .reel-stage video{object-fit:cover}
558
+ .reel-play{display:none;pointer-events:none;width:72px;height:72px}
559
+ .reel-scripted .reel-play{display:block;z-index:1}.reel-scripted.is-playing .reel-play{opacity:0}
560
+ .reel-scripted video{cursor:pointer}
561
+ .reel-scripted video:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
562
+ .reel-stage{isolation:isolate}
563
+ .reel-overlay{position:absolute;z-index:1;left:1px;right:1px;bottom:1px;padding:72px 64px 28px 16px;border-radius:0 0 21px 21px;background:linear-gradient(transparent,rgba(0,0,0,.62));color:#fff;pointer-events:none;text-shadow:0 1px 3px rgba(0,0,0,.6);font-size:14px;line-height:1.4}
564
+ .reel-overlay a{pointer-events:auto;color:#fff;text-decoration:underline}
565
+ .reel-overlay p{margin:6px 0 0;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
566
+ .reel-overlay .card-entity{color:#fff;font-weight:650}
567
+ .reel-author{display:flex;align-items:center;gap:8px;font-size:14px}
568
+ .reel-author .card-avatar{border:1.5px solid #fff}
569
+ .reel-title{display:block;margin-top:6px}
570
+ .reel-rail{position:absolute;z-index:2;right:10px;bottom:64px;display:flex;flex-direction:column;gap:14px;list-style:none;margin:0;padding:0;color:#fff;font:650 12px/1 var(--font-body);text-shadow:0 1px 3px rgba(0,0,0,.6);pointer-events:none}
571
+ .reel-rail li{display:flex;flex-direction:column;align-items:center;gap:4px;margin:0}
572
+ .reel-rail .card-icon{width:26px;height:26px;filter:drop-shadow(0 1px 2px rgba(0,0,0,.5))}
573
+ .video-duration{position:absolute;top:12px;right:12px;padding:3px 7px;border-radius:6px;background:rgba(0,0,0,.6);color:#fff;font:600 11px/1 var(--font-mono)}
574
+ .video-reel figcaption{margin-top:8px}
575
+ .artifact-gallery{margin:var(--figure-spacing) 0;min-width:0}
576
+ .artifact-gallery figcaption{margin-bottom:12px}
577
+ .artifact-gallery figcaption strong{font-size:17px}
578
+ .artifact-gallery figcaption p{margin:4px 0 0;color:var(--muted);font-size:14.5px}
579
+ .gallery-items{list-style:none;margin:0;padding:0}
580
+ .gallery-item{position:relative;margin:0;overflow:hidden;border-radius:var(--radius);border:1px solid var(--line);background:var(--surface-alt)}
581
+ .gallery-item img,.gallery-item video{display:block;width:100%;margin:0;transition:transform .25s ease}
582
+ .gallery-item:hover img{transform:scale(1.03)}
583
+ .gallery-caption{display:block;padding:7px 10px;background:var(--surface);border-top:1px solid var(--line);color:var(--muted);font-size:13px;line-height:1.4}
584
+ .gallery-grid .gallery-items{display:grid;gap:10px}
585
+ .gallery-grid.gallery-cols-2 .gallery-items{grid-template-columns:repeat(2,minmax(0,1fr))}
586
+ .gallery-grid.gallery-cols-3 .gallery-items{grid-template-columns:repeat(3,minmax(0,1fr))}
587
+ .gallery-grid.gallery-cols-4 .gallery-items{grid-template-columns:repeat(4,minmax(0,1fr))}
588
+ .gallery-grid .gallery-item img,.gallery-grid .gallery-item video{aspect-ratio:1/1;object-fit:cover;height:auto}
589
+ .gallery-masonry .gallery-items{column-gap:10px}
590
+ .gallery-masonry.gallery-cols-2 .gallery-items{columns:2}.gallery-masonry.gallery-cols-3 .gallery-items{columns:3}.gallery-masonry.gallery-cols-4 .gallery-items{columns:4}
591
+ .gallery-masonry .gallery-item{break-inside:avoid;margin-bottom:10px}
592
+ .gallery-masonry .gallery-item img,.gallery-masonry .gallery-item video{height:auto}
593
+ .gallery-carousel .gallery-items{display:flex;gap:10px;overflow-x:auto;scroll-snap-type:x mandatory;padding-bottom:8px;scrollbar-width:thin}
594
+ .gallery-carousel .gallery-item{flex:0 0 min(78%,420px);scroll-snap-align:start}
595
+ .gallery-carousel .gallery-item img,.gallery-carousel .gallery-item video{aspect-ratio:4/3;object-fit:cover;height:auto}
596
+ .artifact-events{margin:var(--figure-spacing) 0;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);overflow:hidden}
597
+ .artifact-events figcaption{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;padding:14px 18px;border-bottom:1px solid var(--line)}
598
+ .artifact-events figcaption strong{font-size:17px}
599
+ .events-zone{margin-left:auto;color:var(--muted);font:500 11.5px/1.4 var(--font-mono)}
600
+ .events-days,.events-list{list-style:none;margin:0;padding:0}
601
+ .events-day{display:grid;grid-template-columns:64px minmax(0,1fr);gap:4px;margin:0;padding:14px 18px 14px 12px}
602
+ .events-day+.events-day{border-top:1px solid var(--line)}
603
+ .events-date{display:flex;flex-direction:column;align-items:center;padding-top:2px;line-height:1.1}
604
+ .events-dow,.events-mon{color:var(--muted);font:600 10.5px/1.2 var(--font-mono);text-transform:uppercase;letter-spacing:.1em}
605
+ .events-dom{font:650 26px/1.1 var(--font-display);margin:2px 0}
606
+ .events-list{display:grid;gap:8px}
607
+ .events-item{display:grid;grid-template-columns:84px minmax(0,1fr) auto;align-items:start;gap:12px;margin:0;padding:9px 12px;border-radius:8px;background:color-mix(in srgb,var(--accent) 7%,var(--surface));border-left:3px solid var(--accent)}
608
+ .events-tentative{background:var(--surface);border:1px dashed color-mix(in srgb,var(--warn) 60%,var(--line));border-left:3px dashed var(--warn)}
609
+ .events-cancelled{background:var(--surface-alt);border-left-color:var(--line);opacity:.75}
610
+ .events-cancelled .events-title{text-decoration:line-through;text-decoration-color:var(--muted)}
611
+ .events-time{display:flex;flex-direction:column;color:var(--text);font:600 12.5px/1.45 var(--font-mono);font-variant-numeric:tabular-nums}
612
+ .events-until{color:var(--muted);font-weight:500}
613
+ .events-body{display:flex;flex-direction:column;gap:3px;min-width:0}
614
+ .events-title{font-size:15px;line-height:1.35;overflow-wrap:anywhere}
615
+ .events-meta{display:flex;flex-wrap:wrap;gap:2px 14px;color:var(--muted);font-size:13px}
616
+ .events-meta>span{display:inline-flex;align-items:center;gap:4px}
617
+ .events-meta .card-icon{width:14px;height:14px}
618
+ .events-status{text-transform:uppercase;font:600 10.5px/1.4 var(--font-mono);letter-spacing:.08em;color:var(--warn)}
619
+ .events-cancelled .events-status{color:var(--muted)}
620
+ .events-desc{color:var(--muted);font-size:13.5px}
621
+ .events-people{display:flex;align-items:center;margin-top:4px}
622
+ .events-people .card-avatar{border:2px solid var(--surface);margin-right:-6px}
623
+ .events-more{margin-left:12px;color:var(--muted);font:500 11.5px/1 var(--font-mono)}
624
+ .events-join{align-self:center;padding:5px 12px;border-radius:999px;border:1px solid var(--accent);color:var(--accent);font:600 12px/1 var(--font-body);white-space:nowrap}
625
+ .events-join:hover{background:var(--accent);color:var(--surface);text-decoration:none}
626
+ .artifact-link-card{display:flex;max-width:640px;margin:var(--figure-spacing) 0;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);color:var(--text);overflow:hidden;text-decoration:none;transition:border-color .12s ease}
627
+ .artifact-link-card:hover{border-color:var(--accent);text-decoration:none}
628
+ .artifact-link-card:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
629
+ .link-body{display:flex;flex-direction:column;gap:4px;min-width:0;flex:1;padding:14px 16px}
630
+ .link-site{color:var(--muted);font:500 11px/1.4 var(--font-mono);text-transform:uppercase;letter-spacing:.1em}
631
+ .link-title{font-size:16px;line-height:1.35;overflow-wrap:anywhere}
632
+ .link-desc{color:var(--muted);font-size:14px;line-height:1.45;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
633
+ .link-url{display:inline-flex;align-items:center;gap:5px;margin-top:2px;color:var(--accent);font-size:12.5px}
634
+ .link-url .card-icon{width:13px;height:13px}
635
+ .link-compact .link-image{flex:0 0 31%;max-width:200px;width:31%;object-fit:cover;margin:0;border-left:1px solid var(--line)}
636
+ .link-large{flex-direction:column}
637
+ .link-large .link-image{width:100%;aspect-ratio:1.91/1;object-fit:cover;margin:0;border-bottom:1px solid var(--line)}
638
+ .card-lightbox{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:12px;padding:56px 64px;background:rgba(5,7,12,.92);color:#fff}
639
+ .card-lightbox[hidden]{display:none}
640
+ .card-lightbox img,.card-lightbox video{max-width:100%;max-height:calc(100vh - 140px);object-fit:contain;border-radius:6px;margin:0}
641
+ .card-lightbox p{margin:0;max-width:72ch;text-align:center;font-size:14px;color:#d7dbe6}
642
+ .card-lightbox button{position:absolute;display:flex;align-items:center;justify-content:center;width:44px;height:44px;border:1px solid rgba(255,255,255,.25);border-radius:50%;background:rgba(255,255,255,.08);color:#fff;font:400 22px/1 var(--font-body);cursor:pointer}
643
+ .card-lightbox button:hover{background:rgba(255,255,255,.2)}
644
+ .card-lightbox button:focus-visible{outline:2px solid #fff;outline-offset:2px}
645
+ .card-lightbox .lb-close{top:14px;right:14px}.card-lightbox .lb-prev{left:12px;top:50%}.card-lightbox .lb-next{right:12px;top:50%}
646
+ .card-lightbox .lb-count{position:absolute;top:24px;left:20px;font:500 12px/1 var(--font-mono);color:#aab1c2}
647
+ @media(max-width:600px){
648
+ .artifact-post{padding:14px 14px 10px;border-radius:14px}.post-carousel{margin:12px -14px 0}
649
+ .gallery-grid.gallery-cols-3 .gallery-items,.gallery-grid.gallery-cols-4 .gallery-items{grid-template-columns:repeat(2,minmax(0,1fr))}
650
+ .gallery-masonry.gallery-cols-3 .gallery-items,.gallery-masonry.gallery-cols-4 .gallery-items{columns:2}
651
+ .events-day{grid-template-columns:44px minmax(0,1fr);padding:12px 12px 12px 6px}.events-dom{font-size:21px}
652
+ .events-item{grid-template-columns:minmax(0,1fr) auto;gap:4px 10px}.events-time{flex-direction:row;gap:6px;grid-column:1/-1}.events-until::before{content:"– "}
653
+ .link-compact .link-image{flex-basis:28%}
654
+ .card-lightbox{padding:56px 8px}.card-lightbox .lb-prev,.card-lightbox .lb-next{top:auto;bottom:14px}
655
+ }
656
+ @media(prefers-reduced-motion:reduce){.gallery-item img,.card-play,.post-dots span{transition:none}.gallery-item:hover img{transform:none}}
657
+ @media print{.card-lightbox{display:none!important}.post-carousel{flex-wrap:wrap;overflow:visible;aspect-ratio:auto}.post-slide{flex-basis:50%}.gallery-carousel .gallery-items{flex-wrap:wrap;overflow:visible}}
658
+ `;
659
+ /**
660
+ * One lightbox for every zoomable image or clip on the page, grouped by the
661
+ * component it sits in so arrow keys stay inside one gallery or post. The page
662
+ * builds its own controls: the body sanitizer admits none. Focus returns to the
663
+ * item that opened it.
664
+ */
665
+ export const CARD_SCRIPT = `<script>(()=>{
666
+ const groups=new Map();
667
+ document.querySelectorAll('.card-zoom').forEach(el=>{
668
+ const host=el.closest('.artifact-gallery,.artifact-post');if(!host)return;
669
+ if(el.tagName==='VIDEO')return;
670
+ if(!groups.has(host))groups.set(host,[]);groups.get(host).push(el);
671
+ el.tabIndex=0;el.setAttribute('role','button');el.setAttribute('aria-label','Open '+(el.alt||'image')+' full screen');
672
+ });
673
+ document.querySelectorAll('.post-carousel').forEach(track=>{const dots=[...track.nextElementSibling?.children||[]];if(!dots.length)return;const sync=()=>{const i=Math.round(track.scrollLeft/Math.max(1,track.clientWidth));dots.forEach((d,j)=>d.classList.toggle('is-active',i===j));};track.addEventListener('scroll',sync,{passive:true});sync();});
674
+ // A reel plays on tap like the platforms do; native controls would sit under its caption. Without scripts it keeps them.
675
+ document.querySelectorAll('.reel-stage').forEach(stage=>{const v=stage.querySelector('video');if(!v)return;v.controls=false;v.tabIndex=0;v.setAttribute('role','button');stage.classList.add('reel-scripted');
676
+ const sync=()=>{stage.classList.toggle('is-playing',!v.paused);v.setAttribute('aria-label',(v.paused?'Play ':'Pause ')+(v.dataset.label||(v.dataset.label=v.getAttribute('aria-label')||'video')));};
677
+ const toggle=()=>{if(v.paused)v.play()?.catch(()=>{});else v.pause();};v.addEventListener('click',toggle);v.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();toggle();}});v.addEventListener('play',sync);v.addEventListener('pause',sync);sync();});
678
+ if(!groups.size)return;
679
+ const box=document.createElement('div');box.className='card-lightbox';box.hidden=true;box.setAttribute('role','dialog');box.setAttribute('aria-modal','true');box.setAttribute('aria-label','Media viewer');
680
+ const btn=(cls,label,text)=>{const b=document.createElement('button');b.type='button';b.className=cls;b.setAttribute('aria-label',label);b.textContent=text;box.append(b);return b;};
681
+ const count=document.createElement('span');count.className='lb-count';box.append(count);
682
+ const stage=document.createElement('div');const caption=document.createElement('p');box.append(stage,caption);
683
+ const close=btn('lb-close','Close','\\u00d7'),prev=btn('lb-prev','Previous','\\u2039'),next=btn('lb-next','Next','\\u203a');
684
+ document.body.append(box);
685
+ let list=[],at=0,opener=null;
686
+ const captionOf=el=>el.closest('.gallery-item')?.querySelector('.gallery-caption')?.textContent||el.getAttribute('alt')||el.getAttribute('aria-label')||'';
687
+ const show=i=>{at=(i+list.length)%list.length;const src=list[at];const copy=src.tagName==='VIDEO'?Object.assign(document.createElement('video'),{src:src.currentSrc||src.src,controls:true,autoplay:true,playsInline:true,poster:src.poster||''}):Object.assign(document.createElement('img'),{src:src.currentSrc||src.src,alt:src.alt||''});stage.replaceChildren(copy);caption.textContent=captionOf(src);caption.hidden=!caption.textContent;count.textContent=list.length>1?(at+1)+' / '+list.length:'';prev.hidden=next.hidden=list.length<2;};
688
+ const rest=()=>[...document.body.children].filter(el=>el!==box);
689
+ const open=el=>{list=groups.get(el.closest('.artifact-gallery,.artifact-post'))||[el];opener=el;show(list.indexOf(el));box.hidden=false;rest().forEach(el=>el.inert=true);document.documentElement.style.overflow='hidden';close.focus();};
690
+ const shut=()=>{box.hidden=true;stage.replaceChildren();rest().forEach(el=>el.inert=false);document.documentElement.style.overflow='';opener?.focus();};
691
+ document.addEventListener('click',e=>{const el=e.target.closest?.('.card-zoom');if(el&&el.tagName!=='VIDEO'&&groups.size){e.preventDefault();open(el);}});
692
+ document.addEventListener('keydown',e=>{if(box.hidden){const el=e.target.closest?.('.card-zoom');if(el&&el.tagName!=='VIDEO'&&(e.key==='Enter'||e.key===' ')){e.preventDefault();open(el);}return;}
693
+ if(e.key==='Escape')shut();else if(e.target.tagName==='VIDEO'&&e.key.startsWith('Arrow'))return;else if(e.key==='ArrowRight')show(at+1);else if(e.key==='ArrowLeft')show(at-1);
694
+ else if(e.key==='Tab'){const f=[...box.querySelectorAll('button:not([hidden]),video')];const i=f.indexOf(document.activeElement);if(e.shiftKey&&i<=0){e.preventDefault();f[f.length-1].focus();}else if(!e.shiftKey&&i===f.length-1){e.preventDefault();f[0].focus();}}});
695
+ close.addEventListener('click',shut);prev.addEventListener('click',()=>show(at-1));next.addEventListener('click',()=>show(at+1));
696
+ box.addEventListener('click',e=>{if(e.target===box||e.target===stage)shut();});
697
+ })();</script>`;
698
+ //# sourceMappingURL=cards.js.map