@nabeh/chat-widget 0.1.1 → 0.1.3
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.
- package/README.md +57 -0
- package/dist/browser.cjs +644 -56
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.iife.js +644 -56
- package/dist/browser.iife.js.map +1 -1
- package/dist/browser.js +1 -1
- package/dist/chunk-LET2O6EB.js +1460 -0
- package/dist/chunk-LET2O6EB.js.map +1 -0
- package/dist/index.cjs +644 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.iife.js +644 -56
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-T4LQIVBI.js +0 -872
- package/dist/chunk-T4LQIVBI.js.map +0 -1
package/dist/index.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ChatWidget=(()=>{var
|
|
1
|
+
"use strict";var ChatWidget=(()=>{var ve=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var Jt=Object.prototype.hasOwnProperty;var Gt=(e,t)=>{for(var a in t)ve(e,a,{get:t[a],enumerable:!0})},Qt=(e,t,a,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Yt(t))!Jt.call(e,i)&&i!==a&&ve(e,i,{get:()=>t[i],enumerable:!(n=Xt(t,i))||n.enumerable});return e};var Zt=e=>Qt(ve({},"__esModule",{value:!0}),e);var Pn={};Gt(Pn,{createChatWidget:()=>kt});function at(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ce(e,t){let a={...e};for(let n of Object.keys(t)){let i=t[n],l=a[n];if(at(l)&&at(i)){a[n]=Ce(l,i);continue}i!==void 0&&(a[n]=i)}return a}function ot(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error("Unexpected widget error")}function J(e,t){return`${e.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}function D(e,t,a){return{"Content-Type":"application/json",...e.customHeaders,...a?{"X-Chat-User-Context":a}:{},...t?{Authorization:`Bearer ${t}`}:{}}}async function q(e){if(!e.getUserContext)return null;let t=await e.getUserContext();return t?JSON.stringify(t):null}function pe(e,t,a={}){let n=t.replace(/\{chatId\}/g,encodeURIComponent(a.chatId??"")).replace(/:chatId\b/g,encodeURIComponent(a.chatId??""));return J(e.apiBaseUrl,n)}async function st(e,t){let a=e.getAccessToken?await e.getAccessToken():null,n=await q(e),i=pe(e,e.endpoints.ask,{chatId:t.chatId}),s=/(\{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:D(e,a,n),body:JSON.stringify(s)});if(!p.ok)throw new Error(`Chat backend returned ${p.status}.`);let c=await p.json();if(!Array.isArray(c)){if(!c.answer||typeof c.answer!="string")throw new Error("Chat backend response is missing a valid answer.");return{chatId:c.chatId??t.chatId,answer:c.answer,suggestions:c.suggestions??[],citations:c.citations??[]}}let u=c[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??[],h=g?.scores??[],w=g?.page_numbers??[],L=g?.sheet_names??[],b=g?.row_numbers??[],y=g?.knowledge_names??[],k=f.map((H,v)=>({sourceDocument:H,score:h[v]??null,pageNumber:w[v]??null,sheetName:L[v]??null,rowNumber:b[v]??null,knowledgeName:y[v]??null}));return{chatId:t.chatId,answer:u.answer,suggestions:[],citations:k}}async function rt(e,t){if(!e.endpoints.history)return[];let a=e.getAccessToken?await e.getAccessToken():null,n=await q(e),l=/(\{chatId\}|:chatId\b)/.test(e.endpoints.history)?pe(e,e.endpoints.history,{chatId:t}):(()=>{let u=new URL(J(e.apiBaseUrl,e.endpoints.history));return u.searchParams.set("chat_id",t),u.toString()})(),s=await fetch(l,{method:"GET",headers:D(e,a,n)});if(!s.ok)throw new Error(`Chat history endpoint returned ${s.status}.`);let p=await s.json(),c=Array.isArray(p)?p:p&&typeof p=="object"?p.history??p.messages??p.data??[]:[];return Array.isArray(c)?c.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,h=g.text??g.message??g.content??g.answer;if(typeof h!="string")return null;let w=typeof f=="string"?f.toLowerCase():"assistant";return[{role:w==="user"||w==="human"?"user":"assistant",text:h}]}).flat().filter(u=>!!u):[]}async function it(e){if(!e.endpoints.listChats)return[];let t=e.getAccessToken?await e.getAccessToken():null,a=await q(e),n=await fetch(J(e.apiBaseUrl,e.endpoints.listChats),{method:"GET",headers:D(e,t,a)});if(!n.ok)throw new Error(`Chat list endpoint returned ${n.status}.`);let i=await n.json(),l=Array.isArray(i)?i:i&&typeof i=="object"?i.chats??i.data??i.items??[]:[];return Array.isArray(l)?l.map(s=>{if(!s||typeof s!="object")return null;let p=s,c=p.chatId??p.chat_id??p.id,u=p.title??p.name??p.chatId;if(typeof c!="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,h={chatId:c,title:u,pinned:typeof p.pinned=="boolean"?p.pinned:!1};return g&&(h.createdAt=g),f&&(h.updatedAt=f),h}).filter(s=>!!s):[]}async function lt(e,t,a){let n=e.endpoints.createChat??e.endpoints.listChats;if(!n)return;let i=e.getAccessToken?await e.getAccessToken():null,l=await q(e),s=await fetch(J(e.apiBaseUrl,n),{method:"POST",headers:D(e,i,l),body:JSON.stringify({chatId:t,...a?{title:a}:{}})});if(!s.ok)throw new Error(`Create chat endpoint returned ${s.status}.`)}async function Le(e,t,a){if(!e.endpoints.updateChat)return;let n=e.getAccessToken?await e.getAccessToken():null,i=await q(e),l=pe(e,e.endpoints.updateChat,{chatId:t}),s=await fetch(l,{method:"PATCH",headers:D(e,n,i),body:JSON.stringify(a)});if(!s.ok)throw new Error(`Update chat endpoint returned ${s.status}.`)}async function pt(e,t){if(!e.endpoints.deleteChat)return;let a=e.getAccessToken?await e.getAccessToken():null,n=await q(e),i=pe(e,e.endpoints.deleteChat,{chatId:t}),l=await fetch(i,{method:"DELETE",headers:D(e,a,n)});if(!l.ok)throw new Error(`Delete chat endpoint returned ${l.status}.`)}function B(e,t){let a=ot(t);return e.onError?.(a),a}var Ae={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'},x={displayMode:"widget",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:{},assistantPageUrl:"/knowledge-assistant",embedded:{showHeader:!1},rag:{knowledgeNames:[],enableReferences:!0,loadHistoryOnOpen:!1},theme:Ae,getAccessToken:void 0,getUserContext:void 0,onOpen:void 0,onClose:void 0,onError:void 0,onOpenAssistantPage:void 0};function ct(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,a=Ce(Ae,e.theme??{});return{apiBaseUrl:e.apiBaseUrl,endpoints:{...e.endpoints},mount:t,displayMode:e.displayMode??x.displayMode,position:e.position??x.position,title:e.title??x.title,subtitle:e.subtitle??x.subtitle,welcomeMessage:e.welcomeMessage??x.welcomeMessage,inputPlaceholder:e.inputPlaceholder??x.inputPlaceholder,launcherAriaLabel:e.launcherAriaLabel??x.launcherAriaLabel,closeAriaLabel:e.closeAriaLabel??x.closeAriaLabel,initialSuggestions:e.initialSuggestions??x.initialSuggestions,sourceApp:e.sourceApp??x.sourceApp,locale:e.locale??x.locale,customHeaders:e.customHeaders??x.customHeaders,embedded:{...x.embedded,...e.embedded??{}},rag:{...x.rag,...e.rag??{}},assistantPageUrl:e.assistantPageUrl??x.assistantPageUrl,theme:a,getAccessToken:e.getAccessToken,getUserContext:e.getUserContext,onOpen:e.onOpen,onClose:e.onClose,onError:e.onError,onOpenAssistantPage:e.onOpenAssistantPage}}function o(e,t,a){let n=document.createElement(e);return t&&(n.className=t),a!==void 0&&(n.textContent=a),n}var dt="kp-chat-widget-styles";function ut(e,t){if(e.getElementById(dt))return;let a=document.createElement("style");a.id=dt,a.textContent=en(t),e.appendChild(a)}function en(e){return`
|
|
2
2
|
:host {
|
|
3
3
|
all: initial;
|
|
4
4
|
}
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
--kp-shadow: ${e.shadow};
|
|
15
15
|
--kp-z-index: ${e.zIndex};
|
|
16
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);
|
|
17
19
|
position: fixed;
|
|
18
20
|
bottom: 24px;
|
|
19
21
|
right: 24px;
|
|
@@ -23,6 +25,15 @@
|
|
|
23
25
|
box-sizing: border-box;
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
.kp-chat-widget.kp-chat-widget-embedded {
|
|
29
|
+
position: relative;
|
|
30
|
+
inset: auto;
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
min-height: 640px;
|
|
34
|
+
display: block;
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
*,
|
|
27
38
|
*::before,
|
|
28
39
|
*::after {
|
|
@@ -35,6 +46,21 @@
|
|
|
35
46
|
right: auto;
|
|
36
47
|
}
|
|
37
48
|
|
|
49
|
+
.kp-chat-widget.kp-chat-widget-embedded.bottom-left {
|
|
50
|
+
left: auto;
|
|
51
|
+
right: auto;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.kp-rtl .kp-dropdown-item,
|
|
55
|
+
.kp-rtl .kp-suggestion,
|
|
56
|
+
.kp-rtl .kp-input,
|
|
57
|
+
.kp-rtl .kp-full-page-search-input,
|
|
58
|
+
.kp-rtl .kp-bubble-content,
|
|
59
|
+
.kp-rtl .kp-source-card,
|
|
60
|
+
.kp-rtl .kp-source-panel {
|
|
61
|
+
text-align: right;
|
|
62
|
+
}
|
|
63
|
+
|
|
38
64
|
.kp-launcher {
|
|
39
65
|
width: 72px;
|
|
40
66
|
height: 72px;
|
|
@@ -64,9 +90,11 @@
|
|
|
64
90
|
.kp-input:focus-visible,
|
|
65
91
|
.kp-full-page-new-chat:focus-visible,
|
|
66
92
|
.kp-full-page-close:focus-visible,
|
|
67
|
-
.kp-full-page-search-input:focus-visible,
|
|
68
93
|
.kp-full-page-chat-item:focus-visible,
|
|
69
|
-
.kp-chat-pin:focus-visible
|
|
94
|
+
.kp-chat-pin:focus-visible,
|
|
95
|
+
.kp-message-action:focus-visible,
|
|
96
|
+
.kp-source-chip:focus-visible,
|
|
97
|
+
.kp-source-panel-close:focus-visible {
|
|
70
98
|
outline: 2px solid var(--kp-accent);
|
|
71
99
|
outline-offset: 2px;
|
|
72
100
|
}
|
|
@@ -139,12 +167,11 @@
|
|
|
139
167
|
position: fixed;
|
|
140
168
|
bottom: 88px;
|
|
141
169
|
right: 24px;
|
|
142
|
-
width: 480px;
|
|
143
|
-
max-width: calc(100vw - 24px);
|
|
170
|
+
width: min(480px, calc(100vw - 48px));
|
|
144
171
|
height: min(730px, calc(100vh - 118px));
|
|
145
172
|
background: var(--kp-panel-background);
|
|
146
173
|
border: 1px solid rgba(255, 255, 255, 0.35);
|
|
147
|
-
border-radius:
|
|
174
|
+
border-radius: 24px;
|
|
148
175
|
box-shadow: var(--kp-shadow);
|
|
149
176
|
overflow: hidden;
|
|
150
177
|
display: flex;
|
|
@@ -173,9 +200,7 @@
|
|
|
173
200
|
.kp-full-page {
|
|
174
201
|
position: fixed;
|
|
175
202
|
inset: 0;
|
|
176
|
-
background:
|
|
177
|
-
radial-gradient(circle at top, rgba(32, 185, 210, 0.12), transparent 24%),
|
|
178
|
-
linear-gradient(180deg, #f9fbfd 0%, #eef3f8 100%);
|
|
203
|
+
background: #ffffff;
|
|
179
204
|
opacity: 0;
|
|
180
205
|
pointer-events: none;
|
|
181
206
|
transform: translateY(18px);
|
|
@@ -184,6 +209,18 @@
|
|
|
184
209
|
overflow: hidden;
|
|
185
210
|
}
|
|
186
211
|
|
|
212
|
+
.kp-full-page.kp-full-page-embedded {
|
|
213
|
+
position: relative;
|
|
214
|
+
inset: auto;
|
|
215
|
+
opacity: 1;
|
|
216
|
+
pointer-events: auto;
|
|
217
|
+
transform: none;
|
|
218
|
+
min-height: 100%;
|
|
219
|
+
height: 100%;
|
|
220
|
+
z-index: auto;
|
|
221
|
+
background: transparent;
|
|
222
|
+
}
|
|
223
|
+
|
|
187
224
|
.kp-full-page.open {
|
|
188
225
|
opacity: 1;
|
|
189
226
|
pointer-events: auto;
|
|
@@ -194,20 +231,31 @@
|
|
|
194
231
|
height: 100vh;
|
|
195
232
|
display: flex;
|
|
196
233
|
flex-direction: column;
|
|
197
|
-
padding: 22px
|
|
234
|
+
padding: 22px 28px 26px;
|
|
198
235
|
gap: 16px;
|
|
199
236
|
overflow: hidden;
|
|
200
237
|
}
|
|
201
238
|
|
|
239
|
+
.kp-full-page-embedded .kp-full-page-shell {
|
|
240
|
+
height: 100%;
|
|
241
|
+
min-height: 100%;
|
|
242
|
+
padding: 0;
|
|
243
|
+
gap: 12px;
|
|
244
|
+
}
|
|
245
|
+
|
|
202
246
|
.kp-full-page-header {
|
|
203
247
|
display: flex;
|
|
204
248
|
align-items: center;
|
|
205
249
|
justify-content: space-between;
|
|
206
250
|
gap: 16px;
|
|
207
|
-
padding:
|
|
251
|
+
padding: 8px 4px 0;
|
|
208
252
|
flex: none;
|
|
209
253
|
}
|
|
210
254
|
|
|
255
|
+
.kp-hidden {
|
|
256
|
+
display: none !important;
|
|
257
|
+
}
|
|
258
|
+
|
|
211
259
|
.kp-full-page-brand {
|
|
212
260
|
display: flex;
|
|
213
261
|
align-items: center;
|
|
@@ -251,39 +299,38 @@
|
|
|
251
299
|
box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
|
|
252
300
|
}
|
|
253
301
|
|
|
254
|
-
.kp-full-page-close
|
|
255
|
-
|
|
256
|
-
|
|
302
|
+
.kp-full-page-close,
|
|
303
|
+
.kp-source-panel-close {
|
|
304
|
+
width: 40px;
|
|
305
|
+
height: 40px;
|
|
257
306
|
border: none;
|
|
258
307
|
border-radius: 14px;
|
|
259
308
|
background: rgba(255, 255, 255, 0.82);
|
|
260
309
|
color: #61788a;
|
|
261
|
-
font-size:
|
|
310
|
+
font-size: 24px;
|
|
262
311
|
line-height: 1;
|
|
263
312
|
cursor: pointer;
|
|
264
313
|
box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
|
|
265
314
|
}
|
|
266
315
|
|
|
267
|
-
.kp-full-page-breadcrumb {
|
|
268
|
-
padding: 0 4px;
|
|
269
|
-
color: #8192a0;
|
|
270
|
-
font-size: 13px;
|
|
271
|
-
line-height: 1.5;
|
|
272
|
-
flex: none;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
316
|
.kp-full-page-content {
|
|
276
317
|
display: grid;
|
|
277
|
-
grid-template-columns: 290px minmax(0, 1fr);
|
|
318
|
+
grid-template-columns: 290px minmax(0, 1fr) minmax(0, 0);
|
|
278
319
|
gap: 16px;
|
|
279
320
|
flex: 1;
|
|
280
321
|
min-height: 0;
|
|
281
322
|
overflow: hidden;
|
|
323
|
+
align-items: stretch;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.kp-full-page-embedded .kp-full-page-content {
|
|
327
|
+
height: 100%;
|
|
282
328
|
}
|
|
283
329
|
|
|
284
330
|
.kp-full-page-sidebar,
|
|
285
|
-
.kp-full-page-panel
|
|
286
|
-
|
|
331
|
+
.kp-full-page-panel,
|
|
332
|
+
.kp-source-panel {
|
|
333
|
+
border-radius: 24px;
|
|
287
334
|
border: 1px solid rgba(219, 228, 238, 0.9);
|
|
288
335
|
background: rgba(255, 255, 255, 0.88);
|
|
289
336
|
box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
|
|
@@ -331,6 +378,15 @@
|
|
|
331
378
|
color: #334155;
|
|
332
379
|
font-size: 14px;
|
|
333
380
|
min-width: 0;
|
|
381
|
+
box-shadow: none;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.kp-full-page-search-input:focus,
|
|
385
|
+
.kp-full-page-search-input:focus-visible,
|
|
386
|
+
.kp-full-page-search-input:active {
|
|
387
|
+
outline: none;
|
|
388
|
+
box-shadow: none;
|
|
389
|
+
border: none;
|
|
334
390
|
}
|
|
335
391
|
|
|
336
392
|
.kp-full-page-search-icon {
|
|
@@ -357,7 +413,7 @@
|
|
|
357
413
|
|
|
358
414
|
.kp-full-page-item {
|
|
359
415
|
padding: 12px 12px 13px;
|
|
360
|
-
border-radius:
|
|
416
|
+
border-radius: 14px;
|
|
361
417
|
color: #293845;
|
|
362
418
|
font-size: 15px;
|
|
363
419
|
line-height: 1.5;
|
|
@@ -366,12 +422,14 @@
|
|
|
366
422
|
}
|
|
367
423
|
|
|
368
424
|
.kp-full-page-chat-item {
|
|
425
|
+
position: relative;
|
|
369
426
|
display: flex;
|
|
370
427
|
align-items: center;
|
|
371
428
|
justify-content: space-between;
|
|
372
429
|
gap: 10px;
|
|
373
430
|
cursor: pointer;
|
|
374
431
|
transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
|
|
432
|
+
overflow: visible;
|
|
375
433
|
}
|
|
376
434
|
|
|
377
435
|
.kp-full-page-chat-item:hover {
|
|
@@ -385,6 +443,10 @@
|
|
|
385
443
|
background: rgba(220, 252, 231, 0.72);
|
|
386
444
|
}
|
|
387
445
|
|
|
446
|
+
.kp-full-page-chat-item.menu-open {
|
|
447
|
+
z-index: 4;
|
|
448
|
+
}
|
|
449
|
+
|
|
388
450
|
.kp-full-page-item-title {
|
|
389
451
|
min-width: 0;
|
|
390
452
|
overflow: hidden;
|
|
@@ -411,11 +473,6 @@
|
|
|
411
473
|
line-height: 1.5;
|
|
412
474
|
}
|
|
413
475
|
|
|
414
|
-
.kp-full-page-item-pinned {
|
|
415
|
-
background: rgba(237, 248, 251, 0.92);
|
|
416
|
-
border-color: rgba(127, 208, 217, 0.4);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
476
|
.kp-full-page-main {
|
|
420
477
|
min-width: 0;
|
|
421
478
|
min-height: 0;
|
|
@@ -430,6 +487,112 @@
|
|
|
430
487
|
overflow: hidden;
|
|
431
488
|
}
|
|
432
489
|
|
|
490
|
+
.kp-source-panel {
|
|
491
|
+
min-width: 0;
|
|
492
|
+
min-height: 0;
|
|
493
|
+
overflow: hidden;
|
|
494
|
+
display: none;
|
|
495
|
+
flex-direction: column;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.kp-source-panel.open {
|
|
499
|
+
display: flex;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.kp-full-page-content:has(.kp-source-panel.open) {
|
|
503
|
+
grid-template-columns: 290px minmax(0, 1fr) 320px;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
.kp-source-panel-header {
|
|
507
|
+
display: flex;
|
|
508
|
+
align-items: flex-start;
|
|
509
|
+
justify-content: space-between;
|
|
510
|
+
gap: 12px;
|
|
511
|
+
padding: 18px 18px 12px;
|
|
512
|
+
border-bottom: 1px solid rgba(219, 228, 238, 0.7);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
.kp-source-panel-title {
|
|
516
|
+
font-size: 17px;
|
|
517
|
+
font-weight: 700;
|
|
518
|
+
color: #16394b;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
.kp-source-panel-subtitle {
|
|
522
|
+
margin-top: 4px;
|
|
523
|
+
font-size: 12px;
|
|
524
|
+
color: #7a8a99;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.kp-source-panel-list {
|
|
528
|
+
display: flex;
|
|
529
|
+
flex-direction: column;
|
|
530
|
+
gap: 12px;
|
|
531
|
+
padding: 16px;
|
|
532
|
+
overflow: auto;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.kp-source-panel-empty {
|
|
536
|
+
color: #7a8a99;
|
|
537
|
+
font-size: 14px;
|
|
538
|
+
line-height: 1.5;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.kp-source-card {
|
|
542
|
+
width: 100%;
|
|
543
|
+
text-align: left;
|
|
544
|
+
cursor: pointer;
|
|
545
|
+
appearance: none;
|
|
546
|
+
border: 1px solid rgba(219, 228, 238, 0.9);
|
|
547
|
+
border-radius: 16px;
|
|
548
|
+
background: #ffffff;
|
|
549
|
+
padding: 14px;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.kp-source-card-media {
|
|
553
|
+
display: flex;
|
|
554
|
+
align-items: center;
|
|
555
|
+
margin-bottom: 10px;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
.kp-source-thumb,
|
|
559
|
+
.kp-source-thumb-large {
|
|
560
|
+
flex: none;
|
|
561
|
+
width: 32px;
|
|
562
|
+
height: 32px;
|
|
563
|
+
border-radius: 999px;
|
|
564
|
+
display: inline-flex;
|
|
565
|
+
align-items: center;
|
|
566
|
+
justify-content: center;
|
|
567
|
+
background: linear-gradient(180deg, #eefcf8 0%, #dff7f2 100%);
|
|
568
|
+
border: 1px solid rgba(15, 118, 110, 0.18);
|
|
569
|
+
color: #0f6a75;
|
|
570
|
+
font-size: 14px;
|
|
571
|
+
line-height: 1;
|
|
572
|
+
box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
.kp-source-thumb-large {
|
|
576
|
+
width: 42px;
|
|
577
|
+
height: 42px;
|
|
578
|
+
font-size: 18px;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
.kp-source-card-title {
|
|
582
|
+
font-size: 14px;
|
|
583
|
+
font-weight: 700;
|
|
584
|
+
color: #16394b;
|
|
585
|
+
word-break: break-word;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.kp-source-card-meta {
|
|
589
|
+
margin-top: 8px;
|
|
590
|
+
font-size: 12px;
|
|
591
|
+
line-height: 1.5;
|
|
592
|
+
color: #667a8d;
|
|
593
|
+
word-break: break-word;
|
|
594
|
+
}
|
|
595
|
+
|
|
433
596
|
.kp-full-page-body {
|
|
434
597
|
flex: 1;
|
|
435
598
|
overflow: auto;
|
|
@@ -437,9 +600,7 @@
|
|
|
437
600
|
flex-direction: column;
|
|
438
601
|
gap: 14px;
|
|
439
602
|
padding: 42px 28px 18px;
|
|
440
|
-
background:
|
|
441
|
-
radial-gradient(circle at top, rgba(54, 196, 220, 0.14), transparent 22%),
|
|
442
|
-
linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
|
|
603
|
+
background: #ffffff;
|
|
443
604
|
scroll-behavior: smooth;
|
|
444
605
|
}
|
|
445
606
|
|
|
@@ -588,7 +749,7 @@
|
|
|
588
749
|
position: absolute;
|
|
589
750
|
top: 44px;
|
|
590
751
|
left: 0;
|
|
591
|
-
width:
|
|
752
|
+
width: 184px;
|
|
592
753
|
background: #ffffff;
|
|
593
754
|
border: 1px solid rgba(15, 79, 104, 0.12);
|
|
594
755
|
border-radius: 10px;
|
|
@@ -601,6 +762,11 @@
|
|
|
601
762
|
z-index: 2;
|
|
602
763
|
}
|
|
603
764
|
|
|
765
|
+
.kp-rtl .kp-dropdown {
|
|
766
|
+
left: auto;
|
|
767
|
+
right: 0;
|
|
768
|
+
}
|
|
769
|
+
|
|
604
770
|
.kp-dropdown.open {
|
|
605
771
|
opacity: 1;
|
|
606
772
|
transform: translateY(0);
|
|
@@ -652,6 +818,127 @@
|
|
|
652
818
|
padding-top: 16px;
|
|
653
819
|
}
|
|
654
820
|
|
|
821
|
+
.kp-panel.kp-sheet-open .kp-body,
|
|
822
|
+
.kp-panel.kp-sheet-open .kp-footer,
|
|
823
|
+
.kp-panel.kp-sheet-open .kp-header {
|
|
824
|
+
opacity: 0;
|
|
825
|
+
pointer-events: none;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
.kp-my-chats-sheet {
|
|
829
|
+
position: absolute;
|
|
830
|
+
inset: 0;
|
|
831
|
+
border-radius: inherit;
|
|
832
|
+
border: none;
|
|
833
|
+
background: #ffffff;
|
|
834
|
+
box-shadow: none;
|
|
835
|
+
display: none;
|
|
836
|
+
flex-direction: column;
|
|
837
|
+
z-index: 3;
|
|
838
|
+
overflow: hidden;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
.kp-my-chats-sheet.open {
|
|
842
|
+
display: flex;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
.kp-my-chats-header {
|
|
846
|
+
display: flex;
|
|
847
|
+
align-items: center;
|
|
848
|
+
justify-content: space-between;
|
|
849
|
+
padding: 18px 18px 10px;
|
|
850
|
+
flex: none;
|
|
851
|
+
background: #ffffff;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
.kp-my-chats-nav {
|
|
855
|
+
width: 36px;
|
|
856
|
+
height: 36px;
|
|
857
|
+
border: none;
|
|
858
|
+
border-radius: 999px;
|
|
859
|
+
background: transparent;
|
|
860
|
+
color: #61788a;
|
|
861
|
+
font-size: 22px;
|
|
862
|
+
line-height: 1;
|
|
863
|
+
cursor: pointer;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
.kp-my-chats-body {
|
|
867
|
+
flex: 1;
|
|
868
|
+
overflow: auto;
|
|
869
|
+
padding: 8px 18px 18px;
|
|
870
|
+
background: #ffffff;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
.kp-my-chats-section-label {
|
|
874
|
+
font-size: 14px;
|
|
875
|
+
line-height: 1.5;
|
|
876
|
+
color: #7a8a99;
|
|
877
|
+
margin: 14px 0 10px;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
.kp-my-chats-list {
|
|
881
|
+
display: flex;
|
|
882
|
+
flex-direction: column;
|
|
883
|
+
gap: 10px;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
.kp-chat-actions {
|
|
887
|
+
position: relative;
|
|
888
|
+
flex: none;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
.kp-chat-actions-trigger {
|
|
892
|
+
width: 28px;
|
|
893
|
+
height: 28px;
|
|
894
|
+
border: none;
|
|
895
|
+
border-radius: 999px;
|
|
896
|
+
background: transparent;
|
|
897
|
+
color: #526678;
|
|
898
|
+
font-size: 20px;
|
|
899
|
+
line-height: 1;
|
|
900
|
+
cursor: pointer;
|
|
901
|
+
display: inline-flex;
|
|
902
|
+
align-items: center;
|
|
903
|
+
justify-content: center;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
.kp-chat-actions-menu {
|
|
907
|
+
position: absolute;
|
|
908
|
+
top: 30px;
|
|
909
|
+
inset-inline-end: 0;
|
|
910
|
+
width: 120px;
|
|
911
|
+
padding: 8px;
|
|
912
|
+
border-radius: 10px;
|
|
913
|
+
border: 1px solid rgba(219, 228, 238, 0.95);
|
|
914
|
+
background: #ffffff;
|
|
915
|
+
box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
|
|
916
|
+
display: none;
|
|
917
|
+
flex-direction: column;
|
|
918
|
+
gap: 2px;
|
|
919
|
+
z-index: 20;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
.kp-chat-actions.open .kp-chat-actions-menu {
|
|
923
|
+
display: flex;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
.kp-chat-actions-item {
|
|
927
|
+
width: 100%;
|
|
928
|
+
border: none;
|
|
929
|
+
background: transparent;
|
|
930
|
+
color: #1f2937;
|
|
931
|
+
text-align: left;
|
|
932
|
+
padding: 10px 12px;
|
|
933
|
+
border-radius: 8px;
|
|
934
|
+
font-size: 14px;
|
|
935
|
+
cursor: pointer;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
.kp-chat-actions-item:hover {
|
|
939
|
+
background: rgba(241, 245, 249, 0.95);
|
|
940
|
+
}
|
|
941
|
+
|
|
655
942
|
.kp-hero {
|
|
656
943
|
display: flex;
|
|
657
944
|
gap: 10px;
|
|
@@ -673,32 +960,245 @@
|
|
|
673
960
|
color: #374151;
|
|
674
961
|
}
|
|
675
962
|
|
|
963
|
+
.kp-message-row {
|
|
964
|
+
display: flex;
|
|
965
|
+
align-items: flex-start;
|
|
966
|
+
gap: 10px;
|
|
967
|
+
width: 100%;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
.kp-message-row.user {
|
|
971
|
+
justify-content: flex-end;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
.kp-avatar {
|
|
975
|
+
flex: none;
|
|
976
|
+
width: 36px;
|
|
977
|
+
height: 36px;
|
|
978
|
+
border-radius: 999px;
|
|
979
|
+
display: flex;
|
|
980
|
+
align-items: center;
|
|
981
|
+
justify-content: center;
|
|
982
|
+
font-size: 13px;
|
|
983
|
+
font-weight: 700;
|
|
984
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
.kp-avatar.bot {
|
|
988
|
+
background: linear-gradient(180deg, #e8fbff 0%, #dff7f2 100%);
|
|
989
|
+
color: #0f6a75;
|
|
990
|
+
border: 1px solid rgba(15, 118, 110, 0.16);
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
.kp-avatar.user {
|
|
994
|
+
background: linear-gradient(180deg, #fff4ee 0%, #fbe3d5 100%);
|
|
995
|
+
color: #8c4b1f;
|
|
996
|
+
border: 1px solid rgba(180, 102, 43, 0.16);
|
|
997
|
+
}
|
|
998
|
+
|
|
676
999
|
.kp-bubble {
|
|
677
|
-
max-width: 85
|
|
678
|
-
padding:
|
|
679
|
-
border-radius:
|
|
1000
|
+
max-width: min(85%, 720px);
|
|
1001
|
+
padding: 14px 16px;
|
|
1002
|
+
border-radius: 20px;
|
|
680
1003
|
font-size: 14px;
|
|
681
|
-
line-height: 1.
|
|
682
|
-
white-space: pre-wrap;
|
|
1004
|
+
line-height: 1.65;
|
|
683
1005
|
border: 1px solid var(--kp-border-color);
|
|
684
1006
|
background: #ffffff;
|
|
1007
|
+
box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
|
|
685
1008
|
}
|
|
686
1009
|
|
|
687
1010
|
.kp-bubble.user {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
border-color: rgba(15, 118, 110, 0.22);
|
|
1011
|
+
background: linear-gradient(180deg, #fff8f3 0%, #fdf1e8 100%);
|
|
1012
|
+
border-color: rgba(222, 184, 135, 0.34);
|
|
691
1013
|
}
|
|
692
1014
|
|
|
693
1015
|
.kp-bubble.bot {
|
|
694
|
-
|
|
1016
|
+
background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
.kp-bubble-content {
|
|
1020
|
+
color: var(--kp-text);
|
|
1021
|
+
white-space: normal;
|
|
1022
|
+
word-break: break-word;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
.kp-bubble-content p,
|
|
1026
|
+
.kp-bubble-content ul,
|
|
1027
|
+
.kp-bubble-content ol,
|
|
1028
|
+
.kp-bubble-content table,
|
|
1029
|
+
.kp-bubble-content blockquote {
|
|
1030
|
+
margin: 0;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
.kp-bubble-content p + p,
|
|
1034
|
+
.kp-bubble-content p + ul,
|
|
1035
|
+
.kp-bubble-content p + ol,
|
|
1036
|
+
.kp-bubble-content ul + p,
|
|
1037
|
+
.kp-bubble-content ol + p,
|
|
1038
|
+
.kp-bubble-content .kp-table-wrap + p,
|
|
1039
|
+
.kp-bubble-content p + .kp-table-wrap,
|
|
1040
|
+
.kp-bubble-content h1 + p,
|
|
1041
|
+
.kp-bubble-content h2 + p,
|
|
1042
|
+
.kp-bubble-content h3 + p {
|
|
1043
|
+
margin-top: 12px;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
.kp-bubble-content h1,
|
|
1047
|
+
.kp-bubble-content h2,
|
|
1048
|
+
.kp-bubble-content h3,
|
|
1049
|
+
.kp-bubble-content h4,
|
|
1050
|
+
.kp-bubble-content h5,
|
|
1051
|
+
.kp-bubble-content h6 {
|
|
1052
|
+
margin: 0 0 10px;
|
|
1053
|
+
font-size: 16px;
|
|
1054
|
+
line-height: 1.4;
|
|
1055
|
+
color: #16394b;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
.kp-bubble-content ul,
|
|
1059
|
+
.kp-bubble-content ol {
|
|
1060
|
+
padding-inline-start: 20px;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
.kp-bubble-content code {
|
|
1064
|
+
padding: 2px 6px;
|
|
1065
|
+
border-radius: 8px;
|
|
1066
|
+
background: rgba(226, 232, 240, 0.66);
|
|
1067
|
+
font-size: 0.92em;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
.kp-bubble-content a {
|
|
1071
|
+
color: #0f6a75;
|
|
1072
|
+
text-decoration: underline;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
.kp-table-wrap {
|
|
1076
|
+
overflow-x: auto;
|
|
1077
|
+
margin-top: 8px;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
.kp-bubble-content table {
|
|
1081
|
+
width: 100%;
|
|
1082
|
+
border-collapse: collapse;
|
|
1083
|
+
border: 1px solid rgba(203, 213, 225, 0.95);
|
|
1084
|
+
border-radius: 14px;
|
|
1085
|
+
overflow: hidden;
|
|
1086
|
+
background: #ffffff;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
.kp-bubble-content th,
|
|
1090
|
+
.kp-bubble-content td {
|
|
1091
|
+
padding: 10px 12px;
|
|
1092
|
+
border-bottom: 1px solid rgba(226, 232, 240, 0.95);
|
|
1093
|
+
border-inline-end: 1px solid rgba(226, 232, 240, 0.95);
|
|
1094
|
+
vertical-align: top;
|
|
1095
|
+
text-align: start;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
.kp-bubble-content tr:last-child td {
|
|
1099
|
+
border-bottom: none;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
.kp-bubble-content th:last-child,
|
|
1103
|
+
.kp-bubble-content td:last-child {
|
|
1104
|
+
border-inline-end: none;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
.kp-bubble-content th {
|
|
1108
|
+
background: #f4fbfc;
|
|
1109
|
+
color: #16394b;
|
|
1110
|
+
font-weight: 700;
|
|
695
1111
|
}
|
|
696
1112
|
|
|
697
1113
|
.kp-meta {
|
|
698
1114
|
font-size: 11px;
|
|
699
1115
|
line-height: 1.4;
|
|
700
1116
|
color: var(--kp-muted-text);
|
|
701
|
-
margin-top:
|
|
1117
|
+
margin-top: 10px;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
.kp-source-preview {
|
|
1121
|
+
margin-top: 10px;
|
|
1122
|
+
padding: 12px;
|
|
1123
|
+
border-radius: 16px;
|
|
1124
|
+
border: 1px solid rgba(219, 228, 238, 0.88);
|
|
1125
|
+
background: #ffffff;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
.kp-source-preview-title {
|
|
1129
|
+
font-size: 12px;
|
|
1130
|
+
font-weight: 700;
|
|
1131
|
+
color: #16394b;
|
|
1132
|
+
margin-bottom: 8px;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
.kp-source-preview-list {
|
|
1136
|
+
display: flex;
|
|
1137
|
+
flex-wrap: nowrap;
|
|
1138
|
+
gap: 8px;
|
|
1139
|
+
overflow-x: auto;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
.kp-source-chip {
|
|
1143
|
+
display: inline-flex;
|
|
1144
|
+
align-items: center;
|
|
1145
|
+
gap: 10px;
|
|
1146
|
+
border: 1px solid rgba(15, 118, 110, 0.16);
|
|
1147
|
+
background: #ffffff;
|
|
1148
|
+
color: #0f4f68;
|
|
1149
|
+
border-radius: 999px;
|
|
1150
|
+
padding: 8px 12px;
|
|
1151
|
+
cursor: pointer;
|
|
1152
|
+
font-size: 12px;
|
|
1153
|
+
line-height: 1.3;
|
|
1154
|
+
max-width: 100%;
|
|
1155
|
+
min-width: 0;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
.kp-source-chip-more {
|
|
1159
|
+
background: rgba(236, 254, 255, 0.9);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
.kp-source-chip-label {
|
|
1163
|
+
min-width: 0;
|
|
1164
|
+
overflow: hidden;
|
|
1165
|
+
text-overflow: ellipsis;
|
|
1166
|
+
white-space: nowrap;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
.kp-source-thumb-stack {
|
|
1170
|
+
display: inline-flex;
|
|
1171
|
+
align-items: center;
|
|
1172
|
+
margin-inline-end: 2px;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
.kp-source-thumb.stacked {
|
|
1176
|
+
margin-inline-end: -10px;
|
|
1177
|
+
background: #ffffff;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
.kp-message-actions {
|
|
1181
|
+
display: flex;
|
|
1182
|
+
align-items: center;
|
|
1183
|
+
gap: 8px;
|
|
1184
|
+
margin-top: 10px;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
.kp-message-action {
|
|
1188
|
+
border: 1px solid rgba(219, 228, 238, 0.9);
|
|
1189
|
+
background: #ffffff;
|
|
1190
|
+
color: #4b6478;
|
|
1191
|
+
border-radius: 999px;
|
|
1192
|
+
padding: 7px 10px;
|
|
1193
|
+
cursor: pointer;
|
|
1194
|
+
font-size: 12px;
|
|
1195
|
+
line-height: 1;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
.kp-message-action.active {
|
|
1199
|
+
color: #0f6a75;
|
|
1200
|
+
border-color: rgba(15, 118, 110, 0.3);
|
|
1201
|
+
background: rgba(236, 254, 255, 0.92);
|
|
702
1202
|
}
|
|
703
1203
|
|
|
704
1204
|
.kp-suggestions {
|
|
@@ -731,11 +1231,15 @@
|
|
|
731
1231
|
align-items: center;
|
|
732
1232
|
gap: 10px;
|
|
733
1233
|
border: 1px solid var(--kp-border-color);
|
|
734
|
-
border-radius:
|
|
1234
|
+
border-radius: 16px;
|
|
735
1235
|
padding: 10px 12px;
|
|
736
1236
|
background: #ffffff;
|
|
737
1237
|
}
|
|
738
1238
|
|
|
1239
|
+
.kp-rtl .kp-form {
|
|
1240
|
+
flex-direction: row-reverse;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
739
1243
|
.kp-input {
|
|
740
1244
|
flex: 1;
|
|
741
1245
|
border: none;
|
|
@@ -770,6 +1274,11 @@
|
|
|
770
1274
|
display: flex;
|
|
771
1275
|
align-items: center;
|
|
772
1276
|
justify-content: center;
|
|
1277
|
+
flex: none;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
.kp-rtl .kp-send {
|
|
1281
|
+
transform: scaleX(-1);
|
|
773
1282
|
}
|
|
774
1283
|
|
|
775
1284
|
.kp-note {
|
|
@@ -787,6 +1296,43 @@
|
|
|
787
1296
|
padding: 4px 2px;
|
|
788
1297
|
}
|
|
789
1298
|
|
|
1299
|
+
@media (max-width: 1100px) {
|
|
1300
|
+
.kp-full-page-content:has(.kp-source-panel.open) {
|
|
1301
|
+
grid-template-columns: 260px minmax(0, 1fr);
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
.kp-source-panel.open {
|
|
1305
|
+
position: absolute;
|
|
1306
|
+
inset-inline-end: 28px;
|
|
1307
|
+
top: 92px;
|
|
1308
|
+
bottom: 26px;
|
|
1309
|
+
width: min(320px, calc(100vw - 56px));
|
|
1310
|
+
z-index: 3;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
@media (max-width: 860px) {
|
|
1315
|
+
.kp-full-page-content,
|
|
1316
|
+
.kp-full-page-content:has(.kp-source-panel.open) {
|
|
1317
|
+
grid-template-columns: 1fr;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
.kp-full-page-sidebar {
|
|
1321
|
+
max-height: 260px;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
.kp-full-page-embedded .kp-full-page-sidebar {
|
|
1325
|
+
max-height: none;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
.kp-source-panel.open {
|
|
1329
|
+
position: static;
|
|
1330
|
+
inset: auto;
|
|
1331
|
+
width: auto;
|
|
1332
|
+
max-height: 280px;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
|
|
790
1336
|
@media (max-width: 640px) {
|
|
791
1337
|
.kp-chat-widget,
|
|
792
1338
|
.kp-chat-widget.bottom-left {
|
|
@@ -795,11 +1341,17 @@
|
|
|
795
1341
|
bottom: 16px;
|
|
796
1342
|
}
|
|
797
1343
|
|
|
1344
|
+
.kp-chat-widget.kp-chat-widget-embedded,
|
|
1345
|
+
.kp-chat-widget.kp-chat-widget-embedded.bottom-left {
|
|
1346
|
+
left: auto;
|
|
1347
|
+
right: auto;
|
|
1348
|
+
bottom: auto;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
798
1351
|
.kp-panel,
|
|
799
1352
|
.kp-chat-widget.bottom-left .kp-panel {
|
|
800
1353
|
inset: 0;
|
|
801
1354
|
width: 100vw;
|
|
802
|
-
max-width: none;
|
|
803
1355
|
height: 100vh;
|
|
804
1356
|
border-radius: 0;
|
|
805
1357
|
transform: translateX(72px) scale(0.985);
|
|
@@ -814,16 +1366,12 @@
|
|
|
814
1366
|
padding: 14px;
|
|
815
1367
|
}
|
|
816
1368
|
|
|
817
|
-
.kp-full-page-
|
|
1369
|
+
.kp-full-page-embedded .kp-full-page-shell {
|
|
818
1370
|
padding: 0;
|
|
819
1371
|
}
|
|
820
1372
|
|
|
821
|
-
.kp-full-page-
|
|
822
|
-
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
.kp-full-page-sidebar {
|
|
826
|
-
order: 2;
|
|
1373
|
+
.kp-full-page-header {
|
|
1374
|
+
padding: 0;
|
|
827
1375
|
}
|
|
828
1376
|
|
|
829
1377
|
.kp-full-page-body {
|
|
@@ -838,6 +1386,19 @@
|
|
|
838
1386
|
.kp-full-page-hero-text {
|
|
839
1387
|
font-size: 22px;
|
|
840
1388
|
}
|
|
1389
|
+
|
|
1390
|
+
.kp-message-row {
|
|
1391
|
+
gap: 8px;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
.kp-avatar {
|
|
1395
|
+
width: 32px;
|
|
1396
|
+
height: 32px;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
.kp-bubble {
|
|
1400
|
+
max-width: calc(100% - 40px);
|
|
1401
|
+
}
|
|
841
1402
|
}
|
|
842
1403
|
|
|
843
1404
|
@keyframes kp-cluster-rotate {
|
|
@@ -868,5 +1429,32 @@
|
|
|
868
1429
|
40% { transform: translate(16px, -13px) scale(0.92); opacity: 0.96; }
|
|
869
1430
|
62% { transform: translate(2px, -2px) scale(1); opacity: 0.98; }
|
|
870
1431
|
}
|
|
871
|
-
`}function qe(e){if(typeof document>"u")throw new Error("Chat widget can only be initialized in a browser.");let t=$e(e),n={chatId:de(t),open:!1,fullPageOpen:!1,accessTokenProvider:t.getAccessToken,historyLoadedChatId:null,menuOpen:!1,chats:[],chatSearchTerm:"",loadingChats:!1},s=document.createElement("div");s.dataset.chatWidgetHost="true",t.mount.appendChild(s);let i=s.attachShadow({mode:"open"});De(i,t.theme);let l=o("div",`kp-chat-widget ${t.position}`),r=o("div","kp-overlay"),u=o("button","kp-launcher");u.type="button",u.setAttribute("aria-label",t.launcherAriaLabel),u.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 p=o("section","kp-panel");p.setAttribute("role","dialog"),p.setAttribute("aria-modal","true"),p.setAttribute("aria-label",t.title);let c=o("div","kp-header"),f=o("div","kp-toolbar"),g=o("button","kp-tool-button kp-menu-trigger");g.type="button",g.setAttribute("aria-label","Open chat actions"),g.innerHTML=['<span class="kp-pencil-icon" aria-hidden="true"></span>','<span class="kp-chevron" aria-hidden="true">\u2304</span>'].join("");let m=o("div","kp-dropdown"),z=o("button","kp-dropdown-item","New Chat");z.type="button";let W=o("button","kp-dropdown-item","My Chats");W.type="button";let N=o("button","kp-dropdown-item","Open Knowledge Assistant");N.type="button",m.append(z,W,N),f.append(g,m);let K=o("div","kp-title-wrap"),J=o("h2","kp-title",t.title),G=o("div","kp-subtitle",t.subtitle);K.append(J,G);let b=o("button","kp-close","\xD7");b.type="button",b.setAttribute("aria-label",t.closeAriaLabel),c.append(f,K,b);let F=o("div","kp-body"),Q=o("div","kp-hero"),Fe=o("div","kp-hero-icon","\u2726"),Xe=o("div","kp-hero-text",t.welcomeMessage);Q.append(Fe,Xe);let ue=o("div","kp-footer"),Z=o("form","kp-form"),I=o("input","kp-input");I.type="text",I.autocomplete="off",I.placeholder=t.inputPlaceholder;let ge=o("button","kp-send","\u279C");ge.type="submit";let Ye=o("div","kp-note","Auth token is forwarded from the host app when configured.");Z.append(I,ge),ue.append(Z,Ye),p.append(c,F,ue),l.append(r,u,p),i.appendChild(l),F.appendChild(Q);let fe=o("div","kp-suggestions");F.appendChild(fe);let A={body:F,input:I,suggestions:fe,hero:Q},x=o("section","kp-full-page");x.setAttribute("role","dialog"),x.setAttribute("aria-modal","true"),x.setAttribute("aria-label",`${t.title} page`);let he=o("div","kp-full-page-shell"),me=o("div","kp-full-page-header"),be=o("div","kp-full-page-brand"),Je=o("div","kp-full-page-brand-mark","\u2726"),Ge=o("div","kp-full-page-brand-text",t.title);be.append(Je,Ge);let ke=o("div","kp-full-page-header-actions"),Qe=o("div","kp-full-page-badge","Knowledge Assistant"),X=o("button","kp-full-page-close","\xD7");X.type="button",X.setAttribute("aria-label","Close knowledge assistant page"),ke.append(Qe,X),me.append(be,ke);let Ze=o("div","kp-full-page-breadcrumb","Home \u203A Knowledge Assistant"),xe=o("div","kp-full-page-content"),ye=o("aside","kp-full-page-sidebar"),ee=o("button","kp-full-page-new-chat","+ New Chat");ee.type="button";let ve=o("div","kp-full-page-search"),O=o("input","kp-full-page-search-input");O.type="search",O.placeholder="Search Chat";let et=o("span","kp-full-page-search-icon","\u2315");ve.append(O,et);let tt=o("div","kp-full-page-section-label","Recent Activity"),y=o("div","kp-full-page-recent-list"),nt=o("div","kp-full-page-section-label","Pinned Collections"),v=o("div","kp-full-page-pinned-list");ye.append(ee,ve,tt,y,nt,v);let we=o("main","kp-full-page-main"),Ce=o("section","kp-full-page-panel"),te=o("div","kp-full-page-body"),ne=o("div","kp-full-page-hero"),Le=o("div","kp-full-page-hero-badge");Le.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 at=o("div","kp-full-page-hero-text",t.welcomeMessage);ne.append(Le,at);let Pe=o("div","kp-suggestions kp-full-page-suggestions");te.append(ne,Pe);let Ie=o("div","kp-full-page-footer"),ae=o("form","kp-form kp-full-page-form"),w=o("input","kp-input kp-full-page-input");w.type="text",w.autocomplete="off",w.placeholder=t.inputPlaceholder;let Ae=o("button","kp-send kp-full-page-send","\u279C");Ae.type="submit";let ot=o("div","kp-note kp-full-page-note","Answers are generated based on your access permissions");ae.append(w,Ae),Ie.append(ae,ot),Ce.append(te,Ie),we.appendChild(Ce),xe.append(ye,we),he.append(me,Ze,xe),x.appendChild(he),l.appendChild(x);let k={body:te,input:w,suggestions:Pe,hero:ne},U=()=>({...t,getAccessToken:n.accessTokenProvider});S(A,t.initialSuggestions,async a=>{await C(a,A)}),S(k,t.initialSuggestions,async a=>{await C(a,k)}),R(y,v,n,async a=>{await E(a.chatId)},async a=>{await H(a)});function Te(){n.open||(n.open=!0,n.fullPageOpen=!1,x.classList.remove("open"),u.classList.add("hidden"),r.classList.add("visible"),p.classList.add("open"),t.onOpen?.(),t.rag.loadHistoryOnOpen&&se.loadHistory(),queueMicrotask(()=>I.focus()))}function B(){n.open&&(T(),n.open=!1,u.classList.remove("hidden"),r.classList.remove("visible"),p.classList.remove("open"),t.onClose?.())}async function C(a,d){let L=a.trim();if(!L)return;d.input.value="";try{await pt(L)}catch(P){let $=j(t,P);q(d.body,"bot",`Unable to create chat: ${$.message}`);return}_e(d),q(d.body,"user",L),d.body.scrollTop=d.body.scrollHeight;let M=o("div","kp-loading","Thinking...");d.body.appendChild(M),d.body.scrollTop=d.body.scrollHeight;try{let P=await We(U(),{message:L,chatId:n.chatId,knowledgeNames:await mt(t),...t.rag.enableReferences!==void 0?{enableReferences:t.rag.enableReferences}:{}});M.isConnected&&M.remove(),q(d.body,"bot",P.answer,P.citations?.length),n.historyLoadedChatId=null,await Y(),P.suggestions?.length&&S(d,P.suggestions,async $=>{await C($,d)})}catch(P){let $=j(t,P);M.isConnected&&M.remove(),q(d.body,"bot",`Request failed: ${$.message}`)}}async function Ee(a){let d=n.fullPageOpen?k:A;await C(a,d)}async function He(){n.fullPageOpen=!0,n.open=!1,T(),p.classList.remove("open"),r.classList.remove("visible"),u.classList.add("hidden"),x.classList.add("open"),await Y(),await oe(k,n.chatId),queueMicrotask(()=>w.focus())}function Me(){n.fullPageOpen&&(n.fullPageOpen=!1,x.classList.remove("open"),u.classList.remove("hidden"))}function st(){n.menuOpen=!0,g.classList.add("open"),m.classList.add("open")}function T(){n.menuOpen=!1,g.classList.remove("open"),m.classList.remove("open")}function rt(){n.chatId=de(t),n.historyLoadedChatId=null,ce(A),S(A,t.initialSuggestions,async a=>{await C(a,A)}),T()}async function it(){n.chatId=de(t),n.historyLoadedChatId=null,ce(k),S(k,t.initialSuggestions,async a=>{await C(a,k)}),R(y,v,n,async a=>{await E(a.chatId)},async a=>{await H(a)})}async function Y(){if(!t.endpoints.listChats)return R(y,v,n,async a=>{await E(a.chatId)},async a=>{await H(a)}),[];n.loadingChats=!0,R(y,v,n,async a=>{await E(a.chatId)},async a=>{await H(a)});try{let a=await Oe(U());return n.chats=a,a}catch(a){return j(t,a),n.chats}finally{n.loadingChats=!1,R(y,v,n,async a=>{await E(a.chatId)},async a=>{await H(a)})}}async function pt(a){!t.endpoints.listChats&&!t.endpoints.createChat||n.chats.some(d=>d.chatId===n.chatId)||await Ue(U(),n.chatId,a?xt(a):void 0)}async function E(a){n.chatId=a,n.historyLoadedChatId=null,await oe(k,a),R(y,v,n,async d=>{await E(d.chatId)},async d=>{await H(d)})}async function H(a){if(t.endpoints.updateChat)try{await Be(U(),a.chatId,{pinned:!a.pinned}),await Y()}catch(d){j(t,d)}}async function oe(a,d){ce(a),S(a,t.initialSuggestions,async M=>{await C(M,a)});let L=await Ne(U(),d);return L.length>0&&(_e(a),Ke(a.body,a.hero,a.suggestions),kt(a.body,L)),n.historyLoadedChatId=d,L}let se={open:Te,close:B,toggle(){if(n.open){B();return}Te()},destroy(){document.removeEventListener("keydown",Re),s.remove()},sendMessage:Ee,setAccessTokenProvider(a){n.accessTokenProvider=a},getChatId(){return n.chatId},loadChats(){return Y()},async loadHistory(){let a=n.fullPageOpen?k:A;return oe(a,n.chatId)}};u.addEventListener("click",()=>se.toggle()),b.addEventListener("click",B),r.addEventListener("click",B),g.addEventListener("click",a=>{if(a.stopPropagation(),!n.menuOpen){st();return}T()}),z.addEventListener("click",rt),W.addEventListener("click",async()=>{T(),await He()}),N.addEventListener("click",()=>{He()}),X.addEventListener("click",Me),ee.addEventListener("click",()=>{it(),queueMicrotask(()=>w.focus())}),O.addEventListener("input",()=>{n.chatSearchTerm=O.value.trim().toLowerCase(),R(y,v,n,async a=>{await E(a.chatId)},async a=>{await H(a)})}),p.addEventListener("click",a=>{n.menuOpen&&!m.contains(a.target)&&!g.contains(a.target)&&T(),a.stopPropagation()}),i.addEventListener("click",a=>{let d=a.target;n.menuOpen&&d instanceof Node&&!m.contains(d)&&!g.contains(d)&&T()}),Z.addEventListener("submit",async a=>{a.preventDefault(),await Ee(I.value)}),ae.addEventListener("submit",async a=>{a.preventDefault(),await C(w.value,k)});function Re(a){if(a.key==="Escape"){if(n.fullPageOpen){Me();return}n.open&&B()}}return document.addEventListener("keydown",Re),se}async function mt(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 de(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 q(e,t,n,s){let i=o("div",`kp-bubble ${t}`,n);if(s){let l=o("div","kp-meta",`${s} citation${s>1?"s":""} attached`);i.appendChild(l)}return e.appendChild(i),e.scrollTop=e.scrollHeight,i}function bt(e,t,n){e.textContent="";for(let s of t){let i=o("button","kp-suggestion",s);i.type="button",i.addEventListener("click",async()=>{await n(s)}),e.appendChild(i)}}function S(e,t,n){bt(e.suggestions,t,async s=>{e.input.value=s,await n(s)})}function Ke(e,t,n){let s=new Set([t,n]);for(let i of Array.from(e.children))s.has(i)||i.remove()}function _e(e){e.body.classList.add("kp-conversation-active"),e.hero.remove(),e.suggestions.remove()}function ce(e){e.body.classList.remove("kp-conversation-active"),e.hero.isConnected||e.body.prepend(e.hero),e.suggestions.isConnected||e.body.appendChild(e.suggestions),Ke(e.body,e.hero,e.suggestions),e.input.value=""}function kt(e,t){for(let n of t)q(e,n.role==="assistant"?"bot":"user",n.text)}function R(e,t,n,s,i){if(e.textContent="",t.textContent="",n.loadingChats){e.appendChild(o("div","kp-full-page-empty","Loading chats..."));return}let l=n.chats.filter(r=>n.chatSearchTerm?r.title.toLowerCase().includes(n.chatSearchTerm):!0);if(l.length>0){let r=l.filter(p=>p.pinned),u=l.filter(p=>!p.pinned).slice(0,8);je(e,u,n.chatId,s,i),je(t,r,n.chatId,s,i),u.length===0&&e.appendChild(o("div","kp-full-page-empty","No recent chats yet.")),r.length===0&&t.appendChild(o("div","kp-full-page-empty","No pinned chats yet."));return}e.appendChild(o("div","kp-full-page-empty","No chats yet.")),t.appendChild(o("div","kp-full-page-empty","No pinned chats yet."))}function je(e,t,n,s,i){for(let l of t){let r=o("div",`kp-full-page-item kp-full-page-chat-item${l.chatId===n?" active":""}`),u=o("span","kp-full-page-item-title",l.title),p=o("button","kp-chat-pin",l.pinned?"\u2605":"\u2606");p.type="button",p.setAttribute("aria-label",l.pinned?"Unpin chat":"Pin chat"),p.addEventListener("click",async c=>{c.stopPropagation(),await i(l)}),r.append(u,p),r.setAttribute("role","button"),r.tabIndex=0,r.addEventListener("click",async()=>{await s(l)}),r.addEventListener("keydown",async c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),await s(l))}),e.appendChild(r)}}function xt(e){return e.trim().slice(0,60)||"New Chat"}return ft(yt);})();
|
|
1432
|
+
`}var gt={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 kt(e){if(typeof document>"u")throw new Error("Chat widget can only be initialized in a browser.");let t=ct(e),a=Pe(t.locale),n=ln(t.locale),i=pn(a),l=t.displayMode==="embedded",s={chatId:ce(t),open:!1,fullPageOpen:l,myChatsOpen:!1,accessTokenProvider:t.getAccessToken,historyLoadedChatId:null,menuOpen:!1,chats:[],chatSearchTerm:"",loadingChats:!1,sourcePanelOpen:!1,sourcePanelTitle:null},p=document.createElement("div");p.dataset.chatWidgetHost="true",t.mount.appendChild(p);let c=p.attachShadow({mode:"open"});ut(c,t.theme);let u=o("div",`kp-chat-widget ${t.position}`);u.lang=a,u.dir=i?"rtl":"ltr",l&&(u.classList.add("kp-chat-widget-embedded"),bt(!0)),i&&u.classList.add("kp-rtl");let g=o("div","kp-overlay"),f=o("button","kp-launcher");f.type="button",f.setAttribute("aria-label",t.launcherAriaLabel),f.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 h=o("section","kp-panel");h.setAttribute("role","dialog"),h.setAttribute("aria-modal","true"),h.setAttribute("aria-label",t.title);let w=o("div","kp-header"),L=o("div","kp-toolbar"),b=o("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 y=o("div","kp-dropdown"),k=o("button","kp-dropdown-item",n.newChat);k.type="button";let H=o("button","kp-dropdown-item",n.myChats);H.type="button";let v=o("button","kp-dropdown-item",n.openAssistant);v.type="button",y.append(k,H,v),L.append(b,y);let Se=o("div","kp-title-wrap"),Ct=o("h2","kp-title",t.title),Lt=o("div","kp-subtitle",t.subtitle);Se.append(Ct,Lt);let ee=o("button","kp-close","\xD7");ee.type="button",ee.setAttribute("aria-label",t.closeAriaLabel),w.append(L,Se,ee);let te=o("div","kp-body"),de=o("div","kp-hero"),At=o("div","kp-hero-icon","\u2726"),Pt=o("div","kp-hero-text",t.welcomeMessage);de.append(At,Pt);let Te=o("div","kp-footer"),ue=o("form","kp-form"),E=o("input","kp-input");E.type="text",E.autocomplete="off",E.placeholder=t.inputPlaceholder,E.setAttribute("aria-label",t.inputPlaceholder);let ge=o("button","kp-send","\u279C");ge.type="submit",ge.setAttribute("aria-label",n.send);let St=o("div","kp-note",n.authTokenForwarded);ue.append(E,ge),Te.append(ue,St),h.append(w,te,Te),l||u.append(g,f,h),c.appendChild(u),te.appendChild(de);let Ee=o("div","kp-suggestions");te.appendChild(Ee);let ne=o("section","kp-my-chats-sheet"),Ie=o("div","kp-my-chats-header"),ae=o("button","kp-my-chats-nav","\u2190");ae.type="button",ae.setAttribute("aria-label",n.back);let oe=o("button","kp-my-chats-nav kp-my-chats-close","\xD7");oe.type="button",oe.setAttribute("aria-label",n.close),Ie.append(ae,oe);let Re=o("div","kp-my-chats-body"),Tt=o("div","kp-my-chats-section-label",n.recentActivity),$e=o("div","kp-my-chats-list"),Et=o("div","kp-my-chats-section-label",n.pinnedCollections),Me=o("div","kp-my-chats-list");Re.append(Tt,$e,Et,Me),ne.append(Ie,Re),h.appendChild(ne);let S={body:te,input:E,suggestions:Ee,hero:de,kind:"panel"},A=o("section","kp-full-page");l&&A.classList.add("kp-full-page-embedded","open"),A.setAttribute("role","dialog"),l||A.setAttribute("aria-modal","true"),A.setAttribute("aria-label",`${t.title} page`);let He=o("div","kp-full-page-shell"),fe=o("div","kp-full-page-header"),ze=o("div","kp-full-page-brand"),It=o("div","kp-full-page-brand-mark","\u2726"),Rt=o("div","kp-full-page-brand-text",t.title);ze.append(It,Rt);let Ne=o("div","kp-full-page-header-actions"),$t=o("div","kp-full-page-badge",n.assistantBadge),se=o("button","kp-full-page-close","\xD7");se.type="button",se.setAttribute("aria-label",n.closeAssistantPage),Ne.append($t,se),fe.append(ze,Ne),t.embedded.showHeader||fe.classList.add("kp-hidden");let Oe=o("div","kp-full-page-content"),Ue=o("aside","kp-full-page-sidebar"),he=o("button","kp-full-page-new-chat",`+ ${n.newChat}`);he.type="button";let Be=o("div","kp-full-page-search"),F=o("input","kp-full-page-search-input");F.type="search",F.placeholder=n.searchChat;let Mt=o("span","kp-full-page-search-icon","\u2315");Be.append(F,Mt);let Ht=o("div","kp-full-page-section-label",n.recentActivity),We=o("div","kp-full-page-recent-list"),zt=o("div","kp-full-page-section-label",n.pinnedCollections),je=o("div","kp-full-page-pinned-list");Ue.append(he,Be,Ht,We,zt,je);let De=o("main","kp-full-page-main"),qe=o("section","kp-full-page-panel"),me=o("div","kp-full-page-body"),be=o("div","kp-full-page-hero"),Ve=o("div","kp-full-page-hero-badge");Ve.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 Nt=o("div","kp-full-page-hero-text",t.welcomeMessage);be.append(Ve,Nt);let _e=o("div","kp-suggestions kp-full-page-suggestions");me.append(be,_e);let Fe=o("div","kp-full-page-footer"),ke=o("form","kp-form kp-full-page-form"),P=o("input","kp-input kp-full-page-input");P.type="text",P.autocomplete="off",P.placeholder=t.inputPlaceholder,P.setAttribute("aria-label",t.inputPlaceholder);let xe=o("button","kp-send kp-full-page-send","\u279C");xe.type="submit",xe.setAttribute("aria-label",n.send);let Ot=o("div","kp-note kp-full-page-note",n.answersBasedOnPermissions);ke.append(P,xe),Fe.append(ke,Ot),qe.append(me,Fe),De.appendChild(qe);let re=o("aside","kp-source-panel"),Ke=o("div","kp-source-panel-header"),Xe=o("div","kp-source-panel-title-wrap"),Ye=o("div","kp-source-panel-title",n.allSourcesUsed),Ut=o("div","kp-source-panel-subtitle",n.documentsAndReferences);Xe.append(Ye,Ut);let ie=o("button","kp-source-panel-close","\xD7");ie.type="button",ie.setAttribute("aria-label",n.closeSourcesPanel),Ke.append(Xe,ie);let K=o("div","kp-source-panel-list"),Bt=o("div","kp-source-panel-empty",n.noSources);K.appendChild(Bt),re.append(Ke,K),Oe.append(Ue,De,re),He.append(fe,Oe),A.appendChild(He),u.appendChild(A);let C={body:me,input:P,suggestions:_e,hero:be,kind:"full-page"},z=()=>({...t,getAccessToken:s.accessTokenProvider}),Je=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}},X=(r,d)=>{if(s.sourcePanelOpen=!0,s.sourcePanelTitle=d??n.allSourcesUsed,Ye.textContent=s.sourcePanelTitle,re.classList.add("open"),K.textContent="",r.length===0){K.appendChild(o("div","kp-source-panel-empty",n.noSources));return}for(let m of r)K.appendChild(kn(m,n))},W=()=>{s.sourcePanelOpen=!1,s.sourcePanelTitle=null,re.classList.remove("open")};V(S,t.initialSuggestions,async r=>{await I(r,S)}),V(C,t.initialSuggestions,async r=>{await I(r,C)}),O(),le(),l&&(T(),t.rag.loadHistoryOnOpen&&j(C,s.chatId));function ye(){if(l){s.fullPageOpen=!0,A.classList.add("open");return}s.open||(s.open=!0,s.fullPageOpen=!1,$(),A.classList.remove("open"),f.classList.add("hidden"),g.classList.add("visible"),h.classList.add("open"),t.onOpen?.(),t.rag.loadHistoryOnOpen&&we.loadHistory(),queueMicrotask(()=>E.focus()))}function N(){if(l){W();return}s.open&&(R(),$(),s.open=!1,f.classList.remove("hidden"),g.classList.remove("visible"),h.classList.remove("open"),t.onClose?.())}async function I(r,d){let m=r.trim();if(!m)return;d.input.value="";try{await Vt(m)}catch(M){let Y=B(t,M);Q(d.body,"bot",`${n.unableToCreateChat}: ${Y.message}`,{strings:n,view:d,userName:null,onShowSources:X});return}ft(d),Q(d.body,"user",m,{strings:n,view:d,userName:await Je(),onShowSources:X}),d.body.scrollTop=d.body.scrollHeight;let U=o("div","kp-loading",n.thinking);d.body.appendChild(U),d.body.scrollTop=d.body.scrollHeight;try{let M=await st(z(),{message:m,chatId:s.chatId,knowledgeNames:await tn(t),...t.rag.enableReferences!==void 0?{enableReferences:t.rag.enableReferences}:{}});U.isConnected&&U.remove(),Q(d.body,"bot",M.answer,{strings:n,view:d,userName:null,citations:M.citations??[],onShowSources:X}),s.historyLoadedChatId=null,await T(),M.suggestions?.length&&V(d,M.suggestions,async Y=>{await I(Y,d)})}catch(M){let Y=B(t,M);U.isConnected&&U.remove(),Q(d.body,"bot",`${n.requestFailed}: ${Y.message}`,{strings:n,view:d,userName:null,onShowSources:X})}}async function Ge(r){let d=s.fullPageOpen?C:S;await I(r,d)}async function Wt(){if(l){s.fullPageOpen=!0,A.classList.add("open"),await T(),await j(C,s.chatId),queueMicrotask(()=>P.focus());return}s.fullPageOpen=!0,s.open=!1,R(),$(),h.classList.remove("open"),g.classList.remove("visible"),f.classList.add("hidden"),A.classList.add("open"),await T(),await j(C,s.chatId),queueMicrotask(()=>P.focus())}function Qe(){if(l){W();return}s.fullPageOpen&&(s.fullPageOpen=!1,A.classList.remove("open"),f.classList.remove("hidden"),W())}function jt(){s.menuOpen=!0,b.classList.add("open"),y.classList.add("open")}function R(){s.menuOpen=!1,b.classList.remove("open"),y.classList.remove("open")}function Dt(){s.chatId=ce(t),s.historyLoadedChatId=null,$(),G(S),V(S,t.initialSuggestions,async r=>{await I(r,S)}),R()}async function qt(){s.chatId=ce(t),s.historyLoadedChatId=null,G(C),W(),V(C,t.initialSuggestions,async r=>{await I(r,C)}),O()}async function T(){if(!t.endpoints.listChats)return O(),le(),[];s.loadingChats=!0,O(),le();try{let r=await it(z());return s.chats=r,r}catch(r){return B(t,r),s.chats}finally{s.loadingChats=!1,O(),le()}}async function Vt(r){!t.endpoints.listChats&&!t.endpoints.createChat||s.chats.some(d=>d.chatId===s.chatId)||await lt(z(),s.chatId,r?rn(r,n.newChat):void 0)}async function _t(r){s.chatId=r,s.historyLoadedChatId=null,await j(C,r),O()}async function Ft(r){s.chatId=r,s.historyLoadedChatId=null,await j(S,r),$()}async function Kt(){R(),await T(),s.myChatsOpen=!0,h.classList.add("kp-sheet-open"),ne.classList.add("open")}function $(){s.myChatsOpen=!1,h.classList.remove("kp-sheet-open"),ne.classList.remove("open")}async function Ze(r){if(!t.endpoints.updateChat)return;let d=window.prompt(n.renamePrompt,r.title)?.trim();if(!(!d||d===r.title))try{await Le(z(),r.chatId,{title:d}),await T()}catch(m){B(t,m)}}async function et(r){if(t.endpoints.deleteChat)try{await pt(z(),r.chatId),s.chatId===r.chatId&&(s.chatId=ce(t),s.historyLoadedChatId=null,G(S),G(C)),await T()}catch(d){B(t,d)}}function O(){ht(We,je,s,n,async r=>{await _t(r.chatId)},async r=>{await tt(r)},async r=>{await Ze(r)},async r=>{await et(r)})}function le(){ht($e,Me,s,n,async r=>{await Ft(r.chatId)},async r=>{await tt(r)},async r=>{await Ze(r)},async r=>{await et(r)})}async function tt(r){if(t.endpoints.updateChat)try{await Le(z(),r.chatId,{pinned:!r.pinned}),await T()}catch(d){B(t,d)}}async function j(r,d){G(r),V(r,t.initialSuggestions,async U=>{await I(U,r)});let m=await rt(z(),d);return m.length>0&&(ft(r),xt(r.body,r.hero,r.suggestions),sn(r.body,m,{strings:n,view:r,userName:await Je(),onShowSources:X})),s.historyLoadedChatId=d,m}let we={open:ye,close:N,toggle(){if(l){ye();return}if(s.open){N();return}ye()},destroy(){if(document.removeEventListener("keydown",nt),p.remove(),l){let r=!1;document.querySelectorAll("[data-chat-widget-host]").forEach(d=>{let m=d.shadowRoot;m&&m.querySelector(".kp-chat-widget-embedded")&&(r=!0)}),r||bt(!1)}},sendMessage:Ge,setAccessTokenProvider(r){s.accessTokenProvider=r},getChatId(){return s.chatId},loadChats(){return T()},async loadHistory(){let r=s.fullPageOpen?C:S;return j(r,s.chatId)}};f.addEventListener("click",()=>we.toggle()),ee.addEventListener("click",N),g.addEventListener("click",N),ie.addEventListener("click",W),ae.addEventListener("click",$),oe.addEventListener("click",$),b.addEventListener("click",r=>{if(r.stopPropagation(),!s.menuOpen){jt();return}R()}),k.addEventListener("click",Dt),H.addEventListener("click",async()=>{await Kt()}),v.addEventListener("click",()=>{if(R(),t.onOpenAssistantPage){N(),t.onOpenAssistantPage();return}if(t.assistantPageUrl){N(),window.location.href=t.assistantPageUrl;return}Wt()}),se.addEventListener("click",Qe),he.addEventListener("click",()=>{qt(),queueMicrotask(()=>P.focus())}),F.addEventListener("input",()=>{s.chatSearchTerm=F.value.trim().toLowerCase(),O()}),h.addEventListener("click",r=>{let d=r.target;if(!(d instanceof Element)||!d.closest(".kp-chat-actions")){for(let m of Array.from(c.querySelectorAll(".kp-chat-actions.open")))m.classList.remove("open");for(let m of Array.from(c.querySelectorAll(".kp-full-page-chat-item.menu-open")))m.classList.remove("menu-open")}s.menuOpen&&!y.contains(d)&&!b.contains(d)&&R(),r.stopPropagation()}),c.addEventListener("click",r=>{let d=r.target;if(s.menuOpen&&d instanceof Node&&!y.contains(d)&&!b.contains(d)&&R(),d instanceof Element&&!d.closest(".kp-chat-actions")){for(let m of Array.from(c.querySelectorAll(".kp-chat-actions.open")))m.classList.remove("open");for(let m of Array.from(c.querySelectorAll(".kp-full-page-chat-item.menu-open")))m.classList.remove("menu-open")}}),ue.addEventListener("submit",async r=>{r.preventDefault(),await Ge(E.value)}),ke.addEventListener("submit",async r=>{r.preventDefault(),await I(P.value,C)});function nt(r){if(r.key==="Escape"){if(s.sourcePanelOpen){W();return}if(s.myChatsOpen){$();return}if(s.fullPageOpen){if(l)return;Qe();return}s.open&&N()}}return document.addEventListener("keydown",nt),we}async function tn(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 Q(e,t,a,n){let i=t==="bot"?dn(a,n.citations??[]):{displayText:a,citations:n.citations??[]},l=o("div",`kp-message-row ${t}`),s=an(t==="bot"?n.strings.assistantAvatar:n.userName??n.strings.userAvatar,t),p=o("div",`kp-bubble ${t}`),c=o("div","kp-bubble-content");wn(c,i.displayText),p.appendChild(c);let u=i.citations;if(u.length){let g=o("div","kp-meta",n.strings.citationsAttached(u.length));p.appendChild(g);let f=o("div","kp-source-preview"),h=o("div","kp-source-preview-title",n.strings.sourcesUsed),w=o("div","kp-source-preview-list");for(let b of u.slice(0,2)){let y=mn(b,n.strings);y.addEventListener("click",async()=>{wt(b,n.strings)}),w.appendChild(y)}let L=bn(n.strings);L.addEventListener("click",async()=>{n.onShowSources(u,n.strings.allSourcesUsed)}),w.appendChild(L),f.append(h,w),p.appendChild(f)}return t==="bot"&&p.appendChild(nn(i.displayText,n.strings)),t==="user"?l.append(p,s):l.append(s,p),e.appendChild(l),e.scrollTop=e.scrollHeight,l}function nn(e,t){let a=o("div","kp-message-actions"),n=o("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=o("button","kp-message-action","\u{1F44D}");i.type="button",i.setAttribute("aria-label",t.helpful),i.addEventListener("click",()=>{i.classList.toggle("active"),l.classList.remove("active")});let l=o("button","kp-message-action","\u{1F44E}");return l.type="button",l.setAttribute("aria-label",t.notHelpful),l.addEventListener("click",()=>{l.classList.toggle("active"),i.classList.remove("active")}),a.append(n,i,l),a}function an(e,t){let a=o("div",`kp-avatar ${t}`),n=t==="bot"?"\u2726":cn(e);return a.textContent=n,a.setAttribute("aria-hidden","true"),a}function on(e,t,a){e.textContent="";for(let n of t){let i=o("button","kp-suggestion",n);i.type="button",i.addEventListener("click",async()=>{await a(n)}),e.appendChild(i)}}function V(e,t,a){on(e.suggestions,t,async n=>{e.input.value=n,await a(n)})}function xt(e,t,a){let n=new Set([t,a]);for(let i of Array.from(e.children))n.has(i)||i.remove()}function ft(e){e.body.classList.add("kp-conversation-active"),e.hero.remove(),e.suggestions.remove()}function G(e){e.body.classList.remove("kp-conversation-active"),e.hero.isConnected||e.body.prepend(e.hero),e.suggestions.isConnected||e.body.appendChild(e.suggestions),xt(e.body,e.hero,e.suggestions),e.input.value=""}function sn(e,t,a){for(let n of t)Q(e,n.role==="assistant"?"bot":"user",n.text,a)}function ht(e,t,a,n,i,l,s,p){if(e.textContent="",t.textContent="",a.loadingChats){e.appendChild(o("div","kp-full-page-empty",n.loadingChats));return}let c=a.chats.filter(u=>a.chatSearchTerm?u.title.toLowerCase().includes(a.chatSearchTerm):!0);if(c.length>0){let u=c.filter(f=>f.pinned),g=c.filter(f=>!f.pinned).slice(0,8);mt(e,g,a.chatId,n,i,l,s,p),mt(t,u,a.chatId,n,i,l,s,p),g.length===0&&e.appendChild(o("div","kp-full-page-empty",n.noRecentChats)),u.length===0&&t.appendChild(o("div","kp-full-page-empty",n.noPinnedChats));return}e.appendChild(o("div","kp-full-page-empty",n.noChats)),t.appendChild(o("div","kp-full-page-empty",n.noPinnedChats))}function mt(e,t,a,n,i,l,s,p){for(let c of t){let u=o("div",`kp-full-page-item kp-full-page-chat-item${c.chatId===a?" active":""}`),g=o("span","kp-full-page-item-title",c.title),f=o("div","kp-chat-actions"),h=o("button","kp-chat-actions-trigger","\u22EF");h.type="button",h.setAttribute("aria-label",n.chatActions);let w=o("div","kp-chat-actions-menu"),L=o("button","kp-chat-actions-item",c.pinned?n.unpinChat:n.pinChat);L.type="button",L.addEventListener("click",async k=>{k.stopPropagation(),await l(c)});let b=o("button","kp-chat-actions-item",n.renameChat);b.type="button",b.addEventListener("click",async k=>{k.stopPropagation(),await s(c)});let y=o("button","kp-chat-actions-item",n.deleteChat);y.type="button",y.addEventListener("click",async k=>{k.stopPropagation(),await p(c)}),w.append(L,b,y),f.append(h,w),h.addEventListener("click",k=>{k.stopPropagation();let H=f.classList.contains("open");for(let v of Array.from(e.querySelectorAll(".kp-chat-actions.open")))v.classList.remove("open");for(let v of Array.from(e.querySelectorAll(".kp-full-page-chat-item.menu-open")))v.classList.remove("menu-open");H||(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(c)}),u.addEventListener("keydown",async k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),await i(c))}),u.addEventListener("blur",()=>{f.classList.remove("open"),u.classList.remove("menu-open")}),e.appendChild(u)}}function rn(e,t){return e.trim().slice(0,60)||t}function Pe(e){return e.toLowerCase().split("-")[0]||"en"}function ln(e){let t=gt.en;return gt[Pe(e)]??t}function pn(e){return["ar","fa","he","ur"].includes(Pe(e))}function cn(e){let t=e.split(/\s+/).filter(Boolean).slice(0,2);return t.length===0?"U":t.map(a=>a[0]?.toUpperCase()??"").join("")}function yt(e){return e.knowledgeName?.trim()||e.sourceDocument?.trim()||null}function dn(e,t){let a=un(e);return{displayText:a.displayText,citations:t.length>0?hn(t,a.citations):a.citations}}function un(e){let a=vt(e).split(`
|
|
1433
|
+
`),n=-1;for(let c=0;c<a.length;c+=1)/^#{0,6}\s*References\s*$/i.test(a[c]?.trim()??"")&&(n=c);if(n===-1)return{displayText:e,citations:[]};let i=a.slice(0,n).join(`
|
|
1434
|
+
`).trimEnd(),l=a.slice(n+1).join(`
|
|
1435
|
+
`).trim(),p=gn(l).map(c=>fn(c)).filter(c=>!!c);return{displayText:i,citations:p}}function gn(e){let t=[],a="";for(let n of e.split(`
|
|
1436
|
+
`)){let i=n.trim();if(i){if(/^\d+\.\s+/.test(i)){a&&t.push(a.trim()),a=i.replace(/^\d+\.\s+/,"");continue}a&&(a=`${a} ${i}`)}}return a&&t.push(a.trim()),t}function fn(e){let t=e.match(/https?:\/\/\S+/i);if(!t)return null;let a=t[0],n=e.slice(0,t.index).replace(/[.\s]+$/,"").trim();return{sourceDocument:a,knowledgeName:n||a}}function hn(e,t){let a=[],n=new Set;for(let i of[...e,...t]){let l=`${i.knowledgeName??""}::${i.sourceDocument??""}`;n.has(l)||(n.add(l),a.push(i))}return a}function mn(e,t){let a=o("button","kp-source-chip");a.type="button",a.setAttribute("aria-label",t.openSource);let n=o("span","kp-source-thumb");n.textContent="\u2726";let i=o("span","kp-source-chip-label",yt(e)??t.untitledSource);return a.append(n,i),a}function bn(e){let t=o("button","kp-source-chip kp-source-chip-more");t.type="button";let a=o("span","kp-source-thumb-stack");for(let i=0;i<3;i+=1){let l=o("span","kp-source-thumb stacked");l.textContent="\u2726",a.appendChild(l)}let n=o("span","kp-source-chip-label",e.showAll);return t.append(a,n),t}function kn(e,t){let a=o("button","kp-source-card");a.type="button",a.setAttribute("aria-label",t.openSource),a.addEventListener("click",()=>{wt(e,t)});let n=o("div","kp-source-card-media"),i=o("span","kp-source-thumb kp-source-thumb-large");i.textContent="\u2726";let l=o("div","kp-source-card-title",yt(e)??t.untitledSource),s=o("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}`),s.textContent=p.join(" \u2022 "),n.appendChild(i),a.append(n,l,s),a}function wt(e,t){let a=e.sourceDocument?.trim()||e.knowledgeName?.trim()||t.untitledSource,n=xn(e.sourceDocument);if(n){window.open(n,"_blank","noopener,noreferrer");return}let i=window.open("","_blank","noopener,noreferrer");if(!i)return;let l=Z(a),s=yn(e,t).map(p=>`<li>${Z(p)}</li>`).join("");i.document.write(`<!doctype html>
|
|
1437
|
+
<html lang="en">
|
|
1438
|
+
<head>
|
|
1439
|
+
<meta charset="utf-8">
|
|
1440
|
+
<title>${l}</title>
|
|
1441
|
+
<style>
|
|
1442
|
+
body { font-family: Arial, sans-serif; margin: 32px; color: #1f2937; }
|
|
1443
|
+
.card { max-width: 720px; padding: 24px; border: 1px solid #dbe4ee; border-radius: 16px; background: #fff; }
|
|
1444
|
+
h1 { margin: 0 0 12px; font-size: 24px; }
|
|
1445
|
+
p { margin: 0 0 16px; color: #64748b; }
|
|
1446
|
+
ul { margin: 0; padding-left: 20px; }
|
|
1447
|
+
</style>
|
|
1448
|
+
</head>
|
|
1449
|
+
<body>
|
|
1450
|
+
<div class="card">
|
|
1451
|
+
<h1>${l}</h1>
|
|
1452
|
+
<p>${Z(t.documentsAndReferences)}</p>
|
|
1453
|
+
<ul>${s||`<li>${Z(t.noSources)}</li>`}</ul>
|
|
1454
|
+
</div>
|
|
1455
|
+
</body>
|
|
1456
|
+
</html>`),i.document.close()}function xn(e){if(!e)return null;let t=e.trim();return/^https?:\/\//i.test(t)?t:null}function yn(e,t){let a=[];return e.sourceDocument&&a.push(e.sourceDocument),typeof e.score=="number"&&a.push(`${t.sourceScore}: ${e.score.toFixed(2)}`),typeof e.pageNumber=="number"&&a.push(`${t.sourcePage}: ${e.pageNumber}`),e.sheetName&&a.push(`${t.sourceSheet}: ${e.sheetName}`),typeof e.rowNumber=="number"&&a.push(`${t.sourceRow}: ${e.rowNumber}`),e.knowledgeName&&a.push(`${t.sourceKnowledge}: ${e.knowledgeName}`),a}function wn(e,t){e.innerHTML=vn(vt(t))}function vt(e){return e.replace(/\r\n/g,`
|
|
1457
|
+
`).replace(/<br\s*\/?>/gi,`
|
|
1458
|
+
`)}function vn(e){return e.split(/\n{2,}/).map(a=>a.trim()).filter(Boolean).map(Cn).join("")}function Cn(e){let t=e.split(`
|
|
1459
|
+
`).map(n=>n.trimEnd());if(t.every(n=>/^\s*\|.*\|\s*$/.test(n))&&t.length>=2)return Ln(t);if(t.every(n=>/^\d+\.\s+/.test(n)))return`<ol>${t.map(n=>`<li>${_(n.replace(/^\d+\.\s+/,""))}</li>`).join("")}</ol>`;if(t.every(n=>/^[-*]\s+/.test(n)))return`<ul>${t.map(n=>`<li>${_(n.replace(/^[-*]\s+/,""))}</li>`).join("")}</ul>`;let a=t[0]?.match(/^(#{1,6})\s+(.*)$/);if(a){let n=a[1]??"#",i=a[2]??"",l=n.length;return`<h${l}>${_(i)}</h${l}>`}return`<p>${t.map(n=>_(n)).join("<br>")}</p>`}function Ln(e){let t=e.filter((s,p)=>!(p===1&&/^\s*\|?(\s*:?-{3,}:?\s*\|)+\s*$/.test(s))).map(s=>An(s));if(t.length===0)return"";let a=t[0]??[],n=t.slice(1),i=`<thead><tr>${a.map(s=>`<th>${_(s)}</th>`).join("")}</tr></thead>`,l=n.length?`<tbody>${n.map(s=>`<tr>${s.map(p=>`<td>${_(p)}</td>`).join("")}</tr>`).join("")}</tbody>`:"";return`<div class="kp-table-wrap"><table>${i}${l}</table></div>`}function An(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim())}function _(e){let t=Z(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 Z(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function bt(e){typeof document>"u"||document.querySelectorAll("[data-chat-widget-host]").forEach(t=>{let a=t.shadowRoot;if(a){let n=a.querySelector(".kp-chat-widget");n&&!n.classList.contains("kp-chat-widget-embedded")&&(t.style.display=e?"none":"")}})}return Zt(Pn);})();
|
|
872
1460
|
//# sourceMappingURL=index.iife.js.map
|