@nabeh/chat-widget 0.1.2 → 0.1.4

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.
@@ -1,1404 +0,0 @@
1
- function tt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ye(e,t){let o={...e};for(let n of Object.keys(t)){let i=t[n],s=o[n];if(tt(s)&&tt(i)){o[n]=ye(s,i);continue}i!==void 0&&(o[n]=i)}return o}function nt(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error("Unexpected widget error")}function X(e,t){return`${e.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}function O(e,t,o){return{"Content-Type":"application/json",...e.customHeaders,...o?{"X-Chat-User-Context":o}:{},...t?{Authorization:`Bearer ${t}`}:{}}}async function W(e){if(!e.getUserContext)return null;let t=await e.getUserContext();return t?JSON.stringify(t):null}function le(e,t,o={}){let n=t.replace(/\{chatId\}/g,encodeURIComponent(o.chatId??"")).replace(/:chatId\b/g,encodeURIComponent(o.chatId??""));return X(e.apiBaseUrl,n)}async function ot(e,t){let o=e.getAccessToken?await e.getAccessToken():null,n=await W(e),i=le(e,e.endpoints.ask,{chatId:t.chatId}),d=/(\{chatId\}|:chatId\b)/.test(e.endpoints.ask)?{message:t.message,knowledgeNames:t.knowledgeNames,editLastQa:t.editLastQa??!1,enableReferences:t.enableReferences??!0}:{query:t.message,chat_id:t.chatId,knowledge_names:t.knowledgeNames,edit_last_qa:t.editLastQa??!1,enable_references:t.enableReferences??!0},p=await fetch(i,{method:"POST",headers:O(e,o,n),body:JSON.stringify(d)});if(!p.ok)throw new Error(`Chat backend returned ${p.status}.`);let l=await p.json();if(!Array.isArray(l)){if(!l.answer||typeof l.answer!="string")throw new Error("Chat backend response is missing a valid answer.");return{chatId:l.chatId??t.chatId,answer:l.answer,suggestions:l.suggestions??[],citations:l.citations??[]}}let u=l[0];if(!u?.answer||typeof u.answer!="string")throw new Error("Chat backend response is missing a valid answer.");let g=u.content,f=g?.source_documents??[],m=g?.scores??[],y=g?.page_numbers??[],b=g?.sheet_names??[],x=g?.row_numbers??[],v=g?.knowledge_names??[],k=f.map(($,C)=>({sourceDocument:$,score:m[C]??null,pageNumber:y[C]??null,sheetName:b[C]??null,rowNumber:x[C]??null,knowledgeName:v[C]??null}));return{chatId:t.chatId,answer:u.answer,suggestions:[],citations:k}}async function at(e,t){if(!e.endpoints.history)return[];let o=e.getAccessToken?await e.getAccessToken():null,n=await W(e),s=/(\{chatId\}|:chatId\b)/.test(e.endpoints.history)?le(e,e.endpoints.history,{chatId:t}):(()=>{let u=new URL(X(e.apiBaseUrl,e.endpoints.history));return u.searchParams.set("chat_id",t),u.toString()})(),d=await fetch(s,{method:"GET",headers:O(e,o,n)});if(!d.ok)throw new Error(`Chat history endpoint returned ${d.status}.`);let p=await d.json(),l=Array.isArray(p)?p:p&&typeof p=="object"?p.history??p.messages??p.data??[]:[];return Array.isArray(l)?l.map(u=>{if(!u||typeof u!="object")return null;let g=u;if(typeof g.question=="string"&&typeof g.answer=="string")return[{role:"user",text:g.question},{role:"assistant",text:g.answer}];let f=g.role??g.type??g.sender??g.author,m=g.text??g.message??g.content??g.answer;if(typeof m!="string")return null;let y=typeof f=="string"?f.toLowerCase():"assistant";return[{role:y==="user"||y==="human"?"user":"assistant",text:m}]}).flat().filter(u=>!!u):[]}async function st(e){if(!e.endpoints.listChats)return[];let t=e.getAccessToken?await e.getAccessToken():null,o=await W(e),n=await fetch(X(e.apiBaseUrl,e.endpoints.listChats),{method:"GET",headers:O(e,t,o)});if(!n.ok)throw new Error(`Chat list endpoint returned ${n.status}.`);let i=await n.json(),s=Array.isArray(i)?i:i&&typeof i=="object"?i.chats??i.data??i.items??[]:[];return Array.isArray(s)?s.map(d=>{if(!d||typeof d!="object")return null;let p=d,l=p.chatId??p.chat_id??p.id,u=p.title??p.name??p.chatId;if(typeof l!="string"||typeof u!="string")return null;let g=typeof p.createdAt=="string"?p.createdAt:typeof p.created_at=="string"?p.created_at:null,f=typeof p.updatedAt=="string"?p.updatedAt:typeof p.updated_at=="string"?p.updated_at:null,m={chatId:l,title:u,pinned:typeof p.pinned=="boolean"?p.pinned:!1};return g&&(m.createdAt=g),f&&(m.updatedAt=f),m}).filter(d=>!!d):[]}async function rt(e,t,o){let n=e.endpoints.createChat??e.endpoints.listChats;if(!n)return;let i=e.getAccessToken?await e.getAccessToken():null,s=await W(e),d=await fetch(X(e.apiBaseUrl,n),{method:"POST",headers:O(e,i,s),body:JSON.stringify({chatId:t,...o?{title:o}:{}})});if(!d.ok)throw new Error(`Create chat endpoint returned ${d.status}.`)}async function we(e,t,o){if(!e.endpoints.updateChat)return;let n=e.getAccessToken?await e.getAccessToken():null,i=await W(e),s=le(e,e.endpoints.updateChat,{chatId:t}),d=await fetch(s,{method:"PATCH",headers:O(e,n,i),body:JSON.stringify(o)});if(!d.ok)throw new Error(`Update chat endpoint returned ${d.status}.`)}async function it(e,t){if(!e.endpoints.deleteChat)return;let o=e.getAccessToken?await e.getAccessToken():null,n=await W(e),i=le(e,e.endpoints.deleteChat,{chatId:t}),s=await fetch(i,{method:"DELETE",headers:O(e,o,n)});if(!s.ok)throw new Error(`Delete chat endpoint returned ${s.status}.`)}function U(e,t){let o=nt(t);return e.onError?.(o),o}var ve={accent:"#0f766e",accentSoft:"#ecfeff",panelBackground:"#ffffff",surfaceBackground:"#f8fafc",text:"#1f2937",mutedText:"#64748b",borderColor:"#dbe4ee",shadow:"0 24px 64px rgba(15, 23, 42, 0.20)",zIndex:2147483e3,fontFamily:'"Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif'},w={position:"bottom-right",title:"Knowledge Assistant",subtitle:"Answers are generated based on your access permissions",welcomeMessage:"How can I assist you today?",inputPlaceholder:"Ask your question...",launcherAriaLabel:"Open chat assistant",closeAriaLabel:"Close chat assistant",initialSuggestions:["Which indicators reflect the achievements of Vision KSA goals?","Case studies of real estate initiatives for economic growth","Study of UX for the ministry external portal"],sourceApp:"knowledge-platform",locale:"en",customHeaders:{},rag:{knowledgeNames:[],enableReferences:!0,loadHistoryOnOpen:!1},theme:ve,getAccessToken:void 0,getUserContext:void 0,onOpen:void 0,onClose:void 0,onError:void 0};function pt(e){if(!e.apiBaseUrl?.trim())throw new Error("Chat widget config requires a non-empty apiBaseUrl.");if(!e.endpoints?.ask?.trim())throw new Error("Chat widget config requires endpoints.ask to be provided.");let t=e.mount??document.body,o=ye(ve,e.theme??{});return{apiBaseUrl:e.apiBaseUrl,endpoints:{...e.endpoints},mount:t,position:e.position??w.position,title:e.title??w.title,subtitle:e.subtitle??w.subtitle,welcomeMessage:e.welcomeMessage??w.welcomeMessage,inputPlaceholder:e.inputPlaceholder??w.inputPlaceholder,launcherAriaLabel:e.launcherAriaLabel??w.launcherAriaLabel,closeAriaLabel:e.closeAriaLabel??w.closeAriaLabel,initialSuggestions:e.initialSuggestions??w.initialSuggestions,sourceApp:e.sourceApp??w.sourceApp,locale:e.locale??w.locale,customHeaders:e.customHeaders??w.customHeaders,rag:{...w.rag,...e.rag??{}},theme:o,getAccessToken:e.getAccessToken,getUserContext:e.getUserContext,onOpen:e.onOpen,onClose:e.onClose,onError:e.onError}}function a(e,t,o){let n=document.createElement(e);return t&&(n.className=t),o!==void 0&&(n.textContent=o),n}var lt="kp-chat-widget-styles";function ct(e,t){if(e.getElementById(lt))return;let o=document.createElement("style");o.id=lt,o.textContent=qt(t),e.appendChild(o)}function qt(e){return`
2
- :host {
3
- all: initial;
4
- }
5
-
6
- .kp-chat-widget {
7
- --kp-accent: ${e.accent};
8
- --kp-accent-soft: ${e.accentSoft};
9
- --kp-panel-background: ${e.panelBackground};
10
- --kp-surface-background: ${e.surfaceBackground};
11
- --kp-text: ${e.text};
12
- --kp-muted-text: ${e.mutedText};
13
- --kp-border-color: ${e.borderColor};
14
- --kp-shadow: ${e.shadow};
15
- --kp-z-index: ${e.zIndex};
16
- --kp-font-family: ${e.fontFamily};
17
- --kp-card-background: rgba(255, 255, 255, 0.92);
18
- --kp-soft-highlight: rgba(236, 254, 255, 0.82);
19
- position: fixed;
20
- bottom: 24px;
21
- right: 24px;
22
- z-index: var(--kp-z-index);
23
- font-family: var(--kp-font-family);
24
- color: var(--kp-text);
25
- box-sizing: border-box;
26
- }
27
-
28
- *,
29
- *::before,
30
- *::after {
31
- box-sizing: border-box;
32
- font-family: inherit;
33
- }
34
-
35
- .kp-chat-widget.bottom-left {
36
- left: 24px;
37
- right: auto;
38
- }
39
-
40
- .kp-rtl .kp-dropdown-item,
41
- .kp-rtl .kp-suggestion,
42
- .kp-rtl .kp-input,
43
- .kp-rtl .kp-full-page-search-input,
44
- .kp-rtl .kp-bubble-content,
45
- .kp-rtl .kp-source-card,
46
- .kp-rtl .kp-source-panel {
47
- text-align: right;
48
- }
49
-
50
- .kp-launcher {
51
- width: 72px;
52
- height: 72px;
53
- border: none;
54
- border-radius: 999px;
55
- cursor: pointer;
56
- background: radial-gradient(circle at 30% 30%, #f8fffe 0%, #ecfdf5 52%, #d6f4ef 100%);
57
- box-shadow: 0 16px 32px rgba(15, 118, 110, 0.18);
58
- display: flex;
59
- align-items: center;
60
- justify-content: center;
61
- transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
62
- color: var(--kp-accent);
63
- position: relative;
64
- overflow: hidden;
65
- }
66
-
67
- .kp-launcher:hover {
68
- transform: translateY(-1px);
69
- box-shadow: 0 20px 36px rgba(15, 118, 110, 0.22);
70
- }
71
-
72
- .kp-launcher:focus-visible,
73
- .kp-close:focus-visible,
74
- .kp-send:focus-visible,
75
- .kp-suggestion:focus-visible,
76
- .kp-input:focus-visible,
77
- .kp-full-page-new-chat:focus-visible,
78
- .kp-full-page-close:focus-visible,
79
- .kp-full-page-chat-item:focus-visible,
80
- .kp-chat-pin:focus-visible,
81
- .kp-message-action:focus-visible,
82
- .kp-source-chip:focus-visible,
83
- .kp-source-panel-close:focus-visible {
84
- outline: 2px solid var(--kp-accent);
85
- outline-offset: 2px;
86
- }
87
-
88
- .kp-launcher.hidden {
89
- opacity: 0;
90
- pointer-events: none;
91
- transform: translateY(8px) scale(0.96);
92
- }
93
-
94
- .kp-star-cluster {
95
- position: relative;
96
- width: 50px;
97
- height: 50px;
98
- animation: kp-cluster-rotate 8.5s linear infinite;
99
- }
100
-
101
- .kp-star {
102
- position: absolute;
103
- color: #08384c;
104
- line-height: 1;
105
- transform-origin: center;
106
- }
107
-
108
- .kp-star.main {
109
- top: 50%;
110
- left: 50%;
111
- font-size: 30px;
112
- transform: translate(-50%, -50%) scale(0.96);
113
- animation: kp-main-pulse 3s ease-in-out infinite;
114
- }
115
-
116
- .kp-star.orbit-a {
117
- top: -3px;
118
- left: 50%;
119
- font-size: 18px;
120
- transform: translateX(-50%);
121
- animation: kp-orbit-a 3s ease-in-out infinite;
122
- }
123
-
124
- .kp-star.orbit-b {
125
- right: -3px;
126
- bottom: 5px;
127
- font-size: 18px;
128
- animation: kp-orbit-b 3s ease-in-out infinite;
129
- }
130
-
131
- .kp-star.orbit-c {
132
- left: -1px;
133
- bottom: 5px;
134
- font-size: 18px;
135
- animation: kp-orbit-c 3s ease-in-out infinite;
136
- }
137
-
138
- .kp-overlay {
139
- position: fixed;
140
- inset: 0;
141
- background: rgba(15, 23, 42, 0.18);
142
- opacity: 0;
143
- pointer-events: none;
144
- transition: opacity 220ms ease;
145
- }
146
-
147
- .kp-overlay.visible {
148
- opacity: 1;
149
- pointer-events: auto;
150
- }
151
-
152
- .kp-panel {
153
- position: fixed;
154
- bottom: 88px;
155
- right: 24px;
156
- width: min(480px, calc(100vw - 48px));
157
- height: min(730px, calc(100vh - 118px));
158
- background: var(--kp-panel-background);
159
- border: 1px solid rgba(255, 255, 255, 0.35);
160
- border-radius: 24px;
161
- box-shadow: var(--kp-shadow);
162
- overflow: hidden;
163
- display: flex;
164
- flex-direction: column;
165
- opacity: 0;
166
- transform: translateX(112px) scale(0.97);
167
- transform-origin: bottom right;
168
- pointer-events: none;
169
- transition: opacity 420ms cubic-bezier(0.16, 1, 0.3, 1),
170
- transform 620ms cubic-bezier(0.16, 1, 0.3, 1);
171
- }
172
-
173
- .kp-chat-widget.bottom-left .kp-panel {
174
- left: 24px;
175
- right: auto;
176
- transform: translateX(-112px) scale(0.97);
177
- transform-origin: bottom left;
178
- }
179
-
180
- .kp-panel.open {
181
- opacity: 1;
182
- transform: translateX(0) scale(1);
183
- pointer-events: auto;
184
- }
185
-
186
- .kp-full-page {
187
- position: fixed;
188
- inset: 0;
189
- background: #ffffff;
190
- opacity: 0;
191
- pointer-events: none;
192
- transform: translateY(18px);
193
- transition: opacity 260ms ease, transform 320ms ease;
194
- z-index: calc(var(--kp-z-index) + 2);
195
- overflow: hidden;
196
- }
197
-
198
- .kp-full-page.open {
199
- opacity: 1;
200
- pointer-events: auto;
201
- transform: translateY(0);
202
- }
203
-
204
- .kp-full-page-shell {
205
- height: 100vh;
206
- display: flex;
207
- flex-direction: column;
208
- padding: 22px 28px 26px;
209
- gap: 16px;
210
- overflow: hidden;
211
- }
212
-
213
- .kp-full-page-header {
214
- display: flex;
215
- align-items: center;
216
- justify-content: space-between;
217
- gap: 16px;
218
- padding: 8px 4px 0;
219
- flex: none;
220
- }
221
-
222
- .kp-full-page-brand {
223
- display: flex;
224
- align-items: center;
225
- gap: 12px;
226
- color: #08384c;
227
- }
228
-
229
- .kp-full-page-brand-mark {
230
- width: 44px;
231
- height: 44px;
232
- border-radius: 14px;
233
- display: flex;
234
- align-items: center;
235
- justify-content: center;
236
- background: linear-gradient(135deg, rgba(37, 181, 192, 0.14), rgba(15, 118, 110, 0.08));
237
- font-size: 26px;
238
- box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
239
- }
240
-
241
- .kp-full-page-brand-text {
242
- font-size: 20px;
243
- font-weight: 700;
244
- letter-spacing: -0.02em;
245
- color: #16394b;
246
- }
247
-
248
- .kp-full-page-header-actions {
249
- display: flex;
250
- align-items: center;
251
- gap: 12px;
252
- }
253
-
254
- .kp-full-page-badge {
255
- padding: 10px 14px;
256
- border-radius: 999px;
257
- font-size: 13px;
258
- line-height: 1;
259
- color: #0b556c;
260
- background: rgba(255, 255, 255, 0.82);
261
- border: 1px solid rgba(15, 118, 110, 0.12);
262
- box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
263
- }
264
-
265
- .kp-full-page-close,
266
- .kp-source-panel-close {
267
- width: 40px;
268
- height: 40px;
269
- border: none;
270
- border-radius: 14px;
271
- background: rgba(255, 255, 255, 0.82);
272
- color: #61788a;
273
- font-size: 24px;
274
- line-height: 1;
275
- cursor: pointer;
276
- box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
277
- }
278
-
279
- .kp-full-page-content {
280
- display: grid;
281
- grid-template-columns: 290px minmax(0, 1fr) minmax(0, 0);
282
- gap: 16px;
283
- flex: 1;
284
- min-height: 0;
285
- overflow: hidden;
286
- align-items: stretch;
287
- }
288
-
289
- .kp-full-page-sidebar,
290
- .kp-full-page-panel,
291
- .kp-source-panel {
292
- border-radius: 24px;
293
- border: 1px solid rgba(219, 228, 238, 0.9);
294
- background: rgba(255, 255, 255, 0.88);
295
- box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
296
- backdrop-filter: blur(12px);
297
- }
298
-
299
- .kp-full-page-sidebar {
300
- padding: 18px;
301
- display: flex;
302
- flex-direction: column;
303
- gap: 16px;
304
- min-height: 0;
305
- overflow: auto;
306
- }
307
-
308
- .kp-full-page-new-chat {
309
- width: 100%;
310
- height: 48px;
311
- border: none;
312
- border-radius: 12px;
313
- background: linear-gradient(135deg, #0a465d 0%, #0f6a75 100%);
314
- color: #ffffff;
315
- font-size: 16px;
316
- font-weight: 600;
317
- cursor: pointer;
318
- box-shadow: 0 14px 30px rgba(10, 70, 93, 0.18);
319
- }
320
-
321
- .kp-full-page-search {
322
- display: flex;
323
- align-items: center;
324
- gap: 8px;
325
- height: 44px;
326
- border-radius: 12px;
327
- border: 1px solid rgba(203, 213, 225, 0.95);
328
- background: #ffffff;
329
- padding: 0 12px;
330
- }
331
-
332
- .kp-full-page-search-input {
333
- flex: 1;
334
- border: none;
335
- outline: none;
336
- background: transparent;
337
- color: #334155;
338
- font-size: 14px;
339
- min-width: 0;
340
- box-shadow: none;
341
- }
342
-
343
- .kp-full-page-search-input:focus,
344
- .kp-full-page-search-input:focus-visible,
345
- .kp-full-page-search-input:active {
346
- outline: none;
347
- box-shadow: none;
348
- border: none;
349
- }
350
-
351
- .kp-full-page-search-icon {
352
- color: #607082;
353
- font-size: 20px;
354
- line-height: 1;
355
- }
356
-
357
- .kp-full-page-section-label {
358
- font-size: 12px;
359
- line-height: 1.4;
360
- text-transform: uppercase;
361
- letter-spacing: 0.08em;
362
- color: #8a98a6;
363
- margin-top: 4px;
364
- }
365
-
366
- .kp-full-page-recent-list,
367
- .kp-full-page-pinned-list {
368
- display: flex;
369
- flex-direction: column;
370
- gap: 8px;
371
- }
372
-
373
- .kp-full-page-item {
374
- padding: 12px 12px 13px;
375
- border-radius: 14px;
376
- color: #293845;
377
- font-size: 15px;
378
- line-height: 1.5;
379
- background: rgba(247, 250, 252, 0.9);
380
- border: 1px solid rgba(219, 228, 238, 0.88);
381
- }
382
-
383
- .kp-full-page-chat-item {
384
- position: relative;
385
- display: flex;
386
- align-items: center;
387
- justify-content: space-between;
388
- gap: 10px;
389
- cursor: pointer;
390
- transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
391
- overflow: visible;
392
- }
393
-
394
- .kp-full-page-chat-item:hover {
395
- border-color: rgba(15, 118, 110, 0.34);
396
- background: rgba(240, 253, 250, 0.95);
397
- transform: translateY(-1px);
398
- }
399
-
400
- .kp-full-page-chat-item.active {
401
- border-color: rgba(15, 118, 110, 0.5);
402
- background: rgba(220, 252, 231, 0.72);
403
- }
404
-
405
- .kp-full-page-chat-item.menu-open {
406
- z-index: 4;
407
- }
408
-
409
- .kp-full-page-item-title {
410
- min-width: 0;
411
- overflow: hidden;
412
- text-overflow: ellipsis;
413
- white-space: nowrap;
414
- flex: 1;
415
- }
416
-
417
- .kp-chat-pin {
418
- flex: none;
419
- border: none;
420
- background: transparent;
421
- color: #0f6a75;
422
- font-size: 16px;
423
- line-height: 1;
424
- padding: 0;
425
- cursor: pointer;
426
- }
427
-
428
- .kp-full-page-empty {
429
- padding: 8px 4px 0;
430
- color: #7a8a99;
431
- font-size: 14px;
432
- line-height: 1.5;
433
- }
434
-
435
- .kp-full-page-main {
436
- min-width: 0;
437
- min-height: 0;
438
- display: flex;
439
- }
440
-
441
- .kp-full-page-panel {
442
- flex: 1;
443
- display: flex;
444
- flex-direction: column;
445
- min-height: 0;
446
- overflow: hidden;
447
- }
448
-
449
- .kp-source-panel {
450
- min-width: 0;
451
- min-height: 0;
452
- overflow: hidden;
453
- display: none;
454
- flex-direction: column;
455
- }
456
-
457
- .kp-source-panel.open {
458
- display: flex;
459
- }
460
-
461
- .kp-full-page-content:has(.kp-source-panel.open) {
462
- grid-template-columns: 290px minmax(0, 1fr) 320px;
463
- }
464
-
465
- .kp-source-panel-header {
466
- display: flex;
467
- align-items: flex-start;
468
- justify-content: space-between;
469
- gap: 12px;
470
- padding: 18px 18px 12px;
471
- border-bottom: 1px solid rgba(219, 228, 238, 0.7);
472
- }
473
-
474
- .kp-source-panel-title {
475
- font-size: 17px;
476
- font-weight: 700;
477
- color: #16394b;
478
- }
479
-
480
- .kp-source-panel-subtitle {
481
- margin-top: 4px;
482
- font-size: 12px;
483
- color: #7a8a99;
484
- }
485
-
486
- .kp-source-panel-list {
487
- display: flex;
488
- flex-direction: column;
489
- gap: 12px;
490
- padding: 16px;
491
- overflow: auto;
492
- }
493
-
494
- .kp-source-panel-empty {
495
- color: #7a8a99;
496
- font-size: 14px;
497
- line-height: 1.5;
498
- }
499
-
500
- .kp-source-card {
501
- width: 100%;
502
- text-align: left;
503
- cursor: pointer;
504
- appearance: none;
505
- border: 1px solid rgba(219, 228, 238, 0.9);
506
- border-radius: 16px;
507
- background: #ffffff;
508
- padding: 14px;
509
- }
510
-
511
- .kp-source-card-media {
512
- display: flex;
513
- align-items: center;
514
- margin-bottom: 10px;
515
- }
516
-
517
- .kp-source-thumb,
518
- .kp-source-thumb-large {
519
- flex: none;
520
- width: 32px;
521
- height: 32px;
522
- border-radius: 999px;
523
- display: inline-flex;
524
- align-items: center;
525
- justify-content: center;
526
- background: linear-gradient(180deg, #eefcf8 0%, #dff7f2 100%);
527
- border: 1px solid rgba(15, 118, 110, 0.18);
528
- color: #0f6a75;
529
- font-size: 14px;
530
- line-height: 1;
531
- box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
532
- }
533
-
534
- .kp-source-thumb-large {
535
- width: 42px;
536
- height: 42px;
537
- font-size: 18px;
538
- }
539
-
540
- .kp-source-card-title {
541
- font-size: 14px;
542
- font-weight: 700;
543
- color: #16394b;
544
- word-break: break-word;
545
- }
546
-
547
- .kp-source-card-meta {
548
- margin-top: 8px;
549
- font-size: 12px;
550
- line-height: 1.5;
551
- color: #667a8d;
552
- word-break: break-word;
553
- }
554
-
555
- .kp-full-page-body {
556
- flex: 1;
557
- overflow: auto;
558
- display: flex;
559
- flex-direction: column;
560
- gap: 14px;
561
- padding: 42px 28px 18px;
562
- background: #ffffff;
563
- scroll-behavior: smooth;
564
- }
565
-
566
- .kp-full-page-body.kp-conversation-active {
567
- padding-top: 24px;
568
- }
569
-
570
- .kp-full-page-hero {
571
- display: flex;
572
- flex-direction: column;
573
- align-items: center;
574
- text-align: center;
575
- gap: 22px;
576
- padding: 18px 18px 12px;
577
- max-width: 880px;
578
- width: 100%;
579
- margin: 0 auto;
580
- }
581
-
582
- .kp-full-page-hero-badge {
583
- width: 140px;
584
- height: 140px;
585
- border-radius: 999px;
586
- display: flex;
587
- align-items: center;
588
- justify-content: center;
589
- background: radial-gradient(circle at 30% 30%, #f8fdff 0%, #edf8ff 50%, #e4eef8 100%);
590
- box-shadow:
591
- inset 0 2px 0 rgba(255, 255, 255, 0.9),
592
- 0 22px 40px rgba(15, 23, 42, 0.08);
593
- }
594
-
595
- .kp-star-cluster-static {
596
- animation: none;
597
- }
598
-
599
- .kp-full-page-hero-text {
600
- max-width: 760px;
601
- font-size: 26px;
602
- line-height: 1.5;
603
- font-weight: 700;
604
- letter-spacing: -0.03em;
605
- color: #374151;
606
- }
607
-
608
- .kp-full-page-suggestions {
609
- width: min(520px, 100%);
610
- margin: auto auto 0;
611
- }
612
-
613
- .kp-full-page-footer {
614
- flex: none;
615
- padding: 0 16px 18px;
616
- background: rgba(255, 255, 255, 0.72);
617
- border-top: 1px solid rgba(219, 228, 238, 0.75);
618
- }
619
-
620
- .kp-full-page-form {
621
- max-width: none;
622
- min-height: 56px;
623
- border-radius: 16px;
624
- }
625
-
626
- .kp-full-page-note {
627
- font-size: 13px;
628
- margin-top: 10px;
629
- }
630
-
631
- .kp-header {
632
- display: flex;
633
- justify-content: space-between;
634
- align-items: center;
635
- gap: 12px;
636
- padding: 18px 18px 8px;
637
- background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
638
- }
639
-
640
- .kp-toolbar {
641
- position: relative;
642
- display: flex;
643
- align-items: center;
644
- gap: 8px;
645
- }
646
-
647
- .kp-tool-button {
648
- width: 36px;
649
- height: 36px;
650
- border: none;
651
- border-radius: 12px;
652
- background: transparent;
653
- color: #0f4f68;
654
- cursor: pointer;
655
- display: inline-flex;
656
- align-items: center;
657
- justify-content: center;
658
- padding: 0;
659
- transition: background 140ms ease;
660
- }
661
-
662
- .kp-tool-button:hover {
663
- background: rgba(15, 118, 110, 0.08);
664
- }
665
-
666
- .kp-pencil-icon {
667
- width: 22px;
668
- height: 22px;
669
- position: relative;
670
- display: inline-block;
671
- }
672
-
673
- .kp-pencil-icon::before {
674
- content: "";
675
- position: absolute;
676
- width: 14px;
677
- height: 2.5px;
678
- background: currentColor;
679
- border-radius: 999px;
680
- transform: rotate(-45deg);
681
- top: 3px;
682
- right: 1px;
683
- }
684
-
685
- .kp-pencil-icon::after {
686
- content: "";
687
- position: absolute;
688
- left: 2px;
689
- bottom: 2px;
690
- width: 11px;
691
- height: 11px;
692
- border: 2px solid currentColor;
693
- border-radius: 4px;
694
- }
695
-
696
- .kp-chevron {
697
- font-size: 13px;
698
- color: #66839a;
699
- transition: transform 160ms ease;
700
- margin-left: -2px;
701
- }
702
-
703
- .kp-menu-trigger.open .kp-chevron {
704
- transform: rotate(180deg);
705
- }
706
-
707
- .kp-dropdown {
708
- position: absolute;
709
- top: 44px;
710
- left: 0;
711
- width: 184px;
712
- background: #ffffff;
713
- border: 1px solid rgba(15, 79, 104, 0.12);
714
- border-radius: 10px;
715
- box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
716
- padding: 8px;
717
- opacity: 0;
718
- transform: translateY(-6px);
719
- pointer-events: none;
720
- transition: opacity 180ms ease, transform 180ms ease;
721
- z-index: 2;
722
- }
723
-
724
- .kp-rtl .kp-dropdown {
725
- left: auto;
726
- right: 0;
727
- }
728
-
729
- .kp-dropdown.open {
730
- opacity: 1;
731
- transform: translateY(0);
732
- pointer-events: auto;
733
- }
734
-
735
- .kp-dropdown-item {
736
- width: 100%;
737
- border: none;
738
- background: transparent;
739
- text-align: left;
740
- padding: 10px 12px;
741
- border-radius: 8px;
742
- font-size: 14px;
743
- color: var(--kp-text);
744
- cursor: pointer;
745
- }
746
-
747
- .kp-dropdown-item:hover {
748
- background: rgba(15, 118, 110, 0.08);
749
- }
750
-
751
- .kp-title-wrap {
752
- display: none;
753
- }
754
-
755
- .kp-close {
756
- border: none;
757
- background: transparent;
758
- font-size: 24px;
759
- line-height: 1;
760
- color: var(--kp-muted-text);
761
- cursor: pointer;
762
- padding: 0;
763
- }
764
-
765
- .kp-body {
766
- flex: 1;
767
- overflow: auto;
768
- display: flex;
769
- flex-direction: column;
770
- gap: 12px;
771
- padding: 10px 16px 16px;
772
- background: linear-gradient(180deg, #ffffff 0%, var(--kp-surface-background) 100%);
773
- scroll-behavior: smooth;
774
- }
775
-
776
- .kp-body.kp-conversation-active {
777
- padding-top: 16px;
778
- }
779
-
780
- .kp-panel.kp-sheet-open .kp-body,
781
- .kp-panel.kp-sheet-open .kp-footer,
782
- .kp-panel.kp-sheet-open .kp-header {
783
- opacity: 0;
784
- pointer-events: none;
785
- }
786
-
787
- .kp-my-chats-sheet {
788
- position: absolute;
789
- inset: 0;
790
- border-radius: inherit;
791
- border: none;
792
- background: #ffffff;
793
- box-shadow: none;
794
- display: none;
795
- flex-direction: column;
796
- z-index: 3;
797
- overflow: hidden;
798
- }
799
-
800
- .kp-my-chats-sheet.open {
801
- display: flex;
802
- }
803
-
804
- .kp-my-chats-header {
805
- display: flex;
806
- align-items: center;
807
- justify-content: space-between;
808
- padding: 18px 18px 10px;
809
- flex: none;
810
- background: #ffffff;
811
- }
812
-
813
- .kp-my-chats-nav {
814
- width: 36px;
815
- height: 36px;
816
- border: none;
817
- border-radius: 999px;
818
- background: transparent;
819
- color: #61788a;
820
- font-size: 22px;
821
- line-height: 1;
822
- cursor: pointer;
823
- }
824
-
825
- .kp-my-chats-body {
826
- flex: 1;
827
- overflow: auto;
828
- padding: 8px 18px 18px;
829
- background: #ffffff;
830
- }
831
-
832
- .kp-my-chats-section-label {
833
- font-size: 14px;
834
- line-height: 1.5;
835
- color: #7a8a99;
836
- margin: 14px 0 10px;
837
- }
838
-
839
- .kp-my-chats-list {
840
- display: flex;
841
- flex-direction: column;
842
- gap: 10px;
843
- }
844
-
845
- .kp-chat-actions {
846
- position: relative;
847
- flex: none;
848
- }
849
-
850
- .kp-chat-actions-trigger {
851
- width: 28px;
852
- height: 28px;
853
- border: none;
854
- border-radius: 999px;
855
- background: transparent;
856
- color: #526678;
857
- font-size: 20px;
858
- line-height: 1;
859
- cursor: pointer;
860
- display: inline-flex;
861
- align-items: center;
862
- justify-content: center;
863
- }
864
-
865
- .kp-chat-actions-menu {
866
- position: absolute;
867
- top: 30px;
868
- inset-inline-end: 0;
869
- width: 120px;
870
- padding: 8px;
871
- border-radius: 10px;
872
- border: 1px solid rgba(219, 228, 238, 0.95);
873
- background: #ffffff;
874
- box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
875
- display: none;
876
- flex-direction: column;
877
- gap: 2px;
878
- z-index: 20;
879
- }
880
-
881
- .kp-chat-actions.open .kp-chat-actions-menu {
882
- display: flex;
883
- }
884
-
885
- .kp-chat-actions-item {
886
- width: 100%;
887
- border: none;
888
- background: transparent;
889
- color: #1f2937;
890
- text-align: left;
891
- padding: 10px 12px;
892
- border-radius: 8px;
893
- font-size: 14px;
894
- cursor: pointer;
895
- }
896
-
897
- .kp-chat-actions-item:hover {
898
- background: rgba(241, 245, 249, 0.95);
899
- }
900
-
901
- .kp-hero {
902
- display: flex;
903
- gap: 10px;
904
- padding: 4px 2px 8px;
905
- align-items: flex-start;
906
- }
907
-
908
- .kp-hero-icon {
909
- color: #0ea5b7;
910
- font-size: 28px;
911
- line-height: 1;
912
- margin-top: 2px;
913
- }
914
-
915
- .kp-hero-text {
916
- font-size: 20px;
917
- line-height: 1.45;
918
- font-weight: 700;
919
- color: #374151;
920
- }
921
-
922
- .kp-message-row {
923
- display: flex;
924
- align-items: flex-start;
925
- gap: 10px;
926
- width: 100%;
927
- }
928
-
929
- .kp-message-row.user {
930
- justify-content: flex-end;
931
- }
932
-
933
- .kp-avatar {
934
- flex: none;
935
- width: 36px;
936
- height: 36px;
937
- border-radius: 999px;
938
- display: flex;
939
- align-items: center;
940
- justify-content: center;
941
- font-size: 13px;
942
- font-weight: 700;
943
- box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
944
- }
945
-
946
- .kp-avatar.bot {
947
- background: linear-gradient(180deg, #e8fbff 0%, #dff7f2 100%);
948
- color: #0f6a75;
949
- border: 1px solid rgba(15, 118, 110, 0.16);
950
- }
951
-
952
- .kp-avatar.user {
953
- background: linear-gradient(180deg, #fff4ee 0%, #fbe3d5 100%);
954
- color: #8c4b1f;
955
- border: 1px solid rgba(180, 102, 43, 0.16);
956
- }
957
-
958
- .kp-bubble {
959
- max-width: min(85%, 720px);
960
- padding: 14px 16px;
961
- border-radius: 20px;
962
- font-size: 14px;
963
- line-height: 1.65;
964
- border: 1px solid var(--kp-border-color);
965
- background: #ffffff;
966
- box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
967
- }
968
-
969
- .kp-bubble.user {
970
- background: linear-gradient(180deg, #fff8f3 0%, #fdf1e8 100%);
971
- border-color: rgba(222, 184, 135, 0.34);
972
- }
973
-
974
- .kp-bubble.bot {
975
- background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
976
- }
977
-
978
- .kp-bubble-content {
979
- color: var(--kp-text);
980
- white-space: normal;
981
- word-break: break-word;
982
- }
983
-
984
- .kp-bubble-content p,
985
- .kp-bubble-content ul,
986
- .kp-bubble-content ol,
987
- .kp-bubble-content table,
988
- .kp-bubble-content blockquote {
989
- margin: 0;
990
- }
991
-
992
- .kp-bubble-content p + p,
993
- .kp-bubble-content p + ul,
994
- .kp-bubble-content p + ol,
995
- .kp-bubble-content ul + p,
996
- .kp-bubble-content ol + p,
997
- .kp-bubble-content .kp-table-wrap + p,
998
- .kp-bubble-content p + .kp-table-wrap,
999
- .kp-bubble-content h1 + p,
1000
- .kp-bubble-content h2 + p,
1001
- .kp-bubble-content h3 + p {
1002
- margin-top: 12px;
1003
- }
1004
-
1005
- .kp-bubble-content h1,
1006
- .kp-bubble-content h2,
1007
- .kp-bubble-content h3,
1008
- .kp-bubble-content h4,
1009
- .kp-bubble-content h5,
1010
- .kp-bubble-content h6 {
1011
- margin: 0 0 10px;
1012
- font-size: 16px;
1013
- line-height: 1.4;
1014
- color: #16394b;
1015
- }
1016
-
1017
- .kp-bubble-content ul,
1018
- .kp-bubble-content ol {
1019
- padding-inline-start: 20px;
1020
- }
1021
-
1022
- .kp-bubble-content code {
1023
- padding: 2px 6px;
1024
- border-radius: 8px;
1025
- background: rgba(226, 232, 240, 0.66);
1026
- font-size: 0.92em;
1027
- }
1028
-
1029
- .kp-bubble-content a {
1030
- color: #0f6a75;
1031
- text-decoration: underline;
1032
- }
1033
-
1034
- .kp-table-wrap {
1035
- overflow-x: auto;
1036
- margin-top: 8px;
1037
- }
1038
-
1039
- .kp-bubble-content table {
1040
- width: 100%;
1041
- border-collapse: collapse;
1042
- border: 1px solid rgba(203, 213, 225, 0.95);
1043
- border-radius: 14px;
1044
- overflow: hidden;
1045
- background: #ffffff;
1046
- }
1047
-
1048
- .kp-bubble-content th,
1049
- .kp-bubble-content td {
1050
- padding: 10px 12px;
1051
- border-bottom: 1px solid rgba(226, 232, 240, 0.95);
1052
- border-inline-end: 1px solid rgba(226, 232, 240, 0.95);
1053
- vertical-align: top;
1054
- text-align: start;
1055
- }
1056
-
1057
- .kp-bubble-content tr:last-child td {
1058
- border-bottom: none;
1059
- }
1060
-
1061
- .kp-bubble-content th:last-child,
1062
- .kp-bubble-content td:last-child {
1063
- border-inline-end: none;
1064
- }
1065
-
1066
- .kp-bubble-content th {
1067
- background: #f4fbfc;
1068
- color: #16394b;
1069
- font-weight: 700;
1070
- }
1071
-
1072
- .kp-meta {
1073
- font-size: 11px;
1074
- line-height: 1.4;
1075
- color: var(--kp-muted-text);
1076
- margin-top: 10px;
1077
- }
1078
-
1079
- .kp-source-preview {
1080
- margin-top: 10px;
1081
- padding: 12px;
1082
- border-radius: 16px;
1083
- border: 1px solid rgba(219, 228, 238, 0.88);
1084
- background: #ffffff;
1085
- }
1086
-
1087
- .kp-source-preview-title {
1088
- font-size: 12px;
1089
- font-weight: 700;
1090
- color: #16394b;
1091
- margin-bottom: 8px;
1092
- }
1093
-
1094
- .kp-source-preview-list {
1095
- display: flex;
1096
- flex-wrap: nowrap;
1097
- gap: 8px;
1098
- overflow-x: auto;
1099
- }
1100
-
1101
- .kp-source-chip {
1102
- display: inline-flex;
1103
- align-items: center;
1104
- gap: 10px;
1105
- border: 1px solid rgba(15, 118, 110, 0.16);
1106
- background: #ffffff;
1107
- color: #0f4f68;
1108
- border-radius: 999px;
1109
- padding: 8px 12px;
1110
- cursor: pointer;
1111
- font-size: 12px;
1112
- line-height: 1.3;
1113
- max-width: 100%;
1114
- min-width: 0;
1115
- }
1116
-
1117
- .kp-source-chip-more {
1118
- background: rgba(236, 254, 255, 0.9);
1119
- }
1120
-
1121
- .kp-source-chip-label {
1122
- min-width: 0;
1123
- overflow: hidden;
1124
- text-overflow: ellipsis;
1125
- white-space: nowrap;
1126
- }
1127
-
1128
- .kp-source-thumb-stack {
1129
- display: inline-flex;
1130
- align-items: center;
1131
- margin-inline-end: 2px;
1132
- }
1133
-
1134
- .kp-source-thumb.stacked {
1135
- margin-inline-end: -10px;
1136
- background: #ffffff;
1137
- }
1138
-
1139
- .kp-message-actions {
1140
- display: flex;
1141
- align-items: center;
1142
- gap: 8px;
1143
- margin-top: 10px;
1144
- }
1145
-
1146
- .kp-message-action {
1147
- border: 1px solid rgba(219, 228, 238, 0.9);
1148
- background: #ffffff;
1149
- color: #4b6478;
1150
- border-radius: 999px;
1151
- padding: 7px 10px;
1152
- cursor: pointer;
1153
- font-size: 12px;
1154
- line-height: 1;
1155
- }
1156
-
1157
- .kp-message-action.active {
1158
- color: #0f6a75;
1159
- border-color: rgba(15, 118, 110, 0.3);
1160
- background: rgba(236, 254, 255, 0.92);
1161
- }
1162
-
1163
- .kp-suggestions {
1164
- display: flex;
1165
- flex-direction: column;
1166
- gap: 10px;
1167
- margin-top: auto;
1168
- }
1169
-
1170
- .kp-suggestion {
1171
- border: 1px solid rgba(15, 118, 110, 0.18);
1172
- background: rgba(247, 251, 255, 0.92);
1173
- color: var(--kp-text);
1174
- border-radius: 999px;
1175
- padding: 11px 14px;
1176
- cursor: pointer;
1177
- text-align: left;
1178
- font-size: 14px;
1179
- line-height: 1.35;
1180
- }
1181
-
1182
- .kp-footer {
1183
- padding: 10px 16px 12px;
1184
- border-top: 1px solid rgba(219, 228, 238, 0.85);
1185
- background: #ffffff;
1186
- }
1187
-
1188
- .kp-form {
1189
- display: flex;
1190
- align-items: center;
1191
- gap: 10px;
1192
- border: 1px solid var(--kp-border-color);
1193
- border-radius: 16px;
1194
- padding: 10px 12px;
1195
- background: #ffffff;
1196
- }
1197
-
1198
- .kp-rtl .kp-form {
1199
- flex-direction: row-reverse;
1200
- }
1201
-
1202
- .kp-input {
1203
- flex: 1;
1204
- border: none;
1205
- outline: none;
1206
- box-shadow: none;
1207
- background: transparent;
1208
- color: var(--kp-text);
1209
- font-size: 14px;
1210
- line-height: 1.5;
1211
- min-width: 0;
1212
- appearance: none;
1213
- }
1214
-
1215
- .kp-input:focus,
1216
- .kp-input:focus-visible,
1217
- .kp-input:active {
1218
- border: none;
1219
- outline: none;
1220
- box-shadow: none;
1221
- }
1222
-
1223
- .kp-send {
1224
- width: 40px;
1225
- height: 40px;
1226
- border: none;
1227
- border-radius: 999px;
1228
- background: #e4f1f8;
1229
- color: var(--kp-accent);
1230
- cursor: pointer;
1231
- font-size: 20px;
1232
- line-height: 1;
1233
- display: flex;
1234
- align-items: center;
1235
- justify-content: center;
1236
- flex: none;
1237
- }
1238
-
1239
- .kp-rtl .kp-send {
1240
- transform: scaleX(-1);
1241
- }
1242
-
1243
- .kp-note {
1244
- margin-top: 8px;
1245
- text-align: center;
1246
- font-size: 11px;
1247
- line-height: 1.4;
1248
- color: var(--kp-muted-text);
1249
- }
1250
-
1251
- .kp-loading {
1252
- font-size: 13px;
1253
- line-height: 1.4;
1254
- color: var(--kp-muted-text);
1255
- padding: 4px 2px;
1256
- }
1257
-
1258
- @media (max-width: 1100px) {
1259
- .kp-full-page-content:has(.kp-source-panel.open) {
1260
- grid-template-columns: 260px minmax(0, 1fr);
1261
- }
1262
-
1263
- .kp-source-panel.open {
1264
- position: absolute;
1265
- inset-inline-end: 28px;
1266
- top: 92px;
1267
- bottom: 26px;
1268
- width: min(320px, calc(100vw - 56px));
1269
- z-index: 3;
1270
- }
1271
- }
1272
-
1273
- @media (max-width: 860px) {
1274
- .kp-full-page-content,
1275
- .kp-full-page-content:has(.kp-source-panel.open) {
1276
- grid-template-columns: 1fr;
1277
- }
1278
-
1279
- .kp-full-page-sidebar {
1280
- max-height: 260px;
1281
- }
1282
-
1283
- .kp-source-panel.open {
1284
- position: static;
1285
- inset: auto;
1286
- width: auto;
1287
- max-height: 280px;
1288
- }
1289
- }
1290
-
1291
- @media (max-width: 640px) {
1292
- .kp-chat-widget,
1293
- .kp-chat-widget.bottom-left {
1294
- left: auto;
1295
- right: 16px;
1296
- bottom: 16px;
1297
- }
1298
-
1299
- .kp-panel,
1300
- .kp-chat-widget.bottom-left .kp-panel {
1301
- inset: 0;
1302
- width: 100vw;
1303
- height: 100vh;
1304
- border-radius: 0;
1305
- transform: translateX(72px) scale(0.985);
1306
- transform-origin: center right;
1307
- }
1308
-
1309
- .kp-panel.open {
1310
- transform: translateX(0) scale(1);
1311
- }
1312
-
1313
- .kp-full-page-shell {
1314
- padding: 14px;
1315
- }
1316
-
1317
- .kp-full-page-header {
1318
- padding: 0;
1319
- }
1320
-
1321
- .kp-full-page-body {
1322
- padding: 24px 16px 16px;
1323
- }
1324
-
1325
- .kp-full-page-hero-badge {
1326
- width: 112px;
1327
- height: 112px;
1328
- }
1329
-
1330
- .kp-full-page-hero-text {
1331
- font-size: 22px;
1332
- }
1333
-
1334
- .kp-message-row {
1335
- gap: 8px;
1336
- }
1337
-
1338
- .kp-avatar {
1339
- width: 32px;
1340
- height: 32px;
1341
- }
1342
-
1343
- .kp-bubble {
1344
- max-width: calc(100% - 40px);
1345
- }
1346
- }
1347
-
1348
- @keyframes kp-cluster-rotate {
1349
- from { transform: rotate(0deg); }
1350
- to { transform: rotate(360deg); }
1351
- }
1352
-
1353
- @keyframes kp-main-pulse {
1354
- 0%, 100% { transform: translate(-50%, -50%) scale(0.82); opacity: 0.45; }
1355
- 38% { transform: translate(-50%, -50%) scale(1.04); opacity: 1; }
1356
- 60% { transform: translate(-50%, -50%) scale(0.94); opacity: 0.88; }
1357
- }
1358
-
1359
- @keyframes kp-orbit-a {
1360
- 0%, 100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
1361
- 40% { transform: translate(-50%, 17px) scale(0.92); opacity: 0.96; }
1362
- 62% { transform: translate(-50%, 2px) scale(1); opacity: 0.98; }
1363
- }
1364
-
1365
- @keyframes kp-orbit-b {
1366
- 0%, 100% { transform: translate(0, 0) scale(1); opacity: 1; }
1367
- 40% { transform: translate(-16px, -13px) scale(0.92); opacity: 0.96; }
1368
- 62% { transform: translate(-2px, -2px) scale(1); opacity: 0.98; }
1369
- }
1370
-
1371
- @keyframes kp-orbit-c {
1372
- 0%, 100% { transform: translate(0, 0) scale(1); opacity: 1; }
1373
- 40% { transform: translate(16px, -13px) scale(0.92); opacity: 0.96; }
1374
- 62% { transform: translate(2px, -2px) scale(1); opacity: 0.98; }
1375
- }
1376
- `}var dt={en:{openChatActions:"Open chat actions",newChat:"New Chat",myChats:"My Chats",openAssistant:"Open Knowledge Assistant",back:"Back",close:"Close",assistantBadge:"Knowledge Assistant",closeAssistantPage:"Close knowledge assistant page",searchChat:"Search Chat",recentActivity:"Recent Activity",pinnedCollections:"Pinned Collections",answersBasedOnPermissions:"Answers are generated based on your access permissions",authTokenForwarded:"Auth token is forwarded from the host app when configured.",thinking:"Thinking...",unableToCreateChat:"Unable to create chat",requestFailed:"Request failed",noRecentChats:"No recent chats yet.",noPinnedChats:"No pinned chats yet.",noChats:"No chats yet.",loadingChats:"Loading chats...",pinChat:"Pin chat",unpinChat:"Unpin chat",renameChat:"Rename",deleteChat:"Delete",chatActions:"Chat actions",renamePrompt:"Enter a new chat name",citationsAttached:e=>`${e} citation${e>1?"s":""} attached`,sourcesUsed:"Sources Used",allSourcesUsed:"All Sources Used",documentsAndReferences:"AI documents and references",showAll:"Show All",noSources:"No sources were returned for this answer.",closeSourcesPanel:"Close sources panel",openSource:"Open source",sourceScore:"Score",sourcePage:"Page",sourceSheet:"Sheet",sourceRow:"Row",sourceKnowledge:"Knowledge Base",untitledSource:"Untitled Source",copy:"Copy",copied:"Copied",helpful:"Helpful",notHelpful:"Needs work",send:"Send message",assistantAvatar:"Assistant",userAvatar:"User"},ar:{openChatActions:"\u0641\u062A\u062D \u0625\u062C\u0631\u0627\u0621\u0627\u062A \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",newChat:"\u0645\u062D\u0627\u062F\u062B\u0629 \u062C\u062F\u064A\u062F\u0629",myChats:"\u0645\u062D\u0627\u062F\u062B\u0627\u062A\u064A",openAssistant:"\u0641\u062A\u062D \u0645\u0633\u0627\u0639\u062F \u0627\u0644\u0645\u0639\u0631\u0641\u0629",back:"\u0631\u062C\u0648\u0639",close:"\u0625\u063A\u0644\u0627\u0642",assistantBadge:"\u0645\u0633\u0627\u0639\u062F \u0627\u0644\u0645\u0639\u0631\u0641\u0629",closeAssistantPage:"\u0625\u063A\u0644\u0627\u0642 \u0635\u0641\u062D\u0629 \u0645\u0633\u0627\u0639\u062F \u0627\u0644\u0645\u0639\u0631\u0641\u0629",searchChat:"\u0627\u0628\u062D\u062B \u0641\u064A \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0627\u062A",recentActivity:"\u0627\u0644\u0646\u0634\u0627\u0637 \u0627\u0644\u0623\u062E\u064A\u0631",pinnedCollections:"\u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0627\u062A \u0627\u0644\u0645\u062B\u0628\u062A\u0629",answersBasedOnPermissions:"\u064A\u062A\u0645 \u0625\u0646\u0634\u0627\u0621 \u0627\u0644\u0625\u062C\u0627\u0628\u0627\u062A \u0628\u0646\u0627\u0621\u064B \u0639\u0644\u0649 \u0635\u0644\u0627\u062D\u064A\u0627\u062A \u0627\u0644\u0648\u0635\u0648\u0644 \u0627\u0644\u062E\u0627\u0635\u0629 \u0628\u0643",authTokenForwarded:"\u064A\u062A\u0645 \u062A\u0645\u0631\u064A\u0631 \u0631\u0645\u0632 \u0627\u0644\u062A\u062D\u0642\u0642 \u0645\u0646 \u0627\u0644\u062A\u0637\u0628\u064A\u0642 \u0627\u0644\u0645\u0636\u064A\u0641 \u0639\u0646\u062F \u0627\u0644\u0625\u0639\u062F\u0627\u062F.",thinking:"\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u0641\u0643\u064A\u0631...",unableToCreateChat:"\u062A\u0639\u0630\u0631 \u0625\u0646\u0634\u0627\u0621 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",requestFailed:"\u0641\u0634\u0644 \u0627\u0644\u0637\u0644\u0628",noRecentChats:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0645\u062D\u0627\u062F\u062B\u0627\u062A \u062D\u062F\u064A\u062B\u0629 \u0628\u0639\u062F.",noPinnedChats:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0645\u062D\u0627\u062F\u062B\u0627\u062A \u0645\u062B\u0628\u062A\u0629 \u0628\u0639\u062F.",noChats:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0645\u062D\u0627\u062F\u062B\u0627\u062A \u0628\u0639\u062F.",loadingChats:"\u062C\u0627\u0631\u064D \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0627\u062A...",pinChat:"\u062A\u062B\u0628\u064A\u062A \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",unpinChat:"\u0625\u0644\u063A\u0627\u0621 \u062A\u062B\u0628\u064A\u062A \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",renameChat:"\u0625\u0639\u0627\u062F\u0629 \u062A\u0633\u0645\u064A\u0629",deleteChat:"\u062D\u0630\u0641",chatActions:"\u0625\u062C\u0631\u0627\u0621\u0627\u062A \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",renamePrompt:"\u0623\u062F\u062E\u0644 \u0627\u0633\u0645\u064B\u0627 \u062C\u062F\u064A\u062F\u064B\u0627 \u0644\u0644\u0645\u062D\u0627\u062F\u062B\u0629",citationsAttached:e=>`\u062A\u0645 \u0625\u0631\u0641\u0627\u0642 ${e} \u0645\u0631\u062C\u0639${e>1?"\u0627\u062A":""}`,sourcesUsed:"\u0627\u0644\u0645\u0635\u0627\u062F\u0631 \u0627\u0644\u0645\u0633\u062A\u062E\u062F\u0645\u0629",allSourcesUsed:"\u0643\u0644 \u0627\u0644\u0645\u0635\u0627\u062F\u0631 \u0627\u0644\u0645\u0633\u062A\u062E\u062F\u0645\u0629",documentsAndReferences:"\u0645\u0633\u062A\u0646\u062F\u0627\u062A \u0648\u0645\u0631\u0627\u062C\u0639 \u0627\u0644\u0630\u0643\u0627\u0621 \u0627\u0644\u0627\u0635\u0637\u0646\u0627\u0639\u064A",showAll:"\u0639\u0631\u0636 \u0627\u0644\u0643\u0644",noSources:"\u0644\u0645 \u064A\u062A\u0645 \u0625\u0631\u062C\u0627\u0639 \u0645\u0635\u0627\u062F\u0631 \u0644\u0647\u0630\u0647 \u0627\u0644\u0625\u062C\u0627\u0628\u0629.",closeSourcesPanel:"\u0625\u063A\u0644\u0627\u0642 \u0644\u0648\u062D\u0629 \u0627\u0644\u0645\u0635\u0627\u062F\u0631",openSource:"\u0641\u062A\u062D \u0627\u0644\u0645\u0635\u062F\u0631",sourceScore:"\u0627\u0644\u062F\u0631\u062C\u0629",sourcePage:"\u0627\u0644\u0635\u0641\u062D\u0629",sourceSheet:"\u0627\u0644\u0648\u0631\u0642\u0629",sourceRow:"\u0627\u0644\u0635\u0641",sourceKnowledge:"\u0642\u0627\u0639\u062F\u0629 \u0627\u0644\u0645\u0639\u0631\u0641\u0629",untitledSource:"\u0645\u0635\u062F\u0631 \u0628\u062F\u0648\u0646 \u0639\u0646\u0648\u0627\u0646",copy:"\u0646\u0633\u062E",copied:"\u062A\u0645 \u0627\u0644\u0646\u0633\u062E",helpful:"\u0645\u0641\u064A\u062F",notHelpful:"\u064A\u062D\u062A\u0627\u062C \u062A\u062D\u0633\u064A\u0646",send:"\u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0631\u0633\u0627\u0644\u0629",assistantAvatar:"\u0627\u0644\u0645\u0633\u0627\u0639\u062F",userAvatar:"\u0627\u0644\u0645\u0633\u062A\u062E\u062F\u0645"}};function En(e){if(typeof document>"u")throw new Error("Chat widget can only be initialized in a browser.");let t=pt(e),o=Ce(t.locale),n=Qt(t.locale),i=Gt(o),s={chatId:ce(t),open:!1,fullPageOpen:!1,myChatsOpen:!1,accessTokenProvider:t.getAccessToken,historyLoadedChatId:null,menuOpen:!1,chats:[],chatSearchTerm:"",loadingChats:!1,sourcePanelOpen:!1,sourcePanelTitle:null},d=document.createElement("div");d.dataset.chatWidgetHost="true",t.mount.appendChild(d);let p=d.attachShadow({mode:"open"});ct(p,t.theme);let l=a("div",`kp-chat-widget ${t.position}`);l.lang=o,l.dir=i?"rtl":"ltr",i&&l.classList.add("kp-rtl");let u=a("div","kp-overlay"),g=a("button","kp-launcher");g.type="button",g.setAttribute("aria-label",t.launcherAriaLabel),g.innerHTML=['<span class="kp-star-cluster" aria-hidden="true">','<span class="kp-star orbit-a">\u2726</span>','<span class="kp-star orbit-b">\u2726</span>','<span class="kp-star orbit-c">\u2726</span>','<span class="kp-star main">\u2726</span>',"</span>"].join("");let f=a("section","kp-panel");f.setAttribute("role","dialog"),f.setAttribute("aria-modal","true"),f.setAttribute("aria-label",t.title);let m=a("div","kp-header"),y=a("div","kp-toolbar"),b=a("button","kp-tool-button kp-menu-trigger");b.type="button",b.setAttribute("aria-label",n.openChatActions),b.innerHTML=['<span class="kp-pencil-icon" aria-hidden="true"></span>','<span class="kp-chevron" aria-hidden="true">\u2304</span>'].join("");let x=a("div","kp-dropdown"),v=a("button","kp-dropdown-item",n.newChat);v.type="button";let k=a("button","kp-dropdown-item",n.myChats);k.type="button";let $=a("button","kp-dropdown-item",n.openAssistant);$.type="button",x.append(v,k,$),y.append(b,x);let C=a("div","kp-title-wrap"),xt=a("h2","kp-title",t.title),yt=a("div","kp-subtitle",t.subtitle);C.append(xt,yt);let G=a("button","kp-close","\xD7");G.type="button",G.setAttribute("aria-label",t.closeAriaLabel),m.append(y,C,G);let Z=a("div","kp-body"),de=a("div","kp-hero"),wt=a("div","kp-hero-icon","\u2726"),vt=a("div","kp-hero-text",t.welcomeMessage);de.append(wt,vt);let Le=a("div","kp-footer"),ue=a("form","kp-form"),S=a("input","kp-input");S.type="text",S.autocomplete="off",S.placeholder=t.inputPlaceholder,S.setAttribute("aria-label",t.inputPlaceholder);let ge=a("button","kp-send","\u279C");ge.type="submit",ge.setAttribute("aria-label",n.send);let Ct=a("div","kp-note",n.authTokenForwarded);ue.append(S,ge),Le.append(ue,Ct),f.append(m,Z,Le),l.append(u,g,f),p.appendChild(l),Z.appendChild(de);let Ae=a("div","kp-suggestions");Z.appendChild(Ae);let ee=a("section","kp-my-chats-sheet"),Pe=a("div","kp-my-chats-header"),te=a("button","kp-my-chats-nav","\u2190");te.type="button",te.setAttribute("aria-label",n.back);let ne=a("button","kp-my-chats-nav kp-my-chats-close","\xD7");ne.type="button",ne.setAttribute("aria-label",n.close),Pe.append(te,ne);let Se=a("div","kp-my-chats-body"),Lt=a("div","kp-my-chats-section-label",n.recentActivity),Te=a("div","kp-my-chats-list"),At=a("div","kp-my-chats-section-label",n.pinnedCollections),Ee=a("div","kp-my-chats-list");Se.append(Lt,Te,At,Ee),ee.append(Pe,Se),f.appendChild(ee);let A={body:Z,input:S,suggestions:Ae,hero:de,kind:"panel"},T=a("section","kp-full-page");T.setAttribute("role","dialog"),T.setAttribute("aria-modal","true"),T.setAttribute("aria-label",`${t.title} page`);let Ie=a("div","kp-full-page-shell"),Re=a("div","kp-full-page-header"),$e=a("div","kp-full-page-brand"),Pt=a("div","kp-full-page-brand-mark","\u2726"),St=a("div","kp-full-page-brand-text",t.title);$e.append(Pt,St);let He=a("div","kp-full-page-header-actions"),Tt=a("div","kp-full-page-badge",n.assistantBadge),oe=a("button","kp-full-page-close","\xD7");oe.type="button",oe.setAttribute("aria-label",n.closeAssistantPage),He.append(Tt,oe),Re.append($e,He);let ze=a("div","kp-full-page-content"),Me=a("aside","kp-full-page-sidebar"),fe=a("button","kp-full-page-new-chat",`+ ${n.newChat}`);fe.type="button";let Ne=a("div","kp-full-page-search"),V=a("input","kp-full-page-search-input");V.type="search",V.placeholder=n.searchChat;let Et=a("span","kp-full-page-search-icon","\u2315");Ne.append(V,Et);let It=a("div","kp-full-page-section-label",n.recentActivity),Be=a("div","kp-full-page-recent-list"),Rt=a("div","kp-full-page-section-label",n.pinnedCollections),Ue=a("div","kp-full-page-pinned-list");Me.append(fe,Ne,It,Be,Rt,Ue);let Oe=a("main","kp-full-page-main"),We=a("section","kp-full-page-panel"),he=a("div","kp-full-page-body"),me=a("div","kp-full-page-hero"),je=a("div","kp-full-page-hero-badge");je.innerHTML=['<span class="kp-star-cluster kp-star-cluster-static" aria-hidden="true">','<span class="kp-star orbit-a">\u2726</span>','<span class="kp-star orbit-b">\u2726</span>','<span class="kp-star orbit-c">\u2726</span>','<span class="kp-star main">\u2726</span>',"</span>"].join("");let $t=a("div","kp-full-page-hero-text",t.welcomeMessage);me.append(je,$t);let De=a("div","kp-suggestions kp-full-page-suggestions");he.append(me,De);let Ve=a("div","kp-full-page-footer"),be=a("form","kp-form kp-full-page-form"),P=a("input","kp-input kp-full-page-input");P.type="text",P.autocomplete="off",P.placeholder=t.inputPlaceholder,P.setAttribute("aria-label",t.inputPlaceholder);let ke=a("button","kp-send kp-full-page-send","\u279C");ke.type="submit",ke.setAttribute("aria-label",n.send);let Ht=a("div","kp-note kp-full-page-note",n.answersBasedOnPermissions);be.append(P,ke),Ve.append(be,Ht),We.append(he,Ve),Oe.appendChild(We);let ae=a("aside","kp-source-panel"),qe=a("div","kp-source-panel-header"),_e=a("div","kp-source-panel-title-wrap"),Fe=a("div","kp-source-panel-title",n.allSourcesUsed),zt=a("div","kp-source-panel-subtitle",n.documentsAndReferences);_e.append(Fe,zt);let se=a("button","kp-source-panel-close","\xD7");se.type="button",se.setAttribute("aria-label",n.closeSourcesPanel),qe.append(_e,se);let q=a("div","kp-source-panel-list"),Mt=a("div","kp-source-panel-empty",n.noSources);q.appendChild(Mt),ae.append(qe,q),ze.append(Me,Oe,ae),Ie.append(Re,ze),T.appendChild(Ie),l.appendChild(T);let L={body:he,input:P,suggestions:De,hero:me,kind:"full-page"},H=()=>({...t,getAccessToken:s.accessTokenProvider}),Ke=async()=>{if(!t.getUserContext)return null;try{let r=await t.getUserContext();return r?.displayName?.trim()||r?.email?.trim()||r?.userId?.trim()||null}catch{return null}},_=(r,c)=>{if(s.sourcePanelOpen=!0,s.sourcePanelTitle=c??n.allSourcesUsed,Fe.textContent=s.sourcePanelTitle,ae.classList.add("open"),q.textContent="",r.length===0){q.appendChild(a("div","kp-source-panel-empty",n.noSources));return}for(let h of r)q.appendChild(pn(h,n))},re=()=>{s.sourcePanelOpen=!1,s.sourcePanelTitle=null,ae.classList.remove("open")};j(A,t.initialSuggestions,async r=>{await E(r,A)}),j(L,t.initialSuggestions,async r=>{await E(r,L)}),N(),ie();function Xe(){s.open||(s.open=!0,s.fullPageOpen=!1,I(),T.classList.remove("open"),g.classList.add("hidden"),u.classList.add("visible"),f.classList.add("open"),t.onOpen?.(),t.rag.loadHistoryOnOpen&&xe.loadHistory(),queueMicrotask(()=>S.focus()))}function F(){s.open&&(z(),I(),s.open=!1,g.classList.remove("hidden"),u.classList.remove("visible"),f.classList.remove("open"),t.onClose?.())}async function E(r,c){let h=r.trim();if(!h)return;c.input.value="";try{await Wt(h)}catch(R){let K=U(t,R);J(c.body,"bot",`${n.unableToCreateChat}: ${K.message}`,{strings:n,view:c,userName:null,onShowSources:_});return}ut(c),J(c.body,"user",h,{strings:n,view:c,userName:await Ke(),onShowSources:_}),c.body.scrollTop=c.body.scrollHeight;let B=a("div","kp-loading",n.thinking);c.body.appendChild(B),c.body.scrollTop=c.body.scrollHeight;try{let R=await ot(H(),{message:h,chatId:s.chatId,knowledgeNames:await _t(t),...t.rag.enableReferences!==void 0?{enableReferences:t.rag.enableReferences}:{}});B.isConnected&&B.remove(),J(c.body,"bot",R.answer,{strings:n,view:c,userName:null,citations:R.citations??[],onShowSources:_}),s.historyLoadedChatId=null,await M(),R.suggestions?.length&&j(c,R.suggestions,async K=>{await E(K,c)})}catch(R){let K=U(t,R);B.isConnected&&B.remove(),J(c.body,"bot",`${n.requestFailed}: ${K.message}`,{strings:n,view:c,userName:null,onShowSources:_})}}async function Ye(r){let c=s.fullPageOpen?L:A;await E(r,c)}async function Nt(){s.fullPageOpen=!0,s.open=!1,z(),I(),f.classList.remove("open"),u.classList.remove("visible"),g.classList.add("hidden"),T.classList.add("open"),await M(),await pe(L,s.chatId),queueMicrotask(()=>P.focus())}function Je(){s.fullPageOpen&&(s.fullPageOpen=!1,T.classList.remove("open"),g.classList.remove("hidden"),re())}function Bt(){s.menuOpen=!0,b.classList.add("open"),x.classList.add("open")}function z(){s.menuOpen=!1,b.classList.remove("open"),x.classList.remove("open")}function Ut(){s.chatId=ce(t),s.historyLoadedChatId=null,I(),Y(A),j(A,t.initialSuggestions,async r=>{await E(r,A)}),z()}async function Ot(){s.chatId=ce(t),s.historyLoadedChatId=null,Y(L),re(),j(L,t.initialSuggestions,async r=>{await E(r,L)}),N()}async function M(){if(!t.endpoints.listChats)return N(),ie(),[];s.loadingChats=!0,N(),ie();try{let r=await st(H());return s.chats=r,r}catch(r){return U(t,r),s.chats}finally{s.loadingChats=!1,N(),ie()}}async function Wt(r){!t.endpoints.listChats&&!t.endpoints.createChat||s.chats.some(c=>c.chatId===s.chatId)||await rt(H(),s.chatId,r?Jt(r,n.newChat):void 0)}async function jt(r){s.chatId=r,s.historyLoadedChatId=null,await pe(L,r),N()}async function Dt(r){s.chatId=r,s.historyLoadedChatId=null,await pe(A,r),I()}async function Vt(){z(),await M(),s.myChatsOpen=!0,f.classList.add("kp-sheet-open"),ee.classList.add("open")}function I(){s.myChatsOpen=!1,f.classList.remove("kp-sheet-open"),ee.classList.remove("open")}async function Qe(r){if(!t.endpoints.updateChat)return;let c=window.prompt(n.renamePrompt,r.title)?.trim();if(!(!c||c===r.title))try{await we(H(),r.chatId,{title:c}),await M()}catch(h){U(t,h)}}async function Ge(r){if(t.endpoints.deleteChat)try{await it(H(),r.chatId),s.chatId===r.chatId&&(s.chatId=ce(t),s.historyLoadedChatId=null,Y(A),Y(L)),await M()}catch(c){U(t,c)}}function N(){gt(Be,Ue,s,n,async r=>{await jt(r.chatId)},async r=>{await Ze(r)},async r=>{await Qe(r)},async r=>{await Ge(r)})}function ie(){gt(Te,Ee,s,n,async r=>{await Dt(r.chatId)},async r=>{await Ze(r)},async r=>{await Qe(r)},async r=>{await Ge(r)})}async function Ze(r){if(t.endpoints.updateChat)try{await we(H(),r.chatId,{pinned:!r.pinned}),await M()}catch(c){U(t,c)}}async function pe(r,c){Y(r),j(r,t.initialSuggestions,async B=>{await E(B,r)});let h=await at(H(),c);return h.length>0&&(ut(r),ht(r.body,r.hero,r.suggestions),Yt(r.body,h,{strings:n,view:r,userName:await Ke(),onShowSources:_})),s.historyLoadedChatId=c,h}let xe={open:Xe,close:F,toggle(){if(s.open){F();return}Xe()},destroy(){document.removeEventListener("keydown",et),d.remove()},sendMessage:Ye,setAccessTokenProvider(r){s.accessTokenProvider=r},getChatId(){return s.chatId},loadChats(){return M()},async loadHistory(){let r=s.fullPageOpen?L:A;return pe(r,s.chatId)}};g.addEventListener("click",()=>xe.toggle()),G.addEventListener("click",F),u.addEventListener("click",F),se.addEventListener("click",re),te.addEventListener("click",I),ne.addEventListener("click",I),b.addEventListener("click",r=>{if(r.stopPropagation(),!s.menuOpen){Bt();return}z()}),v.addEventListener("click",Ut),k.addEventListener("click",async()=>{await Vt()}),$.addEventListener("click",()=>{Nt()}),oe.addEventListener("click",Je),fe.addEventListener("click",()=>{Ot(),queueMicrotask(()=>P.focus())}),V.addEventListener("input",()=>{s.chatSearchTerm=V.value.trim().toLowerCase(),N()}),f.addEventListener("click",r=>{let c=r.target;if(!(c instanceof Element)||!c.closest(".kp-chat-actions")){for(let h of Array.from(p.querySelectorAll(".kp-chat-actions.open")))h.classList.remove("open");for(let h of Array.from(p.querySelectorAll(".kp-full-page-chat-item.menu-open")))h.classList.remove("menu-open")}s.menuOpen&&!x.contains(c)&&!b.contains(c)&&z(),r.stopPropagation()}),p.addEventListener("click",r=>{let c=r.target;if(s.menuOpen&&c instanceof Node&&!x.contains(c)&&!b.contains(c)&&z(),c instanceof Element&&!c.closest(".kp-chat-actions")){for(let h of Array.from(p.querySelectorAll(".kp-chat-actions.open")))h.classList.remove("open");for(let h of Array.from(p.querySelectorAll(".kp-full-page-chat-item.menu-open")))h.classList.remove("menu-open")}}),ue.addEventListener("submit",async r=>{r.preventDefault(),await Ye(S.value)}),be.addEventListener("submit",async r=>{r.preventDefault(),await E(P.value,L)});function et(r){if(r.key==="Escape"){if(s.sourcePanelOpen){re();return}if(s.myChatsOpen){I();return}if(s.fullPageOpen){Je();return}s.open&&F()}}return document.addEventListener("keydown",et),xe}async function _t(e){if(e.rag.getKnowledgeNames){let t=await e.rag.getKnowledgeNames();return Array.isArray(t)?t.filter(Boolean):[]}return(e.rag.knowledgeNames??[]).filter(Boolean)}function ce(e){return e.rag.chatId?.trim()?e.rag.chatId:e.rag.chatIdFactory?e.rag.chatIdFactory():typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`kp-chat-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function J(e,t,o,n){let i=t==="bot"?en(o,n.citations??[]):{displayText:o,citations:n.citations??[]},s=a("div",`kp-message-row ${t}`),d=Kt(t==="bot"?n.strings.assistantAvatar:n.userName??n.strings.userAvatar,t),p=a("div",`kp-bubble ${t}`),l=a("div","kp-bubble-content");dn(l,i.displayText),p.appendChild(l);let u=i.citations;if(u.length){let g=a("div","kp-meta",n.strings.citationsAttached(u.length));p.appendChild(g);let f=a("div","kp-source-preview"),m=a("div","kp-source-preview-title",n.strings.sourcesUsed),y=a("div","kp-source-preview-list");for(let x of u.slice(0,2)){let v=sn(x,n.strings);v.addEventListener("click",async()=>{bt(x,n.strings)}),y.appendChild(v)}let b=rn(n.strings);b.addEventListener("click",async()=>{n.onShowSources(u,n.strings.allSourcesUsed)}),y.appendChild(b),f.append(m,y),p.appendChild(f)}return t==="bot"&&p.appendChild(Ft(i.displayText,n.strings)),t==="user"?s.append(p,d):s.append(d,p),e.appendChild(s),e.scrollTop=e.scrollHeight,s}function Ft(e,t){let o=a("div","kp-message-actions"),n=a("button","kp-message-action",t.copy);n.type="button",n.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(e),n.textContent=t.copied,window.setTimeout(()=>{n.textContent=t.copy},1200)}catch{n.textContent=t.copy}});let i=a("button","kp-message-action","\u{1F44D}");i.type="button",i.setAttribute("aria-label",t.helpful),i.addEventListener("click",()=>{i.classList.toggle("active"),s.classList.remove("active")});let s=a("button","kp-message-action","\u{1F44E}");return s.type="button",s.setAttribute("aria-label",t.notHelpful),s.addEventListener("click",()=>{s.classList.toggle("active"),i.classList.remove("active")}),o.append(n,i,s),o}function Kt(e,t){let o=a("div",`kp-avatar ${t}`),n=t==="bot"?"\u2726":Zt(e);return o.textContent=n,o.setAttribute("aria-hidden","true"),o}function Xt(e,t,o){e.textContent="";for(let n of t){let i=a("button","kp-suggestion",n);i.type="button",i.addEventListener("click",async()=>{await o(n)}),e.appendChild(i)}}function j(e,t,o){Xt(e.suggestions,t,async n=>{e.input.value=n,await o(n)})}function ht(e,t,o){let n=new Set([t,o]);for(let i of Array.from(e.children))n.has(i)||i.remove()}function ut(e){e.body.classList.add("kp-conversation-active"),e.hero.remove(),e.suggestions.remove()}function Y(e){e.body.classList.remove("kp-conversation-active"),e.hero.isConnected||e.body.prepend(e.hero),e.suggestions.isConnected||e.body.appendChild(e.suggestions),ht(e.body,e.hero,e.suggestions),e.input.value=""}function Yt(e,t,o){for(let n of t)J(e,n.role==="assistant"?"bot":"user",n.text,o)}function gt(e,t,o,n,i,s,d,p){if(e.textContent="",t.textContent="",o.loadingChats){e.appendChild(a("div","kp-full-page-empty",n.loadingChats));return}let l=o.chats.filter(u=>o.chatSearchTerm?u.title.toLowerCase().includes(o.chatSearchTerm):!0);if(l.length>0){let u=l.filter(f=>f.pinned),g=l.filter(f=>!f.pinned).slice(0,8);ft(e,g,o.chatId,n,i,s,d,p),ft(t,u,o.chatId,n,i,s,d,p),g.length===0&&e.appendChild(a("div","kp-full-page-empty",n.noRecentChats)),u.length===0&&t.appendChild(a("div","kp-full-page-empty",n.noPinnedChats));return}e.appendChild(a("div","kp-full-page-empty",n.noChats)),t.appendChild(a("div","kp-full-page-empty",n.noPinnedChats))}function ft(e,t,o,n,i,s,d,p){for(let l of t){let u=a("div",`kp-full-page-item kp-full-page-chat-item${l.chatId===o?" active":""}`),g=a("span","kp-full-page-item-title",l.title),f=a("div","kp-chat-actions"),m=a("button","kp-chat-actions-trigger","\u22EF");m.type="button",m.setAttribute("aria-label",n.chatActions);let y=a("div","kp-chat-actions-menu"),b=a("button","kp-chat-actions-item",l.pinned?n.unpinChat:n.pinChat);b.type="button",b.addEventListener("click",async k=>{k.stopPropagation(),await s(l)});let x=a("button","kp-chat-actions-item",n.renameChat);x.type="button",x.addEventListener("click",async k=>{k.stopPropagation(),await d(l)});let v=a("button","kp-chat-actions-item",n.deleteChat);v.type="button",v.addEventListener("click",async k=>{k.stopPropagation(),await p(l)}),y.append(b,x,v),f.append(m,y),m.addEventListener("click",k=>{k.stopPropagation();let $=f.classList.contains("open");for(let C of Array.from(e.querySelectorAll(".kp-chat-actions.open")))C.classList.remove("open");for(let C of Array.from(e.querySelectorAll(".kp-full-page-chat-item.menu-open")))C.classList.remove("menu-open");$||(f.classList.add("open"),u.classList.add("menu-open"))}),u.append(g,f),u.setAttribute("role","button"),u.tabIndex=0,u.addEventListener("click",async()=>{await i(l)}),u.addEventListener("keydown",async k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),await i(l))}),u.addEventListener("blur",()=>{f.classList.remove("open"),u.classList.remove("menu-open")}),e.appendChild(u)}}function Jt(e,t){return e.trim().slice(0,60)||t}function Ce(e){return e.toLowerCase().split("-")[0]||"en"}function Qt(e){let t=dt.en;return dt[Ce(e)]??t}function Gt(e){return["ar","fa","he","ur"].includes(Ce(e))}function Zt(e){let t=e.split(/\s+/).filter(Boolean).slice(0,2);return t.length===0?"U":t.map(o=>o[0]?.toUpperCase()??"").join("")}function mt(e){return e.knowledgeName?.trim()||e.sourceDocument?.trim()||null}function en(e,t){let o=tn(e);return{displayText:o.displayText,citations:t.length>0?an(t,o.citations):o.citations}}function tn(e){let o=kt(e).split(`
1377
- `),n=-1;for(let l=0;l<o.length;l+=1)/^#{0,6}\s*References\s*$/i.test(o[l]?.trim()??"")&&(n=l);if(n===-1)return{displayText:e,citations:[]};let i=o.slice(0,n).join(`
1378
- `).trimEnd(),s=o.slice(n+1).join(`
1379
- `).trim(),p=nn(s).map(l=>on(l)).filter(l=>!!l);return{displayText:i,citations:p}}function nn(e){let t=[],o="";for(let n of e.split(`
1380
- `)){let i=n.trim();if(i){if(/^\d+\.\s+/.test(i)){o&&t.push(o.trim()),o=i.replace(/^\d+\.\s+/,"");continue}o&&(o=`${o} ${i}`)}}return o&&t.push(o.trim()),t}function on(e){let t=e.match(/https?:\/\/\S+/i);if(!t)return null;let o=t[0],n=e.slice(0,t.index).replace(/[.\s]+$/,"").trim();return{sourceDocument:o,knowledgeName:n||o}}function an(e,t){let o=[],n=new Set;for(let i of[...e,...t]){let s=`${i.knowledgeName??""}::${i.sourceDocument??""}`;n.has(s)||(n.add(s),o.push(i))}return o}function sn(e,t){let o=a("button","kp-source-chip");o.type="button",o.setAttribute("aria-label",t.openSource);let n=a("span","kp-source-thumb");n.textContent="\u2726";let i=a("span","kp-source-chip-label",mt(e)??t.untitledSource);return o.append(n,i),o}function rn(e){let t=a("button","kp-source-chip kp-source-chip-more");t.type="button";let o=a("span","kp-source-thumb-stack");for(let i=0;i<3;i+=1){let s=a("span","kp-source-thumb stacked");s.textContent="\u2726",o.appendChild(s)}let n=a("span","kp-source-chip-label",e.showAll);return t.append(o,n),t}function pn(e,t){let o=a("button","kp-source-card");o.type="button",o.setAttribute("aria-label",t.openSource),o.addEventListener("click",()=>{bt(e,t)});let n=a("div","kp-source-card-media"),i=a("span","kp-source-thumb kp-source-thumb-large");i.textContent="\u2726";let s=a("div","kp-source-card-title",mt(e)??t.untitledSource),d=a("div","kp-source-card-meta"),p=[];return typeof e.score=="number"&&p.push(`${t.sourceScore}: ${e.score.toFixed(2)}`),typeof e.pageNumber=="number"&&p.push(`${t.sourcePage}: ${e.pageNumber}`),e.sheetName&&p.push(`${t.sourceSheet}: ${e.sheetName}`),typeof e.rowNumber=="number"&&p.push(`${t.sourceRow}: ${e.rowNumber}`),e.knowledgeName&&p.push(`${t.sourceKnowledge}: ${e.knowledgeName}`),d.textContent=p.join(" \u2022 "),n.appendChild(i),o.append(n,s,d),o}function bt(e,t){let o=e.sourceDocument?.trim()||e.knowledgeName?.trim()||t.untitledSource,n=ln(e.sourceDocument);if(n){window.open(n,"_blank","noopener,noreferrer");return}let i=window.open("","_blank","noopener,noreferrer");if(!i)return;let s=Q(o),d=cn(e,t).map(p=>`<li>${Q(p)}</li>`).join("");i.document.write(`<!doctype html>
1381
- <html lang="en">
1382
- <head>
1383
- <meta charset="utf-8">
1384
- <title>${s}</title>
1385
- <style>
1386
- body { font-family: Arial, sans-serif; margin: 32px; color: #1f2937; }
1387
- .card { max-width: 720px; padding: 24px; border: 1px solid #dbe4ee; border-radius: 16px; background: #fff; }
1388
- h1 { margin: 0 0 12px; font-size: 24px; }
1389
- p { margin: 0 0 16px; color: #64748b; }
1390
- ul { margin: 0; padding-left: 20px; }
1391
- </style>
1392
- </head>
1393
- <body>
1394
- <div class="card">
1395
- <h1>${s}</h1>
1396
- <p>${Q(t.documentsAndReferences)}</p>
1397
- <ul>${d||`<li>${Q(t.noSources)}</li>`}</ul>
1398
- </div>
1399
- </body>
1400
- </html>`),i.document.close()}function ln(e){if(!e)return null;let t=e.trim();return/^https?:\/\//i.test(t)?t:null}function cn(e,t){let o=[];return e.sourceDocument&&o.push(e.sourceDocument),typeof e.score=="number"&&o.push(`${t.sourceScore}: ${e.score.toFixed(2)}`),typeof e.pageNumber=="number"&&o.push(`${t.sourcePage}: ${e.pageNumber}`),e.sheetName&&o.push(`${t.sourceSheet}: ${e.sheetName}`),typeof e.rowNumber=="number"&&o.push(`${t.sourceRow}: ${e.rowNumber}`),e.knowledgeName&&o.push(`${t.sourceKnowledge}: ${e.knowledgeName}`),o}function dn(e,t){e.innerHTML=un(kt(t))}function kt(e){return e.replace(/\r\n/g,`
1401
- `).replace(/<br\s*\/?>/gi,`
1402
- `)}function un(e){return e.split(/\n{2,}/).map(o=>o.trim()).filter(Boolean).map(gn).join("")}function gn(e){let t=e.split(`
1403
- `).map(n=>n.trimEnd());if(t.every(n=>/^\s*\|.*\|\s*$/.test(n))&&t.length>=2)return fn(t);if(t.every(n=>/^\d+\.\s+/.test(n)))return`<ol>${t.map(n=>`<li>${D(n.replace(/^\d+\.\s+/,""))}</li>`).join("")}</ol>`;if(t.every(n=>/^[-*]\s+/.test(n)))return`<ul>${t.map(n=>`<li>${D(n.replace(/^[-*]\s+/,""))}</li>`).join("")}</ul>`;let o=t[0]?.match(/^(#{1,6})\s+(.*)$/);if(o){let n=o[1]??"#",i=o[2]??"",s=n.length;return`<h${s}>${D(i)}</h${s}>`}return`<p>${t.map(n=>D(n)).join("<br>")}</p>`}function fn(e){let t=e.filter((d,p)=>!(p===1&&/^\s*\|?(\s*:?-{3,}:?\s*\|)+\s*$/.test(d))).map(d=>hn(d));if(t.length===0)return"";let o=t[0]??[],n=t.slice(1),i=`<thead><tr>${o.map(d=>`<th>${D(d)}</th>`).join("")}</tr></thead>`,s=n.length?`<tbody>${n.map(d=>`<tr>${d.map(p=>`<td>${D(p)}</td>`).join("")}</tr>`).join("")}</tbody>`:"";return`<div class="kp-table-wrap"><table>${i}${s}</table></div>`}function hn(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim())}function D(e){let t=Q(e);return t=t.replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>'),t=t.replace(/`([^`]+)`/g,"<code>$1</code>"),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*([^*]+)\*/g,"<em>$1</em>"),t}function Q(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}export{En as a};
1404
- //# sourceMappingURL=chunk-IFIILMOK.js.map