@escalated-dev/escalated 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +380 -357
  3. package/package.json +85 -81
  4. package/src/components/ActiveChatsPanel.vue +246 -246
  5. package/src/components/AdminDashboard.stories.js +1423 -1423
  6. package/src/components/AttachmentList.vue +65 -65
  7. package/src/components/ChatActionBar.vue +226 -226
  8. package/src/components/ChatBubble.vue +162 -162
  9. package/src/components/ChatComposer.vue +308 -308
  10. package/src/components/ChatQueue.vue +222 -222
  11. package/src/components/ChatThread.vue +197 -197
  12. package/src/components/CustomTicketActions.stories.js +71 -0
  13. package/src/components/CustomTicketActions.vue +101 -0
  14. package/src/components/EscalatedLayout.vue +619 -598
  15. package/src/components/FollowButton.vue +20 -1
  16. package/src/components/MentionDropdown.vue +154 -154
  17. package/src/components/MetricComparison.vue +89 -89
  18. package/src/components/PercentileChart.vue +67 -67
  19. package/src/components/PeriodSelector.vue +98 -98
  20. package/src/components/PresenceIndicator.vue +228 -213
  21. package/src/components/ReplyComposer.vue +336 -336
  22. package/src/components/ReplyThread.vue +153 -153
  23. package/src/components/ReportChart.vue +395 -395
  24. package/src/components/ReportExportButton.vue +108 -108
  25. package/src/components/SaveViewDialog.vue +172 -172
  26. package/src/components/SavedViewSidebar.vue +208 -208
  27. package/src/components/SkillTagManager.vue +29 -22
  28. package/src/components/SnoozeButton.vue +247 -247
  29. package/src/components/TicketFilters.vue +270 -270
  30. package/src/components/TicketList.vue +655 -655
  31. package/src/components/TicketSidebar.vue +4 -0
  32. package/src/components/TicketSplitDialog.vue +98 -98
  33. package/src/components/TicketSubjects.stories.js +63 -0
  34. package/src/components/TicketSubjects.vue +107 -0
  35. package/src/components/TwoFactorSetup.vue +1 -37
  36. package/src/components/VariableTokenInput.vue +111 -111
  37. package/src/components/WorkflowActionConfig.vue +287 -287
  38. package/src/components/WorkflowActionList.vue +350 -350
  39. package/src/components/WorkflowConditionBuilder.vue +265 -265
  40. package/src/components/WorkflowTriggerSelector.vue +125 -125
  41. package/src/components/admin/newsletters/AnalyticsTiles.stories.js +14 -0
  42. package/src/components/admin/newsletters/AnalyticsTiles.vue +55 -0
  43. package/src/components/admin/newsletters/DeliveriesTable.stories.js +28 -0
  44. package/src/components/admin/newsletters/DeliveriesTable.vue +104 -0
  45. package/src/components/admin/newsletters/DynamicFilterBuilder.stories.js +11 -0
  46. package/src/components/admin/newsletters/DynamicFilterBuilder.vue +53 -0
  47. package/src/components/admin/newsletters/ListMemberTable.stories.js +12 -0
  48. package/src/components/admin/newsletters/ListMemberTable.vue +53 -0
  49. package/src/components/admin/newsletters/MarkdownEditor.stories.js +6 -0
  50. package/src/components/admin/newsletters/MarkdownEditor.vue +53 -0
  51. package/src/components/admin/newsletters/MergeFieldDropdown.stories.js +6 -0
  52. package/src/components/admin/newsletters/MergeFieldDropdown.vue +84 -0
  53. package/src/components/admin/newsletters/PreviewIframe.stories.js +7 -0
  54. package/src/components/admin/newsletters/PreviewIframe.vue +40 -0
  55. package/src/components/admin/newsletters/SummaryTiles.stories.js +8 -0
  56. package/src/components/admin/newsletters/SummaryTiles.vue +63 -0
  57. package/src/composables/useChat.js +187 -187
  58. package/src/composables/useI18n.js +30 -8
  59. package/src/composables/useMentions.js +134 -134
  60. package/src/composables/usePermissions.js +31 -0
  61. package/src/composables/useRealtime.js +182 -182
  62. package/src/index.js +85 -84
  63. package/src/locales/README.md +13 -0
  64. package/src/locales/ar.json +727 -727
  65. package/src/locales/de.json +690 -690
  66. package/src/locales/en.json +889 -729
  67. package/src/locales/es.json +691 -691
  68. package/src/locales/fr.json +691 -691
  69. package/src/locales/index.js +16 -16
  70. package/src/locales/it.json +727 -727
  71. package/src/locales/ja.json +727 -727
  72. package/src/locales/ko.json +727 -727
  73. package/src/locales/nl.json +727 -727
  74. package/src/locales/pl.json +727 -727
  75. package/src/locales/pt-BR.json +727 -727
  76. package/src/locales/ru.json +727 -727
  77. package/src/locales/tr.json +727 -727
  78. package/src/locales/zh-CN.json +727 -727
  79. package/src/pages/Admin/Newsletters/Compose.vue +192 -0
  80. package/src/pages/Admin/Newsletters/Edit.vue +24 -0
  81. package/src/pages/Admin/Newsletters/Index.vue +141 -0
  82. package/src/pages/Admin/Newsletters/Lists/Create.vue +64 -0
  83. package/src/pages/Admin/Newsletters/Lists/Index.vue +59 -0
  84. package/src/pages/Admin/Newsletters/Lists/Show.vue +53 -0
  85. package/src/pages/Admin/Newsletters/Settings.vue +85 -0
  86. package/src/pages/Admin/Newsletters/Show.vue +140 -0
  87. package/src/pages/Admin/Newsletters/Templates/Create.vue +11 -0
  88. package/src/pages/Admin/Newsletters/Templates/Index.vue +54 -0
  89. package/src/pages/Admin/Newsletters/Templates/Show.vue +65 -0
  90. package/src/pages/Admin/Newsletters/usePreview.js +44 -0
  91. package/src/pages/Admin/Reports/AgentDetail.vue +132 -132
  92. package/src/pages/Admin/Reports/AgentRanking.vue +246 -246
  93. package/src/pages/Admin/Reports/Cohorts.vue +180 -180
  94. package/src/pages/Admin/Reports/Comparison.vue +141 -141
  95. package/src/pages/Admin/Reports/Dashboard.vue +226 -226
  96. package/src/pages/Admin/Reports/ResolutionTimes.vue +164 -164
  97. package/src/pages/Admin/Reports/ResponseTimes.vue +164 -164
  98. package/src/pages/Admin/Reports/SlaTrends.vue +183 -183
  99. package/src/pages/Admin/Settings/SsoSettings.vue +157 -4
  100. package/src/pages/Admin/Settings/TwoFactor.vue +32 -6
  101. package/src/pages/Admin/Settings.vue +1008 -1008
  102. package/src/pages/Admin/Skills/Form.vue +164 -4
  103. package/src/pages/Admin/Skills/Index.vue +14 -3
  104. package/src/pages/Admin/Tickets/Index.vue +126 -126
  105. package/src/pages/Admin/Tickets/Show.vue +254 -249
  106. package/src/pages/Admin/Users/Index.vue +145 -0
  107. package/src/pages/Admin/Workflows/Builder.vue +207 -207
  108. package/src/pages/Admin/Workflows/Index.vue +235 -235
  109. package/src/pages/Admin/Workflows/Logs.vue +286 -286
  110. package/src/pages/Agent/TicketIndex.vue +112 -112
  111. package/src/pages/Agent/TicketShow.vue +547 -494
  112. package/src/pages/Customer/Index.vue +26 -1
  113. package/src/pages/Customer/KnowledgeBase/Article.vue +129 -129
  114. package/src/plugin.js +175 -175
  115. package/src/utils/mentionHighlight.js +24 -24
  116. package/src/widget/EscalatedWidget.vue +804 -804
  117. package/src/widget/index.js +254 -254
@@ -1,336 +1,336 @@
1
- <script setup>
2
- import { ref, computed, inject } from 'vue';
3
- import { router } from '@inertiajs/vue3';
4
- import FileDropzone from './FileDropzone.vue';
5
- import MentionDropdown from './MentionDropdown.vue';
6
- import { useMentions } from '../composables/useMentions';
7
-
8
- const props = defineProps({
9
- action: { type: String, required: true },
10
- cannedResponses: { type: Array, default: () => [] },
11
- allowNotes: { type: Boolean, default: false },
12
- placeholder: { type: String, default: 'Type your reply...' },
13
- submitLabel: { type: String, default: null },
14
- typingEndpoint: { type: String, default: '' },
15
- });
16
-
17
- const emit = defineEmits(['submit']);
18
- const escDark = inject(
19
- 'esc-dark',
20
- computed(() => false),
21
- );
22
-
23
- const body = ref('');
24
- const isNote = ref(false);
25
- const files = ref([]);
26
- const submitting = ref(false);
27
- const textareaRef = ref(null);
28
- const mentionDropdownRef = ref(null);
29
-
30
- const {
31
- suggestions,
32
- isActive: mentionActive,
33
- loading: mentionLoading,
34
- onTextChange,
35
- insertMention,
36
- close: closeMentions,
37
- } = useMentions();
38
-
39
- function onMentionInput() {
40
- if (textareaRef.value) {
41
- onTextChange(textareaRef.value, body.value);
42
- }
43
- }
44
-
45
- function handleMentionSelect(agent) {
46
- body.value = insertMention(body.value, agent);
47
- textareaRef.value?.focus();
48
- }
49
-
50
- function handleMentionKeydown(e) {
51
- if (mentionActive.value && mentionDropdownRef.value) {
52
- const handled = mentionDropdownRef.value.onKeydown(e);
53
- if (handled) return;
54
- }
55
- }
56
-
57
- // Typing indicator: debounced POST every 5 seconds while typing
58
- let lastTypingSent = 0;
59
- let typingTimer = null;
60
-
61
- function onTyping() {
62
- if (!props.typingEndpoint) return;
63
- const now = Date.now();
64
- if (now - lastTypingSent < 5000) return;
65
- lastTypingSent = now;
66
- sendTypingIndicator();
67
-
68
- // Clear typing after 6 seconds of inactivity
69
- window.clearTimeout(typingTimer);
70
- typingTimer = window.setTimeout(() => {
71
- lastTypingSent = 0;
72
- }, 6000);
73
- }
74
-
75
- async function sendTypingIndicator() {
76
- try {
77
- await fetch(props.typingEndpoint, {
78
- method: 'POST',
79
- headers: {
80
- Accept: 'application/json',
81
- 'Content-Type': 'application/json',
82
- 'X-Requested-With': 'XMLHttpRequest',
83
- 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content || '',
84
- },
85
- });
86
- } catch {
87
- // silently ignore
88
- }
89
- }
90
-
91
- function onBlur() {
92
- window.clearTimeout(typingTimer);
93
- lastTypingSent = 0;
94
- }
95
-
96
- function insertCanned(response) {
97
- body.value += response.body;
98
- }
99
-
100
- function handleFiles(newFiles) {
101
- files.value = [...files.value, ...newFiles];
102
- }
103
-
104
- function removeFile(index) {
105
- files.value.splice(index, 1);
106
- }
107
-
108
- function submit() {
109
- if (!body.value.trim() || submitting.value) return;
110
- submitting.value = true;
111
- window.clearTimeout(typingTimer);
112
- lastTypingSent = 0;
113
-
114
- const payload = {
115
- body: body.value,
116
- is_internal_note: isNote.value,
117
- attachments: files.value,
118
- };
119
-
120
- emit('submit', payload);
121
-
122
- router.post(props.action, payload, {
123
- preserveScroll: true,
124
- onSuccess: () => {
125
- body.value = '';
126
- files.value = [];
127
- isNote.value = false;
128
- },
129
- onFinish: () => {
130
- submitting.value = false;
131
- },
132
- });
133
- }
134
-
135
- const buttonLabel = computed(() => {
136
- if (props.submitLabel) return props.submitLabel;
137
- return isNote.value ? 'Add Note' : 'Send Reply';
138
- });
139
- </script>
140
-
141
- <template>
142
- <!-- Dark mode -->
143
- <div v-if="escDark" class="rounded-xl border border-white/[0.06] bg-neutral-900/60 p-4">
144
- <div v-if="allowNotes" class="mb-3 flex gap-2">
145
- <button
146
- :class="[
147
- 'rounded-lg px-3 py-1.5 text-sm font-medium transition-colors',
148
- !isNote
149
- ? 'bg-cyan-500/15 text-white ring-1 ring-cyan-500/20'
150
- : 'text-gray-400 hover:bg-white/[0.04]',
151
- ]"
152
- @click="isNote = false"
153
- >
154
- Reply
155
- </button>
156
- <button
157
- :class="[
158
- 'rounded-lg px-3 py-1.5 text-sm font-medium transition-colors',
159
- isNote
160
- ? 'bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/20'
161
- : 'text-gray-400 hover:bg-white/[0.04]',
162
- ]"
163
- aria-label="Internal note"
164
- @click="isNote = true"
165
- >
166
- Internal Note
167
- </button>
168
- </div>
169
-
170
- <div
171
- v-if="isNote"
172
- class="mb-2 rounded-lg bg-amber-500/10 px-3 py-1.5 text-xs text-amber-400 ring-1 ring-amber-500/20"
173
- >
174
- This note is only visible to agents.
175
- </div>
176
-
177
- <div class="relative">
178
- <textarea
179
- ref="textareaRef"
180
- v-model="body"
181
- rows="4"
182
- :placeholder="placeholder"
183
- aria-label="Reply message"
184
- class="w-full rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10"
185
- @keydown="
186
- handleMentionKeydown($event);
187
- onTyping();
188
- "
189
- @input="onMentionInput"
190
- @blur="onBlur"
191
- ></textarea>
192
- <MentionDropdown
193
- ref="mentionDropdownRef"
194
- :suggestions="suggestions"
195
- :visible="mentionActive"
196
- :loading="mentionLoading"
197
- class="bottom-0 left-0 translate-y-full"
198
- @select="handleMentionSelect"
199
- @close="closeMentions"
200
- />
201
- </div>
202
-
203
- <FileDropzone class="mt-2" @files="handleFiles" />
204
-
205
- <div v-if="files.length" class="mt-2 space-y-1">
206
- <div v-for="(file, i) in files" :key="i" class="flex items-center gap-2 text-sm text-gray-400">
207
- <span>{{ file.name }}</span>
208
- <button aria-label="Remove attachment" class="text-rose-400 hover:text-rose-300" @click="removeFile(i)">
209
- &times;
210
- </button>
211
- </div>
212
- </div>
213
-
214
- <div class="mt-3 flex items-center justify-between">
215
- <div v-if="cannedResponses.length">
216
- <select
217
- class="rounded-lg border border-white/10 bg-gray-900 px-2 py-1 text-xs text-gray-400"
218
- @change="
219
- insertCanned(cannedResponses[$event.target.value]);
220
- $event.target.value = '';
221
- "
222
- >
223
- <option value="">Canned responses...</option>
224
- <option v-for="(cr, i) in cannedResponses" :key="cr.id" :value="i">{{ cr.title }}</option>
225
- </select>
226
- </div>
227
- <div v-else></div>
228
- <button
229
- :disabled="!body.trim() || submitting"
230
- :class="[
231
- 'rounded-lg px-4 py-2 text-sm font-medium text-white transition-all',
232
- isNote
233
- ? 'bg-amber-500 hover:bg-amber-400'
234
- : 'bg-gradient-to-r from-cyan-500 to-violet-500 hover:from-cyan-400 hover:to-violet-400',
235
- (!body.trim() || submitting) && 'cursor-not-allowed opacity-40',
236
- ]"
237
- @click="submit"
238
- >
239
- {{ buttonLabel }}
240
- </button>
241
- </div>
242
- </div>
243
-
244
- <!-- Light mode -->
245
- <div v-else class="rounded-lg border border-gray-200 bg-white p-4">
246
- <div v-if="allowNotes" class="mb-3 flex gap-2">
247
- <button
248
- :class="[
249
- 'rounded-md px-3 py-1 text-sm font-medium',
250
- !isNote ? 'bg-blue-100 text-blue-700' : 'text-gray-500 hover:bg-gray-100',
251
- ]"
252
- @click="isNote = false"
253
- >
254
- Reply
255
- </button>
256
- <button
257
- :class="[
258
- 'rounded-md px-3 py-1 text-sm font-medium',
259
- isNote ? 'bg-yellow-100 text-yellow-700' : 'text-gray-500 hover:bg-gray-100',
260
- ]"
261
- aria-label="Internal note"
262
- @click="isNote = true"
263
- >
264
- Internal Note
265
- </button>
266
- </div>
267
-
268
- <div v-if="isNote" class="mb-2 rounded bg-yellow-50 px-3 py-1.5 text-xs text-yellow-700">
269
- This note is only visible to agents.
270
- </div>
271
-
272
- <div class="relative">
273
- <textarea
274
- ref="textareaRef"
275
- v-model="body"
276
- rows="4"
277
- :placeholder="placeholder"
278
- aria-label="Reply message"
279
- class="w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
280
- @keydown="
281
- handleMentionKeydown($event);
282
- onTyping();
283
- "
284
- @input="onMentionInput"
285
- @blur="onBlur"
286
- ></textarea>
287
- <MentionDropdown
288
- ref="mentionDropdownRef"
289
- :suggestions="suggestions"
290
- :visible="mentionActive"
291
- :loading="mentionLoading"
292
- class="bottom-0 left-0 translate-y-full"
293
- @select="handleMentionSelect"
294
- @close="closeMentions"
295
- />
296
- </div>
297
-
298
- <FileDropzone class="mt-2" @files="handleFiles" />
299
-
300
- <div v-if="files.length" class="mt-2 space-y-1">
301
- <div v-for="(file, i) in files" :key="i" class="flex items-center gap-2 text-sm text-gray-600">
302
- <span>{{ file.name }}</span>
303
- <button aria-label="Remove attachment" class="text-red-500 hover:text-red-700" @click="removeFile(i)">
304
- &times;
305
- </button>
306
- </div>
307
- </div>
308
-
309
- <div class="mt-3 flex items-center justify-between">
310
- <div v-if="cannedResponses.length">
311
- <select
312
- class="rounded border border-gray-300 px-2 py-1 text-xs text-gray-600"
313
- @change="
314
- insertCanned(cannedResponses[$event.target.value]);
315
- $event.target.value = '';
316
- "
317
- >
318
- <option value="">Canned responses...</option>
319
- <option v-for="(cr, i) in cannedResponses" :key="cr.id" :value="i">{{ cr.title }}</option>
320
- </select>
321
- </div>
322
- <div v-else></div>
323
- <button
324
- :disabled="!body.trim() || submitting"
325
- :class="[
326
- 'rounded-md px-4 py-2 text-sm font-medium text-white',
327
- isNote ? 'bg-yellow-500 hover:bg-yellow-600' : 'bg-blue-600 hover:bg-blue-700',
328
- (!body.trim() || submitting) && 'cursor-not-allowed opacity-50',
329
- ]"
330
- @click="submit"
331
- >
332
- {{ buttonLabel }}
333
- </button>
334
- </div>
335
- </div>
336
- </template>
1
+ <script setup>
2
+ import { ref, computed, inject } from 'vue';
3
+ import { router } from '@inertiajs/vue3';
4
+ import FileDropzone from './FileDropzone.vue';
5
+ import MentionDropdown from './MentionDropdown.vue';
6
+ import { useMentions } from '../composables/useMentions';
7
+
8
+ const props = defineProps({
9
+ action: { type: String, required: true },
10
+ cannedResponses: { type: Array, default: () => [] },
11
+ allowNotes: { type: Boolean, default: false },
12
+ placeholder: { type: String, default: 'Type your reply...' },
13
+ submitLabel: { type: String, default: null },
14
+ typingEndpoint: { type: String, default: '' },
15
+ });
16
+
17
+ const emit = defineEmits(['submit']);
18
+ const escDark = inject(
19
+ 'esc-dark',
20
+ computed(() => false),
21
+ );
22
+
23
+ const body = ref('');
24
+ const isNote = ref(false);
25
+ const files = ref([]);
26
+ const submitting = ref(false);
27
+ const textareaRef = ref(null);
28
+ const mentionDropdownRef = ref(null);
29
+
30
+ const {
31
+ suggestions,
32
+ isActive: mentionActive,
33
+ loading: mentionLoading,
34
+ onTextChange,
35
+ insertMention,
36
+ close: closeMentions,
37
+ } = useMentions();
38
+
39
+ function onMentionInput() {
40
+ if (textareaRef.value) {
41
+ onTextChange(textareaRef.value, body.value);
42
+ }
43
+ }
44
+
45
+ function handleMentionSelect(agent) {
46
+ body.value = insertMention(body.value, agent);
47
+ textareaRef.value?.focus();
48
+ }
49
+
50
+ function handleMentionKeydown(e) {
51
+ if (mentionActive.value && mentionDropdownRef.value) {
52
+ const handled = mentionDropdownRef.value.onKeydown(e);
53
+ if (handled) return;
54
+ }
55
+ }
56
+
57
+ // Typing indicator: debounced POST every 5 seconds while typing
58
+ let lastTypingSent = 0;
59
+ let typingTimer = null;
60
+
61
+ function onTyping() {
62
+ if (!props.typingEndpoint) return;
63
+ const now = Date.now();
64
+ if (now - lastTypingSent < 5000) return;
65
+ lastTypingSent = now;
66
+ sendTypingIndicator();
67
+
68
+ // Clear typing after 6 seconds of inactivity
69
+ window.clearTimeout(typingTimer);
70
+ typingTimer = window.setTimeout(() => {
71
+ lastTypingSent = 0;
72
+ }, 6000);
73
+ }
74
+
75
+ async function sendTypingIndicator() {
76
+ try {
77
+ await fetch(props.typingEndpoint, {
78
+ method: 'POST',
79
+ headers: {
80
+ Accept: 'application/json',
81
+ 'Content-Type': 'application/json',
82
+ 'X-Requested-With': 'XMLHttpRequest',
83
+ 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content || '',
84
+ },
85
+ });
86
+ } catch {
87
+ // silently ignore
88
+ }
89
+ }
90
+
91
+ function onBlur() {
92
+ window.clearTimeout(typingTimer);
93
+ lastTypingSent = 0;
94
+ }
95
+
96
+ function insertCanned(response) {
97
+ body.value += response.body;
98
+ }
99
+
100
+ function handleFiles(newFiles) {
101
+ files.value = [...files.value, ...newFiles];
102
+ }
103
+
104
+ function removeFile(index) {
105
+ files.value.splice(index, 1);
106
+ }
107
+
108
+ function submit() {
109
+ if (!body.value.trim() || submitting.value) return;
110
+ submitting.value = true;
111
+ window.clearTimeout(typingTimer);
112
+ lastTypingSent = 0;
113
+
114
+ const payload = {
115
+ body: body.value,
116
+ is_internal_note: isNote.value,
117
+ attachments: files.value,
118
+ };
119
+
120
+ emit('submit', payload);
121
+
122
+ router.post(props.action, payload, {
123
+ preserveScroll: true,
124
+ onSuccess: () => {
125
+ body.value = '';
126
+ files.value = [];
127
+ isNote.value = false;
128
+ },
129
+ onFinish: () => {
130
+ submitting.value = false;
131
+ },
132
+ });
133
+ }
134
+
135
+ const buttonLabel = computed(() => {
136
+ if (props.submitLabel) return props.submitLabel;
137
+ return isNote.value ? 'Add Note' : 'Send Reply';
138
+ });
139
+ </script>
140
+
141
+ <template>
142
+ <!-- Dark mode -->
143
+ <div v-if="escDark" class="rounded-xl border border-white/[0.06] bg-neutral-900/60 p-4">
144
+ <div v-if="allowNotes" class="mb-3 flex gap-2">
145
+ <button
146
+ :class="[
147
+ 'rounded-lg px-3 py-1.5 text-sm font-medium transition-colors',
148
+ !isNote
149
+ ? 'bg-cyan-500/15 text-white ring-1 ring-cyan-500/20'
150
+ : 'text-gray-400 hover:bg-white/[0.04]',
151
+ ]"
152
+ @click="isNote = false"
153
+ >
154
+ Reply
155
+ </button>
156
+ <button
157
+ :class="[
158
+ 'rounded-lg px-3 py-1.5 text-sm font-medium transition-colors',
159
+ isNote
160
+ ? 'bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/20'
161
+ : 'text-gray-400 hover:bg-white/[0.04]',
162
+ ]"
163
+ aria-label="Internal note"
164
+ @click="isNote = true"
165
+ >
166
+ Internal Note
167
+ </button>
168
+ </div>
169
+
170
+ <div
171
+ v-if="isNote"
172
+ class="mb-2 rounded-lg bg-amber-500/10 px-3 py-1.5 text-xs text-amber-400 ring-1 ring-amber-500/20"
173
+ >
174
+ This note is only visible to agents.
175
+ </div>
176
+
177
+ <div class="relative">
178
+ <textarea
179
+ ref="textareaRef"
180
+ v-model="body"
181
+ rows="4"
182
+ :placeholder="placeholder"
183
+ aria-label="Reply message"
184
+ class="w-full rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-gray-200 placeholder-gray-500 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10"
185
+ @keydown="
186
+ handleMentionKeydown($event);
187
+ onTyping();
188
+ "
189
+ @input="onMentionInput"
190
+ @blur="onBlur"
191
+ ></textarea>
192
+ <MentionDropdown
193
+ ref="mentionDropdownRef"
194
+ :suggestions="suggestions"
195
+ :visible="mentionActive"
196
+ :loading="mentionLoading"
197
+ class="bottom-0 left-0 translate-y-full"
198
+ @select="handleMentionSelect"
199
+ @close="closeMentions"
200
+ />
201
+ </div>
202
+
203
+ <FileDropzone class="mt-2" @files="handleFiles" />
204
+
205
+ <div v-if="files.length" class="mt-2 space-y-1">
206
+ <div v-for="(file, i) in files" :key="i" class="flex items-center gap-2 text-sm text-gray-400">
207
+ <span>{{ file.name }}</span>
208
+ <button aria-label="Remove attachment" class="text-rose-400 hover:text-rose-300" @click="removeFile(i)">
209
+ &times;
210
+ </button>
211
+ </div>
212
+ </div>
213
+
214
+ <div class="mt-3 flex items-center justify-between">
215
+ <div v-if="cannedResponses.length">
216
+ <select
217
+ class="rounded-lg border border-white/10 bg-gray-900 px-2 py-1 text-xs text-gray-400"
218
+ @change="
219
+ insertCanned(cannedResponses[$event.target.value]);
220
+ $event.target.value = '';
221
+ "
222
+ >
223
+ <option value="">Canned responses...</option>
224
+ <option v-for="(cr, i) in cannedResponses" :key="cr.id" :value="i">{{ cr.title }}</option>
225
+ </select>
226
+ </div>
227
+ <div v-else></div>
228
+ <button
229
+ :disabled="!body.trim() || submitting"
230
+ :class="[
231
+ 'rounded-lg px-4 py-2 text-sm font-medium text-white transition-all',
232
+ isNote
233
+ ? 'bg-amber-500 hover:bg-amber-400'
234
+ : 'bg-gradient-to-r from-cyan-500 to-violet-500 hover:from-cyan-400 hover:to-violet-400',
235
+ (!body.trim() || submitting) && 'cursor-not-allowed opacity-40',
236
+ ]"
237
+ @click="submit"
238
+ >
239
+ {{ buttonLabel }}
240
+ </button>
241
+ </div>
242
+ </div>
243
+
244
+ <!-- Light mode -->
245
+ <div v-else class="rounded-lg border border-gray-200 bg-white p-4">
246
+ <div v-if="allowNotes" class="mb-3 flex gap-2">
247
+ <button
248
+ :class="[
249
+ 'rounded-md px-3 py-1 text-sm font-medium',
250
+ !isNote ? 'bg-blue-100 text-blue-700' : 'text-gray-500 hover:bg-gray-100',
251
+ ]"
252
+ @click="isNote = false"
253
+ >
254
+ Reply
255
+ </button>
256
+ <button
257
+ :class="[
258
+ 'rounded-md px-3 py-1 text-sm font-medium',
259
+ isNote ? 'bg-yellow-100 text-yellow-700' : 'text-gray-500 hover:bg-gray-100',
260
+ ]"
261
+ aria-label="Internal note"
262
+ @click="isNote = true"
263
+ >
264
+ Internal Note
265
+ </button>
266
+ </div>
267
+
268
+ <div v-if="isNote" class="mb-2 rounded bg-yellow-50 px-3 py-1.5 text-xs text-yellow-700">
269
+ This note is only visible to agents.
270
+ </div>
271
+
272
+ <div class="relative">
273
+ <textarea
274
+ ref="textareaRef"
275
+ v-model="body"
276
+ rows="4"
277
+ :placeholder="placeholder"
278
+ aria-label="Reply message"
279
+ class="w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
280
+ @keydown="
281
+ handleMentionKeydown($event);
282
+ onTyping();
283
+ "
284
+ @input="onMentionInput"
285
+ @blur="onBlur"
286
+ ></textarea>
287
+ <MentionDropdown
288
+ ref="mentionDropdownRef"
289
+ :suggestions="suggestions"
290
+ :visible="mentionActive"
291
+ :loading="mentionLoading"
292
+ class="bottom-0 left-0 translate-y-full"
293
+ @select="handleMentionSelect"
294
+ @close="closeMentions"
295
+ />
296
+ </div>
297
+
298
+ <FileDropzone class="mt-2" @files="handleFiles" />
299
+
300
+ <div v-if="files.length" class="mt-2 space-y-1">
301
+ <div v-for="(file, i) in files" :key="i" class="flex items-center gap-2 text-sm text-gray-600">
302
+ <span>{{ file.name }}</span>
303
+ <button aria-label="Remove attachment" class="text-red-500 hover:text-red-700" @click="removeFile(i)">
304
+ &times;
305
+ </button>
306
+ </div>
307
+ </div>
308
+
309
+ <div class="mt-3 flex items-center justify-between">
310
+ <div v-if="cannedResponses.length">
311
+ <select
312
+ class="rounded border border-gray-300 px-2 py-1 text-xs text-gray-600"
313
+ @change="
314
+ insertCanned(cannedResponses[$event.target.value]);
315
+ $event.target.value = '';
316
+ "
317
+ >
318
+ <option value="">Canned responses...</option>
319
+ <option v-for="(cr, i) in cannedResponses" :key="cr.id" :value="i">{{ cr.title }}</option>
320
+ </select>
321
+ </div>
322
+ <div v-else></div>
323
+ <button
324
+ :disabled="!body.trim() || submitting"
325
+ :class="[
326
+ 'rounded-md px-4 py-2 text-sm font-medium text-white',
327
+ isNote ? 'bg-yellow-500 hover:bg-yellow-600' : 'bg-blue-600 hover:bg-blue-700',
328
+ (!body.trim() || submitting) && 'cursor-not-allowed opacity-50',
329
+ ]"
330
+ @click="submit"
331
+ >
332
+ {{ buttonLabel }}
333
+ </button>
334
+ </div>
335
+ </div>
336
+ </template>