@burdenoff/microfe-support 2026.510.52 → 2026.511.2

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 (48) hide show
  1. package/dist/generated/global-operations.js +177 -93
  2. package/dist/generated/global-operations.js.map +1 -1
  3. package/dist/generated/global-types.js.map +1 -1
  4. package/dist/node_modules/dompurify/dist/purify.es.js +225 -181
  5. package/dist/node_modules/dompurify/dist/purify.es.js.map +1 -1
  6. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +211 -169
  7. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -1
  8. package/dist/support/SupportAdminRoutes.js +15 -12
  9. package/dist/support/SupportAdminRoutes.js.map +1 -1
  10. package/dist/support/components/settings/CannedResponsesSettings.js +204 -71
  11. package/dist/support/components/settings/CannedResponsesSettings.js.map +1 -1
  12. package/dist/support/components/tickets/MessageComposer.js +137 -107
  13. package/dist/support/components/tickets/MessageComposer.js.map +1 -1
  14. package/dist/support/components/tickets/MessageThread.js +11 -11
  15. package/dist/support/components/tickets/MessageThread.js.map +1 -1
  16. package/dist/support/components/tickets/TicketHeader.js +55 -45
  17. package/dist/support/components/tickets/TicketHeader.js.map +1 -1
  18. package/dist/support/components/tickets/TicketSidebar.js +105 -114
  19. package/dist/support/components/tickets/TicketSidebar.js.map +1 -1
  20. package/dist/support/hooks/useKnowledgeBaseOperations.js +79 -76
  21. package/dist/support/hooks/useKnowledgeBaseOperations.js.map +1 -1
  22. package/dist/support/hooks/useSettingsOperations.js +15 -9
  23. package/dist/support/hooks/useSettingsOperations.js.map +1 -1
  24. package/dist/support/hooks/useTicketOperations.js +130 -86
  25. package/dist/support/hooks/useTicketOperations.js.map +1 -1
  26. package/dist/support/pages/AnalyticsPage.js +41 -45
  27. package/dist/support/pages/AnalyticsPage.js.map +1 -1
  28. package/dist/support/pages/ArticleDetailAdminPage.js +148 -147
  29. package/dist/support/pages/ArticleDetailAdminPage.js.map +1 -1
  30. package/dist/support/pages/ArticleDetailUserPage.js +71 -70
  31. package/dist/support/pages/ArticleDetailUserPage.js.map +1 -1
  32. package/dist/support/pages/CreateTicketPage.js +120 -138
  33. package/dist/support/pages/CreateTicketPage.js.map +1 -1
  34. package/dist/support/pages/KnowledgeBaseAdminPage.js +27 -24
  35. package/dist/support/pages/KnowledgeBaseAdminPage.js.map +1 -1
  36. package/dist/support/pages/KnowledgeBaseUserPage.js +27 -24
  37. package/dist/support/pages/KnowledgeBaseUserPage.js.map +1 -1
  38. package/dist/support/pages/SettingsPage.js +3 -1
  39. package/dist/support/pages/SettingsPage.js.map +1 -1
  40. package/dist/support/pages/TicketDetailAdminPage.js +121 -94
  41. package/dist/support/pages/TicketDetailAdminPage.js.map +1 -1
  42. package/dist/support/pages/TicketListPage.js +168 -157
  43. package/dist/support/pages/TicketListPage.js.map +1 -1
  44. package/dist/support/utils/index.js +19 -14
  45. package/dist/support/utils/index.js.map +1 -1
  46. package/dist/support/utils/supportFiles.js +27 -24
  47. package/dist/support/utils/supportFiles.js.map +1 -1
  48. package/package.json +2 -2
@@ -4,130 +4,160 @@ import { Loader2 as i, Lock as a, Paperclip as o, Send as s } from "lucide-react
4
4
  import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
5
5
  import { useI18n as d } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
6
6
  //#region src/support/components/tickets/MessageComposer.tsx
7
- var f = ({ ticketId: f, onSendMessage: p, placeholder: m = "Type your message...", disabled: h = !1, allowInternalNotes: g = !1 }) => {
8
- let { t: _ } = d(), [v, y] = r(""), [b, x] = r(!1), [S, C] = r(!1), [w, T] = r([]), E = n(null), D = n(null);
7
+ var f = ({ ticketId: f, onSendMessage: p, placeholder: m = "Type your message...", disabled: h = !1, allowInternalNotes: g = !1, cannedResponses: _ = [], cannedResponsesLoading: v = !1 }) => {
8
+ let { t: y } = d(), [b, x] = r(""), [S, C] = r(!1), [w, T] = r(!1), [E, D] = r([]), O = n(null), k = n(null);
9
9
  t(() => {
10
- let e = E.current;
10
+ let e = O.current;
11
11
  e && (e.style.height = "auto", e.style.height = `${e.scrollHeight}px`);
12
- }, [v]);
13
- let O = async (e) => {
14
- if (e.preventDefault(), !(!v.trim() && w.length === 0 || S)) {
15
- C(!0);
12
+ }, [b]);
13
+ let A = async (e) => {
14
+ if (e.preventDefault(), !(!b.trim() && E.length === 0 || w)) {
15
+ T(!0);
16
16
  try {
17
- let e = await p(v.trim(), b, w);
18
- e?.preserveMessage || y(""), x(!1), e?.preserveAttachedFiles || T([]);
17
+ let e = await p(b.trim(), S, E);
18
+ e?.preserveMessage || x(""), C(!1), e?.preserveAttachedFiles || D([]);
19
19
  } catch (e) {
20
20
  console.error("Failed to send message:", e);
21
21
  } finally {
22
- C(!1);
22
+ T(!1);
23
23
  }
24
24
  }
25
- }, k = (e) => {
26
- e.key === "Enter" && !e.shiftKey && (e.preventDefault(), O(e));
27
- }, A = () => {
28
- D.current?.click();
29
25
  }, j = (e) => {
26
+ e.key === "Enter" && !e.shiftKey && (e.preventDefault(), A(e));
27
+ }, M = () => {
28
+ k.current?.click();
29
+ }, N = (e) => {
30
30
  let t = Array.from(e.target.files || []);
31
- T((e) => [...e, ...t]), e.target.value = "";
32
- }, M = (e) => {
33
- T((t) => t.filter((t, n) => n !== e));
31
+ D((e) => [...e, ...t]), e.target.value = "";
32
+ }, P = (e) => {
33
+ D((t) => t.filter((t, n) => n !== e));
34
+ }, F = (e) => {
35
+ let t = _.find((t) => t.id === e);
36
+ t && (x((e) => {
37
+ let n = e.trimEnd();
38
+ return n ? `${n}\n\n${t.content}` : t.content;
39
+ }), requestAnimationFrame(() => O.current?.focus()));
34
40
  };
35
41
  return /* @__PURE__ */ l("div", {
36
42
  className: "shrink-0 border-t border-border bg-background",
37
43
  children: /* @__PURE__ */ u("form", {
38
- onSubmit: O,
44
+ onSubmit: A,
39
45
  className: "p-4",
40
- children: [g && /* @__PURE__ */ l("div", {
41
- className: "flex items-center gap-2 mb-3",
42
- children: /* @__PURE__ */ u("label", {
43
- className: "flex items-center gap-2 cursor-pointer",
44
- children: [/* @__PURE__ */ l("input", {
45
- type: "checkbox",
46
- checked: b,
47
- onChange: (e) => x(e.target.checked),
48
- className: "rounded border-border",
49
- disabled: h
50
- }), /* @__PURE__ */ u("span", {
51
- className: "text-sm flex items-center gap-1 text-muted-foreground",
52
- children: [/* @__PURE__ */ l(a, { size: 14 }), e(_, "support.messageComposer.internalNote", "Internal Note (not visible to customer)")]
53
- })]
54
- })
55
- }), /* @__PURE__ */ u("div", {
56
- className: "relative",
57
- children: [
58
- /* @__PURE__ */ l("textarea", {
59
- ref: E,
60
- value: v,
61
- onChange: (e) => y(e.target.value),
62
- onKeyDown: k,
63
- placeholder: e(_, "support.messageComposer.placeholder", m),
64
- disabled: h || S,
65
- rows: 1,
66
- className: `auto-resize w-full px-4 py-3 rounded-lg border resize-none transition-colors ${b ? "border-status-warning-bg bg-status-warning-bg-subtle" : "border-border bg-background"} text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary`
67
- }),
68
- /* @__PURE__ */ l("input", {
69
- ref: D,
70
- type: "file",
71
- multiple: !0,
72
- onChange: j,
73
- className: "hidden",
74
- accept: "image/*,.pdf,.doc,.docx,.txt"
75
- }),
76
- w.length > 0 && /* @__PURE__ */ l("div", {
77
- className: "flex flex-wrap gap-2 mt-2",
78
- children: w.map((e, t) => /* @__PURE__ */ u("div", {
79
- className: "flex items-center gap-2 px-3 py-1 rounded-lg bg-muted text-sm",
80
- children: [
81
- /* @__PURE__ */ l(o, { size: 14 }),
82
- /* @__PURE__ */ l("span", {
83
- className: "max-w-[200px] truncate",
84
- children: e.name
85
- }),
86
- /* @__PURE__ */ l("button", {
87
- type: "button",
88
- onClick: () => M(t),
89
- className: "text-muted-foreground hover:text-foreground transition-colors",
90
- children: "×"
91
- })
92
- ]
93
- }, `${e.name}-${t}`))
94
- }),
95
- /* @__PURE__ */ u("div", {
96
- className: "flex items-center justify-between mt-3",
97
- children: [/* @__PURE__ */ u("button", {
98
- type: "button",
99
- onClick: A,
100
- className: "flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-muted-foreground hover:bg-muted",
101
- disabled: h || S,
102
- children: [
103
- /* @__PURE__ */ l(o, { size: 18 }),
104
- /* @__PURE__ */ l("span", {
105
- className: "text-sm",
106
- children: e(_, "support.messageComposer.attachFiles", "Attach files")
107
- }),
108
- w.length > 0 && /* @__PURE__ */ l("span", {
109
- className: "text-xs bg-primary text-primary-foreground rounded-full px-2 py-0.5",
110
- children: w.length
111
- })
112
- ]
113
- }), /* @__PURE__ */ u("div", {
114
- className: "flex items-center gap-2",
115
- children: [/* @__PURE__ */ l("span", {
116
- className: "text-xs text-muted-foreground hidden sm:inline",
117
- children: e(_, "support.messageComposer.hint", "Markdown supported. Press Enter to send, Shift+Enter for new line")
118
- }), /* @__PURE__ */ l("button", {
119
- type: "submit",
120
- disabled: !v.trim() && w.length === 0 || h || S,
121
- className: `flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${b ? "bg-status-warning-bg hover:bg-status-warning-bg/90 text-on-accent" : "bg-primary hover:bg-primary/90 text-primary-foreground"}`,
122
- children: S ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(i, {
123
- size: 18,
124
- className: "animate-spin"
125
- }), e(_, "support.messageComposer.sending", "Sending...")] }) : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(s, { size: 18 }), e(_, "support.messageComposer.send", "Send")] })
126
- })]
46
+ children: [
47
+ g && /* @__PURE__ */ l("div", {
48
+ className: "flex items-center gap-2 mb-3",
49
+ children: /* @__PURE__ */ u("label", {
50
+ className: "flex items-center gap-2 cursor-pointer",
51
+ children: [/* @__PURE__ */ l("input", {
52
+ type: "checkbox",
53
+ checked: S,
54
+ onChange: (e) => C(e.target.checked),
55
+ className: "rounded border-border",
56
+ disabled: h
57
+ }), /* @__PURE__ */ u("span", {
58
+ className: "text-sm flex items-center gap-1 text-muted-foreground",
59
+ children: [/* @__PURE__ */ l(a, { size: 14 }), e(y, "support.messageComposer.internalNote", "Internal Note (not visible to customer)")]
127
60
  })]
128
61
  })
129
- ]
130
- })]
62
+ }),
63
+ g && /* @__PURE__ */ u("div", {
64
+ className: "mb-3 flex flex-col gap-1 sm:max-w-sm",
65
+ children: [/* @__PURE__ */ l("label", {
66
+ htmlFor: "support-canned-response",
67
+ className: "text-sm font-medium text-foreground",
68
+ children: e(y, "support.messageComposer.cannedResponses", "Canned responses")
69
+ }), /* @__PURE__ */ u("select", {
70
+ id: "support-canned-response",
71
+ value: "",
72
+ onChange: (e) => F(e.target.value),
73
+ disabled: h || w || v || _.length === 0,
74
+ className: "rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-50",
75
+ children: [/* @__PURE__ */ l("option", {
76
+ value: "",
77
+ children: v ? e(y, "support.messageComposer.loadingCannedResponses", "Loading saved replies...") : _.length > 0 ? e(y, "support.messageComposer.selectCannedResponse", "Insert a saved reply") : e(y, "support.messageComposer.noCannedResponses", "No saved replies available")
78
+ }), _.map((e) => /* @__PURE__ */ l("option", {
79
+ value: e.id,
80
+ children: e.shortcut ? `${e.title} (${e.shortcut})` : e.title
81
+ }, e.id))]
82
+ })]
83
+ }),
84
+ /* @__PURE__ */ u("div", {
85
+ className: "relative",
86
+ children: [
87
+ /* @__PURE__ */ l("textarea", {
88
+ ref: O,
89
+ value: b,
90
+ onChange: (e) => x(e.target.value),
91
+ onKeyDown: j,
92
+ placeholder: e(y, "support.messageComposer.placeholder", m),
93
+ disabled: h || w,
94
+ rows: 1,
95
+ className: `auto-resize w-full px-4 py-3 rounded-lg border resize-none transition-colors ${S ? "border-status-warning-bg bg-status-warning-bg-subtle" : "border-border bg-background"} text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary`
96
+ }),
97
+ /* @__PURE__ */ l("input", {
98
+ ref: k,
99
+ type: "file",
100
+ multiple: !0,
101
+ onChange: N,
102
+ className: "hidden",
103
+ accept: "image/*,.pdf,.doc,.docx,.txt"
104
+ }),
105
+ E.length > 0 && /* @__PURE__ */ l("div", {
106
+ className: "flex flex-wrap gap-2 mt-2",
107
+ children: E.map((e, t) => /* @__PURE__ */ u("div", {
108
+ className: "flex items-center gap-2 px-3 py-1 rounded-lg bg-muted text-sm",
109
+ children: [
110
+ /* @__PURE__ */ l(o, { size: 14 }),
111
+ /* @__PURE__ */ l("span", {
112
+ className: "max-w-[200px] truncate",
113
+ children: e.name
114
+ }),
115
+ /* @__PURE__ */ l("button", {
116
+ type: "button",
117
+ onClick: () => P(t),
118
+ className: "text-muted-foreground hover:text-foreground transition-colors",
119
+ children: "×"
120
+ })
121
+ ]
122
+ }, `${e.name}-${t}`))
123
+ }),
124
+ /* @__PURE__ */ u("div", {
125
+ className: "flex items-center justify-between mt-3",
126
+ children: [/* @__PURE__ */ u("button", {
127
+ type: "button",
128
+ onClick: M,
129
+ className: "flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-muted-foreground hover:bg-muted",
130
+ disabled: h || w,
131
+ children: [
132
+ /* @__PURE__ */ l(o, { size: 18 }),
133
+ /* @__PURE__ */ l("span", {
134
+ className: "text-sm",
135
+ children: e(y, "support.messageComposer.attachFiles", "Attach files")
136
+ }),
137
+ E.length > 0 && /* @__PURE__ */ l("span", {
138
+ className: "text-xs bg-primary text-primary-foreground rounded-full px-2 py-0.5",
139
+ children: E.length
140
+ })
141
+ ]
142
+ }), /* @__PURE__ */ u("div", {
143
+ className: "flex items-center gap-2",
144
+ children: [/* @__PURE__ */ l("span", {
145
+ className: "text-xs text-muted-foreground hidden sm:inline",
146
+ children: e(y, "support.messageComposer.hint", "Markdown supported. Press Enter to send, Shift+Enter for new line")
147
+ }), /* @__PURE__ */ l("button", {
148
+ type: "submit",
149
+ disabled: !b.trim() && E.length === 0 || h || w,
150
+ className: `flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${S ? "bg-status-warning-bg hover:bg-status-warning-bg/90 text-on-accent" : "bg-primary hover:bg-primary/90 text-primary-foreground"}`,
151
+ children: w ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(i, {
152
+ size: 18,
153
+ className: "animate-spin"
154
+ }), e(y, "support.messageComposer.sending", "Sending...")] }) : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(s, { size: 18 }), e(y, "support.messageComposer.send", "Send")] })
155
+ })]
156
+ })]
157
+ })
158
+ ]
159
+ })
160
+ ]
131
161
  })
132
162
  });
133
163
  };
@@ -1 +1 @@
1
- {"version":3,"file":"MessageComposer.js","names":[],"sources":["../../../../src/support/components/tickets/MessageComposer.tsx"],"sourcesContent":["import { useState, useRef, useEffect, type FC } from 'react';\nimport { Send, Paperclip, Lock, Loader2 } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { tWithFallback } from '../../utils/i18n';\n\nexport interface MessageComposerSendResult {\n preserveAttachedFiles?: boolean;\n preserveMessage?: boolean;\n}\n\ninterface MessageComposerProps {\n ticketId: string;\n onSendMessage: (\n content: string,\n isInternal: boolean,\n files: File[]\n ) => Promise<MessageComposerSendResult | void>;\n placeholder?: string;\n disabled?: boolean;\n allowInternalNotes?: boolean;\n}\n\nexport const MessageComposer: FC<MessageComposerProps> = ({\n ticketId: _ticketId,\n onSendMessage,\n placeholder = 'Type your message...',\n disabled = false,\n allowInternalNotes = false,\n}) => {\n const { t } = useI18n();\n const [message, setMessage] = useState('');\n const [isInternal, setIsInternal] = useState(false);\n const [isSending, setIsSending] = useState(false);\n const [attachedFiles, setAttachedFiles] = useState<File[]>([]);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Auto-resize textarea as content changes\n useEffect(() => {\n const textarea = textareaRef.current;\n if (textarea) {\n // Reset height to auto to get the correct scrollHeight\n textarea.style.height = 'auto';\n // Set height to scrollHeight (content height) but respect CSS max-height\n textarea.style.height = `${textarea.scrollHeight}px`;\n }\n }, [message]);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n if ((!message.trim() && attachedFiles.length === 0) || isSending) return;\n\n setIsSending(true);\n try {\n const result = await onSendMessage(message.trim(), isInternal, attachedFiles);\n if (!result?.preserveMessage) {\n setMessage('');\n }\n setIsInternal(false);\n if (!result?.preserveAttachedFiles) {\n setAttachedFiles([]);\n }\n } catch (error) {\n console.error('Failed to send message:', error);\n } finally {\n setIsSending(false);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n handleSubmit(e);\n }\n };\n\n const handleAttachFiles = () => {\n fileInputRef.current?.click();\n };\n\n const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(e.target.files || []);\n setAttachedFiles((prev) => [...prev, ...files]);\n // Reset input so the same file can be selected again\n e.target.value = '';\n };\n\n const handleRemoveFile = (index: number) => {\n setAttachedFiles((prev) => prev.filter((_, i) => i !== index));\n };\n\n return (\n <div className=\"shrink-0 border-t border-border bg-background\">\n <form onSubmit={handleSubmit} className=\"p-4\">\n {/* Internal note toggle */}\n {allowInternalNotes && (\n <div className=\"flex items-center gap-2 mb-3\">\n <label className=\"flex items-center gap-2 cursor-pointer\">\n <input\n type=\"checkbox\"\n checked={isInternal}\n onChange={(e) => setIsInternal(e.target.checked)}\n className=\"rounded border-border\"\n disabled={disabled}\n />\n <span className=\"text-sm flex items-center gap-1 text-muted-foreground\">\n <Lock size={14} />\n {tWithFallback(\n t,\n 'support.messageComposer.internalNote',\n 'Internal Note (not visible to customer)'\n )}\n </span>\n </label>\n </div>\n )}\n\n {/* Message input */}\n <div className=\"relative\">\n <textarea\n ref={textareaRef}\n value={message}\n onChange={(e) => setMessage(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={tWithFallback(t, 'support.messageComposer.placeholder', placeholder)}\n disabled={disabled || isSending}\n rows={1}\n className={`auto-resize w-full px-4 py-3 rounded-lg border resize-none transition-colors ${\n isInternal\n ? 'border-status-warning-bg bg-status-warning-bg-subtle'\n : 'border-border bg-background'\n } text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary`}\n />\n\n {/* Hidden file input */}\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple\n onChange={handleFileChange}\n className=\"hidden\"\n accept=\"image/*,.pdf,.doc,.docx,.txt\"\n />\n\n {/* Attached files display */}\n {attachedFiles.length > 0 && (\n <div className=\"flex flex-wrap gap-2 mt-2\">\n {attachedFiles.map((file, index) => (\n <div\n key={`${file.name}-${index}`}\n className=\"flex items-center gap-2 px-3 py-1 rounded-lg bg-muted text-sm\"\n >\n <Paperclip size={14} />\n <span className=\"max-w-[200px] truncate\">{file.name}</span>\n <button\n type=\"button\"\n onClick={() => handleRemoveFile(index)}\n className=\"text-muted-foreground hover:text-foreground transition-colors\"\n >\n ×\n </button>\n </div>\n ))}\n </div>\n )}\n\n {/* Actions */}\n <div className=\"flex items-center justify-between mt-3\">\n <button\n type=\"button\"\n onClick={handleAttachFiles}\n className=\"flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-muted-foreground hover:bg-muted\"\n disabled={disabled || isSending}\n >\n <Paperclip size={18} />\n <span className=\"text-sm\">\n {tWithFallback(t, 'support.messageComposer.attachFiles', 'Attach files')}\n </span>\n {attachedFiles.length > 0 && (\n <span className=\"text-xs bg-primary text-primary-foreground rounded-full px-2 py-0.5\">\n {attachedFiles.length}\n </span>\n )}\n </button>\n\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-muted-foreground hidden sm:inline\">\n {tWithFallback(\n t,\n 'support.messageComposer.hint',\n 'Markdown supported. Press Enter to send, Shift+Enter for new line'\n )}\n </span>\n <button\n type=\"submit\"\n disabled={(!message.trim() && attachedFiles.length === 0) || disabled || isSending}\n className={`flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${\n isInternal\n ? 'bg-status-warning-bg hover:bg-status-warning-bg/90 text-on-accent'\n : 'bg-primary hover:bg-primary/90 text-primary-foreground'\n }`}\n >\n {isSending ? (\n <>\n <Loader2 size={18} className=\"animate-spin\" />\n {tWithFallback(t, 'support.messageComposer.sending', 'Sending...')}\n </>\n ) : (\n <>\n <Send size={18} />\n {tWithFallback(t, 'support.messageComposer.send', 'Send')}\n </>\n )}\n </button>\n </div>\n </div>\n </div>\n </form>\n </div>\n );\n};\n"],"mappings":";;;;;;AAsBA,IAAa,KAA6C,EACxD,UAAU,GACV,kBACA,iBAAc,wBACd,cAAW,IACX,wBAAqB,SACjB;CACJ,IAAM,EAAE,SAAM,GAAS,EACjB,CAAC,GAAS,KAAc,EAAS,GAAG,EACpC,CAAC,GAAY,KAAiB,EAAS,GAAM,EAC7C,CAAC,GAAW,KAAgB,EAAS,GAAM,EAC3C,CAAC,GAAe,KAAoB,EAAiB,EAAE,CAAC,EACxD,IAAc,EAA4B,KAAK,EAC/C,IAAe,EAAyB,KAAK;AAGnD,SAAgB;EACd,IAAM,IAAW,EAAY;AAC7B,EAAI,MAEF,EAAS,MAAM,SAAS,QAExB,EAAS,MAAM,SAAS,GAAG,EAAS,aAAa;IAElD,CAAC,EAAQ,CAAC;CAEb,IAAM,IAAe,OAAO,MAAuB;AACjD,QAAE,gBAAgB,EACb,GAAC,EAAQ,MAAM,IAAI,EAAc,WAAW,KAAM,IAEvD;KAAa,GAAK;AAClB,OAAI;IACF,IAAM,IAAS,MAAM,EAAc,EAAQ,MAAM,EAAE,GAAY,EAAc;AAK7E,IAJK,GAAQ,mBACX,EAAW,GAAG,EAEhB,EAAc,GAAM,EACf,GAAQ,yBACX,EAAiB,EAAE,CAAC;YAEf,GAAO;AACd,YAAQ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AAU;gBACZ,EAAc,KAAK,GAAM,MACxB,kBAAC,OAAD;OAEE,WAAU;iBAFZ;QAIE,kBAAC,GAAD,EAAW,MAAM,IAAM,CAAA;QACvB,kBAAC,QAAD;SAAM,WAAU;mBAA0B,EAAK;SAAY,CAAA;QAC3D,kBAAC,UAAD;SACE,MAAK;SACL,eAAe,EAAiB,EAAM;SACtC,WAAU;mBACX;SAEQ,CAAA;QACL;SAZC,GAAG,EAAK,KAAK,GAAG,IAYjB,CACN;MACE,CAAA;KAIR,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,UAAD;OACE,MAAK;OACL,SAAS;OACT,WAAU;OACV,UAAU,KAAY;iBAJxB;QAME,kBAAC,GAAD,EAAW,MAAM,IAAM,CAAA;QACvB,kBAAC,QAAD;SAAM,WAAU;mBACb,EAAc,GAAG,uCAAuC,eAAe;SACnE,CAAA;QACN,EAAc,SAAS,KACtB,kBAAC,QAAD;SAAM,WAAU;mBACb,EAAc;SACV,CAAA;QAEF;UAET,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,QAAD;QAAM,WAAU;kBACb,EACC,GACA,gCACA,oEACD;QACI,CAAA,EACP,kBAAC,UAAD;QACE,MAAK;QACL,UAAW,CAAC,EAAQ,MAAM,IAAI,EAAc,WAAW,KAAM,KAAY;QACzE,WAAW,8HACT,IACI,sEACA;kBAGL,IACC,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;SAAS,MAAM;SAAI,WAAU;SAAiB,CAAA,EAC7C,EAAc,GAAG,mCAAmC,aAAa,CACjE,EAAA,CAAA,GAEH,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA,EACjB,EAAc,GAAG,gCAAgC,OAAO,CACxD,EAAA,CAAA;QAEE,CAAA,CACL;SACF;;KACF;MACD;;EACH,CAAA"}
1
+ {"version":3,"file":"MessageComposer.js","names":[],"sources":["../../../../src/support/components/tickets/MessageComposer.tsx"],"sourcesContent":["import { useState, useRef, useEffect, type FC } from 'react';\nimport { Send, Paperclip, Lock, Loader2 } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { tWithFallback } from '../../utils/i18n';\n\nexport interface MessageComposerSendResult {\n preserveAttachedFiles?: boolean;\n preserveMessage?: boolean;\n}\n\ninterface MessageComposerProps {\n ticketId: string;\n onSendMessage: (\n content: string,\n isInternal: boolean,\n files: File[]\n ) => Promise<MessageComposerSendResult | void>;\n placeholder?: string;\n disabled?: boolean;\n allowInternalNotes?: boolean;\n cannedResponses?: CannedResponseOption[];\n cannedResponsesLoading?: boolean;\n}\n\nexport interface CannedResponseOption {\n id: string;\n title: string;\n content: string;\n shortcut?: string | null;\n}\n\nexport const MessageComposer: FC<MessageComposerProps> = ({\n ticketId: _ticketId,\n onSendMessage,\n placeholder = 'Type your message...',\n disabled = false,\n allowInternalNotes = false,\n cannedResponses = [],\n cannedResponsesLoading = false,\n}) => {\n const { t } = useI18n();\n const [message, setMessage] = useState('');\n const [isInternal, setIsInternal] = useState(false);\n const [isSending, setIsSending] = useState(false);\n const [attachedFiles, setAttachedFiles] = useState<File[]>([]);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Auto-resize textarea as content changes\n useEffect(() => {\n const textarea = textareaRef.current;\n if (textarea) {\n // Reset height to auto to get the correct scrollHeight\n textarea.style.height = 'auto';\n // Set height to scrollHeight (content height) but respect CSS max-height\n textarea.style.height = `${textarea.scrollHeight}px`;\n }\n }, [message]);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n if ((!message.trim() && attachedFiles.length === 0) || isSending) return;\n\n setIsSending(true);\n try {\n const result = await onSendMessage(message.trim(), isInternal, attachedFiles);\n if (!result?.preserveMessage) {\n setMessage('');\n }\n setIsInternal(false);\n if (!result?.preserveAttachedFiles) {\n setAttachedFiles([]);\n }\n } catch (error) {\n console.error('Failed to send message:', error);\n } finally {\n setIsSending(false);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n handleSubmit(e);\n }\n };\n\n const handleAttachFiles = () => {\n fileInputRef.current?.click();\n };\n\n const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(e.target.files || []);\n setAttachedFiles((prev) => [...prev, ...files]);\n // Reset input so the same file can be selected again\n e.target.value = '';\n };\n\n const handleRemoveFile = (index: number) => {\n setAttachedFiles((prev) => prev.filter((_, i) => i !== index));\n };\n\n const handleInsertCannedResponse = (responseId: string) => {\n const selectedResponse = cannedResponses.find((response) => response.id === responseId);\n if (!selectedResponse) return;\n\n setMessage((currentMessage) => {\n const trimmedMessage = currentMessage.trimEnd();\n return trimmedMessage\n ? `${trimmedMessage}\\n\\n${selectedResponse.content}`\n : selectedResponse.content;\n });\n\n requestAnimationFrame(() => textareaRef.current?.focus());\n };\n\n return (\n <div className=\"shrink-0 border-t border-border bg-background\">\n <form onSubmit={handleSubmit} className=\"p-4\">\n {/* Internal note toggle */}\n {allowInternalNotes && (\n <div className=\"flex items-center gap-2 mb-3\">\n <label className=\"flex items-center gap-2 cursor-pointer\">\n <input\n type=\"checkbox\"\n checked={isInternal}\n onChange={(e) => setIsInternal(e.target.checked)}\n className=\"rounded border-border\"\n disabled={disabled}\n />\n <span className=\"text-sm flex items-center gap-1 text-muted-foreground\">\n <Lock size={14} />\n {tWithFallback(\n t,\n 'support.messageComposer.internalNote',\n 'Internal Note (not visible to customer)'\n )}\n </span>\n </label>\n </div>\n )}\n\n {allowInternalNotes && (\n <div className=\"mb-3 flex flex-col gap-1 sm:max-w-sm\">\n <label\n htmlFor=\"support-canned-response\"\n className=\"text-sm font-medium text-foreground\"\n >\n {tWithFallback(t, 'support.messageComposer.cannedResponses', 'Canned responses')}\n </label>\n <select\n id=\"support-canned-response\"\n value=\"\"\n onChange={(event) => handleInsertCannedResponse(event.target.value)}\n disabled={\n disabled || isSending || cannedResponsesLoading || cannedResponses.length === 0\n }\n className=\"rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n <option value=\"\">\n {cannedResponsesLoading\n ? tWithFallback(\n t,\n 'support.messageComposer.loadingCannedResponses',\n 'Loading saved replies...'\n )\n : cannedResponses.length > 0\n ? tWithFallback(\n t,\n 'support.messageComposer.selectCannedResponse',\n 'Insert a saved reply'\n )\n : tWithFallback(\n t,\n 'support.messageComposer.noCannedResponses',\n 'No saved replies available'\n )}\n </option>\n {cannedResponses.map((response) => (\n <option key={response.id} value={response.id}>\n {response.shortcut ? `${response.title} (${response.shortcut})` : response.title}\n </option>\n ))}\n </select>\n </div>\n )}\n\n {/* Message input */}\n <div className=\"relative\">\n <textarea\n ref={textareaRef}\n value={message}\n onChange={(e) => setMessage(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={tWithFallback(t, 'support.messageComposer.placeholder', placeholder)}\n disabled={disabled || isSending}\n rows={1}\n className={`auto-resize w-full px-4 py-3 rounded-lg border resize-none transition-colors ${\n isInternal\n ? 'border-status-warning-bg bg-status-warning-bg-subtle'\n : 'border-border bg-background'\n } text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary`}\n />\n\n {/* Hidden file input */}\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple\n onChange={handleFileChange}\n className=\"hidden\"\n accept=\"image/*,.pdf,.doc,.docx,.txt\"\n />\n\n {/* Attached files display */}\n {attachedFiles.length > 0 && (\n <div className=\"flex flex-wrap gap-2 mt-2\">\n {attachedFiles.map((file, index) => (\n <div\n key={`${file.name}-${index}`}\n className=\"flex items-center gap-2 px-3 py-1 rounded-lg bg-muted text-sm\"\n >\n <Paperclip size={14} />\n <span className=\"max-w-[200px] truncate\">{file.name}</span>\n <button\n type=\"button\"\n onClick={() => handleRemoveFile(index)}\n className=\"text-muted-foreground hover:text-foreground transition-colors\"\n >\n ×\n </button>\n </div>\n ))}\n </div>\n )}\n\n {/* Actions */}\n <div className=\"flex items-center justify-between mt-3\">\n <button\n type=\"button\"\n onClick={handleAttachFiles}\n className=\"flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-muted-foreground hover:bg-muted\"\n disabled={disabled || isSending}\n >\n <Paperclip size={18} />\n <span className=\"text-sm\">\n {tWithFallback(t, 'support.messageComposer.attachFiles', 'Attach files')}\n </span>\n {attachedFiles.length > 0 && (\n <span className=\"text-xs bg-primary text-primary-foreground rounded-full px-2 py-0.5\">\n {attachedFiles.length}\n </span>\n )}\n </button>\n\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-muted-foreground hidden sm:inline\">\n {tWithFallback(\n t,\n 'support.messageComposer.hint',\n 'Markdown supported. Press Enter to send, Shift+Enter for new line'\n )}\n </span>\n <button\n type=\"submit\"\n disabled={(!message.trim() && attachedFiles.length === 0) || disabled || isSending}\n className={`flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${\n isInternal\n ? 'bg-status-warning-bg hover:bg-status-warning-bg/90 text-on-accent'\n : 'bg-primary hover:bg-primary/90 text-primary-foreground'\n }`}\n >\n {isSending ? (\n <>\n <Loader2 size={18} className=\"animate-spin\" />\n {tWithFallback(t, 'support.messageComposer.sending', 'Sending...')}\n </>\n ) : (\n <>\n <Send size={18} />\n {tWithFallback(t, 'support.messageComposer.send', 'Send')}\n </>\n )}\n </button>\n </div>\n </div>\n </div>\n </form>\n </div>\n );\n};\n"],"mappings":";;;;;;AA+BA,IAAa,KAA6C,EACxD,UAAU,GACV,kBACA,iBAAc,wBACd,cAAW,IACX,wBAAqB,IACrB,qBAAkB,EAAE,EACpB,4BAAyB,SACrB;CACJ,IAAM,EAAE,SAAM,GAAS,EACjB,CAAC,GAAS,KAAc,EAAS,GAAG,E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A,UAAA,CACE,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA,EACjB,EAAc,GAAG,gCAAgC,OAAO,CACxD,EAAA,CAAA;SAEE,CAAA,CACL;UACF;;MACF;;IACD;;EACH,CAAA"}
@@ -20,9 +20,9 @@ var o = {
20
20
  label: "System",
21
21
  isAgent: !0
22
22
  }
23
- }, s = ({ ticketId: s, messages: c, currentUserId: l, showInternalMessages: u = !1, showRealAgentIdentity: d = !1 }) => {
24
- let f = u ? c : c.filter((e) => !e.isInternal);
25
- return !f || f.length === 0 ? /* @__PURE__ */ a("div", {
23
+ }, s = ({ ticketId: s, messages: c, currentUserId: l, viewerRole: u = "customer", showInternalMessages: d = !1, showRealAgentIdentity: f = !1 }) => {
24
+ let p = d ? c : c.filter((e) => !e.isInternal);
25
+ return !p || p.length === 0 ? /* @__PURE__ */ a("div", {
26
26
  className: "flex flex-col items-center justify-center py-12",
27
27
  children: [/* @__PURE__ */ i("p", {
28
28
  className: "text-lg text-muted-foreground",
@@ -33,20 +33,20 @@ var o = {
33
33
  })]
34
34
  }) : /* @__PURE__ */ i("div", {
35
35
  className: "space-y-4",
36
- children: f.map((c) => {
37
- let u = c.authorId === l, f = o[c.type] || o.SYSTEM_MESSAGE, p = c.type === "CUSTOMER_REPLY", m = c.isInternal || c.type === "INTERNAL_NOTE", h = c.context?.custom ?? void 0, g = c.author ?? null, _ = g ? g.isAnonymized : !0, v = g?.displayName ?? h?.authorAlias ?? "Support Agent", y = _ ? v : g ? g.displayName : d ? h?.authorName ?? h?.authorEmail ?? c.authorId : v, b = c.type === "AGENT_REPLY" ? d && !_ ? y : v : c.type === "CUSTOMER_REPLY" ? u ? "You" : "Customer" : f.label;
36
+ children: p.map((c) => {
37
+ let d = c.authorId === l, p = o[c.type] || o.SYSTEM_MESSAGE, m = c.type === "CUSTOMER_REPLY", h = p.isAgent && c.type !== "SYSTEM_MESSAGE", g = u === "agent" ? h : m, _ = c.isInternal || c.type === "INTERNAL_NOTE", v = c.context?.custom ?? void 0, y = c.author ?? null, b = y ? y.isAnonymized : !0, x = y?.displayName ?? v?.authorAlias ?? "Support Agent", S = b ? x : y ? y.displayName : f ? v?.authorName ?? v?.authorEmail ?? c.authorId : x, C = c.type === "AGENT_REPLY" ? f && !b ? S : x : c.type === "CUSTOMER_REPLY" ? d ? "You" : "Customer" : p.label;
38
38
  return /* @__PURE__ */ i("div", {
39
- className: `flex ${u ? "justify-end" : "justify-start"}`,
39
+ className: `flex ${g ? "justify-end" : "justify-start"}`,
40
40
  children: /* @__PURE__ */ a("div", {
41
- className: `max-w-[70%] rounded-lg p-4 ${m ? "border-2 border-status-warning-bg bg-status-warning-bg-subtle" : p ? "bg-muted" : "bg-primary/10"}`,
41
+ className: `max-w-[70%] rounded-lg p-4 ${_ ? "border-2 border-status-warning-bg bg-status-warning-bg-subtle" : m ? "bg-muted" : "bg-primary/10"}`,
42
42
  children: [
43
43
  /* @__PURE__ */ a("div", {
44
44
  className: "flex items-center gap-2 mb-2",
45
45
  children: [/* @__PURE__ */ i("div", {
46
- className: `w-8 h-8 rounded-full flex items-center justify-center transition-colors duration-200 ${p ? "bg-accent/10" : "bg-primary/20"}`,
46
+ className: `w-8 h-8 rounded-full flex items-center justify-center transition-colors duration-200 ${m ? "bg-accent/10" : "bg-primary/20"}`,
47
47
  children: /* @__PURE__ */ i(r, {
48
48
  size: 16,
49
- className: p ? "text-accent" : "text-primary"
49
+ className: m ? "text-accent" : "text-primary"
50
50
  })
51
51
  }), /* @__PURE__ */ a("div", {
52
52
  className: "flex-1",
@@ -54,8 +54,8 @@ var o = {
54
54
  className: "flex items-center gap-2",
55
55
  children: [/* @__PURE__ */ i("span", {
56
56
  className: "font-medium text-sm text-foreground",
57
- children: b
58
- }), m && /* @__PURE__ */ a("span", {
57
+ children: C
58
+ }), _ && /* @__PURE__ */ a("span", {
59
59
  className: "text-xs px-2 py-0.5 rounded flex items-center gap-1 bg-status-warning-bg text-on-accent",
60
60
  children: [/* @__PURE__ */ i(n, { size: 10 }), "Internal"]
61
61
  })]
@@ -1 +1 @@
1
- {"version":3,"file":"MessageThread.js","names":[],"sources":["../../../../src/support/components/tickets/MessageThread.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { User, Lock } from 'lucide-react';\nimport type { SupportMessage, MessageType } from '../../../generated/global-types';\nimport { AttachmentList } from './AttachmentList';\nimport { MarkdownContent } from './MarkdownContent';\n\ninterface MessageThreadProps {\n ticketId: string;\n messages: SupportMessage[];\n currentUserId?: string;\n showInternalMessages?: boolean;\n showRealAgentIdentity?: boolean;\n}\n\n// Message type display configuration\nconst messageTypeConfig: Record<MessageType, { label: string; isAgent: boolean }> = {\n CUSTOMER_REPLY: { label: 'Customer', isAgent: false },\n AGENT_REPLY: { label: 'Agent', isAgent: true },\n INTERNAL_NOTE: { label: 'Internal Note', isAgent: true },\n SYSTEM_MESSAGE: { label: 'System', isAgent: true },\n};\n\nexport const MessageThread: FC<MessageThreadProps> = ({\n ticketId,\n messages,\n currentUserId,\n showInternalMessages = false,\n showRealAgentIdentity = false,\n}) => {\n const visibleMessages = showInternalMessages\n ? messages\n : messages.filter((msg) => !msg.isInternal);\n\n if (!visibleMessages || visibleMessages.length === 0) {\n return (\n <div className=\"flex flex-col items-center justify-center py-12\">\n <p className=\"text-lg text-muted-foreground\">No messages yet</p>\n <p className=\"text-sm mt-2 text-muted-foreground/70\">\n Start the conversation by sending a message\n </p>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-4\">\n {visibleMessages.map((msg) => {\n const isCurrentUser = msg.authorId === currentUserId;\n const typeConfig = messageTypeConfig[msg.type] || messageTypeConfig.SYSTEM_MESSAGE;\n const isCustomer = msg.type === 'CUSTOMER_REPLY';\n const isInternal = msg.isInternal || msg.type === 'INTERNAL_NOTE';\n const customContext =\n (msg.context?.custom as Record<string, unknown> | null | undefined) ?? undefined;\n // Privacy: prefer the backend-resolved `author` projection — it gates\n // real-vs-alias identity by viewer actor type. Fall back to the legacy\n // `context.custom` snapshot for older messages where `author` is null.\n const author =\n (\n msg as {\n author?: {\n displayName: string;\n avatar: string;\n isAnonymized: boolean;\n kind: string;\n } | null;\n }\n ).author ?? null;\n // The backend has the AUTHORITATIVE privacy decision. If it says\n // `isAnonymized`, we MUST NOT reach back into `context.custom` to\n // recover the real name — the prop `showRealAgentIdentity` is only a\n // UI preference for callers that are already in the admin context.\n const backendAnonymized = author ? author.isAnonymized : true;\n const agentAlias =\n author?.displayName ??\n (customContext?.authorAlias as string | undefined) ??\n 'Support Agent';\n const realAgentName = backendAnonymized\n ? agentAlias\n : author\n ? author.displayName\n : showRealAgentIdentity\n ? ((customContext?.authorName as string | undefined) ??\n (customContext?.authorEmail as string | undefined) ??\n msg.authorId)\n : agentAlias;\n const displayName =\n msg.type === 'AGENT_REPLY'\n ? showRealAgentIdentity && !backendAnonymized\n ? realAgentName\n : agentAlias\n : msg.type === 'CUSTOMER_REPLY'\n ? isCurrentUser\n ? 'You'\n : 'Customer'\n : typeConfig.label;\n\n return (\n <div key={msg.id} className={`flex ${isCurrentUser ? 'justify-end' : 'justify-start'}`}>\n <div\n className={`max-w-[70%] rounded-lg p-4 ${\n isInternal\n ? 'border-2 border-status-warning-bg bg-status-warning-bg-subtle'\n : isCustomer\n ? 'bg-muted'\n : 'bg-primary/10'\n }`}\n >\n {/* Message header */}\n <div className=\"flex items-center gap-2 mb-2\">\n <div\n className={`w-8 h-8 rounded-full flex items-center justify-center transition-colors duration-200 ${\n isCustomer ? 'bg-accent/10' : 'bg-primary/20'\n }`}\n >\n <User size={16} className={isCustomer ? 'text-accent' : 'text-primary'} />\n </div>\n <div className=\"flex-1\">\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium text-sm text-foreground\">{displayName}</span>\n {isInternal && (\n <span className=\"text-xs px-2 py-0.5 rounded flex items-center gap-1 bg-status-warning-bg text-on-accent\">\n <Lock size={10} />\n Internal\n </span>\n )}\n </div>\n <span className=\"text-xs text-muted-foreground\">\n {new Date(msg.createdAt).toLocaleString()}\n </span>\n </div>\n </div>\n\n {/* Message content */}\n <MarkdownContent content={msg.message} className=\"text-sm\" />\n\n <div className=\"mt-3\">\n <AttachmentList fileIds={msg.attachments || []} ticketId={ticketId} />\n </div>\n </div>\n </div>\n );\n })}\n </div>\n );\n};\n"],"mappings":";;;;;AAeA,IAAM,IAA8E;CAClF,gBAAgB;EAAE,OAAO;EAAY,SAAS;EAAO;CACrD,aAAa;EAAE,OAAO;EAAS,SAAS;EAAM;CAC9C,eAAe;EAAE,OAAO;EAAiB,SAAS;EAAM;CACxD,gBAAgB;EAAE,OAAO;EAAU,SAAS;EAAM;CACnD,EAEY,KAAyC,EACpD,aACA,aACA,kBACA,0BAAuB,IACvB,2BAAwB,SACpB;CACJ,IAAM,IAAkB,IACpB,IACA,EAAS,QAAQ,MAAQ,CAAC,EAAI,WAAW;AAa7C,QAXI,CAAC,KAAmB,EAAgB,WAAW,IAE/C,kBAAC,OAAD;EAAK,WAAU;YAAf,CACE,kBAAC,KAAD;GAAG,WAAU;aAAgC;GAAmB,CAAA,EAChE,kBAAC,KAAD;GAAG,WAAU;aAAwC;GAEjD,CAAA,CACA;MAKR,kBAAC,OAAD;EAAK,WAAU;YACZ,EAAgB,KAAK,MAAQ;GAC5B,IAAM,IAAgB,EAAI,aAAa,GACjC,IAAa,EAAkB,EAAI,SAAS,EAAkB,gBAC9D,IAAa,EAAI,SAAS,kBAC1B,IAAa,EAAI,cAAc,EAAI,SAAS,iBAC5C,IACH,EAAI,SAAS,UAAyD,KAAA,GAInE,IAEF,EAQA,UAAU,MAKR,IAAoB,IAAS,EAAO,eAAe,IACnD,IACJ,GAAQ,eACP,GAAe,eAChB,iBACI,IAAgB,IAClB,IACA,IACE,EAAO,cACP,IACI,GAAe,cAChB,GAAe,eAChB,EAAI,WACJ,GACF,IACJ,EAAI,SAAS,gBACT,KAAyB,CAAC,IACxB,IACA,IACF,EAAI,SAAS,mBACX,IACE,QACA,aACF,EAAW;AAEnB,UACE,kBAAC,OAAD;IAAkB,WAAW,QAAQ,IAAgB,gBAAgB;cACnE,kBAAC,OAAD;KACE,WAAW,8BACT,IACI,kEACA,IACE,aACA;eANV;MAUE,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,OAAD;QACE,WAAW,wFACT,IAAa,iBAAiB;kBAGhC,kBAAC,GAAD;SAAM,MAAM;SAAI,WAAW,IAAa,gBAAgB;SAAkB,CAAA;QACtE,CAAA,EACN,kBAAC,OAAD;QAAK,WAAU;kBAAf,CACE,kBAAC,OAAD;SAAK,WAAU;mBAAf,CACE,kBAAC,QAAD;UAAM,WAAU;oBAAuC;UAAmB,CAAA,EACzE,KACC,kBAAC,QAAD;UAAM,WAAU;oBAAhB,CACE,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA,EAAA,WAEb;YAEL;YACN,kBAAC,QAAD;SAAM,WAAU;mBACb,IAAI,KAAK,EAAI,UAAU,CAAC,gBAAgB;SACpC,CAAA,CACH;UACF;;MAGN,kBAAC,GAAD;OAAiB,SAAS,EAAI;OAAS,WAAU;OAAY,CAAA;MAE7D,kBAAC,OAAD;OAAK,WAAU;iBACb,kBAAC,GAAD;QAAgB,SAAS,EAAI,eAAe,EAAE;QAAY;QAAY,CAAA;OAClE,CAAA;MACF;;IACF,EA1CI,EAAI,GA0CR;IAER;EACE,CAAA"}
1
+ {"version":3,"file":"MessageThread.js","names":[],"sources":["../../../../src/support/components/tickets/MessageThread.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { User, Lock } from 'lucide-react';\nimport type { SupportMessage, MessageType } from '../../../generated/global-types';\nimport { AttachmentList } from './AttachmentList';\nimport { MarkdownContent } from './MarkdownContent';\n\ninterface MessageThreadProps {\n ticketId: string;\n messages: SupportMessage[];\n currentUserId?: string;\n viewerRole?: 'customer' | 'agent';\n showInternalMessages?: boolean;\n showRealAgentIdentity?: boolean;\n}\n\n// Message type display configuration\nconst messageTypeConfig: Record<MessageType, { label: string; isAgent: boolean }> = {\n CUSTOMER_REPLY: { label: 'Customer', isAgent: false },\n AGENT_REPLY: { label: 'Agent', isAgent: true },\n INTERNAL_NOTE: { label: 'Internal Note', isAgent: true },\n SYSTEM_MESSAGE: { label: 'System', isAgent: true },\n};\n\nexport const MessageThread: FC<MessageThreadProps> = ({\n ticketId,\n messages,\n currentUserId,\n viewerRole = 'customer',\n showInternalMessages = false,\n showRealAgentIdentity = false,\n}) => {\n const visibleMessages = showInternalMessages\n ? messages\n : messages.filter((msg) => !msg.isInternal);\n\n if (!visibleMessages || visibleMessages.length === 0) {\n return (\n <div className=\"flex flex-col items-center justify-center py-12\">\n <p className=\"text-lg text-muted-foreground\">No messages yet</p>\n <p className=\"text-sm mt-2 text-muted-foreground/70\">\n Start the conversation by sending a message\n </p>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-4\">\n {visibleMessages.map((msg) => {\n const isCurrentUser = msg.authorId === currentUserId;\n const typeConfig = messageTypeConfig[msg.type] || messageTypeConfig.SYSTEM_MESSAGE;\n const isCustomer = msg.type === 'CUSTOMER_REPLY';\n const isAgentMessage = typeConfig.isAgent && msg.type !== 'SYSTEM_MESSAGE';\n const alignEnd = viewerRole === 'agent' ? isAgentMessage : isCustomer;\n const isInternal = msg.isInternal || msg.type === 'INTERNAL_NOTE';\n const customContext =\n (msg.context?.custom as Record<string, unknown> | null | undefined) ?? undefined;\n // Privacy: prefer the backend-resolved `author` projection — it gates\n // real-vs-alias identity by viewer actor type. Fall back to the legacy\n // `context.custom` snapshot for older messages where `author` is null.\n const author =\n (\n msg as {\n author?: {\n displayName: string;\n avatar: string;\n isAnonymized: boolean;\n kind: string;\n } | null;\n }\n ).author ?? null;\n // The backend has the AUTHORITATIVE privacy decision. If it says\n // `isAnonymized`, we MUST NOT reach back into `context.custom` to\n // recover the real name — the prop `showRealAgentIdentity` is only a\n // UI preference for callers that are already in the admin context.\n const backendAnonymized = author ? author.isAnonymized : true;\n const agentAlias =\n author?.displayName ??\n (customContext?.authorAlias as string | undefined) ??\n 'Support Agent';\n const realAgentName = backendAnonymized\n ? agentAlias\n : author\n ? author.displayName\n : showRealAgentIdentity\n ? ((customContext?.authorName as string | undefined) ??\n (customContext?.authorEmail as string | undefined) ??\n msg.authorId)\n : agentAlias;\n const displayName =\n msg.type === 'AGENT_REPLY'\n ? showRealAgentIdentity && !backendAnonymized\n ? realAgentName\n : agentAlias\n : msg.type === 'CUSTOMER_REPLY'\n ? isCurrentUser\n ? 'You'\n : 'Customer'\n : typeConfig.label;\n\n return (\n <div key={msg.id} className={`flex ${alignEnd ? 'justify-end' : 'justify-start'}`}>\n <div\n className={`max-w-[70%] rounded-lg p-4 ${\n isInternal\n ? 'border-2 border-status-warning-bg bg-status-warning-bg-subtle'\n : isCustomer\n ? 'bg-muted'\n : 'bg-primary/10'\n }`}\n >\n {/* Message header */}\n <div className=\"flex items-center gap-2 mb-2\">\n <div\n className={`w-8 h-8 rounded-full flex items-center justify-center transition-colors duration-200 ${\n isCustomer ? 'bg-accent/10' : 'bg-primary/20'\n }`}\n >\n <User size={16} className={isCustomer ? 'text-accent' : 'text-primary'} />\n </div>\n <div className=\"flex-1\">\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium text-sm text-foreground\">{displayName}</span>\n {isInternal && (\n <span className=\"text-xs px-2 py-0.5 rounded flex items-center gap-1 bg-status-warning-bg text-on-accent\">\n <Lock size={10} />\n Internal\n </span>\n )}\n </div>\n <span className=\"text-xs text-muted-foreground\">\n {new Date(msg.createdAt).toLocaleString()}\n </span>\n </div>\n </div>\n\n {/* Message content */}\n <MarkdownContent content={msg.message} className=\"text-sm\" />\n\n <div className=\"mt-3\">\n <AttachmentList fileIds={msg.attachments || []} ticketId={ticketId} />\n </div>\n </div>\n </div>\n );\n })}\n </div>\n );\n};\n"],"mappings":";;;;;AAgBA,IAAM,IAA8E;CAClF,gBAAgB;EAAE,OAAO;EAAY,SAAS;EAAO;CACrD,aAAa;EAAE,OAAO;EAAS,SAAS;EAAM;CAC9C,eAAe;EAAE,OAAO;EAAiB,SAAS;EAAM;CACx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