@cossistant/react 0.0.31 → 0.0.33

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.
Files changed (145) hide show
  1. package/hooks/index.d.ts +2 -2
  2. package/hooks/index.js +2 -2
  3. package/hooks/private/use-grouped-messages.d.ts +27 -2
  4. package/hooks/private/use-grouped-messages.d.ts.map +1 -1
  5. package/hooks/private/use-grouped-messages.js +156 -103
  6. package/hooks/private/use-grouped-messages.js.map +1 -1
  7. package/hooks/use-new-message-sound.d.ts.map +1 -1
  8. package/hooks/use-new-message-sound.js +2 -2
  9. package/hooks/use-new-message-sound.js.map +1 -1
  10. package/hooks/use-send-message.js +1 -1
  11. package/hooks/use-send-message.js.map +1 -1
  12. package/hooks/use-typing-sound.d.ts.map +1 -1
  13. package/hooks/use-typing-sound.js +2 -2
  14. package/hooks/use-typing-sound.js.map +1 -1
  15. package/index.d.ts +2 -2
  16. package/index.js +2 -2
  17. package/package.json +4 -6
  18. package/packages/tiny-markdown/src/context/index.d.ts +1 -0
  19. package/packages/tiny-markdown/src/context/tiny-markdown-context.d.ts +3 -0
  20. package/packages/tiny-markdown/src/hooks/index.d.ts +4 -0
  21. package/packages/tiny-markdown/src/hooks/use-caret-position.d.ts +1 -0
  22. package/packages/tiny-markdown/src/hooks/use-tiny-markdown.d.ts +1 -0
  23. package/packages/tiny-markdown/src/hooks/use-tiny-mention.d.ts +1 -0
  24. package/packages/tiny-markdown/src/hooks/use-tiny-shortcuts.d.ts +1 -0
  25. package/packages/tiny-markdown/src/index.d.ts +4 -0
  26. package/packages/tiny-markdown/src/types.d.ts +75 -0
  27. package/packages/tiny-markdown/src/types.d.ts.map +1 -0
  28. package/packages/tiny-markdown/src/utils/index.d.ts +3 -0
  29. package/packages/tiny-markdown/src/utils/markdown-parser.d.ts +1 -0
  30. package/packages/tiny-markdown/src/utils/mention-parser.d.ts +1 -0
  31. package/packages/tiny-markdown/src/utils/merge-refs.d.ts +1 -0
  32. package/packages/types/src/api/conversation.d.ts +316 -12
  33. package/packages/types/src/api/conversation.d.ts.map +1 -1
  34. package/packages/types/src/api/timeline-item.d.ts +236 -9
  35. package/packages/types/src/api/timeline-item.d.ts.map +1 -1
  36. package/packages/types/src/realtime-events.d.ts +259 -13
  37. package/packages/types/src/realtime-events.d.ts.map +1 -1
  38. package/packages/types/src/schemas.d.ts +79 -3
  39. package/packages/types/src/schemas.d.ts.map +1 -1
  40. package/primitives/avatar/image.d.ts +1 -1
  41. package/primitives/command-block-utils.d.ts +26 -0
  42. package/primitives/command-block-utils.d.ts.map +1 -0
  43. package/primitives/command-block-utils.js +310 -0
  44. package/primitives/command-block-utils.js.map +1 -0
  45. package/primitives/index.d.ts +7 -3
  46. package/primitives/index.js +11 -2
  47. package/primitives/index.parts.d.ts +6 -2
  48. package/primitives/index.parts.js +5 -1
  49. package/primitives/multimodal-input.d.ts +2 -2
  50. package/primitives/multimodal-input.d.ts.map +1 -1
  51. package/primitives/timeline-code-block.d.ts +32 -0
  52. package/primitives/timeline-code-block.d.ts.map +1 -0
  53. package/primitives/timeline-code-block.js +66 -0
  54. package/primitives/timeline-code-block.js.map +1 -0
  55. package/primitives/timeline-command-block.d.ts +29 -0
  56. package/primitives/timeline-command-block.d.ts.map +1 -0
  57. package/primitives/timeline-command-block.js +97 -0
  58. package/primitives/timeline-command-block.js.map +1 -0
  59. package/primitives/timeline-item-group.d.ts.map +1 -1
  60. package/primitives/timeline-item-group.js +5 -15
  61. package/primitives/timeline-item-group.js.map +1 -1
  62. package/primitives/timeline-item.d.ts +23 -3
  63. package/primitives/timeline-item.d.ts.map +1 -1
  64. package/primitives/timeline-item.js +151 -80
  65. package/primitives/timeline-item.js.map +1 -1
  66. package/primitives/timeline-message-layout.d.ts +9 -0
  67. package/primitives/timeline-message-layout.d.ts.map +1 -0
  68. package/primitives/timeline-message-layout.js +20 -0
  69. package/primitives/timeline-message-layout.js.map +1 -0
  70. package/provider.d.ts.map +1 -1
  71. package/provider.js +6 -3
  72. package/provider.js.map +1 -1
  73. package/realtime/event-filter.js +4 -3
  74. package/realtime/event-filter.js.map +1 -1
  75. package/sounds/sound-data.d.ts +6 -0
  76. package/sounds/sound-data.d.ts.map +1 -0
  77. package/sounds/sound-data.js +7 -0
  78. package/sounds/sound-data.js.map +1 -0
  79. package/support/components/avatar-stack.js +1 -1
  80. package/support/components/avatar-stack.js.map +1 -1
  81. package/support/components/avatar.d.ts +1 -2
  82. package/support/components/avatar.d.ts.map +1 -1
  83. package/support/components/avatar.js +9 -7
  84. package/support/components/avatar.js.map +1 -1
  85. package/support/components/button.d.ts +2 -2
  86. package/support/components/button.d.ts.map +1 -1
  87. package/support/components/button.js +1 -0
  88. package/support/components/button.js.map +1 -1
  89. package/support/components/conversation-button-link.js +2 -1
  90. package/support/components/conversation-button-link.js.map +1 -1
  91. package/support/components/conversation-event.d.ts +3 -0
  92. package/support/components/conversation-event.d.ts.map +1 -1
  93. package/support/components/conversation-event.js +46 -15
  94. package/support/components/conversation-event.js.map +1 -1
  95. package/support/components/conversation-resolved-feedback.d.ts +1 -1
  96. package/support/components/conversation-resolved-feedback.d.ts.map +1 -1
  97. package/support/components/conversation-resolved-feedback.js +56 -13
  98. package/support/components/conversation-resolved-feedback.js.map +1 -1
  99. package/support/components/conversation-timeline.d.ts.map +1 -1
  100. package/support/components/conversation-timeline.js +12 -0
  101. package/support/components/conversation-timeline.js.map +1 -1
  102. package/support/components/index.d.ts +2 -1
  103. package/support/components/index.js +2 -1
  104. package/support/components/timeline-activity-group.d.ts +25 -0
  105. package/support/components/timeline-activity-group.d.ts.map +1 -0
  106. package/support/components/timeline-activity-group.js +104 -0
  107. package/support/components/timeline-activity-group.js.map +1 -0
  108. package/support/components/timeline-code-block.d.ts +14 -0
  109. package/support/components/timeline-code-block.d.ts.map +1 -0
  110. package/support/components/timeline-code-block.js +44 -0
  111. package/support/components/timeline-code-block.js.map +1 -0
  112. package/support/components/timeline-command-block.d.ts +12 -0
  113. package/support/components/timeline-command-block.d.ts.map +1 -0
  114. package/support/components/timeline-command-block.js +42 -0
  115. package/support/components/timeline-command-block.js.map +1 -0
  116. package/support/components/timeline-message-item.d.ts +2 -1
  117. package/support/components/timeline-message-item.d.ts.map +1 -1
  118. package/support/components/timeline-message-item.js +23 -3
  119. package/support/components/timeline-message-item.js.map +1 -1
  120. package/support/components/typing-indicator.d.ts.map +1 -1
  121. package/support/components/typing-indicator.js +15 -7
  122. package/support/components/typing-indicator.js.map +1 -1
  123. package/support/index.d.ts +4 -4
  124. package/support/pages/conversation-history.js +1 -1
  125. package/support/pages/conversation.js +4 -2
  126. package/support/pages/conversation.js.map +1 -1
  127. package/support/pages/home.js +1 -1
  128. package/support/store/support-store.d.ts +5 -5
  129. package/support/text/locales/en.js +3 -0
  130. package/support/text/locales/en.js.map +1 -1
  131. package/support/text/locales/es.js +3 -0
  132. package/support/text/locales/es.js.map +1 -1
  133. package/support/text/locales/fr.js +3 -0
  134. package/support/text/locales/fr.js.map +1 -1
  135. package/support/text/locales/keys.d.ts +9 -0
  136. package/support/text/locales/keys.d.ts.map +1 -1
  137. package/support/text/locales/keys.js +3 -0
  138. package/support/text/locales/keys.js.map +1 -1
  139. package/utils/metadata-hash.d.ts +1 -1
  140. package/utils/metadata-hash.js +9 -4
  141. package/utils/metadata-hash.js.map +1 -1
  142. package/utils/timeline-item-sender.d.ts +17 -0
  143. package/utils/timeline-item-sender.d.ts.map +1 -0
  144. package/utils/timeline-item-sender.js +43 -0
  145. package/utils/timeline-item-sender.js.map +1 -0
@@ -0,0 +1,29 @@
1
+ import { CommandPackageManager, CommandVariants } from "./command-block-utils.js";
2
+ import * as React$1 from "react";
3
+
4
+ //#region src/primitives/timeline-command-block.d.ts
5
+ type TimelineCommandBlockRenderState = {
6
+ commands: CommandVariants;
7
+ packageManagers: readonly CommandPackageManager[];
8
+ activePackageManager: CommandPackageManager;
9
+ activeCommand: string;
10
+ setPackageManager: (packageManager: CommandPackageManager) => void;
11
+ hasCopied: boolean;
12
+ onCopy: () => Promise<boolean>;
13
+ };
14
+ type TimelineCommandBlockProps = {
15
+ commands: CommandVariants;
16
+ className?: string;
17
+ children?: (state: TimelineCommandBlockRenderState) => React$1.ReactNode;
18
+ };
19
+ /**
20
+ * Shared command block UI with package-manager tabs and copy action.
21
+ */
22
+ declare function TimelineCommandBlock({
23
+ commands,
24
+ className,
25
+ children
26
+ }: TimelineCommandBlockProps): React$1.ReactElement;
27
+ //#endregion
28
+ export { TimelineCommandBlock, TimelineCommandBlockProps, TimelineCommandBlockRenderState };
29
+ //# sourceMappingURL=timeline-command-block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeline-command-block.d.ts","names":[],"sources":["../../src/primitives/timeline-command-block.tsx"],"sourcesContent":[],"mappings":";;;;KAWY,+BAAA;YACD;EADC,eAAA,EAAA,SAEe,qBAFgB,EAAA;EAChC,oBAAA,EAEY,qBAFZ;EACgB,aAAA,EAAA,MAAA;EACJ,iBAAA,EAAA,CAAA,cAAA,EAEc,qBAFd,EAAA,GAAA,IAAA;EAEc,SAAA,EAAA,OAAA;EAEtB,MAAA,EAAA,GAAA,GAAA,OAAA,CAAA,OAAA,CAAA;CAAO;AAGV,KAAA,yBAAA,GAAyB;EAC1B,QAAA,EAAA,eAAA;EAES,SAAA,CAAA,EAAA,MAAA;EAAoC,QAAM,CAAA,EAAA,CAAA,KAAA,EAA1C,+BAA0C,EAAA,GAAN,OAAA,CAAM,SAAA;CAAS;AAkCvE;;;AAGC,iBAHe,oBAAA,CAGf;EAAA,QAAA;EAAA,SAAA;EAAA;AAAA,CAAA,EACE,yBADF,CAAA,EAC8B,OAAA,CAAM,YADpC"}
@@ -0,0 +1,97 @@
1
+ import { COMMAND_PACKAGE_MANAGERS, COMMAND_PREFERENCE_EVENT, COMMAND_PREFERENCE_STORAGE_KEY, DEFAULT_PACKAGE_MANAGER, isCommandPackageManager } from "./command-block-utils.js";
2
+ import * as React$1 from "react";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+
5
+ //#region src/primitives/timeline-command-block.tsx
6
+ function readStoredPackageManager() {
7
+ if (typeof window === "undefined") return DEFAULT_PACKAGE_MANAGER;
8
+ const storedValue = window.localStorage.getItem(COMMAND_PREFERENCE_STORAGE_KEY);
9
+ if (storedValue && isCommandPackageManager(storedValue)) return storedValue;
10
+ return DEFAULT_PACKAGE_MANAGER;
11
+ }
12
+ async function copyToClipboard(value) {
13
+ if (typeof navigator === "undefined" || !navigator.clipboard) return false;
14
+ try {
15
+ await navigator.clipboard.writeText(value);
16
+ return true;
17
+ } catch {
18
+ return false;
19
+ }
20
+ }
21
+ /**
22
+ * Shared command block UI with package-manager tabs and copy action.
23
+ */
24
+ function TimelineCommandBlock({ commands, className, children }) {
25
+ const [packageManager, setPackageManager] = React$1.useState(() => readStoredPackageManager());
26
+ const [hasCopied, setHasCopied] = React$1.useState(false);
27
+ React$1.useEffect(() => {
28
+ if (typeof window === "undefined") return;
29
+ setPackageManager(readStoredPackageManager());
30
+ const onStorageChange = (event) => {
31
+ if (event.key !== COMMAND_PREFERENCE_STORAGE_KEY) return;
32
+ if (event.newValue && isCommandPackageManager(event.newValue)) setPackageManager(event.newValue);
33
+ };
34
+ const onPreferenceEvent = (event) => {
35
+ const nextValue = event.detail;
36
+ if (nextValue && isCommandPackageManager(nextValue)) setPackageManager(nextValue);
37
+ };
38
+ window.addEventListener("storage", onStorageChange);
39
+ window.addEventListener(COMMAND_PREFERENCE_EVENT, onPreferenceEvent);
40
+ return () => {
41
+ window.removeEventListener("storage", onStorageChange);
42
+ window.removeEventListener(COMMAND_PREFERENCE_EVENT, onPreferenceEvent);
43
+ };
44
+ }, []);
45
+ React$1.useEffect(() => {
46
+ if (!hasCopied) return;
47
+ const timer = window.setTimeout(() => {
48
+ setHasCopied(false);
49
+ }, 1800);
50
+ return () => {
51
+ window.clearTimeout(timer);
52
+ };
53
+ }, [hasCopied]);
54
+ const setPackageManagerPreference = React$1.useCallback((nextValue) => {
55
+ setPackageManager(nextValue);
56
+ if (typeof window === "undefined") return;
57
+ window.localStorage.setItem(COMMAND_PREFERENCE_STORAGE_KEY, nextValue);
58
+ window.dispatchEvent(new CustomEvent(COMMAND_PREFERENCE_EVENT, { detail: nextValue }));
59
+ }, []);
60
+ const activeCommand = commands[packageManager];
61
+ const onCopy = React$1.useCallback(async () => {
62
+ const didCopy = await copyToClipboard(activeCommand);
63
+ if (didCopy) setHasCopied(true);
64
+ return didCopy;
65
+ }, [activeCommand]);
66
+ const renderState = {
67
+ commands,
68
+ packageManagers: COMMAND_PACKAGE_MANAGERS,
69
+ activePackageManager: packageManager,
70
+ activeCommand,
71
+ setPackageManager: setPackageManagerPreference,
72
+ hasCopied,
73
+ onCopy
74
+ };
75
+ return /* @__PURE__ */ jsx("div", {
76
+ className,
77
+ "data-co-command-block": "",
78
+ children: typeof children === "function" ? children(renderState) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", { children: COMMAND_PACKAGE_MANAGERS.map((manager) => /* @__PURE__ */ jsx("button", {
79
+ onClick: () => setPackageManagerPreference(manager),
80
+ type: "button",
81
+ children: manager
82
+ }, manager)) }), /* @__PURE__ */ jsx("button", {
83
+ onClick: () => {
84
+ onCopy();
85
+ },
86
+ type: "button",
87
+ children: hasCopied ? "Copied" : "Copy"
88
+ })] }), /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", {
89
+ className: "language-bash",
90
+ children: activeCommand
91
+ }) })] })
92
+ });
93
+ }
94
+
95
+ //#endregion
96
+ export { TimelineCommandBlock };
97
+ //# sourceMappingURL=timeline-command-block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeline-command-block.js","names":["React","renderState: TimelineCommandBlockRenderState"],"sources":["../../src/primitives/timeline-command-block.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n\tCOMMAND_PACKAGE_MANAGERS,\n\tCOMMAND_PREFERENCE_EVENT,\n\tCOMMAND_PREFERENCE_STORAGE_KEY,\n\ttype CommandPackageManager,\n\ttype CommandVariants,\n\tDEFAULT_PACKAGE_MANAGER,\n\tisCommandPackageManager,\n} from \"./command-block-utils\";\n\nexport type TimelineCommandBlockRenderState = {\n\tcommands: CommandVariants;\n\tpackageManagers: readonly CommandPackageManager[];\n\tactivePackageManager: CommandPackageManager;\n\tactiveCommand: string;\n\tsetPackageManager: (packageManager: CommandPackageManager) => void;\n\thasCopied: boolean;\n\tonCopy: () => Promise<boolean>;\n};\n\nexport type TimelineCommandBlockProps = {\n\tcommands: CommandVariants;\n\tclassName?: string;\n\tchildren?: (state: TimelineCommandBlockRenderState) => React.ReactNode;\n};\n\nfunction readStoredPackageManager(): CommandPackageManager {\n\tif (typeof window === \"undefined\") {\n\t\treturn DEFAULT_PACKAGE_MANAGER;\n\t}\n\n\tconst storedValue = window.localStorage.getItem(\n\t\tCOMMAND_PREFERENCE_STORAGE_KEY\n\t);\n\tif (storedValue && isCommandPackageManager(storedValue)) {\n\t\treturn storedValue;\n\t}\n\n\treturn DEFAULT_PACKAGE_MANAGER;\n}\n\nasync function copyToClipboard(value: string): Promise<boolean> {\n\tif (typeof navigator === \"undefined\" || !navigator.clipboard) {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tawait navigator.clipboard.writeText(value);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Shared command block UI with package-manager tabs and copy action.\n */\nexport function TimelineCommandBlock({\n\tcommands,\n\tclassName,\n\tchildren,\n}: TimelineCommandBlockProps): React.ReactElement {\n\tconst [packageManager, setPackageManager] =\n\t\tReact.useState<CommandPackageManager>(() => readStoredPackageManager());\n\tconst [hasCopied, setHasCopied] = React.useState(false);\n\n\tReact.useEffect(() => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\n\t\tsetPackageManager(readStoredPackageManager());\n\n\t\tconst onStorageChange = (event: StorageEvent) => {\n\t\t\tif (event.key !== COMMAND_PREFERENCE_STORAGE_KEY) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (event.newValue && isCommandPackageManager(event.newValue)) {\n\t\t\t\tsetPackageManager(event.newValue);\n\t\t\t}\n\t\t};\n\n\t\tconst onPreferenceEvent = (event: Event) => {\n\t\t\tconst nextValue = (event as CustomEvent<CommandPackageManager>).detail;\n\t\t\tif (nextValue && isCommandPackageManager(nextValue)) {\n\t\t\t\tsetPackageManager(nextValue);\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(\"storage\", onStorageChange);\n\t\twindow.addEventListener(\n\t\t\tCOMMAND_PREFERENCE_EVENT,\n\t\t\tonPreferenceEvent as EventListener\n\t\t);\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener(\"storage\", onStorageChange);\n\t\t\twindow.removeEventListener(\n\t\t\t\tCOMMAND_PREFERENCE_EVENT,\n\t\t\t\tonPreferenceEvent as EventListener\n\t\t\t);\n\t\t};\n\t}, []);\n\n\tReact.useEffect(() => {\n\t\tif (!hasCopied) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst timer = window.setTimeout(() => {\n\t\t\tsetHasCopied(false);\n\t\t}, 1800);\n\n\t\treturn () => {\n\t\t\twindow.clearTimeout(timer);\n\t\t};\n\t}, [hasCopied]);\n\n\tconst setPackageManagerPreference = React.useCallback(\n\t\t(nextValue: CommandPackageManager) => {\n\t\t\tsetPackageManager(nextValue);\n\n\t\t\tif (typeof window === \"undefined\") {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\twindow.localStorage.setItem(COMMAND_PREFERENCE_STORAGE_KEY, nextValue);\n\t\t\twindow.dispatchEvent(\n\t\t\t\tnew CustomEvent<CommandPackageManager>(COMMAND_PREFERENCE_EVENT, {\n\t\t\t\t\tdetail: nextValue,\n\t\t\t\t})\n\t\t\t);\n\t\t},\n\t\t[]\n\t);\n\n\tconst activeCommand = commands[packageManager];\n\n\tconst onCopy = React.useCallback(async () => {\n\t\tconst didCopy = await copyToClipboard(activeCommand);\n\t\tif (didCopy) {\n\t\t\tsetHasCopied(true);\n\t\t}\n\n\t\treturn didCopy;\n\t}, [activeCommand]);\n\n\tconst renderState: TimelineCommandBlockRenderState = {\n\t\tcommands,\n\t\tpackageManagers: COMMAND_PACKAGE_MANAGERS,\n\t\tactivePackageManager: packageManager,\n\t\tactiveCommand,\n\t\tsetPackageManager: setPackageManagerPreference,\n\t\thasCopied,\n\t\tonCopy,\n\t};\n\n\treturn (\n\t\t<div className={className} data-co-command-block=\"\">\n\t\t\t{typeof children === \"function\" ? (\n\t\t\t\tchildren(renderState)\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t{COMMAND_PACKAGE_MANAGERS.map((manager) => (\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\tkey={manager}\n\t\t\t\t\t\t\t\t\tonClick={() => setPackageManagerPreference(manager)}\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{manager}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\tvoid onCopy();\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{hasCopied ? \"Copied\" : \"Copy\"}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<pre>\n\t\t\t\t\t\t<code className=\"language-bash\">{activeCommand}</code>\n\t\t\t\t\t</pre>\n\t\t\t\t</>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;AA2BA,SAAS,2BAAkD;AAC1D,KAAI,OAAO,WAAW,YACrB,QAAO;CAGR,MAAM,cAAc,OAAO,aAAa,QACvC,+BACA;AACD,KAAI,eAAe,wBAAwB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MAAM,gBAAgB,SAAS;CAE/B,MAAM,SAASA,QAAM,YAAY,YAAY;EAC5C,MAAM,UAAU,MAAM,gBAAgB,cAAc;AACpD,MAAI,QACH,cAAa,KAAK;AAGnB,SAAO;IACL,CAAC,cAAc,CAAC;CAEnB,MAAMC,cAA+C;EACpD;EACA,iBAAiB;EACjB,sBAAsB;EACtB;EACA,mBAAmB;EACnB;EACA;EACA;AAED,QACC,oBAAC;EAAe;EAAW,yBAAsB;YAC/C,OAAO,aAAa,aACpB,SAAS,YAAY,GAErB,4CACC,qBAAC,oBACA,oBAAC,mBACC,yBAAyB,KAAK,YAC9B,oBAAC;GAEA,eAAe,4BAA4B,QAAQ;GACnD,MAAK;aAEJ;KAJI,QAKG,CACR,GACG,EAEN,oBAAC;GACA,eAAe;AACd,IAAK,QAAQ;;GAEd,MAAK;aAEJ,YAAY,WAAW;IAChB,IACJ,EAEN,oBAAC,mBACA,oBAAC;GAAK,WAAU;aAAiB;IAAqB,GACjD,IACJ;GAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"timeline-item-group.d.ts","names":[],"sources":["../../src/primitives/timeline-item-group.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AASA;AAyBA;AACsB,KA1BV,4BAAA,GA0BU;EAArB,UAAM,EAxBM,UAwBN;EAD8B,QAAA,EAAA,MAAA;EAKjC,UAAM,CAAA,EA1BI,UA0BJ;EACG,cAAA,EAAA,OAAA;EAAiC,kBAAM,EAAA,OAAA;EAG5C,SAAA,EAAA,OAAA;EAIM,IAAA,EAAA,OAAA;EAIK,YAAA,EAAA,OAAA;EAAG,SAAA,EAAA,MAAA;EAST,WAAA,EAAA,MAAA,GAuGT,SAAA;EAvG0B,UAAA,EAAA,MAAA,GAAA,SAAA;EAAA,mBAAA,CAAA,EAAA,OAAA;EAAA,SAAA,CAAA,EAAA,SAAA,MAAA,EAAA;CArB1B;AACS,KAND,sBAAA,GAAyB,IAMxB,CALZ,OAAA,CAAM,cAKM,CALS,cAKT,CAAA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eAAA;aAfvC,OAAA,CAAM;;;QAIA,OAAA,CAAM;;;;;KAqDJ,mCAAA,GAAsC,KACjD,OAAA,CAAM,eAAe;aAIlB,OAAA,CAAM;aAEG;;;;;QAEH,OAAA,CAAM;;;;oBAIG;;;;;;;cAQN,gCAA8B,OAAA,CAAA,0BAAA,KAAA,OAAA,CAAA,eAAA;aAhBvC,OAAA,CAAM;aAEG;;;;;QAEH,OAAA,CAAM;;;;oBAIG"}
@@ -1,4 +1,5 @@
1
1
  import { useRenderElement } from "../utils/use-render-element.js";
2
+ import { getTimelineItemSender } from "../utils/timeline-item-sender.js";
2
3
  import * as React$1 from "react";
3
4
 
4
5
  //#region src/primitives/timeline-item-group.tsx
@@ -13,21 +14,10 @@ const TimelineItemGroup = (() => {
13
14
  const { viewerType, ...elementProps } = restProps;
14
15
  const firstItem = items[0];
15
16
  const lastItem = items.at(-1);
16
- let senderId = "";
17
- let senderType;
18
- if (firstItem?.visitorId) {
19
- senderId = firstItem.visitorId;
20
- senderType = "visitor";
21
- } else if (firstItem?.aiAgentId) {
22
- senderId = firstItem.aiAgentId;
23
- senderType = "ai";
24
- } else if (firstItem?.userId) {
25
- senderId = firstItem.userId;
26
- senderType = "team_member";
27
- } else {
28
- senderId = firstItem?.id || "unknown";
29
- senderType = "team_member";
30
- }
17
+ const { senderId, senderType } = firstItem ? getTimelineItemSender(firstItem) : {
18
+ senderId: "unknown",
19
+ senderType: "team_member"
20
+ };
31
21
  const isSentByViewer = viewerId ? senderId === viewerId : viewerType ? senderType === viewerType : false;
32
22
  const isReceivedByViewer = viewerId ? senderId !== viewerId : viewerType ? senderType !== viewerType : true;
33
23
  const isVisitor = senderType === "visitor";
@@ -1 +1 @@
1
- {"version":3,"file":"timeline-item-group.js","names":["React","senderType: SenderType","renderProps: TimelineItemGroupRenderProps","_lastReaderIds: string[]","_readers: Array<{ userId: string; isLastRead: boolean }>"],"sources":["../../src/primitives/timeline-item-group.tsx"],"sourcesContent":["import type { SenderType } from \"@cossistant/types\";\nimport type { TimelineItem as TimelineItemType } from \"@cossistant/types/api/timeline-item\";\nimport * as React from \"react\";\nimport { useRenderElement } from \"../utils/use-render-element\";\n\n/**\n * Shape returned to render-prop children describing the grouped timeline items state\n * and viewer specific flags.\n */\nexport type TimelineItemGroupRenderProps = {\n\t// Sender information\n\tsenderType: SenderType;\n\tsenderId: string;\n\tviewerType?: SenderType;\n\n\t// POV flags - who is viewing\n\tisSentByViewer: boolean; // True if the current viewer sent these items\n\tisReceivedByViewer: boolean; // True if the current viewer received these items\n\n\t// Sender type flags for convenience\n\tisVisitor: boolean;\n\tisAI: boolean;\n\tisTeamMember: boolean;\n\n\t// Item info\n\titemCount: number;\n\tfirstItemId: string | undefined;\n\tlastItemId: string | undefined;\n\n\t// Seen status\n\thasBeenSeenByViewer?: boolean;\n\tseenByIds?: readonly string[]; // IDs of users who have seen the last item in group\n};\n\nexport type TimelineItemGroupProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: TimelineItemGroupRenderProps) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\titems: TimelineItemType[];\n\n\t// POV context - who is viewing these timeline items\n\tviewerId?: string; // ID of the current viewer\n\tviewerType?: SenderType; // Type of the current viewer\n\n\t// Seen data\n\tseenByIds?: readonly string[]; // IDs of users who have seen these timeline items\n\tlastReadItemIds?: Map<string, string>; // Map of userId -> lastItemId they read\n};\n\n/**\n * Groups sequential timeline items from the same sender and exposes render helpers\n * that describe who sent the batch and whether the active viewer has seen it.\n * Consumers can either render their own layout via a render prop or rely on\n * slotted children. Typically used for MESSAGE-type items; EVENT items are usually rendered separately.\n */\nexport const TimelineItemGroup = (() => {\n\tconst Component = React.forwardRef<HTMLDivElement, TimelineItemGroupProps>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\titems = [],\n\t\t\t\tviewerId,\n\t\t\t\tseenByIds = [] as readonly string[],\n\t\t\t\tlastReadItemIds,\n\t\t\t\t...restProps\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst { viewerType, ...elementProps } = restProps;\n\n\t\t\t// Determine sender type from first timeline item in group\n\t\t\tconst firstItem = items[0];\n\t\t\tconst lastItem = items.at(-1);\n\n\t\t\t// Determine sender info\n\t\t\tlet senderId = \"\";\n\t\t\tlet senderType: SenderType;\n\n\t\t\tif (firstItem?.visitorId) {\n\t\t\t\tsenderId = firstItem.visitorId;\n\t\t\t\tsenderType = \"visitor\" as SenderType;\n\t\t\t} else if (firstItem?.aiAgentId) {\n\t\t\t\tsenderId = firstItem.aiAgentId;\n\t\t\t\tsenderType = \"ai\" as SenderType;\n\t\t\t} else if (firstItem?.userId) {\n\t\t\t\tsenderId = firstItem.userId;\n\t\t\t\tsenderType = \"team_member\" as SenderType;\n\t\t\t} else {\n\t\t\t\t// Fallback\n\t\t\t\tsenderId = firstItem?.id || \"unknown\";\n\t\t\t\tsenderType = \"team_member\" as SenderType;\n\t\t\t}\n\n\t\t\t// Determine POV\n\t\t\tconst isSentByViewer = viewerId\n\t\t\t\t? senderId === viewerId\n\t\t\t\t: viewerType\n\t\t\t\t\t? senderType === viewerType\n\t\t\t\t\t: false;\n\t\t\tconst isReceivedByViewer = viewerId\n\t\t\t\t? senderId !== viewerId\n\t\t\t\t: viewerType\n\t\t\t\t\t? senderType !== viewerType\n\t\t\t\t\t: true;\n\n\t\t\t// Convenience flags\n\t\t\tconst isVisitor = senderType === \"visitor\";\n\t\t\tconst isAI = senderType === \"ai\";\n\t\t\tconst isTeamMember = senderType === \"team_member\";\n\n\t\t\t// Check if viewer has seen these timeline items\n\t\t\tconst hasBeenSeenByViewer = viewerId\n\t\t\t\t? seenByIds.includes(viewerId)\n\t\t\t\t: undefined;\n\n\t\t\tconst renderProps: TimelineItemGroupRenderProps = {\n\t\t\t\tsenderType,\n\t\t\t\tsenderId,\n\t\t\t\tviewerType,\n\t\t\t\tisSentByViewer,\n\t\t\t\tisReceivedByViewer,\n\t\t\t\tisVisitor,\n\t\t\t\tisAI,\n\t\t\t\tisTeamMember,\n\t\t\t\titemCount: items.length,\n\t\t\t\tfirstItemId: firstItem?.id,\n\t\t\t\tlastItemId: lastItem?.id,\n\t\t\t\thasBeenSeenByViewer,\n\t\t\t\tseenByIds,\n\t\t\t};\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\" ? children(renderProps) : children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tstate: renderProps,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\trole: \"group\",\n\t\t\t\t\t\t\"aria-label\": `Timeline item group from ${senderType}`,\n\t\t\t\t\t\t...elementProps,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemGroup\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupAvatarProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode;\n\tasChild?: boolean;\n\tclassName?: string;\n};\n\n/**\n * Optional slot rendered next to a grouped batch to display an avatar, agent\n * badge or any other sender metadata supplied by the consumer UI.\n */\nexport const TimelineItemGroupAvatar = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupAvatarProps\n\t>(({ children, className, asChild = false, ...props }, ref) =>\n\t\tuseRenderElement(\n\t\t\t\"div\",\n\t\t\t{\n\t\t\t\tclassName,\n\t\t\t\tasChild,\n\t\t\t},\n\t\t\t{\n\t\t\t\tref,\n\t\t\t\tprops: {\n\t\t\t\t\t...props,\n\t\t\t\t\tchildren,\n\t\t\t\t},\n\t\t\t}\n\t\t)\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupAvatar\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupHeaderProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: {\n\t\t\t\tname?: string;\n\t\t\t\tsenderId?: string;\n\t\t\t\tsenderType?: SenderType;\n\t\t }) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\tname?: string;\n\tsenderId?: string;\n\tsenderType?: SenderType;\n};\n\n/**\n * Decorative or semantic wrapper rendered above a timeline item batch. Useful for\n * injecting agent names, timestamps or custom status labels tied to the sender\n * metadata supplied by `TimelineItemGroup`.\n */\nexport const TimelineItemGroupHeader = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupHeaderProps\n\t>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\tname,\n\t\t\t\tsenderId,\n\t\t\t\tsenderType,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children({ name, senderId, senderType })\n\t\t\t\t\t: children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupHeader\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupContentProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode;\n\tasChild?: boolean;\n\tclassName?: string;\n};\n\n/**\n * Container for the actual timeline items within a batch. Consumers can\n * override the structure while inheriting layout props passed down from the\n * parent group.\n */\nexport const TimelineItemGroupContent = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupContentProps\n\t>(({ children, className, asChild = false, ...props }, ref) =>\n\t\tuseRenderElement(\n\t\t\t\"div\",\n\t\t\t{\n\t\t\t\tclassName,\n\t\t\t\tasChild,\n\t\t\t},\n\t\t\t{\n\t\t\t\tref,\n\t\t\t\tprops: {\n\t\t\t\t\t...props,\n\t\t\t\t\tchildren,\n\t\t\t\t},\n\t\t\t}\n\t\t)\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupContent\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupSeenIndicatorProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: {\n\t\t\t\tseenByIds: readonly string[];\n\t\t\t\thasBeenSeen: boolean;\n\t\t }) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\tseenByIds?: readonly string[];\n};\n\n/**\n * Utility slot for showing who has viewed the most recent timeline item in the\n * group. Works with simple text children or a render prop for advanced\n * displays.\n */\nexport const TimelineItemGroupSeenIndicator = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupSeenIndicatorProps\n\t>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\tseenByIds = [] as readonly string[],\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst hasBeenSeen = seenByIds.length > 0;\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children({ seenByIds, hasBeenSeen })\n\t\t\t\t\t: children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupSeenIndicator\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupReadIndicatorProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: {\n\t\t\t\treaders: Array<{ userId: string; isLastRead: boolean }>;\n\t\t\t\tlastReaderIds: string[];\n\t\t }) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\titemId: string;\n\tlastReadItemIds?: Map<string, string>;\n};\n\n/**\n * Renders read receipts for the tail timeline item in a group. It surfaces the list\n * of readers and callers can decide whether to render avatars, tooltips or a\n * basic label.\n */\nexport const TimelineItemGroupReadIndicator = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupReadIndicatorProps\n\t>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\titemId,\n\t\t\t\tlastReadItemIds,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\t// Find all users who stopped reading at this timeline item\n\t\t\tconst { lastReaderIds, readers } = React.useMemo(() => {\n\t\t\t\tconst _lastReaderIds: string[] = [];\n\t\t\t\tconst _readers: Array<{ userId: string; isLastRead: boolean }> = [];\n\n\t\t\t\tif (lastReadItemIds) {\n\t\t\t\t\tlastReadItemIds.forEach((lastItemId, userId) => {\n\t\t\t\t\t\tif (lastItemId === itemId) {\n\t\t\t\t\t\t\t_lastReaderIds.push(userId);\n\t\t\t\t\t\t\t_readers.push({ userId, isLastRead: true });\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn { lastReaderIds: _lastReaderIds, readers: _readers };\n\t\t\t}, [itemId, lastReadItemIds]);\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children({ readers, lastReaderIds })\n\t\t\t\t\t: children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupReadIndicator\";\n\treturn Component;\n})();\n"],"mappings":";;;;;;;;;;AA4DA,MAAa,2BAA2B;CACvC,MAAM,YAAYA,QAAM,YAEtB,EACC,UACA,WACA,UAAU,OACV,QAAQ,EAAE,EACV,UACA,YAAY,EAAE,EACd,iBACA,GAAG,aAEJ,QACI;EACJ,MAAM,EAAE,YAAY,GAAG,iBAAiB;EAGxC,MAAM,YAAY,MAAM;EACxB,MAAM,WAAW,MAAM,GAAG,GAAG;EAG7B,IAAI,WAAW;EACf,IAAIC;AAEJ,MAAI,WAAW,WAAW;AACzB,cAAW,UAAU;AACrB,gBAAa;aACH,WAAW,WAAW;AAChC,cAAW,UAAU;AACrB,gBAAa;aACH,WAAW,QAAQ;AAC7B,cAAW,UAAU;AACrB,gBAAa;SACP;AAEN,cAAW,WAAW,MAAM;AAC5B,gBAAa;;EAId,MAAM,iBAAiB,WACpB,aAAa,WACb,aACC,eAAe,aACf;EACJ,MAAM,qBAAqB,WACxB,aAAa,WACb,aACC,eAAe,aACf;EAGJ,MAAM,YAAY,eAAe;EACjC,MAAM,OAAO,eAAe;EAC5B,MAAM,eAAe,eAAe;EAGpC,MAAM,sBAAsB,WACzB,UAAU,SAAS,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UAAU,OACV,YAAY,EAAE,EACd,GAAG,SAEJ,QACI;EACJ,MAAM,cAAc,UAAU,SAAS;EACvC,MAAM,UACL,OAAO,aAAa,aACjB,SAAS;GAAE;GAAW;GAAa,CAAC,GACpC;AAEJ,SAAO,iBACN,OACA;GACC;GACA;GACA,EACD;GACC;GACA,OAAO;IACN,GAAG;IACH,UAAU;IACV;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ;;;;;;AAuBJ,MAAa,wCAAwC;CACpD,MAAM,YAAYA,QAAM,YAKtB,EACC,UACA,WACA,UAAU,OACV,QACA,iBACA,GAAG,SAEJ,QACI;EAEJ,MAAM,EAAE,eAAe,YAAYA,QAAM,cAAc;GACtD,MAAMG,iBAA2B,EAAE;GACnC,MAAMC,WAA2D,EAAE;AAEnE,OAAI,gBACH,iBAAgB,SAAS,YAAY,WAAW;AAC/C,QAAI,eAAe,QAAQ;AAC1B,oBAAe,KAAK,OAAO;AAC3B,cAAS,KAAK;MAAE;MAAQ,YAAY;MAAM,CAAC;;KAE3C;AAGH,UAAO;IAAE,eAAe;IAAgB,SAAS;IAAU;KACzD,CAAC,QAAQ,gBAAgB,CAAC;EAE7B,MAAM,UACL,OAAO,aAAa,aACjB,SAAS;GAAE;GAAS;GAAe,CAAC,GACpC;AAEJ,SAAO,iBACN,OACA;GACC;GACA;GACA,EACD;GACC;GACA,OAAO;IACN,GAAG;IACH,UAAU;IACV;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ"}
1
+ {"version":3,"file":"timeline-item-group.js","names":["React","renderProps: TimelineItemGroupRenderProps","_lastReaderIds: string[]","_readers: Array<{ userId: string; isLastRead: boolean }>"],"sources":["../../src/primitives/timeline-item-group.tsx"],"sourcesContent":["import type { SenderType } from \"@cossistant/types\";\nimport type { TimelineItem as TimelineItemType } from \"@cossistant/types/api/timeline-item\";\nimport * as React from \"react\";\nimport { getTimelineItemSender } from \"../utils/timeline-item-sender\";\nimport { useRenderElement } from \"../utils/use-render-element\";\n\n/**\n * Shape returned to render-prop children describing the grouped timeline items state\n * and viewer specific flags.\n */\nexport type TimelineItemGroupRenderProps = {\n\t// Sender information\n\tsenderType: SenderType;\n\tsenderId: string;\n\tviewerType?: SenderType;\n\n\t// POV flags - who is viewing\n\tisSentByViewer: boolean; // True if the current viewer sent these items\n\tisReceivedByViewer: boolean; // True if the current viewer received these items\n\n\t// Sender type flags for convenience\n\tisVisitor: boolean;\n\tisAI: boolean;\n\tisTeamMember: boolean;\n\n\t// Item info\n\titemCount: number;\n\tfirstItemId: string | undefined;\n\tlastItemId: string | undefined;\n\n\t// Seen status\n\thasBeenSeenByViewer?: boolean;\n\tseenByIds?: readonly string[]; // IDs of users who have seen the last item in group\n};\n\nexport type TimelineItemGroupProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: TimelineItemGroupRenderProps) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\titems: TimelineItemType[];\n\n\t// POV context - who is viewing these timeline items\n\tviewerId?: string; // ID of the current viewer\n\tviewerType?: SenderType; // Type of the current viewer\n\n\t// Seen data\n\tseenByIds?: readonly string[]; // IDs of users who have seen these timeline items\n\tlastReadItemIds?: Map<string, string>; // Map of userId -> lastItemId they read\n};\n\n/**\n * Groups sequential timeline items from the same sender and exposes render helpers\n * that describe who sent the batch and whether the active viewer has seen it.\n * Consumers can either render their own layout via a render prop or rely on\n * slotted children. Typically used for MESSAGE-type items; EVENT items are usually rendered separately.\n */\nexport const TimelineItemGroup = (() => {\n\tconst Component = React.forwardRef<HTMLDivElement, TimelineItemGroupProps>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\titems = [],\n\t\t\t\tviewerId,\n\t\t\t\tseenByIds = [] as readonly string[],\n\t\t\t\tlastReadItemIds,\n\t\t\t\t...restProps\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst { viewerType, ...elementProps } = restProps;\n\n\t\t\t// Determine sender type from first timeline item in group\n\t\t\tconst firstItem = items[0];\n\t\t\tconst lastItem = items.at(-1);\n\n\t\t\tconst { senderId, senderType } = firstItem\n\t\t\t\t? getTimelineItemSender(firstItem)\n\t\t\t\t: { senderId: \"unknown\", senderType: \"team_member\" as SenderType };\n\n\t\t\t// Determine POV\n\t\t\tconst isSentByViewer = viewerId\n\t\t\t\t? senderId === viewerId\n\t\t\t\t: viewerType\n\t\t\t\t\t? senderType === viewerType\n\t\t\t\t\t: false;\n\t\t\tconst isReceivedByViewer = viewerId\n\t\t\t\t? senderId !== viewerId\n\t\t\t\t: viewerType\n\t\t\t\t\t? senderType !== viewerType\n\t\t\t\t\t: true;\n\n\t\t\t// Convenience flags\n\t\t\tconst isVisitor = senderType === \"visitor\";\n\t\t\tconst isAI = senderType === \"ai\";\n\t\t\tconst isTeamMember = senderType === \"team_member\";\n\n\t\t\t// Check if viewer has seen these timeline items\n\t\t\tconst hasBeenSeenByViewer = viewerId\n\t\t\t\t? seenByIds.includes(viewerId)\n\t\t\t\t: undefined;\n\n\t\t\tconst renderProps: TimelineItemGroupRenderProps = {\n\t\t\t\tsenderType,\n\t\t\t\tsenderId,\n\t\t\t\tviewerType,\n\t\t\t\tisSentByViewer,\n\t\t\t\tisReceivedByViewer,\n\t\t\t\tisVisitor,\n\t\t\t\tisAI,\n\t\t\t\tisTeamMember,\n\t\t\t\titemCount: items.length,\n\t\t\t\tfirstItemId: firstItem?.id,\n\t\t\t\tlastItemId: lastItem?.id,\n\t\t\t\thasBeenSeenByViewer,\n\t\t\t\tseenByIds,\n\t\t\t};\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\" ? children(renderProps) : children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tstate: renderProps,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\trole: \"group\",\n\t\t\t\t\t\t\"aria-label\": `Timeline item group from ${senderType}`,\n\t\t\t\t\t\t...elementProps,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemGroup\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupAvatarProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode;\n\tasChild?: boolean;\n\tclassName?: string;\n};\n\n/**\n * Optional slot rendered next to a grouped batch to display an avatar, agent\n * badge or any other sender metadata supplied by the consumer UI.\n */\nexport const TimelineItemGroupAvatar = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupAvatarProps\n\t>(({ children, className, asChild = false, ...props }, ref) =>\n\t\tuseRenderElement(\n\t\t\t\"div\",\n\t\t\t{\n\t\t\t\tclassName,\n\t\t\t\tasChild,\n\t\t\t},\n\t\t\t{\n\t\t\t\tref,\n\t\t\t\tprops: {\n\t\t\t\t\t...props,\n\t\t\t\t\tchildren,\n\t\t\t\t},\n\t\t\t}\n\t\t)\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupAvatar\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupHeaderProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: {\n\t\t\t\tname?: string;\n\t\t\t\tsenderId?: string;\n\t\t\t\tsenderType?: SenderType;\n\t\t }) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\tname?: string;\n\tsenderId?: string;\n\tsenderType?: SenderType;\n};\n\n/**\n * Decorative or semantic wrapper rendered above a timeline item batch. Useful for\n * injecting agent names, timestamps or custom status labels tied to the sender\n * metadata supplied by `TimelineItemGroup`.\n */\nexport const TimelineItemGroupHeader = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupHeaderProps\n\t>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\tname,\n\t\t\t\tsenderId,\n\t\t\t\tsenderType,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children({ name, senderId, senderType })\n\t\t\t\t\t: children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupHeader\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupContentProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode;\n\tasChild?: boolean;\n\tclassName?: string;\n};\n\n/**\n * Container for the actual timeline items within a batch. Consumers can\n * override the structure while inheriting layout props passed down from the\n * parent group.\n */\nexport const TimelineItemGroupContent = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupContentProps\n\t>(({ children, className, asChild = false, ...props }, ref) =>\n\t\tuseRenderElement(\n\t\t\t\"div\",\n\t\t\t{\n\t\t\t\tclassName,\n\t\t\t\tasChild,\n\t\t\t},\n\t\t\t{\n\t\t\t\tref,\n\t\t\t\tprops: {\n\t\t\t\t\t...props,\n\t\t\t\t\tchildren,\n\t\t\t\t},\n\t\t\t}\n\t\t)\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupContent\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupSeenIndicatorProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: {\n\t\t\t\tseenByIds: readonly string[];\n\t\t\t\thasBeenSeen: boolean;\n\t\t }) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\tseenByIds?: readonly string[];\n};\n\n/**\n * Utility slot for showing who has viewed the most recent timeline item in the\n * group. Works with simple text children or a render prop for advanced\n * displays.\n */\nexport const TimelineItemGroupSeenIndicator = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupSeenIndicatorProps\n\t>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\tseenByIds = [] as readonly string[],\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst hasBeenSeen = seenByIds.length > 0;\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children({ seenByIds, hasBeenSeen })\n\t\t\t\t\t: children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupSeenIndicator\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupReadIndicatorProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: {\n\t\t\t\treaders: Array<{ userId: string; isLastRead: boolean }>;\n\t\t\t\tlastReaderIds: string[];\n\t\t }) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\titemId: string;\n\tlastReadItemIds?: Map<string, string>;\n};\n\n/**\n * Renders read receipts for the tail timeline item in a group. It surfaces the list\n * of readers and callers can decide whether to render avatars, tooltips or a\n * basic label.\n */\nexport const TimelineItemGroupReadIndicator = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupReadIndicatorProps\n\t>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\titemId,\n\t\t\t\tlastReadItemIds,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\t// Find all users who stopped reading at this timeline item\n\t\t\tconst { lastReaderIds, readers } = React.useMemo(() => {\n\t\t\t\tconst _lastReaderIds: string[] = [];\n\t\t\t\tconst _readers: Array<{ userId: string; isLastRead: boolean }> = [];\n\n\t\t\t\tif (lastReadItemIds) {\n\t\t\t\t\tlastReadItemIds.forEach((lastItemId, userId) => {\n\t\t\t\t\t\tif (lastItemId === itemId) {\n\t\t\t\t\t\t\t_lastReaderIds.push(userId);\n\t\t\t\t\t\t\t_readers.push({ userId, isLastRead: true });\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn { lastReaderIds: _lastReaderIds, readers: _readers };\n\t\t\t}, [itemId, lastReadItemIds]);\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children({ readers, lastReaderIds })\n\t\t\t\t\t: children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupReadIndicator\";\n\treturn Component;\n})();\n"],"mappings":";;;;;;;;;;;AA6DA,MAAa,2BAA2B;CACvC,MAAM,YAAYA,QAAM,YAEtB,EACC,UACA,WACA,UAAU,OACV,QAAQ,EAAE,EACV,UACA,YAAY,EAAE,EACd,iBACA,GAAG,aAEJ,QACI;EACJ,MAAM,EAAE,YAAY,GAAG,iBAAiB;EAGxC,MAAM,YAAY,MAAM;EACxB,MAAM,WAAW,MAAM,GAAG,GAAG;EAE7B,MAAM,EAAE,UAAU,eAAe,YAC9B,sBAAsB,UAAU,GAChC;GAAE,UAAU;GAAW,YAAY;GAA6B;EAGnE,MAAM,iBAAiB,WACpB,aAAa,WACb,aACC,eAAe,aACf;EACJ,MAAM,qBAAqB,WACxB,aAAa,WACb,aACC,eAAe,aACf;EAGJ,MAAM,YAAY,eAAe;EACjC,MAAM,OAAO,eAAe;EAC5B,MAAM,eAAe,eAAe;EAGpC,MAAM,sBAAsB,WACzB,UAAU,SAAS,SAAS,GAC5B;EAEH,MAAMC,cAA4C;GACjD;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,MAAM;GACjB,aAAa,WAAW;GACxB,YAAY,UAAU;GACtB;GACA;GACA;EAED,MAAM,UACL,OAAO,aAAa,aAAa,SAAS,YAAY,GAAG;AAE1D,SAAO,iBACN,OACA;GACC;GACA;GACA,EACD;GACC;GACA,OAAO;GACP,OAAO;IACN,MAAM;IACN,cAAc,4BAA4B;IAC1C,GAAG;IACH,UAAU;IACV;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ;;;;;AAeJ,MAAa,iCAAiC;CAC7C,MAAM,YAAYD,QAAM,YAGrB,EAAE,UAAU,WAAW,UAAU,OAAO,GAAG,SAAS,QACtD,iBACC,OACA;EACC;EACA;EACA,EACD;EACC;EACA,OAAO;GACN,GAAG;GACH;GACA;EACD,CACD,CACD;AA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Q;AAC1B,oBAAe,KAAK,OAAO;AAC3B,cAAS,KAAK;MAAE;MAAQ,YAAY;MAAM,CAAC;;KAE3C;AAGH,UAAO;IAAE,eAAe;IAAgB,SAAS;IAAU;KACzD,CAAC,QAAQ,gBAAgB,CAAC;EAE7B,MAAM,UACL,OAAO,aAAa,aACjB,SAAS;GAAE;GAAS;GAAe,CAAC,GACpC;AAEJ,SAAO,iBACN,OACA;GACC;GACA;GACA,EACD;GACC;GACA,OAAO;IACN,GAAG;IACH,UAAU;IACV;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ"}
@@ -1,4 +1,5 @@
1
1
  import { TimelineItem as TimelineItem$1 } from "../packages/types/src/api/timeline-item.js";
2
+ import { CommandVariants } from "./command-block-utils.js";
2
3
  import * as React$1 from "react";
3
4
 
4
5
  //#region src/primitives/timeline-item.d.ts
@@ -14,7 +15,7 @@ type TimelineItemRenderProps = {
14
15
  timestamp: Date;
15
16
  text: string | null;
16
17
  senderType: "visitor" | "ai" | "human";
17
- itemType: "message" | "event" | "identification";
18
+ itemType: "message" | "event" | "identification" | "tool";
18
19
  };
19
20
  type TimelineItemProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
20
21
  children?: React$1.ReactNode | ((props: TimelineItemRenderProps) => React$1.ReactNode);
@@ -25,7 +26,7 @@ type TimelineItemProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"
25
26
  /**
26
27
  * Generic timeline item wrapper that adds accessibility attributes and resolves the
27
28
  * sender type into convenient render props for custom layouts. Works with
28
- * both MESSAGE and EVENT timeline item types.
29
+ * message, event, identification, and tool timeline item types.
29
30
  */
30
31
  declare const TimelineItem: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
31
32
  children?: React$1.ReactNode | ((props: TimelineItemRenderProps) => React$1.ReactNode);
@@ -33,12 +34,30 @@ declare const TimelineItem: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLA
33
34
  className?: string;
34
35
  item: TimelineItem$1;
35
36
  } & React$1.RefAttributes<HTMLDivElement>>;
37
+ type TimelineInlineCodeRendererProps = {
38
+ code: string;
39
+ };
40
+ type TimelineCodeBlockRendererProps = {
41
+ code: string;
42
+ language?: string;
43
+ fileName?: string;
44
+ };
45
+ type TimelineCommandBlockRendererProps = {
46
+ command: string;
47
+ commands: CommandVariants;
48
+ };
49
+ type TimelineItemContentMarkdownRenderers = {
50
+ inlineCode?: (props: TimelineInlineCodeRendererProps) => React$1.ReactNode;
51
+ codeBlock?: (props: TimelineCodeBlockRendererProps) => React$1.ReactNode;
52
+ commandBlock?: (props: TimelineCommandBlockRendererProps) => React$1.ReactNode;
53
+ };
36
54
  type TimelineItemContentProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
37
55
  children?: React$1.ReactNode | ((content: string) => React$1.ReactNode);
38
56
  asChild?: boolean;
39
57
  className?: string;
40
58
  text?: string | null;
41
59
  renderMarkdown?: boolean;
60
+ markdownRenderers?: TimelineItemContentMarkdownRenderers;
42
61
  };
43
62
  /**
44
63
  * Renders the content of a timeline item, optionally piping Markdown content through a
@@ -51,6 +70,7 @@ declare const TimelineItemContent: React$1.ForwardRefExoticComponent<Omit<React$
51
70
  className?: string;
52
71
  text?: string | null;
53
72
  renderMarkdown?: boolean;
73
+ markdownRenderers?: TimelineItemContentMarkdownRenderers;
54
74
  } & React$1.RefAttributes<HTMLDivElement>>;
55
75
  type TimelineItemTimestampProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, "children"> & {
56
76
  children?: React$1.ReactNode | ((timestamp: Date) => React$1.ReactNode);
@@ -71,5 +91,5 @@ declare const TimelineItemTimestamp: React$1.ForwardRefExoticComponent<Omit<Reac
71
91
  format?: (date: Date) => string;
72
92
  } & React$1.RefAttributes<HTMLSpanElement>>;
73
93
  //#endregion
74
- export { TimelineItem, TimelineItemContent, TimelineItemContentProps, TimelineItemProps, TimelineItemRenderProps, TimelineItemTimestamp, TimelineItemTimestampProps };
94
+ export { TimelineCodeBlockRendererProps, TimelineCommandBlockRendererProps, TimelineInlineCodeRendererProps, TimelineItem, TimelineItemContent, TimelineItemContentMarkdownRenderers, TimelineItemContentProps, TimelineItemProps, TimelineItemRenderProps, TimelineItemTimestamp, TimelineItemTimestampProps };
75
95
  //# sourceMappingURL=timeline-item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timeline-item.d.ts","names":[],"sources":["../../src/primitives/timeline-item.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAUA;AAUA;AACsB,KAXV,uBAAA,GAWU;EAArB,SAAM,EAAA,OAAA;EADyB,IAAA,EAAA,OAAA;EAK5B,OAAM,EAAA,OAAA;EACG,SAAA,EAZD,IAYC;EAA4B,IAAA,EAAM,MAAA,GAAA,IAAA;EAGxC,UAAA,EAAA,SAAA,GAAA,IAAA,GAAA,OAAA;EAAgB,QAAA,EAAA,SAAA,GAAA,OAAA,GAAA,gBAAA;AAQvB,CAAA;AAAyB,KAjBb,iBAAA,GAAoB,IAiBP,CAhBxB,OAAA,CAAM,cAgBkB,CAhBH,cAgBG,CAAA,EAAA,UAAA,CAAA,GAAA;EAAA,QAAA,CAAA,EAZrB,OAAA,CAAM,SAYe,GAAA,CAAA,CAAA,KAAA,EAXZ,uBAWY,EAAA,GAXgB,OAAA,CAAM,SAWtB,CAAA;EAAA,OAAA,CAAA,EAAA,OAAA;EAZrB,SAAM,CAAA,EAAA,MAAA;EACG,IAAA,EAGN,cAHM;CAA4B;;;;;;AAoM7B,cAzLC,YAyLuB,EAzLX,OAAA,CAAA,yBAyLW,CAzLX,IAyLW,CAzLX,OAAA,CAAA,cAyLW,CAzLX,cAyLW,CAAA,EAAA,UAAA,CAAA,GAAA;EACd,QAAA,CAAA,EAtMlB,OAAA,CAAM,SAsMY,GAAA,CAAA,CAAA,KAAA,EArMT,uBAqMS,EAAA,GArMmB,OAAA,CAAM,SAqMzB,CAAA;EAArB,OAAM,CAAA,EAAA,OAAA;EADgC,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,GA7EwC,OAAA,CAAM,SA6E9C,CAAA;EACK,OAAA,CAAA,EAAA,OAAA;EAAI,SAAA,CAAA,EAAA,MAAA;EAOR,IAAA,CAAA,EAAA,MAAA,GAAA,IAAA;EAAqB,cAAA,CAAA,EAAA,OAAA;EAAA,iBAAA,CAAA,EAhFb,oCAgFa;CAAA,wBAAA,eAAA,CAAA,CAAA;AAXtB,KAJA,0BAAA,GAA6B,IAIvB,CAHjB,OAAA,CAAM,cAGW,CAHI,eAGJ,CAAA,EAAA,UAAA,CAAA,GAAA;EAAyB,QAAA,CAAA,EAA/B,OAAA,CAAM,SAAyB,GAAA,CAAA,CAAA,SAAA,EAAA,IAAA,EAAA,GAAS,OAAA,CAAM,SAAf,CAAA;EAAS,OAAM,CAAA,EAAA,OAAA;EAG9C,SAAA,CAAA,EAAA,MAAA;EACK,SAAA,EADL,IACK;kBAAA;;;;;;cAOJ,uBAAqB,OAAA,CAAA,0BAAA,KAAA,OAAA,CAAA,eAAA;aAXtB,OAAA,CAAM,yBAAyB,SAAS,OAAA,CAAM;;;aAG9C;kBACK"}
@@ -1,14 +1,16 @@
1
1
  import { useRenderElement } from "../utils/use-render-element.js";
2
+ import { mapCommandVariants, mapInlineCommandFromParagraphChildren } from "./command-block-utils.js";
3
+ import { TimelineCodeBlock } from "./timeline-code-block.js";
4
+ import { TimelineCommandBlock } from "./timeline-command-block.js";
2
5
  import * as React$1 from "react";
3
- import { jsx } from "react/jsx-runtime";
4
- import ReactMarkdown from "react-markdown";
5
- import remarkBreaks from "remark-breaks";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { hasMarkdownFormatting, parseMarkdown } from "@cossistant/tiny-markdown/utils";
6
8
 
7
9
  //#region src/primitives/timeline-item.tsx
8
10
  /**
9
11
  * Generic timeline item wrapper that adds accessibility attributes and resolves the
10
12
  * sender type into convenient render props for custom layouts. Works with
11
- * both MESSAGE and EVENT timeline item types.
13
+ * message, event, identification, and tool timeline item types.
12
14
  */
13
15
  const TimelineItem = (() => {
14
16
  const Component = React$1.forwardRef(({ children, className, asChild = false, item, ...props }, ref) => {
@@ -29,6 +31,7 @@ const TimelineItem = (() => {
29
31
  const itemTypeLabel = (() => {
30
32
  if (item.type === "event") return "Event";
31
33
  if (item.type === "identification") return "Identification";
34
+ if (item.type === "tool") return "Tool call";
32
35
  if (isVisitor) return "visitor";
33
36
  if (isAI) return "AI assistant";
34
37
  return "human agent";
@@ -41,7 +44,7 @@ const TimelineItem = (() => {
41
44
  state: renderProps,
42
45
  props: {
43
46
  role: "article",
44
- "aria-label": `${item.type === "message" ? "Message" : "Event"} from ${itemTypeLabel}`,
47
+ "aria-label": `${item.type === "message" ? "Message" : item.type === "tool" ? "Tool call" : "Event"} from ${itemTypeLabel}`,
45
48
  ...props,
46
49
  children: content
47
50
  }
@@ -50,83 +53,147 @@ const TimelineItem = (() => {
50
53
  Component.displayName = "TimelineItem";
51
54
  return Component;
52
55
  })();
53
- const MemoizedMarkdownBlock = React$1.memo(({ content }) => {
54
- return /* @__PURE__ */ jsx(ReactMarkdown, {
55
- components: {
56
- p: ({ children }) => {
57
- if (children === void 0 || children === null || children === "" || Array.isArray(children) && children.every((c) => c === "\n" || c === "" || c == null)) return null;
58
- return /* @__PURE__ */ jsx("span", {
56
+ function parseMentionHref(href) {
57
+ if (!href.startsWith("mention:")) return null;
58
+ const parts = href.split(":");
59
+ const mentionType = parts[1];
60
+ const mentionId = parts.slice(2).join(":");
61
+ if (!(mentionType && mentionId)) return null;
62
+ return {
63
+ mentionType,
64
+ mentionId
65
+ };
66
+ }
67
+ function renderInlineCode(code, key, renderers) {
68
+ if (renderers?.inlineCode) return /* @__PURE__ */ jsx(React$1.Fragment, { children: renderers.inlineCode({ code }) }, key);
69
+ return /* @__PURE__ */ jsx("code", { children: code }, key);
70
+ }
71
+ function renderCodeBlock(props, key, renderers) {
72
+ if (renderers?.codeBlock) return /* @__PURE__ */ jsx(React$1.Fragment, { children: renderers.codeBlock(props) }, key);
73
+ return /* @__PURE__ */ jsx(TimelineCodeBlock, {
74
+ code: props.code,
75
+ fileName: props.fileName,
76
+ language: props.language
77
+ }, key);
78
+ }
79
+ function renderCommandBlock(props, key, renderers) {
80
+ if (renderers?.commandBlock) return /* @__PURE__ */ jsx(React$1.Fragment, { children: renderers.commandBlock(props) }, key);
81
+ return /* @__PURE__ */ jsx(TimelineCommandBlock, { commands: props.commands }, key);
82
+ }
83
+ function hasNonWhitespaceParagraphContent(children) {
84
+ return children.some((child) => child.type !== "text" || child.content.trim().length > 0);
85
+ }
86
+ function renderMarkdownToken(token, key, renderers) {
87
+ switch (token.type) {
88
+ case "text": return token.content;
89
+ case "strong": return /* @__PURE__ */ jsx("strong", {
90
+ className: "font-semibold",
91
+ children: token.children.map((child, index) => renderMarkdownToken(child, `${key}-${index}`, renderers))
92
+ }, key);
93
+ case "em": return /* @__PURE__ */ jsx("em", {
94
+ className: "italic",
95
+ children: token.children.map((child, index) => renderMarkdownToken(child, `${key}-${index}`, renderers))
96
+ }, key);
97
+ case "code": {
98
+ if (token.inline) return renderInlineCode(token.content, key, renderers);
99
+ const commandVariants = mapCommandVariants(token.content);
100
+ if (commandVariants) return renderCommandBlock({
101
+ command: token.content,
102
+ commands: commandVariants
103
+ }, key, renderers);
104
+ return renderCodeBlock({
105
+ code: token.content,
106
+ fileName: token.fileName,
107
+ language: token.language
108
+ }, key, renderers);
109
+ }
110
+ case "p": {
111
+ const inlineCommand = mapInlineCommandFromParagraphChildren(token.children);
112
+ if (inlineCommand) {
113
+ const beforeChildren = token.children.slice(0, inlineCommand.index);
114
+ const afterChildren = token.children.slice(inlineCommand.index + 1);
115
+ const hasBefore = hasNonWhitespaceParagraphContent(beforeChildren);
116
+ const hasAfter = hasNonWhitespaceParagraphContent(afterChildren);
117
+ if (!(hasBefore || hasAfter)) return renderCommandBlock({
118
+ command: inlineCommand.command,
119
+ commands: inlineCommand.variants
120
+ }, key, renderers);
121
+ return /* @__PURE__ */ jsxs("div", {
59
122
  className: "mt-1 block first:mt-0",
60
- children
61
- });
62
- },
63
- br: () => /* @__PURE__ */ jsx("br", {}),
64
- code: ({ children, ...props }) => {
65
- return !("className" in props && typeof props.className === "string" && props.className.includes("language-")) ? /* @__PURE__ */ jsx("code", {
66
- className: "rounded bg-co-background-300 px-1 py-0.5 text-xs",
67
- children
68
- }) : /* @__PURE__ */ jsx("pre", {
69
- className: "overflow-x-auto rounded bg-co-background-300 p-2",
70
- children: /* @__PURE__ */ jsx("code", {
71
- className: "text-xs",
72
- children
73
- })
74
- });
75
- },
76
- strong: ({ children }) => /* @__PURE__ */ jsx("strong", {
77
- className: "font-semibold",
78
- children
79
- }),
80
- ol: ({ children }) => /* @__PURE__ */ jsx("ol", {
81
- className: "my-0 list-decimal pl-6",
82
- children
83
- }),
84
- ul: ({ children }) => /* @__PURE__ */ jsx("ul", {
85
- className: "my-0 list-disc pl-6",
86
- children
87
- }),
88
- li: ({ children }) => /* @__PURE__ */ jsx("li", {
89
- className: "[&>span.block]:mt-0 [&>span.block]:inline",
90
- children
91
- }),
92
- blockquote: ({ children }) => /* @__PURE__ */ jsx("blockquote", {
93
- className: "my-1 border-co-border border-l-2 pl-3 italic opacity-80",
94
- children
95
- }),
96
- em: ({ children }) => /* @__PURE__ */ jsx("em", {
97
- className: "italic",
98
- children
99
- }),
100
- a: ({ href, children, node }) => {
101
- const rawHref = href || node?.properties?.href || "";
102
- if (rawHref.startsWith("mention:")) {
103
- const parts = rawHref.split(":");
104
- const mentionType = parts[1];
105
- const mentionId = parts.slice(2).join(":");
106
- return /* @__PURE__ */ jsx("span", {
107
- className: "rounded bg-co-orange/15 font-medium text-co-orange",
108
- "data-mention-id": mentionId,
109
- "data-mention-type": mentionType,
110
- children
111
- });
112
- }
113
- return /* @__PURE__ */ jsx("a", {
114
- className: "underline hover:opacity-80",
115
- href,
116
- rel: "noopener noreferrer",
117
- target: "_blank",
118
- children
119
- });
123
+ children: [
124
+ hasBefore ? /* @__PURE__ */ jsx("span", {
125
+ className: "block",
126
+ children: beforeChildren.map((child, index) => renderMarkdownToken(child, `${key}-before-${index}`, renderers))
127
+ }) : null,
128
+ renderCommandBlock({
129
+ command: inlineCommand.command,
130
+ commands: inlineCommand.variants
131
+ }, `${key}-command`, renderers),
132
+ hasAfter ? /* @__PURE__ */ jsx("span", {
133
+ className: "mt-1 block",
134
+ children: afterChildren.map((child, index) => renderMarkdownToken(child, `${key}-after-${index}`, renderers))
135
+ }) : null
136
+ ]
137
+ }, key);
120
138
  }
121
- },
122
- remarkPlugins: [remarkBreaks],
123
- urlTransform: (url) => url,
139
+ return /* @__PURE__ */ jsx("span", {
140
+ className: "mt-1 block first:mt-0",
141
+ children: token.children.map((child, index) => renderMarkdownToken(child, `${key}-${index}`, renderers))
142
+ }, key);
143
+ }
144
+ case "blockquote": return /* @__PURE__ */ jsx("blockquote", {
145
+ className: "my-1 border-co-border border-l-2 pl-3 italic opacity-80",
146
+ children: token.children.map((child, index) => renderMarkdownToken(child, `${key}-${index}`, renderers))
147
+ }, key);
148
+ case "ul": return /* @__PURE__ */ jsx("ul", {
149
+ className: "my-0 list-disc pl-6",
150
+ children: token.children.map((child, index) => renderMarkdownToken(child, `${key}-${index}`, renderers))
151
+ }, key);
152
+ case "ol": return /* @__PURE__ */ jsx("ol", {
153
+ className: "my-0 list-decimal pl-6",
154
+ children: token.children.map((child, index) => renderMarkdownToken(child, `${key}-${index}`, renderers))
155
+ }, key);
156
+ case "li": return /* @__PURE__ */ jsx("li", {
157
+ className: "[&>span.block]:mt-0 [&>span.block]:inline",
158
+ children: token.children.map((child, index) => renderMarkdownToken(child, `${key}-${index}`, renderers))
159
+ }, key);
160
+ case "a": {
161
+ const mention = parseMentionHref(token.href);
162
+ if (mention) return /* @__PURE__ */ jsx("span", {
163
+ className: "rounded bg-co-orange/15 font-medium text-co-orange",
164
+ "data-mention-id": mention.mentionId,
165
+ "data-mention-type": mention.mentionType,
166
+ children: token.children.map((child, index) => renderMarkdownToken(child, `${key}-${index}`, renderers))
167
+ }, key);
168
+ return /* @__PURE__ */ jsx("a", {
169
+ className: "underline hover:opacity-80",
170
+ href: token.href,
171
+ rel: "noopener noreferrer",
172
+ target: "_blank",
173
+ children: token.children.map((child, index) => renderMarkdownToken(child, `${key}-${index}`, renderers))
174
+ }, key);
175
+ }
176
+ case "mention": return /* @__PURE__ */ jsxs("span", {
177
+ className: "rounded bg-co-orange/15 font-medium text-co-orange",
178
+ "data-mention-id": token.mention.id,
179
+ "data-mention-type": token.mention.type,
180
+ children: ["@", token.mention.name]
181
+ }, key);
182
+ case "header": return /* @__PURE__ */ jsx("span", {
183
+ className: token.level === 1 ? "mt-1 block text-base font-semibold first:mt-0" : token.level === 2 ? "mt-1 block text-sm font-semibold first:mt-0" : "mt-1 block text-sm font-medium first:mt-0",
184
+ children: token.children.map((child, index) => renderMarkdownToken(child, `${key}-${index}`, renderers))
185
+ }, key);
186
+ case "br": return /* @__PURE__ */ jsx("br", {}, key);
187
+ default: return null;
188
+ }
189
+ }
190
+ const MemoizedMarkdownBlock = React$1.memo(({ content, markdownRenderers }) => {
191
+ if (!hasMarkdownFormatting(content)) return /* @__PURE__ */ jsx("span", {
192
+ className: "whitespace-pre-wrap break-words",
124
193
  children: content
125
194
  });
126
- }, (prevProps, nextProps) => {
127
- if (prevProps.content !== nextProps.content) return false;
128
- return true;
129
- });
195
+ return /* @__PURE__ */ jsx(Fragment, { children: parseMarkdown(content).map((token, index) => renderMarkdownToken(token, `markdown-${index}`, markdownRenderers)) });
196
+ }, (prevProps, nextProps) => prevProps.content === nextProps.content && prevProps.markdownRenderers === nextProps.markdownRenderers);
130
197
  MemoizedMarkdownBlock.displayName = "MemoizedMarkdownBlock";
131
198
  /**
132
199
  * Renders the content of a timeline item, optionally piping Markdown content through a
@@ -134,15 +201,19 @@ MemoizedMarkdownBlock.displayName = "MemoizedMarkdownBlock";
134
201
  * formatting.
135
202
  */
136
203
  const TimelineItemContent = (() => {
137
- const Component = React$1.forwardRef(({ children, className, asChild = false, text = "", renderMarkdown = true, ...props }, ref) => {
204
+ const Component = React$1.forwardRef(({ children, className, asChild = false, text = "", renderMarkdown = true, markdownRenderers, ...props }, ref) => {
138
205
  const content = React$1.useMemo(() => {
139
206
  const textContent = text ?? "";
140
207
  if (typeof children === "function") return children(textContent);
141
208
  if (children) return children;
142
- if (renderMarkdown && textContent) return /* @__PURE__ */ jsx(MemoizedMarkdownBlock, { content: textContent });
209
+ if (renderMarkdown && textContent) return /* @__PURE__ */ jsx(MemoizedMarkdownBlock, {
210
+ content: textContent,
211
+ markdownRenderers
212
+ });
143
213
  return textContent;
144
214
  }, [
145
215
  children,
216
+ markdownRenderers,
146
217
  text,
147
218
  renderMarkdown
148
219
  ]);