atagen

malice

public
Star0
Watch0
05a48e9e79429877d5ccbef7c37361311e3d29db
2
ssh://brewery@pls.lobotomise.me:33/atagen/malice.git
web/src/lib/MessageRow.svelteSvelte594 lines23.7 KB
1
<script lang="ts">
2
  import MediaAttachmentView from './MediaAttachmentView.svelte';
3
  import MxcAvatar from './MxcAvatar.svelte';
4
  import Emoji from './Emoji.svelte';
5
  import EmojiText from './EmojiText.svelte';
6
  import MessageText from './MessageText.svelte';
7
  import ReactionPicker from './ReactionPicker.svelte';
8
  import LinkCard from './LinkCard.svelte';
9
  import { mediaUrl, messageMediaUrl } from './api';
10
  import type { ImagePack, LinkPreview, Person, QuickReaction, ReplyReference, SendState, TimelineContent, TimelineEvent } from './types';
11
  import { senderLabel } from './types';
12
  import { formatClock, formatDay, initialsOf, senderHue } from './format';
13
  import { findUrls } from './urls';
14
  import { mentionsFromHtml, resolveMentions, stripMarkdownPills } from './mentions';
15
16
  export let itemId: string;
17
  export let event: TimelineEvent;
18
  export let showSender: boolean;
19
  export let reacting: boolean;
20
  export let onReact: (eventId: string, key: string, shortcode?: string) => void;
21
  export let senderAvatar: string | null = null;
22
  export let quickReactions: QuickReaction[] = [];
23
  export let packs: ImagePack[] = [];
24
  export let onQuickChange: (list: QuickReaction[]) => void = () => {};
25
  export let linkPreviews: Record<string, LinkPreview | null> = {};
26
  export let loadPreview: ((url: string) => void) | null = null;
27
  export let people: Record<string, Person> = {};
28
  export let onReply: ((target: ReplyReference) => void) | null = null;
29
  export let onJump: ((eventId: string) => void) | null = null;
30
  export let onEdit: ((eventId: string, body: string) => void) | null = null;
31
  export let editing = false;
32
  export let showSent = true;
33
  export let self: string | null = null;
34
  export let onUser: ((userId: string, x: number, y: number, menu: boolean) => void) | null = null;
35
  export let onCloneSticker: ((eventId: string, body: string, x: number, y: number) => void) | null = null;
36
  export let onMore: ((event: TimelineEvent, x: number, y: number) => void) | null = null;
37
38
  function openUser(ev: MouseEvent, menu: boolean): void {
39
    if (!onUser) return;
40
    const rect = (ev.currentTarget as HTMLElement).getBoundingClientRect();
41
    onUser(event.sender.user_id, menu ? ev.clientX : rect.left, menu ? ev.clientY : rect.bottom + 4, menu);
42
  }
43
44
  const PICKER_WIDTH = 320;
45
  const PICKER_HEIGHT = 380;
46
  const PICKER_MARGIN = 8;
47
  const MAX_READERS = 3;
48
  const STATE_LABELS: Record<string, string> = {
49
    'm.room.pinned_events': 'changed the pinned messages',
50
    'm.room.power_levels': 'changed the room permissions',
51
    'm.room.join_rules': 'changed who can join',
52
    'm.room.history_visibility': 'changed who can read history',
53
    'm.room.guest_access': 'changed guest access',
54
    'm.room.canonical_alias': 'changed the room address',
55
    'm.room.server_acl': 'changed the server access list',
56
    'm.space.child': 'changed the rooms in this space',
57
    'm.space.parent': 'changed the parent space',
58
    'im.ponies.room_emotes': 'updated a sticker pack'
59
  };
60
61
  let row: HTMLDivElement;
62
  let pickerPop: HTMLDivElement | undefined;
63
  let selected = false;
64
  let pickerOpen = false;
65
  let pickerStyle = '';
66
67
  const MEMBERSHIP_LABELS: Record<string, string> = {
68
    Joined: 'joined the room',
69
    Left: 'left the room',
70
    Banned: 'was banned',
71
    Unbanned: 'was unbanned',
72
    Kicked: 'was kicked',
73
    KickedAndBanned: 'was kicked and banned',
74
    Invited: 'was invited',
75
    InvitationAccepted: 'accepted the invite',
76
    InvitationRejected: 'rejected the invite',
77
    InvitationRevoked: 'had the invite revoked',
78
    Knocked: 'requested to join',
79
    KnockAccepted: 'was let in',
80
    KnockRetracted: 'withdrew the request to join',
81
    KnockDenied: 'had the request to join denied'
82
  };
83
84
  $: name = senderLabel(event.sender);
85
  $: displayName = event.sender.name_ambiguous ? `${name} (${event.sender.user_id})` : name;
86
  $: readers = event.read_by.map((id) => people[id] ?? { user_id: id, name: id, avatar: null });
87
  $: interactive = event.content.kind === 'Message' || event.content.kind === 'Sticker' || event.content.kind === 'Poll';
88
  $: message = event.content.kind === 'Message' ? event.content.message : null;
89
  $: stripped = stripMarkdownPills(message ? (message.media ? message.media.caption : message.body) ?? '' : '');
90
  $: linked = message ? [...mentionsFromHtml(message.formatted_body), ...stripped.mentions] : [];
91
  $: mentions = resolveMentions(stripped.text, linked);
92
  $: mentionsMe = self !== null && [...linked, ...mentions].some((m) => m.user_id === self);
93
  $: previews = findUrls(stripped.text);
94
  $: bundled = message ? message.link_previews : [];
95
  $: cards = previews
96
    .map((link) => ({ link, preview: bundled.find((b) => b.url === link.href) ?? linkPreviews[link.href] ?? null }))
97
    .filter((c) => c.preview && (c.preview.title || c.preview.description || c.preview.image));
98
  $: if (loadPreview) {
99
    for (const link of previews) {
100
      if (!bundled.some((b) => b.url === link.href) && !(link.href in linkPreviews)) loadPreview(link.href);
101
    }
102
  }
103
104
  function sendLabel(state: SendState): string {
105
    if (state.kind === 'Failed') return state.will_retry ? 'failed — will retry' : 'failed — not delivered';
106
    if (state.kind === 'Sending') return 'sending…';
107
    if (showSent && event.own && state.kind === 'Sent' && event.event_id) return '✓ sent';
108
    return '';
109
  }
110
111
  function toggleSelected(e: MouseEvent) {
112
    if (!interactive || (e.target as Element).closest('a, button, input, video, audio, .picker-pop')) return;
113
    selected = !selected;
114
  }
115
116
  function deselectOutside(e: PointerEvent) {
117
    if (selected && !pickerOpen && !row.contains(e.target as Node)) selected = false;
118
  }
119
120
  function openPicker(e: MouseEvent) {
121
    if (pickerOpen) {
122
      pickerOpen = false;
123
      return;
124
    }
125
    const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
126
    const height = Math.min(PICKER_HEIGHT, window.innerHeight - 2 * PICKER_MARGIN);
127
    const below = window.innerHeight - rect.bottom - PICKER_MARGIN >= height;
128
    const top = below ? rect.bottom + 4 : Math.max(PICKER_MARGIN, rect.top - height - 4);
129
    const maxLeft = window.innerWidth - PICKER_WIDTH - PICKER_MARGIN;
130
    const left = Math.max(PICKER_MARGIN, Math.min(rect.right - PICKER_WIDTH, maxLeft));
131
    pickerStyle = `top:${top}px;left:${left}px;height:${height}px`;
132
    selected = true;
133
    pickerOpen = true;
134
  }
135
136
  function closePicker() {
137
    pickerOpen = false;
138
  }
139
140
  function isImageKey(key: string): boolean {
141
    return key.startsWith('mxc://') || packs.some((p) => p.images.some((i) => i.reaction_key === key));
142
  }
143
144
  function react(key: string, shortcode: string | null) {
145
    if (shortcode && isImageKey(key)) onReact(event.event_id ?? '', key, shortcode);
146
    else onReact(event.event_id ?? '', key);
147
  }
148
149
  function reply() {
150
    if (!event.event_id || !onReply) return;
151
    onReply({
152
      event_id: event.event_id,
153
      details: { kind: 'Ready', sender: event.sender, content: event.content, timestamp_ms: event.timestamp_ms }
154
    });
155
  }
156
157
  $: editableBody =
158
    event.own && event.editable && event.event_id && event.content.kind === 'Message' && event.content.message.kind === 'Text'
159
      ? event.content.message.body
160
      : null;
161
162
  function edit() {
163
    if (!event.event_id || editableBody === null || !onEdit) return;
164
    onEdit(event.event_id, editableBody);
165
  }
166
167
  function reactorNames(senders: string[]): string {
168
    const names = senders.map((id) => people[id]?.name ?? id);
169
    if (names.length <= 12) return names.join(', ');
170
    return `${names.slice(0, 12).join(', ')} and ${names.length - 12} more`;
171
  }
172
173
  function pick(key: string, shortcode: string | null) {
174
    pickerOpen = false;
175
    react(key, shortcode);
176
  }
177
178
  function closeOnScroll(e: Event) {
179
    if (pickerOpen && !pickerPop?.contains(e.target as Node)) pickerOpen = false;
180
  }
181
182
  function actorLabel(userId: string, name: string | null): string {
183
    return name ?? userId;
184
  }
185
186
  function replyPreview(content: TimelineContent): string {
187
    if (content.kind === 'Message') return stripMarkdownPills(content.message.body).text;
188
    if (content.kind === 'Sticker') return content.body || 'Sticker';
189
    if (content.kind === 'Poll') return `Poll: ${content.question}`;
190
    if (content.kind === 'Redacted') return 'Message deleted';
191
    if (content.kind === 'UnableToDecrypt') return 'Unable to decrypt';
192
    return systemLine(content);
193
  }
194
195
  function systemLine(content: TimelineContent): string {
196
    switch (content.kind) {
197
      case 'Redacted':
198
        return 'Message deleted';
199
      case 'UnableToDecrypt':
200
        return `Message from ${displayName} could not be decrypted`;
201
      case 'Membership': {
202
        const who = actorLabel(content.user_id, content.display_name);
203
        return `${who} ${MEMBERSHIP_LABELS[content.change] ?? 'updated their membership'}`;
204
      }
205
      case 'Profile': {
206
        const who = actorLabel(content.user_id, null);
207
        const parts: string[] = [];
208
        if (content.display_name) {
209
          parts.push(
210
            content.display_name.new
211
              ? `changed their display name to "${content.display_name.new}"`
212
              : 'removed their display name'
213
          );
214
        }
215
        if (content.avatar) parts.push('changed their avatar');
216
        return `${who} ${parts.length > 0 ? parts.join(' and ') : 'updated their profile'}`;
217
      }
218
      case 'RoomName':
219
        return content.name
220
          ? `${displayName} changed the room name to "${content.name}"`
221
          : `${displayName} removed the room name`;
222
      case 'RoomTopic':
223
        return content.topic
224
          ? `${displayName} changed the topic to "${content.topic}"`
225
          : `${displayName} removed the topic`;
226
      case 'RoomAvatar':
227
        return content.avatar ? `${displayName} changed the room avatar` : `${displayName} removed the room avatar`;
228
      case 'EncryptionEnabled':
229
        return `${displayName} enabled encryption in this room`;
230
      case 'RoomCreated':
231
        return `${displayName} created the room`;
232
      case 'RoomUpgraded':
233
        return `${displayName} upgraded the room to a new version`;
234
      case 'OtherState':
235
        return `${displayName} ${STATE_LABELS[content.event_type] ?? `sent a state event (${content.event_type})`}`;
236
      case 'Other':
237
        return `${displayName} sent an event (${content.event_type})`;
238
      default:
239
        return displayName;
240
    }
241
  }
242
</script>
243
244
<svelte:window
245
  on:pointerdown={deselectOutside}
246
  on:keydown={(e) => e.key === 'Escape' && (selected = false)}
247
  on:scroll|capture={closeOnScroll}
248
  on:resize={closePicker}
249
/>
250
251
<!-- svelte-ignore a11y_click_events_have_key_events a11y_no_static_element_interactions -->
252
<div
253
  class="msg"
254
  class:own={event.own}
255
  class:editing
256
  class:mentioned={mentionsMe}
257
  class:system={!interactive}
258
  class:has-readers={interactive && readers.length > 0}
259
  class:selected
260
  data-item={itemId}
261
  data-event={event.event_id}
262
  bind:this={row}
263
  on:click={toggleSelected}
264
>
265
  {#if interactive && event.event_id}
266
    <div class="actions" role="toolbar" aria-label={`Actions for message from ${displayName}`}>
267
      {#each quickReactions as r (r.key)}
268
        {@const label = r.shortcode ? `:${r.shortcode}:` : r.key}
269
        <button
270
          type="button"
271
          title={`React ${label}`}
272
          aria-label={`React ${label} to message from ${displayName}`}
273
          disabled={reacting}
274
          on:click={() => react(r.key, r.shortcode)}
275
        >
276
          {#if r.key.startsWith('mxc://')}
277
            <img class="emote" src={mediaUrl(r.key) ?? ''} alt="" />
278
          {:else}
279
            <Emoji emoji={r.key} size={18} />
280
          {/if}
281
        </button>
282
      {/each}
283
      <button
284
        type="button"
285
        title="Add reaction"
286
        aria-label={`Add reaction to message from ${displayName}`}
287
        aria-haspopup="dialog"
288
        aria-expanded={pickerOpen}
289
        on:pointerdown|stopPropagation
290
        on:click={openPicker}
291
      >
292
        ☺+
293
      </button>
294
      {#if onCloneSticker && event.content.kind === 'Sticker'}
295
        {@const stickerBody = event.content.body}
296
        {@const stickerId = event.event_id}
297
        <button
298
          type="button"
299
          title="Clone sticker"
300
          aria-label="Clone sticker to one of your packs"
301
          on:click|stopPropagation={(ev) => onCloneSticker?.(stickerId, stickerBody, ev.clientX, ev.clientY)}
302
        >
303
          ⧉
304
        </button>
305
      {/if}
306
      {#if onReply}
307
        <button
308
          type="button"
309
          title="Reply"
310
          aria-label={`Reply to message from ${displayName}`}
311
          on:click|stopPropagation={reply}
312
        >
313
          ↩
314
        </button>
315
      {/if}
316
      {#if onEdit && editableBody !== null}
317
        <button type="button" title="Edit" aria-label="Edit your message" on:click|stopPropagation={edit}>
318
          ✎
319
        </button>
320
      {/if}
321
      {#if onMore}
322
        <button
323
          type="button"
324
          title="More"
325
          aria-label={`More actions for message from ${displayName}`}
326
          aria-haspopup="menu"
327
          on:click|stopPropagation={(ev) => onMore?.(event, ev.clientX, ev.clientY)}
328
        >
329
          ⋯
330
        </button>
331
      {/if}
332
    </div>
333
    {#if pickerOpen}
334
      <div class="picker-pop" style={pickerStyle} bind:this={pickerPop}>
335
        <ReactionPicker {packs} quick={quickReactions} onPick={pick} {onQuickChange} onClose={closePicker} />
336
      </div>
337
    {/if}
338
  {/if}
339
  {#if showSender}
340
    <button
341
      type="button"
342
      class="user-hit"
343
      tabindex="-1"
344
      aria-hidden="true"
345
      on:click|stopPropagation={(ev) => openUser(ev, false)}
346
      on:contextmenu|preventDefault|stopPropagation={(ev) => openUser(ev, true)}
347
    >
348
      {#if senderAvatar}
349
        <MxcAvatar mxc={senderAvatar} label={name} size={34} />
350
      {:else}
351
        <span class="avatar" style={`background:hsl(${senderHue(event.sender.user_id)} 35% 32%)`}>
352
          {initialsOf(name)}
353
        </span>
354
      {/if}
355
    </button>
356
  {:else}
357
    <div class="avatar-spacer" aria-hidden="true">
358
      <span class="hover-time">{formatClock(event.timestamp_ms)}</span>
359
    </div>
360
  {/if}
361
  <div class="msg-body">
362
    {#if showSender}
363
      <div class="msg-head">
364
        <button
365
          type="button"
366
          class="sender"
367
          style={`color:hsl(${senderHue(event.sender.user_id)} 70% var(--name-lightness))`}
368
          on:click|stopPropagation={(ev) => openUser(ev, false)}
369
          on:contextmenu|preventDefault|stopPropagation={(ev) => openUser(ev, true)}
370
        >
371
          {displayName}
372
        </button>
373
        <time class="time" datetime={new Date(event.timestamp_ms).toISOString()}>
374
          {formatDay(event.timestamp_ms)} {formatClock(event.timestamp_ms)}
375
        </time>
376
        {#if event.content.kind === 'Message' && event.content.message.edited}
377
          <span class="edited" title="Edited">(edited)</span>
378
        {/if}
379
      </div>
380
    {/if}
381
    {#if event.reply_to}
382
      {@const target = event.reply_to.event_id}
383
      <button
384
        type="button"
385
        class="reply-quote"
386
        disabled={!onJump}
387
        title="Jump to the original message"
388
        on:click|stopPropagation={() => onJump?.(target)}
389
      >
390
        {#if event.reply_to.details.kind === 'Ready'}
391
          <span class="reply-sender">{senderLabel(event.reply_to.details.sender)}</span>
392
          <span class="reply-text"><EmojiText text={replyPreview(event.reply_to.details.content)} /></span>
393
        {:else if event.reply_to.details.kind === 'Pending'}
394
          Loading reply…
395
        {:else}
396
          Reply unavailable
397
        {/if}
398
      </button>
399
    {/if}
400
401
    {#if event.content.kind === 'Message'}
402
      {@const m = event.content.message}
403
      {#if stripped.text}
404
        <div class="text" class:emote={m.kind === 'Emote'} class:notice={m.kind === 'Notice' || m.kind === 'ServerNotice'}>{#if m.kind === 'Emote'}* {displayName} {/if}<MessageText text={stripped.text} html={m.formatted_body} jumbo={m.kind === 'Text'} {mentions} {self} nameOf={(id) => people[id]?.name ?? null} />{#if m.edited && !showSender}<span class="edited" title="Edited">(edited)</span>{/if}</div>
405
      {/if}
406
      {#if m.media}
407
        <MediaAttachmentView attachment={m.media} />
408
      {/if}
409
      {#if cards.length > 0}
410
        <div class="link-previews">
411
          {#each cards as card (card.link.href)}
412
            <LinkCard link={card.link} preview={card.preview} />
413
          {/each}
414
        </div>
415
      {/if}
416
    {:else if event.content.kind === 'Sticker'}
417
      {#if event.content.body}<p class="text"><EmojiText text={event.content.body} /></p>{/if}
418
      {#if event.content.media}
419
        <MediaAttachmentView attachment={event.content.media} />
420
      {/if}
421
    {:else if event.content.kind === 'Poll'}
422
      <p class="text">📊 {event.content.question}</p>
423
    {:else}
424
      <p class="system-line">{systemLine(event.content)}</p>
425
    {/if}
426
427
    {#if interactive && event.reactions.length > 0}
428
      <div class="reactions" aria-label="Reactions">
429
        {#each event.reactions as r (r.key)}
430
          <button
431
            type="button"
432
            class="reaction"
433
            class:mine={r.own}
434
            aria-describedby={`${itemId}-reactors-${r.key}`}
435
            disabled={!event.event_id || reacting}
436
            on:click={() => event.event_id && onReact(event.event_id, r.key)}
437
          >
438
            {#if r.image}
439
              <img class="emote" src={messageMediaUrl(r.image, 'Thumbnail')} alt={r.shortcode ?? ''} title={r.shortcode ?? ''} />
440
            {:else if r.key.startsWith('mxc://')}
441
              <img class="emote" src={mediaUrl(r.key) ?? ''} alt="" />
442
            {:else}
443
              <Emoji emoji={r.key} size={16} />
444
            {/if}
445
            <span class="count">{r.count}</span>
446
            <span class="reactors" role="tooltip" id={`${itemId}-reactors-${r.key}`}>
447
              <span class="reactors-key">{r.shortcode ? `:${r.shortcode}:` : r.key.startsWith('mxc://') ? 'custom emote' : r.key}</span>
448
              {reactorNames(r.senders)}
449
            </span>
450
          </button>
451
        {/each}
452
      </div>
453
    {/if}
454
    {#if interactive && sendLabel(event.send_state)}
455
      <div class="msg-foot">
456
        <span class="sendstate" class:failed={event.send_state.kind === 'Failed'}>{sendLabel(event.send_state)}</span>
457
      </div>
458
    {/if}
459
    {#if interactive && readers.length > 0}
460
      {@const seenBy = `Seen by ${readers.map((r) => r.name).join(', ')}`}
461
      <div class="readby" title={seenBy} aria-label={seenBy} role="img">
462
        {#each readers.slice(0, MAX_READERS) as r (r.user_id)}
463
          <MxcAvatar mxc={r.avatar} label={r.name} size={16} />
464
        {/each}
465
        {#if readers.length > MAX_READERS}<span class="more">+{readers.length - MAX_READERS}</span>{/if}
466
      </div>
467
    {/if}
468
  </div>
469
</div>
470
471
<style>
472
  .msg { position: relative; display: flex; gap: 10px; padding: var(--msg-gap, 3px) 0; }
473
  .msg:hover, .msg.selected { background: var(--hover-faint); }
474
  .msg:hover .hover-time, .msg.selected .hover-time { opacity: 1; }
475
  .msg-foot { display: flex; align-items: center; gap: 8px; }
476
  .sendstate { font-size: 11px; color: var(--muted); }
477
  .sendstate.failed { color: var(--danger); }
478
  .link-previews { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-width: 420px; }
479
  .avatar {
480
    flex: none;
481
    width: 34px; height: 34px;
482
    border-radius: 50%;
483
    display: grid; place-items: center;
484
    font-size: 12px; font-weight: 700; color: #fff;
485
  }
486
  .avatar-spacer { flex: none; width: 34px; padding-top: 2px; text-align: center; }
487
  .hover-time { opacity: 0; font-size: 10.5px; color: var(--muted); }
488
  .msg-body { min-width: 0; flex: 1; }
489
  .msg-head { display: flex; align-items: baseline; gap: 8px; }
490
  .sender { font-weight: 650; font-size: 13.5px; padding: 0; border: none; background: none; font-family: inherit; cursor: pointer; }
491
  .sender:hover { text-decoration: underline; }
492
  .user-hit { flex: none; align-self: flex-start; padding: 0; border: none; background: none; border-radius: 50%; cursor: pointer; }
493
  .time, .edited { color: var(--muted); font-size: 11.5px; }
494
  .text .edited { margin-left: 6px; }
495
  .msg.editing { background: color-mix(in srgb, var(--accent) 10%, transparent); }
496
  .msg.mentioned { background: color-mix(in srgb, var(--warn) 8%, transparent); box-shadow: inset 2px 0 0 var(--warn); }
497
  .reply-quote {
498
    display: flex; gap: 6px; align-items: baseline;
499
    max-width: min(100%, 520px);
500
    border: none;
501
    border-left: 2px solid var(--accent);
502
    padding: 2px 8px;
503
    margin: 2px 0 4px;
504
    color: var(--muted);
505
    font-size: 12.5px;
506
    text-align: left;
507
    background: var(--bg-soft);
508
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
509
    cursor: pointer;
510
  }
511
  .reply-quote:disabled { cursor: default; }
512
  .reply-quote:hover:not(:disabled) { color: var(--text); }
513
  .reply-sender { flex: none; font-weight: 650; }
514
  .reply-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
515
  :global(.msg.flash) { animation: reply-flash 1.2s ease-out; }
516
  @keyframes -global-reply-flash { from { background: color-mix(in srgb, var(--accent) 22%, transparent); } }
517
  .text {
518
    margin: 1px 0 2px;
519
    font-size: 14px;
520
    line-height: var(--msg-line-height, 1.5);
521
    white-space: pre-wrap;
522
    overflow-wrap: anywhere;
523
  }
524
  .text.emote { font-style: italic; color: var(--muted); }
525
  .text.notice { color: var(--muted); }
526
  .system-line { color: var(--muted); font-size: 12.5px; font-style: italic; margin: 1px 0; }
527
  .msg.system { opacity: 0.85; }
528
  .reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
529
  .reaction {
530
    display: inline-flex; align-items: center; gap: 4px;
531
    background: var(--bg-soft);
532
    border: 1px solid var(--border);
533
    border-radius: var(--r-sm);
534
    padding: 1px 8px;
535
    font-size: 13px;
536
    color: var(--text);
537
    cursor: pointer;
538
  }
539
  .reaction { position: relative; }
540
  .reactors {
541
    position: absolute;
542
    left: 0;
543
    bottom: calc(100% + 6px);
544
    z-index: 15;
545
    display: none;
546
    width: max-content;
547
    max-width: 260px;
548
    padding: 6px 9px;
549
    border: 1px solid var(--border);
550
    border-radius: var(--r-md);
551
    background: var(--panel-2);
552
    box-shadow: 0 6px 18px rgb(0 0 0 / 0.3);
553
    color: var(--text);
554
    font-size: 12px;
555
    line-height: 1.35;
556
    text-align: left;
557
    white-space: normal;
558
    pointer-events: none;
559
  }
560
  .reactors-key { display: block; color: var(--muted); font-size: 11px; }
561
  .reaction:hover .reactors, .reaction:focus-visible .reactors { display: block; }
562
  .reaction.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
563
  .reaction:disabled { cursor: default; opacity: 0.85; }
564
  .msg.has-readers .msg-body { padding-right: 72px; }
565
  .readby { position: absolute; right: 12px; bottom: 4px; display: flex; align-items: center; }
566
  .readby > :global(* + *) { margin-left: -4px; }
567
  .readby :global(.mxc-avatar), .readby :global(.mxc-fallback) { box-shadow: 0 0 0 1.5px var(--bg); }
568
  .readby .more { margin-left: 3px; font-size: 10.5px; color: var(--muted); }
569
  .actions {
570
    position: absolute; top: -12px; right: 10px; z-index: 2;
571
    display: flex; gap: 2px;
572
    padding: 2px;
573
    background: var(--bg-soft);
574
    border: 1px solid var(--border);
575
    border-radius: var(--r-md);
576
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
577
    opacity: 0;
578
    pointer-events: none;
579
  }
580
  .msg:hover .actions, .msg:focus-within .actions, .msg.selected .actions { opacity: 1; pointer-events: auto; }
581
  :global(.timeline-inner:has(.msg.selected)) .msg:not(.selected) .actions { opacity: 0; pointer-events: none; }
582
  .actions button {
583
    background: transparent;
584
    border: 1px solid transparent;
585
    border-radius: var(--r-sm);
586
    cursor: pointer;
587
    font-size: 14px;
588
    padding: 1px 5px;
589
  }
590
  .actions button:hover:not(:disabled) { border-color: var(--border); background: var(--hover); }
591
  .actions button:disabled { opacity: 0.4; cursor: default; }
592
  .emote { width: 1.3em; height: 1.3em; object-fit: contain; vertical-align: middle; }
593
  .picker-pop { position: fixed; z-index: 60; width: 320px; max-width: calc(100vw - 16px); animation: pop-in var(--pop); }
594
</style>