@escalated-dev/escalated 0.6.0 → 0.7.1

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 (187) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +125 -2
  3. package/package.json +40 -5
  4. package/src/components/ActiveChatsPanel.vue +246 -0
  5. package/src/components/ActivityTimeline.stories.js +55 -0
  6. package/src/components/ActivityTimeline.vue +83 -66
  7. package/src/components/AdminDashboard.stories.js +1423 -0
  8. package/src/components/AgentLoadIndicator.stories.js +37 -0
  9. package/src/components/AgentLoadIndicator.vue +49 -0
  10. package/src/components/AgentPerformanceCard.vue +44 -0
  11. package/src/components/ArticleEditor.vue +82 -0
  12. package/src/components/AssigneeSelect.vue +37 -23
  13. package/src/components/AttachmentList.vue +65 -37
  14. package/src/components/AuditLogEntry.vue +95 -0
  15. package/src/components/BulkActionBar.vue +166 -97
  16. package/src/components/CategoryTree.vue +89 -0
  17. package/src/components/ChartWidget.vue +46 -0
  18. package/src/components/ChatActionBar.vue +226 -0
  19. package/src/components/ChatBubble.vue +162 -0
  20. package/src/components/ChatComposer.vue +308 -0
  21. package/src/components/ChatQueue.vue +222 -0
  22. package/src/components/ChatThread.vue +197 -0
  23. package/src/components/CollisionWarning.stories.js +30 -0
  24. package/src/components/CollisionWarning.vue +68 -0
  25. package/src/components/ConditionalFieldRules.vue +135 -0
  26. package/src/components/ContextPanel.vue +66 -0
  27. package/src/components/ContextPanelSection.vue +65 -0
  28. package/src/components/CustomFieldRenderer.vue +159 -0
  29. package/src/components/EscalatedLayout.vue +424 -70
  30. package/src/components/FileDropzone.vue +57 -41
  31. package/src/components/FollowButton.stories.js +30 -0
  32. package/src/components/FollowButton.vue +88 -63
  33. package/src/components/KeyboardShortcutHelp.vue +213 -123
  34. package/src/components/KnowledgePanel.vue +122 -0
  35. package/src/components/KpiCard.stories.js +32 -0
  36. package/src/components/KpiCard.vue +88 -0
  37. package/src/components/MacroDropdown.vue +150 -90
  38. package/src/components/MentionDropdown.vue +154 -0
  39. package/src/components/MetricComparison.vue +89 -0
  40. package/src/components/PercentileChart.vue +67 -0
  41. package/src/components/PeriodSelector.vue +98 -0
  42. package/src/components/PermissionMatrix.vue +107 -0
  43. package/src/components/PinnedNotes.vue +129 -90
  44. package/src/components/PluginSlot.vue +68 -62
  45. package/src/components/PresenceIndicator.vue +138 -28
  46. package/src/components/PriorityBadge.stories.js +33 -0
  47. package/src/components/PriorityBadge.vue +46 -39
  48. package/src/components/QuickFilters.vue +65 -49
  49. package/src/components/ReplyComposer.vue +207 -30
  50. package/src/components/ReplyThread.vue +111 -21
  51. package/src/components/ReportChart.vue +395 -0
  52. package/src/components/ReportExportButton.vue +108 -0
  53. package/src/components/SatisfactionRating.vue +180 -128
  54. package/src/components/SaveViewDialog.vue +172 -0
  55. package/src/components/SavedViewSidebar.vue +208 -0
  56. package/src/components/ScheduleEditor.vue +104 -0
  57. package/src/components/SideConversation.vue +165 -0
  58. package/src/components/SideConversationList.vue +147 -0
  59. package/src/components/SkillTagManager.vue +79 -0
  60. package/src/components/SlaComplianceChart.vue +46 -0
  61. package/src/components/SlaTimer.stories.js +35 -0
  62. package/src/components/SlaTimer.vue +62 -49
  63. package/src/components/SnoozeButton.vue +247 -0
  64. package/src/components/StatsCard.stories.js +24 -0
  65. package/src/components/StatsCard.vue +18 -6
  66. package/src/components/StatusBadge.stories.js +53 -0
  67. package/src/components/StatusBadge.vue +78 -46
  68. package/src/components/TagSelect.vue +84 -53
  69. package/src/components/TicketFilters.vue +247 -46
  70. package/src/components/TicketLinkPanel.vue +193 -0
  71. package/src/components/TicketList.vue +536 -74
  72. package/src/components/TicketMergeDialog.vue +157 -0
  73. package/src/components/TicketSidebar.vue +167 -99
  74. package/src/components/TicketSplitDialog.vue +98 -0
  75. package/src/components/TicketTypeSelector.vue +21 -0
  76. package/src/components/TotpInput.stories.js +9 -0
  77. package/src/components/TotpInput.vue +81 -0
  78. package/src/components/TwoFactorSetup.vue +113 -0
  79. package/src/components/VariableTokenInput.vue +111 -0
  80. package/src/components/WorkflowActionConfig.vue +287 -0
  81. package/src/components/WorkflowActionList.vue +350 -0
  82. package/src/components/WorkflowConditionBuilder.vue +265 -0
  83. package/src/components/WorkflowTriggerSelector.vue +125 -0
  84. package/src/composables/useChat.js +187 -0
  85. package/src/composables/useDebouncedSearch.js +38 -0
  86. package/src/composables/useI18n.js +80 -80
  87. package/src/composables/useKeyboardShortcuts.js +46 -46
  88. package/src/composables/useMentions.js +134 -0
  89. package/src/composables/usePluginExtensions.js +159 -67
  90. package/src/composables/usePluginHooks.js +65 -0
  91. package/src/composables/useRealtime.js +182 -0
  92. package/src/defineEscalatedPlugin.js +76 -50
  93. package/src/index.js +77 -28
  94. package/src/locales/ar.json +727 -0
  95. package/src/locales/de.json +678 -430
  96. package/src/locales/en.json +717 -430
  97. package/src/locales/es.json +679 -430
  98. package/src/locales/fr.json +680 -431
  99. package/src/locales/index.js +12 -2
  100. package/src/locales/it.json +727 -0
  101. package/src/locales/ja.json +727 -0
  102. package/src/locales/ko.json +727 -0
  103. package/src/locales/nl.json +727 -0
  104. package/src/locales/pl.json +727 -0
  105. package/src/locales/pt-BR.json +727 -0
  106. package/src/locales/ru.json +727 -0
  107. package/src/locales/tr.json +727 -0
  108. package/src/locales/zh-CN.json +727 -0
  109. package/src/pages/Admin/ApiTokens/Index.vue +381 -217
  110. package/src/pages/Admin/AuditLog/Index.vue +154 -0
  111. package/src/pages/Admin/BusinessHours/Form.vue +172 -0
  112. package/src/pages/Admin/BusinessHours/Index.vue +113 -0
  113. package/src/pages/Admin/CannedResponses/Index.vue +82 -25
  114. package/src/pages/Admin/Capacity/Index.vue +134 -0
  115. package/src/pages/Admin/CustomFields/Form.vue +195 -0
  116. package/src/pages/Admin/CustomFields/Index.vue +134 -0
  117. package/src/pages/Admin/CustomObjects/Form.vue +202 -0
  118. package/src/pages/Admin/CustomObjects/Index.vue +127 -0
  119. package/src/pages/Admin/CustomObjects/Records.vue +228 -0
  120. package/src/pages/Admin/Departments/Form.vue +35 -11
  121. package/src/pages/Admin/Departments/Index.vue +74 -21
  122. package/src/pages/Admin/EscalationRules/Form.vue +86 -25
  123. package/src/pages/Admin/EscalationRules/Index.vue +158 -37
  124. package/src/pages/Admin/Import/Connect.vue +95 -0
  125. package/src/pages/Admin/Import/Index.vue +102 -0
  126. package/src/pages/Admin/Import/Mapping.vue +110 -0
  127. package/src/pages/Admin/Import/Progress.vue +153 -0
  128. package/src/pages/Admin/Import/Review.vue +76 -0
  129. package/src/pages/Admin/KnowledgeBase/Articles/Form.vue +142 -0
  130. package/src/pages/Admin/KnowledgeBase/Articles/Index.vue +195 -0
  131. package/src/pages/Admin/KnowledgeBase/Categories/Index.vue +193 -0
  132. package/src/pages/Admin/Macros/Index.vue +448 -287
  133. package/src/pages/Admin/Plugins/Index.vue +327 -197
  134. package/src/pages/Admin/Reports/AgentDetail.vue +132 -0
  135. package/src/pages/Admin/Reports/AgentMetrics.vue +115 -0
  136. package/src/pages/Admin/Reports/AgentRanking.vue +246 -0
  137. package/src/pages/Admin/Reports/Cohorts.vue +180 -0
  138. package/src/pages/Admin/Reports/Comparison.vue +141 -0
  139. package/src/pages/Admin/Reports/CsatReport.vue +127 -0
  140. package/src/pages/Admin/Reports/Dashboard.vue +226 -0
  141. package/src/pages/Admin/Reports/ResolutionTimes.vue +164 -0
  142. package/src/pages/Admin/Reports/ResponseTimes.vue +164 -0
  143. package/src/pages/Admin/Reports/SlaReport.vue +162 -0
  144. package/src/pages/Admin/Reports/SlaTrends.vue +183 -0
  145. package/src/pages/Admin/Reports.vue +206 -101
  146. package/src/pages/Admin/Roles/Form.vue +71 -0
  147. package/src/pages/Admin/Roles/Index.vue +122 -0
  148. package/src/pages/Admin/Settings/CsatSettings.vue +165 -0
  149. package/src/pages/Admin/Settings/DataRetention.vue +182 -0
  150. package/src/pages/Admin/Settings/EmailSettings.vue +243 -0
  151. package/src/pages/Admin/Settings/Sandbox.vue +135 -0
  152. package/src/pages/Admin/Settings/SsoSettings.vue +218 -0
  153. package/src/pages/Admin/Settings/TwoFactor.vue +110 -0
  154. package/src/pages/Admin/Settings.vue +847 -99
  155. package/src/pages/Admin/Skills/Form.vue +53 -0
  156. package/src/pages/Admin/Skills/Index.vue +94 -0
  157. package/src/pages/Admin/SlaPolicies/Form.vue +62 -19
  158. package/src/pages/Admin/SlaPolicies/Index.vue +85 -23
  159. package/src/pages/Admin/Statuses/Form.vue +114 -0
  160. package/src/pages/Admin/Statuses/Index.vue +153 -0
  161. package/src/pages/Admin/Tags/Index.vue +121 -35
  162. package/src/pages/Admin/Tickets/Index.vue +96 -9
  163. package/src/pages/Admin/Tickets/Show.vue +130 -37
  164. package/src/pages/Admin/Webhooks/DeliveryLog.vue +120 -0
  165. package/src/pages/Admin/Webhooks/Form.vue +110 -0
  166. package/src/pages/Admin/Webhooks/Index.vue +136 -0
  167. package/src/pages/Admin/Workflows/Builder.vue +207 -0
  168. package/src/pages/Admin/Workflows/Index.vue +235 -0
  169. package/src/pages/Admin/Workflows/Logs.vue +286 -0
  170. package/src/pages/Agent/Dashboard.vue +311 -186
  171. package/src/pages/Agent/TicketIndex.vue +80 -6
  172. package/src/pages/Agent/TicketShow.vue +399 -60
  173. package/src/pages/Customer/Create.vue +37 -10
  174. package/src/pages/Customer/Index.vue +9 -2
  175. package/src/pages/Customer/KnowledgeBase/Article.vue +129 -0
  176. package/src/pages/Customer/KnowledgeBase/Index.vue +151 -0
  177. package/src/pages/Customer/Show.vue +69 -63
  178. package/src/pages/Guest/Create.vue +40 -15
  179. package/src/pages/Guest/Show.vue +124 -93
  180. package/src/plugin.js +111 -1
  181. package/src/utils/constants.js +30 -0
  182. package/src/utils/formatting.js +35 -0
  183. package/src/utils/mentionHighlight.js +24 -0
  184. package/src/utils/sanitizeHtml.js +78 -64
  185. package/src/widget/EscalatedWidget.vue +804 -0
  186. package/src/widget/index.js +254 -0
  187. package/src/pages/Admin/Plugins.vue +0 -129
@@ -1,93 +1,124 @@
1
- <script setup>
2
- import EscalatedLayout from '../../components/EscalatedLayout.vue';
3
- import StatusBadge from '../../components/StatusBadge.vue';
4
- import PriorityBadge from '../../components/PriorityBadge.vue';
5
- import ReplyThread from '../../components/ReplyThread.vue';
6
- import AttachmentList from '../../components/AttachmentList.vue';
7
- import SatisfactionRating from '../../components/SatisfactionRating.vue';
8
- import { useForm } from '@inertiajs/vue3';
9
- import { ref } from 'vue';
10
-
11
- const props = defineProps({ ticket: Object, token: String });
12
-
13
- const isResolved = ['resolved', 'closed'].includes(props.ticket.status);
14
-
15
- const replyForm = useForm({ body: '', attachments: [] });
16
- const showCopied = ref(false);
17
-
18
- function submitReply() {
19
- replyForm.post(route('escalated.guest.tickets.reply', props.token), {
20
- onSuccess: () => replyForm.reset(),
21
- });
22
- }
23
-
24
- function copyLink() {
25
- navigator.clipboard.writeText(window.location.href);
26
- showCopied.value = true;
27
- setTimeout(() => showCopied.value = false, 2000);
28
- }
29
- </script>
30
-
31
- <template>
32
- <EscalatedLayout :title="ticket.subject">
33
- <div class="mx-auto max-w-3xl">
34
- <!-- Bookmark notice -->
35
- <div class="mb-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3">
36
- <div class="flex items-start gap-3">
37
- <svg class="mt-0.5 h-5 w-5 shrink-0 text-amber-500" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z" /></svg>
38
- <div>
39
- <p class="text-sm font-medium text-amber-800">Bookmark this page</p>
40
- <p class="mt-0.5 text-xs text-amber-600">This is your private link to view and reply to this ticket.</p>
41
- </div>
42
- <button @click="copyLink"
43
- class="ml-auto shrink-0 rounded-md border border-amber-300 bg-white px-2.5 py-1 text-xs font-medium text-amber-700 hover:bg-amber-50">
44
- {{ showCopied ? 'Copied!' : 'Copy Link' }}
45
- </button>
46
- </div>
47
- </div>
48
-
49
- <!-- Ticket header -->
50
- <div class="mb-4 flex flex-wrap items-center gap-3">
51
- <span class="font-mono text-sm text-gray-500">{{ ticket.reference }}</span>
52
- <StatusBadge :status="ticket.status" />
53
- <PriorityBadge :priority="ticket.priority" />
54
- <span v-if="ticket.department" class="text-sm text-gray-500">{{ ticket.department.name }}</span>
55
- </div>
56
-
57
- <!-- CSAT Rating -->
58
- <SatisfactionRating v-if="isResolved && !ticket.satisfaction_rating"
59
- :action="route('escalated.guest.tickets.rate', token)" />
60
-
61
- <!-- Description -->
62
- <div class="mb-6 rounded-lg border border-gray-200 bg-white p-4">
63
- <p class="whitespace-pre-wrap text-sm text-gray-700">{{ ticket.description }}</p>
64
- <AttachmentList v-if="ticket.attachments?.length" :attachments="ticket.attachments" class="mt-3" />
65
- </div>
66
-
67
- <!-- Replies -->
68
- <div class="mb-6">
69
- <h2 class="mb-4 text-lg font-semibold text-gray-900">Replies</h2>
70
- <ReplyThread :replies="ticket.replies || []" />
71
- </div>
72
-
73
- <!-- Reply form -->
74
- <div v-if="ticket.status !== 'closed'" class="rounded-lg border border-gray-200 bg-white p-4">
75
- <h2 class="mb-4 text-lg font-semibold text-gray-900">Reply</h2>
76
- <form @submit.prevent="submitReply">
77
- <textarea v-model="replyForm.body" rows="4" required placeholder="Write your reply..."
78
- class="w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"></textarea>
79
- <div v-if="replyForm.errors.body" class="mt-1 text-sm text-red-600">{{ replyForm.errors.body }}</div>
80
- <div class="mt-3 flex justify-end">
81
- <button type="submit" :disabled="replyForm.processing"
82
- class="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50">
83
- {{ replyForm.processing ? 'Sending...' : 'Send Reply' }}
84
- </button>
85
- </div>
86
- </form>
87
- </div>
88
- <div v-else class="rounded-lg border border-gray-200 bg-gray-50 px-4 py-6 text-center text-sm text-gray-500">
89
- This ticket is closed. No further replies can be added.
90
- </div>
91
- </div>
92
- </EscalatedLayout>
93
- </template>
1
+ <script setup>
2
+ import EscalatedLayout from '../../components/EscalatedLayout.vue';
3
+ import StatusBadge from '../../components/StatusBadge.vue';
4
+ import PriorityBadge from '../../components/PriorityBadge.vue';
5
+ import ReplyThread from '../../components/ReplyThread.vue';
6
+ import AttachmentList from '../../components/AttachmentList.vue';
7
+ import SatisfactionRating from '../../components/SatisfactionRating.vue';
8
+ import { useForm } from '@inertiajs/vue3';
9
+ import { ref } from 'vue';
10
+
11
+ const props = defineProps({ ticket: Object, token: String });
12
+
13
+ const isResolved = ['resolved', 'closed'].includes(props.ticket.status);
14
+
15
+ const replyForm = useForm({ body: '', attachments: [] });
16
+ const showCopied = ref(false);
17
+
18
+ function submitReply() {
19
+ replyForm.post(route('escalated.guest.tickets.reply', props.token), {
20
+ onSuccess: () => replyForm.reset(),
21
+ });
22
+ }
23
+
24
+ function copyLink() {
25
+ navigator.clipboard.writeText(window.location.href);
26
+ showCopied.value = true;
27
+ setTimeout(() => (showCopied.value = false), 2000);
28
+ }
29
+ </script>
30
+
31
+ <template>
32
+ <EscalatedLayout :title="ticket.subject">
33
+ <div class="mx-auto max-w-3xl">
34
+ <!-- Bookmark notice -->
35
+ <div class="mb-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3">
36
+ <div class="flex items-start gap-3">
37
+ <svg
38
+ class="mt-0.5 h-5 w-5 shrink-0 text-amber-500"
39
+ fill="none"
40
+ stroke="currentColor"
41
+ stroke-width="1.5"
42
+ viewBox="0 0 24 24"
43
+ >
44
+ <path
45
+ stroke-linecap="round"
46
+ stroke-linejoin="round"
47
+ d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"
48
+ />
49
+ </svg>
50
+ <div>
51
+ <p class="text-sm font-medium text-amber-800">Bookmark this page</p>
52
+ <p class="mt-0.5 text-xs text-amber-600">
53
+ This is your private link to view and reply to this ticket.
54
+ </p>
55
+ </div>
56
+ <button
57
+ class="ml-auto shrink-0 rounded-md border border-amber-300 bg-white px-2.5 py-1 text-xs font-medium text-amber-700 hover:bg-amber-50"
58
+ @click="copyLink"
59
+ >
60
+ {{ showCopied ? 'Copied!' : 'Copy Link' }}
61
+ </button>
62
+ </div>
63
+ </div>
64
+
65
+ <!-- Ticket header -->
66
+ <div class="mb-4 flex flex-wrap items-center gap-3">
67
+ <span class="font-mono text-sm text-gray-500">{{ ticket.reference }}</span>
68
+ <StatusBadge :status="ticket.status" />
69
+ <PriorityBadge :priority="ticket.priority" />
70
+ <span v-if="ticket.department" class="text-sm text-gray-500">{{ ticket.department.name }}</span>
71
+ </div>
72
+
73
+ <!-- CSAT Rating -->
74
+ <SatisfactionRating
75
+ v-if="isResolved && !ticket.satisfaction_rating"
76
+ :action="route('escalated.guest.tickets.rate', token)"
77
+ />
78
+
79
+ <!-- Description -->
80
+ <div class="mb-6 rounded-lg border border-gray-200 bg-white p-4">
81
+ <p class="whitespace-pre-wrap text-sm text-gray-700">{{ ticket.description }}</p>
82
+ <AttachmentList v-if="ticket.attachments?.length" :attachments="ticket.attachments" class="mt-3" />
83
+ </div>
84
+
85
+ <!-- Replies -->
86
+ <div class="mb-6">
87
+ <h2 class="mb-4 text-lg font-semibold text-gray-900">Replies</h2>
88
+ <ReplyThread :replies="ticket.replies || []" />
89
+ </div>
90
+
91
+ <!-- Reply form -->
92
+ <div v-if="ticket.status !== 'closed'" class="rounded-lg border border-gray-200 bg-white p-4">
93
+ <h2 class="mb-4 text-lg font-semibold text-gray-900">Reply</h2>
94
+ <form @submit.prevent="submitReply">
95
+ <textarea
96
+ v-model="replyForm.body"
97
+ rows="4"
98
+ required
99
+ placeholder="Write your reply..."
100
+ class="w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
101
+ ></textarea>
102
+ <div v-if="replyForm.errors.body" class="mt-1 text-sm text-red-600">
103
+ {{ replyForm.errors.body }}
104
+ </div>
105
+ <div class="mt-3 flex justify-end">
106
+ <button
107
+ type="submit"
108
+ :disabled="replyForm.processing"
109
+ class="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50"
110
+ >
111
+ {{ replyForm.processing ? 'Sending...' : 'Send Reply' }}
112
+ </button>
113
+ </div>
114
+ </form>
115
+ </div>
116
+ <div
117
+ v-else
118
+ class="rounded-lg border border-gray-200 bg-gray-50 px-4 py-6 text-center text-sm text-gray-500"
119
+ >
120
+ This ticket is closed. No further replies can be added.
121
+ </div>
122
+ </div>
123
+ </EscalatedLayout>
124
+ </template>
package/src/plugin.js CHANGED
@@ -17,6 +17,8 @@ import { markRaw } from 'vue';
17
17
  */
18
18
  export const EscalatedPlugin = {
19
19
  install(app, options = {}) {
20
+ installRouteShim();
21
+
20
22
  if (options.layout) {
21
23
  app.provide('escalated-layout', markRaw(options.layout));
22
24
  }
@@ -24,10 +26,43 @@ export const EscalatedPlugin = {
24
26
  if (options.theme) {
25
27
  app.provide('escalated-theme', options.theme);
26
28
  applyTheme(options.theme);
29
+
30
+ if (options.theme.panel) {
31
+ const panelConfig = options.theme.panel;
32
+ applyPanelTheme(panelConfig);
33
+ app.provide('escalated-panel', {
34
+ appName: panelConfig.appName || 'Escalated',
35
+ logo: panelConfig.logo || null,
36
+ mode: panelConfig.mode || 'dark',
37
+ });
38
+ }
27
39
  }
28
40
  },
29
41
  };
30
42
 
43
+ // 77 components in this package call the Ziggy `route()` helper (Laravel's
44
+ // named-route URL generator). Laravel hosts ship Ziggy and get `window.route`
45
+ // for free; other host frameworks (Rails, Django, NestJS, Phoenix, Symfony,
46
+ // Adonis, Go, .NET, Spring, WordPress) don't, and the call sites would
47
+ // otherwise throw a bare ReferenceError deep inside a component render with
48
+ // no hint at the cause.
49
+ //
50
+ // Install a stub that throws an informative error instead, so the host app's
51
+ // first failing request points at the actual missing dependency. Laravel hosts
52
+ // that already have Ziggy loaded are left alone.
53
+ function installRouteShim() {
54
+ if (typeof window === 'undefined') return;
55
+ if (typeof window.route === 'function') return;
56
+
57
+ window.route = function escalatedRouteShimMissing(name) {
58
+ throw new Error(
59
+ `[escalated] window.route('${name}') called, but no \`route()\` helper is installed on this host. ` +
60
+ `The escalated agent/admin UI depends on Laravel's Ziggy-style \`route(name, params)\` helper. ` +
61
+ `Install Ziggy (on Laravel hosts) or register a compatible shim on window.route before mounting the app.`,
62
+ );
63
+ };
64
+ }
65
+
31
66
  const themeDefaults = {
32
67
  primary: '#4f46e5',
33
68
  primaryHover: null,
@@ -55,7 +90,7 @@ function darken(hex, percent) {
55
90
  const r = Math.max(0, (num >> 16) - Math.round(2.55 * percent));
56
91
  const g = Math.max(0, ((num >> 8) & 0x00ff) - Math.round(2.55 * percent));
57
92
  const b = Math.max(0, (num & 0x0000ff) - Math.round(2.55 * percent));
58
- return `#${(r << 16 | g << 8 | b).toString(16).padStart(6, '0')}`;
93
+ return `#${((r << 16) | (g << 8) | b).toString(16).padStart(6, '0')}`;
59
94
  }
60
95
 
61
96
  function scaleBorderRadius(radius, factor) {
@@ -63,3 +98,78 @@ function scaleBorderRadius(radius, factor) {
63
98
  if (!match) return radius;
64
99
  return `${(parseFloat(match[1]) * factor).toFixed(2)}${match[2] || 'rem'}`;
65
100
  }
101
+
102
+ const panelDarkDefaults = {
103
+ bg: '#000000',
104
+ sidebarBg: '#0a0a0a',
105
+ topbarBg: 'rgba(0,0,0,0.8)',
106
+ surface: 'rgba(23,23,23,0.6)',
107
+ surfaceAlt: '#0a0a0a',
108
+ border: 'rgba(255,255,255,0.06)',
109
+ borderInput: 'rgba(255,255,255,0.1)',
110
+ text: '#ffffff',
111
+ textSecondary: '#e5e5e5',
112
+ textTertiary: '#a3a3a3',
113
+ textMuted: '#737373',
114
+ accent: '#06b6d4',
115
+ accentSecondary: '#8b5cf6',
116
+ accentHover: '#22d3ee',
117
+ accentSecondaryHover: '#a78bfa',
118
+ hover: 'rgba(255,255,255,0.03)',
119
+ active: 'rgba(255,255,255,0.08)',
120
+ };
121
+
122
+ const panelLightDefaults = {
123
+ bg: '#f9fafb',
124
+ sidebarBg: '#ffffff',
125
+ topbarBg: 'rgba(255,255,255,0.95)',
126
+ surface: '#ffffff',
127
+ surfaceAlt: '#f9fafb',
128
+ border: '#e5e7eb',
129
+ borderInput: '#d1d5db',
130
+ text: '#111827',
131
+ textSecondary: '#374151',
132
+ textTertiary: '#6b7280',
133
+ textMuted: '#9ca3af',
134
+ accent: '#3b82f6',
135
+ accentSecondary: '#6366f1',
136
+ accentHover: '#2563eb',
137
+ accentSecondaryHover: '#818cf8',
138
+ hover: 'rgba(0,0,0,0.02)',
139
+ active: '#eff6ff',
140
+ };
141
+
142
+ const panelTokenMap = {
143
+ bg: '--esc-panel-bg',
144
+ sidebarBg: '--esc-panel-sidebar-bg',
145
+ topbarBg: '--esc-panel-topbar-bg',
146
+ surface: '--esc-panel-surface',
147
+ surfaceAlt: '--esc-panel-surface-alt',
148
+ border: '--esc-panel-border',
149
+ borderInput: '--esc-panel-border-input',
150
+ text: '--esc-panel-text',
151
+ textSecondary: '--esc-panel-text-secondary',
152
+ textTertiary: '--esc-panel-text-tertiary',
153
+ textMuted: '--esc-panel-text-muted',
154
+ accent: '--esc-panel-accent',
155
+ accentSecondary: '--esc-panel-accent-secondary',
156
+ accentHover: '--esc-panel-accent-hover',
157
+ accentSecondaryHover: '--esc-panel-accent-secondary-hover',
158
+ hover: '--esc-panel-hover',
159
+ active: '--esc-panel-active',
160
+ };
161
+
162
+ function applyPanelTheme(panelConfig) {
163
+ const defaults = panelConfig.mode === 'light' ? panelLightDefaults : panelDarkDefaults;
164
+ const overrides = {};
165
+ for (const key of Object.keys(panelTokenMap)) {
166
+ if (panelConfig[key] !== undefined) {
167
+ overrides[key] = panelConfig[key];
168
+ }
169
+ }
170
+ const merged = { ...defaults, ...overrides };
171
+ const style = document.documentElement.style;
172
+ for (const [key, cssVar] of Object.entries(panelTokenMap)) {
173
+ style.setProperty(cssVar, merged[key]);
174
+ }
175
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Shared ticket constants used across multiple components.
3
+ * Single source of truth for statuses, priorities, and types.
4
+ */
5
+
6
+ export const TICKET_STATUSES = [
7
+ 'open',
8
+ 'in_progress',
9
+ 'waiting_on_customer',
10
+ 'waiting_on_agent',
11
+ 'escalated',
12
+ 'resolved',
13
+ 'closed',
14
+ ];
15
+
16
+ export const TICKET_PRIORITIES = ['low', 'medium', 'high', 'urgent', 'critical'];
17
+
18
+ export const TICKET_TYPES = [
19
+ { value: 'question', label: 'Question', color: 'text-cyan-400' },
20
+ { value: 'problem', label: 'Problem', color: 'text-rose-400' },
21
+ { value: 'incident', label: 'Incident', color: 'text-amber-400' },
22
+ { value: 'task', label: 'Task', color: 'text-violet-400' },
23
+ ];
24
+
25
+ export const TICKET_TYPE_COLORS = {
26
+ question: { dark: 'bg-cyan-500/20 text-cyan-400', light: 'bg-cyan-100 text-cyan-700' },
27
+ problem: { dark: 'bg-rose-500/20 text-rose-400', light: 'bg-rose-100 text-rose-700' },
28
+ incident: { dark: 'bg-amber-500/20 text-amber-400', light: 'bg-amber-100 text-amber-700' },
29
+ task: { dark: 'bg-violet-500/20 text-violet-400', light: 'bg-violet-100 text-violet-700' },
30
+ };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Shared formatting utilities for ticket display.
3
+ */
4
+
5
+ /**
6
+ * Returns a human-readable relative time string (e.g. "5m ago", "3h ago", "2d ago").
7
+ * @param {string|Date} date
8
+ * @returns {string}
9
+ */
10
+ export function timeAgo(date) {
11
+ if (!date) return '';
12
+ const diff = Date.now() - new Date(date).getTime();
13
+ const mins = Math.floor(diff / 60000);
14
+ if (mins < 60) return `${mins}m ago`;
15
+ const hrs = Math.floor(mins / 60);
16
+ if (hrs < 24) return `${hrs}h ago`;
17
+ const days = Math.floor(hrs / 24);
18
+ return `${days}d ago`;
19
+ }
20
+
21
+ /**
22
+ * Returns a Tailwind CSS class for the SLA indicator dot based on ticket SLA state.
23
+ * @param {Object} ticket
24
+ * @returns {string}
25
+ */
26
+ export function slaClass(ticket) {
27
+ if (ticket.sla_first_response_breached || ticket.sla_resolution_breached) return 'bg-rose-500';
28
+ if (ticket.first_response_due_at || ticket.resolution_due_at) {
29
+ const due = ticket.resolution_due_at || ticket.first_response_due_at;
30
+ const mins = (new Date(due) - Date.now()) / 60000;
31
+ if (mins < 30) return 'bg-amber-500';
32
+ return 'bg-emerald-500';
33
+ }
34
+ return '';
35
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * HTML-encode a string to prevent injection via mention names.
3
+ */
4
+ function escapeHtml(str) {
5
+ return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
6
+ }
7
+
8
+ /**
9
+ * Replace @{Name} patterns in text with styled mention badges.
10
+ *
11
+ * @param {string} html - The HTML or text content
12
+ * @param {boolean} dark - Whether dark mode is active
13
+ * @returns {string} HTML with mentions wrapped in styled spans
14
+ */
15
+ export function highlightMentions(html, dark = false) {
16
+ if (!html) return '';
17
+
18
+ const pillClass = dark
19
+ ? 'inline-flex items-center rounded-full bg-cyan-500/15 px-1.5 py-0.5 text-xs font-medium text-cyan-400 ring-1 ring-cyan-500/20'
20
+ : 'inline-flex items-center rounded-full bg-blue-100 px-1.5 py-0.5 text-xs font-medium text-blue-700 ring-1 ring-blue-200';
21
+
22
+ // Replace @{Name} with styled pill, encoding the name to prevent injection
23
+ return html.replace(/@\{([^}]+)\}/g, (match, name) => `<span class="${pillClass}">@${escapeHtml(name)}</span>`);
24
+ }
@@ -1,64 +1,78 @@
1
- /**
2
- * Sanitize HTML to prevent stored XSS.
3
- *
4
- * Uses the DOM parser to walk the tree and strip dangerous elements and
5
- * attributes rather than regex, which avoids incomplete-sanitization pitfalls.
6
- */
7
-
8
- const DANGEROUS_TAGS = new Set([
9
- 'script', 'style', 'iframe', 'object', 'embed', 'form', 'input',
10
- 'textarea', 'button', 'select', 'option', 'link', 'meta', 'base',
11
- 'applet', 'noscript', 'noframes',
12
- ])
13
-
14
- const URI_ATTRS = new Set(['href', 'src', 'action', 'formaction', 'xlink:href'])
15
-
16
- export function sanitizeHtml(html) {
17
- if (!html) return ''
18
-
19
- const doc = new DOMParser().parseFromString(html, 'text/html')
20
-
21
- // Remove dangerous elements
22
- for (const tag of DANGEROUS_TAGS) {
23
- const els = doc.body.getElementsByTagName(tag)
24
- while (els.length) els[0].remove()
25
- }
26
-
27
- // Walk all remaining elements and strip dangerous attributes
28
- const all = doc.body.querySelectorAll('*')
29
- for (let i = 0; i < all.length; i++) {
30
- const el = all[i]
31
- const attrs = [...el.attributes]
32
- for (let j = 0; j < attrs.length; j++) {
33
- const name = attrs[j].name.toLowerCase()
34
-
35
- // Remove event handlers (onclick, onerror, etc.)
36
- if (name.startsWith('on')) {
37
- el.removeAttribute(attrs[j].name)
38
- continue
39
- }
40
-
41
- // Remove javascript: / vbscript: / dangerous data: URIs
42
- if (URI_ATTRS.has(name)) {
43
- const val = (attrs[j].value || '').replace(/[\s\u0000-\u001F]+/g, '').toLowerCase()
44
- if (
45
- val.startsWith('javascript:') ||
46
- val.startsWith('vbscript:') ||
47
- (val.startsWith('data:') && !val.startsWith('data:image/'))
48
- ) {
49
- el.removeAttribute(attrs[j].name)
50
- }
51
- }
52
-
53
- // Remove style attributes containing expressions or javascript
54
- if (name === 'style') {
55
- const val = (attrs[j].value || '').toLowerCase()
56
- if (val.includes('expression(') || val.includes('javascript:') || val.includes('url(')) {
57
- el.removeAttribute(attrs[j].name)
58
- }
59
- }
60
- }
61
- }
62
-
63
- return doc.body.innerHTML
64
- }
1
+ /**
2
+ * Sanitize HTML to prevent stored XSS.
3
+ *
4
+ * Uses the DOM parser to walk the tree and strip dangerous elements and
5
+ * attributes rather than regex, which avoids incomplete-sanitization pitfalls.
6
+ */
7
+
8
+ const DANGEROUS_TAGS = new Set([
9
+ 'script',
10
+ 'style',
11
+ 'iframe',
12
+ 'object',
13
+ 'embed',
14
+ 'form',
15
+ 'input',
16
+ 'textarea',
17
+ 'button',
18
+ 'select',
19
+ 'option',
20
+ 'link',
21
+ 'meta',
22
+ 'base',
23
+ 'applet',
24
+ 'noscript',
25
+ 'noframes',
26
+ ]);
27
+
28
+ const URI_ATTRS = new Set(['href', 'src', 'action', 'formaction', 'xlink:href']);
29
+
30
+ export function sanitizeHtml(html) {
31
+ if (!html) return '';
32
+
33
+ const doc = new DOMParser().parseFromString(html, 'text/html');
34
+
35
+ // Remove dangerous elements
36
+ for (const tag of DANGEROUS_TAGS) {
37
+ const els = doc.body.getElementsByTagName(tag);
38
+ while (els.length) els[0].remove();
39
+ }
40
+
41
+ // Walk all remaining elements and strip dangerous attributes
42
+ const all = doc.body.querySelectorAll('*');
43
+ for (let i = 0; i < all.length; i++) {
44
+ const el = all[i];
45
+ const attrs = [...el.attributes];
46
+ for (let j = 0; j < attrs.length; j++) {
47
+ const name = attrs[j].name.toLowerCase();
48
+
49
+ // Remove event handlers (onclick, onerror, etc.)
50
+ if (name.startsWith('on')) {
51
+ el.removeAttribute(attrs[j].name);
52
+ continue;
53
+ }
54
+
55
+ // Remove javascript: / vbscript: / dangerous data: URIs
56
+ if (URI_ATTRS.has(name)) {
57
+ const val = (attrs[j].value || '').replace(/[\s\u0000-\u001F]+/g, '').toLowerCase();
58
+ if (
59
+ val.startsWith('javascript:') ||
60
+ val.startsWith('vbscript:') ||
61
+ (val.startsWith('data:') && !val.startsWith('data:image/'))
62
+ ) {
63
+ el.removeAttribute(attrs[j].name);
64
+ }
65
+ }
66
+
67
+ // Remove style attributes containing expressions or javascript
68
+ if (name === 'style') {
69
+ const val = (attrs[j].value || '').toLowerCase();
70
+ if (val.includes('expression(') || val.includes('javascript:') || val.includes('url(')) {
71
+ el.removeAttribute(attrs[j].name);
72
+ }
73
+ }
74
+ }
75
+ }
76
+
77
+ return doc.body.innerHTML;
78
+ }