@antzsoft/chat-core 1.3.8 → 1.3.9

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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, e as CursorPaginatedResponse, M as Message, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, o as PersistStorage, p as PresignedUrlRequest, q as PresignedUrlResponse, F as FileResponse, r as CompletedPart, s as FileType, t as AntzChatConfig, u as UploadableFile, B as BatchUploadResult } from './storage-BJvQhWxC.cjs';
2
- export { v as Attachment, w as CompressedFile, x as CompressionAlgorithm, y as CompressionConfig, z as ConversationType, D as ConversationUpdatedEvent, E as FileSizeLimits, G as LastReaction, H as MessageAckEvent, I as MessageContent, J as MessageDeletedEvent, K as MessageDeletedForMeEvent, N as MessageDeliveredEvent, O as MessageMetadata, Q as MessageReaction, T as MessageReceiptEntry, V as MessageReplyReference, W as MessageStarUpdatedEvent, X as MessageUpdatedEvent, Y as MessagesDeliveredEvent, Z as MultipartPartUrl, _ as MultipartUploadInfo, $ as NewMessageEvent, a0 as OptimisticAttachment, a1 as PlatformCompressFn, a2 as PlatformUploadFn, a3 as PlatformUploadPartFn, a4 as QuietHours, a5 as ReactionGroup, a6 as ReactionUpdatedEvent, a7 as ReactionUser, a8 as ReadReceiptEvent, a9 as ReplyAttachmentSnapshot, aa as ResolvedFileSizeLimits, ab as SendMessageAttachment, ac as SyncDeletedForMe, ad as SyncDeliveredReceipt, ae as SyncParticipantChange, af as SyncReactionEntry, ag as SyncReactions, ah as SyncReadReceipt, ai as SyncStarEntry, aj as SystemMessageMetadata, ak as TypingIndicatorEvent, al as UploadConfig, am as UploadProgress, an as UserStatusEvent, ao as resolveConfig, ap as storageApi, aq as uploadBatch } from './storage-BJvQhWxC.cjs';
1
+ import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, e as CursorPaginatedResponse, M as Message, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, o as PersistStorage, p as PresignedUrlRequest, q as PresignedUrlResponse, F as FileResponse, r as CompletedPart, s as FileType, t as AntzChatConfig, u as UploadableFile, B as BatchUploadResult } from './storage-C_b-SFFH.cjs';
2
+ export { v as Attachment, w as CompressedFile, x as CompressionAlgorithm, y as CompressionConfig, z as ConversationType, D as ConversationUpdatedEvent, E as FileSizeLimits, G as LastReaction, H as MENTION_ALL_ID, I as MessageAckEvent, J as MessageContent, K as MessageDeletedEvent, N as MessageDeletedForMeEvent, O as MessageDeliveredEvent, Q as MessageMetadata, T as MessageReaction, V as MessageReceiptEntry, W as MessageReplyReference, X as MessageStarUpdatedEvent, Y as MessageUpdatedEvent, Z as MessagesDeliveredEvent, _ as MultipartPartUrl, $ as MultipartUploadInfo, a0 as NewMessageEvent, a1 as OptimisticAttachment, a2 as PlatformCompressFn, a3 as PlatformUploadFn, a4 as PlatformUploadPartFn, a5 as QuietHours, a6 as ReactionGroup, a7 as ReactionUpdatedEvent, a8 as ReactionUser, a9 as ReadReceiptEvent, aa as ReplyAttachmentSnapshot, ab as ResolvedFileSizeLimits, ac as SendMessageAttachment, ad as SyncDeletedForMe, ae as SyncDeliveredReceipt, af as SyncParticipantChange, ag as SyncReactionEntry, ah as SyncReactions, ai as SyncReadReceipt, aj as SyncStarEntry, ak as SystemMessageMetadata, al as TypingIndicatorEvent, am as UploadConfig, an as UploadProgress, ao as UserStatusEvent, ap as resolveConfig, aq as storageApi, ar as uploadBatch } from './storage-C_b-SFFH.cjs';
3
3
  import { AxiosInstance } from 'axios';
4
4
  import { Socket } from 'socket.io-client';
5
5
  import * as zustand_middleware from 'zustand/middleware';
@@ -536,6 +536,66 @@ declare function normalizeAxiosError(error: unknown): AntzChatError;
536
536
  */
537
537
  declare function resolveSystemMessageText(message: Message, currentUserId: string): string;
538
538
 
539
+ interface ParsedMention {
540
+ /** userId, or "all" */
541
+ id: string;
542
+ /** display name captured from the token (fallback for rendering) */
543
+ displayName: string;
544
+ /** start index of the whole token in the text (UTF-16) */
545
+ start: number;
546
+ /** end index (exclusive) of the whole token in the text (UTF-16) */
547
+ end: number;
548
+ }
549
+ /** A segment of a message: either plain text or a mention to render specially. */
550
+ type MentionPart = {
551
+ type: 'text';
552
+ text: string;
553
+ } | {
554
+ type: 'mention';
555
+ id: string;
556
+ displayName: string;
557
+ };
558
+ /**
559
+ * A piece used to compose outgoing text. Plain strings pass through verbatim;
560
+ * mention objects are serialized to `@[displayName](id)` tokens.
561
+ */
562
+ type MentionSegment = string | {
563
+ id: string;
564
+ displayName: string;
565
+ };
566
+ /**
567
+ * Finds every `@[name](id)` mention token in the text, in order of appearance.
568
+ * Pure/computed — nothing is stored. Safe to call on every render.
569
+ */
570
+ declare function parseMentions(text: string | undefined | null): ParsedMention[];
571
+ /**
572
+ * Splits text into ordered parts (plain text + mentions) for rendering.
573
+ * The caller supplies `resolveName(id, fallbackName)` to look up the current
574
+ * display name from its own directory; return the fallback when unresolvable.
575
+ * When no resolver is given, the token's embedded name is used.
576
+ */
577
+ declare function renderMentionParts(text: string | undefined | null, resolveName?: (id: string, fallbackName: string) => string): MentionPart[];
578
+ /**
579
+ * Builds outgoing message text + the `mentions` id array from composer segments.
580
+ * Deduplicates ids (a user mentioned twice is fanned out once).
581
+ *
582
+ * Example:
583
+ * buildMentionText(['Hey ', { id: 'u1', displayName: 'Alice' }, ', look'])
584
+ * → { text: 'Hey @[Alice](u1), look', mentions: ['u1'] }
585
+ */
586
+ declare function buildMentionText(segments: MentionSegment[]): {
587
+ text: string;
588
+ mentions: string[];
589
+ };
590
+ /**
591
+ * Re-derives the `mentions` id array from message text — the source of truth is
592
+ * always the tokens present in the text. Use this after an edit so a mention whose
593
+ * token was removed drops out of the array (FR-10).
594
+ */
595
+ declare function extractMentionIds(text: string | undefined | null): string[];
596
+ /** True when the mentions list targets everyone (@all). */
597
+ declare function isMentionAll(mentions: string[] | undefined): boolean;
598
+
539
599
  interface ClientSocketHandle {
540
600
  emit: typeof socketEmit;
541
601
  on(event: string, handler: (...args: unknown[]) => void): void;
@@ -667,4 +727,4 @@ declare class AntzChatClient {
667
727
  uploadIcon(conversationId: string, file: UploadableFile): Promise<Conversation>;
668
728
  }
669
729
 
670
- export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, type LastReadEntry, type ListMessagesParams, LoginCredentials, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, performHandshake, reconnectSocket, refreshSocketAuth, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
730
+ export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, type LastReadEntry, type ListMessagesParams, LoginCredentials, type MentionPart, type MentionSegment, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, type ParsedMention, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, buildMentionText, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, extractMentionIds, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isMentionAll, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, parseMentions, performHandshake, reconnectSocket, refreshSocketAuth, renderMentionParts, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, e as CursorPaginatedResponse, M as Message, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, o as PersistStorage, p as PresignedUrlRequest, q as PresignedUrlResponse, F as FileResponse, r as CompletedPart, s as FileType, t as AntzChatConfig, u as UploadableFile, B as BatchUploadResult } from './storage-BJvQhWxC.js';
2
- export { v as Attachment, w as CompressedFile, x as CompressionAlgorithm, y as CompressionConfig, z as ConversationType, D as ConversationUpdatedEvent, E as FileSizeLimits, G as LastReaction, H as MessageAckEvent, I as MessageContent, J as MessageDeletedEvent, K as MessageDeletedForMeEvent, N as MessageDeliveredEvent, O as MessageMetadata, Q as MessageReaction, T as MessageReceiptEntry, V as MessageReplyReference, W as MessageStarUpdatedEvent, X as MessageUpdatedEvent, Y as MessagesDeliveredEvent, Z as MultipartPartUrl, _ as MultipartUploadInfo, $ as NewMessageEvent, a0 as OptimisticAttachment, a1 as PlatformCompressFn, a2 as PlatformUploadFn, a3 as PlatformUploadPartFn, a4 as QuietHours, a5 as ReactionGroup, a6 as ReactionUpdatedEvent, a7 as ReactionUser, a8 as ReadReceiptEvent, a9 as ReplyAttachmentSnapshot, aa as ResolvedFileSizeLimits, ab as SendMessageAttachment, ac as SyncDeletedForMe, ad as SyncDeliveredReceipt, ae as SyncParticipantChange, af as SyncReactionEntry, ag as SyncReactions, ah as SyncReadReceipt, ai as SyncStarEntry, aj as SystemMessageMetadata, ak as TypingIndicatorEvent, al as UploadConfig, am as UploadProgress, an as UserStatusEvent, ao as resolveConfig, ap as storageApi, aq as uploadBatch } from './storage-BJvQhWxC.js';
1
+ import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, e as CursorPaginatedResponse, M as Message, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, o as PersistStorage, p as PresignedUrlRequest, q as PresignedUrlResponse, F as FileResponse, r as CompletedPart, s as FileType, t as AntzChatConfig, u as UploadableFile, B as BatchUploadResult } from './storage-C_b-SFFH.js';
2
+ export { v as Attachment, w as CompressedFile, x as CompressionAlgorithm, y as CompressionConfig, z as ConversationType, D as ConversationUpdatedEvent, E as FileSizeLimits, G as LastReaction, H as MENTION_ALL_ID, I as MessageAckEvent, J as MessageContent, K as MessageDeletedEvent, N as MessageDeletedForMeEvent, O as MessageDeliveredEvent, Q as MessageMetadata, T as MessageReaction, V as MessageReceiptEntry, W as MessageReplyReference, X as MessageStarUpdatedEvent, Y as MessageUpdatedEvent, Z as MessagesDeliveredEvent, _ as MultipartPartUrl, $ as MultipartUploadInfo, a0 as NewMessageEvent, a1 as OptimisticAttachment, a2 as PlatformCompressFn, a3 as PlatformUploadFn, a4 as PlatformUploadPartFn, a5 as QuietHours, a6 as ReactionGroup, a7 as ReactionUpdatedEvent, a8 as ReactionUser, a9 as ReadReceiptEvent, aa as ReplyAttachmentSnapshot, ab as ResolvedFileSizeLimits, ac as SendMessageAttachment, ad as SyncDeletedForMe, ae as SyncDeliveredReceipt, af as SyncParticipantChange, ag as SyncReactionEntry, ah as SyncReactions, ai as SyncReadReceipt, aj as SyncStarEntry, ak as SystemMessageMetadata, al as TypingIndicatorEvent, am as UploadConfig, an as UploadProgress, ao as UserStatusEvent, ap as resolveConfig, aq as storageApi, ar as uploadBatch } from './storage-C_b-SFFH.js';
3
3
  import { AxiosInstance } from 'axios';
4
4
  import { Socket } from 'socket.io-client';
5
5
  import * as zustand_middleware from 'zustand/middleware';
@@ -536,6 +536,66 @@ declare function normalizeAxiosError(error: unknown): AntzChatError;
536
536
  */
537
537
  declare function resolveSystemMessageText(message: Message, currentUserId: string): string;
538
538
 
539
+ interface ParsedMention {
540
+ /** userId, or "all" */
541
+ id: string;
542
+ /** display name captured from the token (fallback for rendering) */
543
+ displayName: string;
544
+ /** start index of the whole token in the text (UTF-16) */
545
+ start: number;
546
+ /** end index (exclusive) of the whole token in the text (UTF-16) */
547
+ end: number;
548
+ }
549
+ /** A segment of a message: either plain text or a mention to render specially. */
550
+ type MentionPart = {
551
+ type: 'text';
552
+ text: string;
553
+ } | {
554
+ type: 'mention';
555
+ id: string;
556
+ displayName: string;
557
+ };
558
+ /**
559
+ * A piece used to compose outgoing text. Plain strings pass through verbatim;
560
+ * mention objects are serialized to `@[displayName](id)` tokens.
561
+ */
562
+ type MentionSegment = string | {
563
+ id: string;
564
+ displayName: string;
565
+ };
566
+ /**
567
+ * Finds every `@[name](id)` mention token in the text, in order of appearance.
568
+ * Pure/computed — nothing is stored. Safe to call on every render.
569
+ */
570
+ declare function parseMentions(text: string | undefined | null): ParsedMention[];
571
+ /**
572
+ * Splits text into ordered parts (plain text + mentions) for rendering.
573
+ * The caller supplies `resolveName(id, fallbackName)` to look up the current
574
+ * display name from its own directory; return the fallback when unresolvable.
575
+ * When no resolver is given, the token's embedded name is used.
576
+ */
577
+ declare function renderMentionParts(text: string | undefined | null, resolveName?: (id: string, fallbackName: string) => string): MentionPart[];
578
+ /**
579
+ * Builds outgoing message text + the `mentions` id array from composer segments.
580
+ * Deduplicates ids (a user mentioned twice is fanned out once).
581
+ *
582
+ * Example:
583
+ * buildMentionText(['Hey ', { id: 'u1', displayName: 'Alice' }, ', look'])
584
+ * → { text: 'Hey @[Alice](u1), look', mentions: ['u1'] }
585
+ */
586
+ declare function buildMentionText(segments: MentionSegment[]): {
587
+ text: string;
588
+ mentions: string[];
589
+ };
590
+ /**
591
+ * Re-derives the `mentions` id array from message text — the source of truth is
592
+ * always the tokens present in the text. Use this after an edit so a mention whose
593
+ * token was removed drops out of the array (FR-10).
594
+ */
595
+ declare function extractMentionIds(text: string | undefined | null): string[];
596
+ /** True when the mentions list targets everyone (@all). */
597
+ declare function isMentionAll(mentions: string[] | undefined): boolean;
598
+
539
599
  interface ClientSocketHandle {
540
600
  emit: typeof socketEmit;
541
601
  on(event: string, handler: (...args: unknown[]) => void): void;
@@ -667,4 +727,4 @@ declare class AntzChatClient {
667
727
  uploadIcon(conversationId: string, file: UploadableFile): Promise<Conversation>;
668
728
  }
669
729
 
670
- export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, type LastReadEntry, type ListMessagesParams, LoginCredentials, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, performHandshake, reconnectSocket, refreshSocketAuth, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
730
+ export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, type LastReadEntry, type ListMessagesParams, LoginCredentials, type MentionPart, type MentionSegment, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, type ParsedMention, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, buildMentionText, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, extractMentionIds, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isMentionAll, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, parseMentions, performHandshake, reconnectSocket, refreshSocketAuth, renderMentionParts, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
package/dist/index.js CHANGED
@@ -515,7 +515,7 @@ var conversationsApi = {
515
515
  `/conversations/${conversationId}/participants`,
516
516
  filter ? { params: { filter } } : void 0
517
517
  );
518
- return data;
518
+ return (data ?? []).map(normalizeParticipant);
519
519
  },
520
520
  /**
521
521
  * Get unread message count for a single conversation.
@@ -1064,6 +1064,80 @@ var socketEmit = {
1064
1064
  }
1065
1065
  };
1066
1066
 
1067
+ // src/types/index.ts
1068
+ var MENTION_ALL_ID = "all";
1069
+
1070
+ // src/utils/mentions.ts
1071
+ var MENTION_TOKEN_SOURCE = "@\\[([^\\]]+)\\]\\((all|[a-fA-F0-9]{24})\\)";
1072
+ function sanitizeDisplayName(name) {
1073
+ return name.replace(/[\[\]()]/g, "").trim() || "user";
1074
+ }
1075
+ function parseMentions(text) {
1076
+ if (!text) return [];
1077
+ const re = new RegExp(MENTION_TOKEN_SOURCE, "g");
1078
+ const out = [];
1079
+ let m;
1080
+ while ((m = re.exec(text)) !== null) {
1081
+ out.push({
1082
+ id: m[2],
1083
+ displayName: m[1],
1084
+ start: m.index,
1085
+ end: m.index + m[0].length
1086
+ });
1087
+ }
1088
+ return out;
1089
+ }
1090
+ function renderMentionParts(text, resolveName) {
1091
+ if (!text) return [];
1092
+ const mentions = parseMentions(text);
1093
+ if (mentions.length === 0) return [{ type: "text", text }];
1094
+ const parts = [];
1095
+ let cursor = 0;
1096
+ for (const mn of mentions) {
1097
+ if (mn.start > cursor) {
1098
+ parts.push({ type: "text", text: text.slice(cursor, mn.start) });
1099
+ }
1100
+ const displayName = resolveName ? resolveName(mn.id, mn.displayName) : mn.displayName;
1101
+ parts.push({ type: "mention", id: mn.id, displayName });
1102
+ cursor = mn.end;
1103
+ }
1104
+ if (cursor < text.length) {
1105
+ parts.push({ type: "text", text: text.slice(cursor) });
1106
+ }
1107
+ return parts;
1108
+ }
1109
+ function buildMentionText(segments) {
1110
+ let text = "";
1111
+ const ids = [];
1112
+ const seen = /* @__PURE__ */ new Set();
1113
+ for (const seg of segments) {
1114
+ if (typeof seg === "string") {
1115
+ text += seg;
1116
+ } else {
1117
+ text += `@[${sanitizeDisplayName(seg.displayName)}](${seg.id})`;
1118
+ if (!seen.has(seg.id)) {
1119
+ seen.add(seg.id);
1120
+ ids.push(seg.id);
1121
+ }
1122
+ }
1123
+ }
1124
+ return { text, mentions: ids };
1125
+ }
1126
+ function extractMentionIds(text) {
1127
+ const ids = [];
1128
+ const seen = /* @__PURE__ */ new Set();
1129
+ for (const mn of parseMentions(text)) {
1130
+ if (!seen.has(mn.id)) {
1131
+ seen.add(mn.id);
1132
+ ids.push(mn.id);
1133
+ }
1134
+ }
1135
+ return ids;
1136
+ }
1137
+ function isMentionAll(mentions) {
1138
+ return !!mentions?.includes(MENTION_ALL_ID);
1139
+ }
1140
+
1067
1141
  // src/client-facade.ts
1068
1142
  var AntzChatClient = class {
1069
1143
  constructor(rawConfig) {
@@ -1121,8 +1195,10 @@ export {
1121
1195
  AntzChatPermissionError,
1122
1196
  AntzChatServerError,
1123
1197
  AntzChatValidationError,
1198
+ MENTION_ALL_ID,
1124
1199
  appConfigApi,
1125
1200
  authApi,
1201
+ buildMentionText,
1126
1202
  connectSocket,
1127
1203
  conversationsApi,
1128
1204
  createAuthStore,
@@ -1131,6 +1207,7 @@ export {
1131
1207
  devicesApi,
1132
1208
  disconnectSocket,
1133
1209
  encryptPayload,
1210
+ extractMentionIds,
1134
1211
  fetchServerKeys,
1135
1212
  generateEphemeralKey,
1136
1213
  getApiClient,
@@ -1142,14 +1219,17 @@ export {
1142
1219
  getSocketStatus,
1143
1220
  initApiClient,
1144
1221
  initAuthStore,
1222
+ isMentionAll,
1145
1223
  isTransitEnvelope,
1146
1224
  messagesApi,
1147
1225
  normalizeAxiosError,
1148
1226
  normalizeConversation,
1149
1227
  onSocketStatus,
1228
+ parseMentions,
1150
1229
  performHandshake,
1151
1230
  reconnectSocket,
1152
1231
  refreshSocketAuth,
1232
+ renderMentionParts,
1153
1233
  resetAuthStore,
1154
1234
  resolveConfig,
1155
1235
  resolveSystemMessageText,