@inkeep/agents-ui 0.16.1 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +167 -161
- package/dist/primitives/atoms/icons/built-in-icons.cjs +1 -1
- package/dist/primitives/atoms/icons/built-in-icons.d.ts +4 -1
- package/dist/primitives/atoms/icons/built-in-icons.js +94 -91
- package/dist/primitives/atoms/icons/collections/pi.cjs +1 -1
- package/dist/primitives/atoms/icons/collections/pi.d.ts +3 -0
- package/dist/primitives/atoms/icons/collections/pi.js +82 -37
- package/dist/primitives/atoms/icons/inkeep-default-icons.cjs +1 -1
- package/dist/primitives/atoms/icons/inkeep-default-icons.js +4 -1
- package/dist/primitives/components/embedded-chat/file-upload-input.cjs +1 -1
- package/dist/primitives/components/embedded-chat/file-upload-input.d.ts +0 -1
- package/dist/primitives/components/embedded-chat/file-upload-input.js +346 -207
- package/dist/primitives/components/embedded-chat/use-chat-action.cjs +1 -1
- package/dist/primitives/components/embedded-chat/use-chat-action.js +16 -14
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.cjs +2 -2
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +257 -256
- package/dist/primitives/components/embedded-chat.cjs +3 -3
- package/dist/primitives/components/embedded-chat.d.ts +1 -1
- package/dist/primitives/components/embedded-chat.js +102 -94
- package/dist/primitives/components/tagline-logo-icon.js +50 -9
- package/dist/primitives/hooks/use-events-api.cjs +1 -0
- package/dist/primitives/hooks/use-events-api.d.ts +29 -0
- package/dist/primitives/hooks/use-events-api.js +43 -0
- package/dist/primitives/hooks/use-initial-conversation.js +4 -1
- package/dist/primitives/hooks/use-input-notification.js +9 -9
- package/dist/primitives/index.cjs +1 -1
- package/dist/primitives/index.js +150 -144
- package/dist/primitives/providers/base-events-provider.cjs +1 -1
- package/dist/primitives/providers/base-events-provider.d.ts +2 -0
- package/dist/primitives/providers/base-events-provider.js +6 -5
- package/dist/primitives/providers/chat-auth-provider.cjs +1 -0
- package/dist/primitives/providers/chat-auth-provider.d.ts +27 -0
- package/dist/primitives/providers/chat-auth-provider.js +46 -0
- package/dist/primitives/providers/chat-base-events-provider.cjs +1 -0
- package/dist/primitives/providers/chat-base-events-provider.d.ts +12 -0
- package/dist/primitives/providers/chat-base-events-provider.js +73 -0
- package/dist/primitives/providers/feedback-provider.cjs +1 -1
- package/dist/primitives/providers/feedback-provider.js +37 -31
- package/dist/primitives/providers/index.cjs +1 -1
- package/dist/primitives/providers/index.d.ts +2 -0
- package/dist/primitives/providers/index.js +57 -51
- package/dist/react/embedded-chat.cjs +1 -1
- package/dist/react/embedded-chat.js +101 -99
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.js +167 -161
- package/dist/styled/components/embedded-chat/image-preview-modal.js +9 -2
- package/dist/styled/components/embedded-chat.js +14 -2
- package/dist/styled/components/embedded-search.js +7 -1
- package/dist/styled/components/message.cjs +1 -1
- package/dist/styled/components/message.js +74 -71
- package/dist/styled/index.cjs +1 -1
- package/dist/styled/index.js +155 -149
- package/dist/types/config/ai.d.ts +5 -0
- package/dist/types/events.d.ts +11 -0
- package/dist/types/icons/built-in.d.ts +1 -1
- package/dist/types/icons/custom.d.ts +3 -0
- package/package.json +2 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface ChatAuthContextValue {
|
|
2
|
+
authToken: string | null;
|
|
3
|
+
isAuthenticated: boolean;
|
|
4
|
+
isAuthLoading: boolean;
|
|
5
|
+
isAuthConfigured: boolean;
|
|
6
|
+
refreshAuthToken: () => Promise<string | null>;
|
|
7
|
+
sessionToken: string | null;
|
|
8
|
+
refreshSession: () => Promise<string | null>;
|
|
9
|
+
getCaptchaHeader: () => Promise<Record<string, string>>;
|
|
10
|
+
invalidateCaptcha: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Resolved bearer token, in priority order:
|
|
13
|
+
* apiKey ?? (isAuthenticated ? authToken : sessionToken)
|
|
14
|
+
* This is what should be sent as `Authorization: Bearer <token>` for run API calls.
|
|
15
|
+
*/
|
|
16
|
+
effectiveAuthToken: string | null;
|
|
17
|
+
/**
|
|
18
|
+
* The `refreshSession` callback to pass into `useInkeepApiClient` for 401 retries.
|
|
19
|
+
* Undefined when `apiKey` or JWT auth is in use, since neither has an anonymous
|
|
20
|
+
* session to refresh — in those modes a 401 is terminal and shouldn't retry.
|
|
21
|
+
*/
|
|
22
|
+
applicableRefreshSession: (() => Promise<string | null>) | undefined;
|
|
23
|
+
}
|
|
24
|
+
export declare const ChatAuthProvider: React.FC<{
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const useChatAuth: () => ChatAuthContextValue;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as T } from "react/jsx-runtime";
|
|
3
|
+
import { useContext as y, createContext as S } from "react";
|
|
4
|
+
import { useInkeepConfig as x } from "./config-provider.js";
|
|
5
|
+
import { useModal as w } from "../components/modal/modal-provider.js";
|
|
6
|
+
import { useOptionalChatBubble as B } from "./chat-bubble-provider.js";
|
|
7
|
+
import { useOptionalSidebarChat as I } from "./sidebar-chat-provider.js";
|
|
8
|
+
import { useAuthToken as P } from "../hooks/use-auth-token.js";
|
|
9
|
+
import { useCaptcha as R } from "../components/embedded-chat/use-captcha.js";
|
|
10
|
+
import { useAnonymousSession as L } from "../hooks/use-anonymous-session.js";
|
|
11
|
+
const p = S(void 0), J = ({ children: t }) => {
|
|
12
|
+
const { baseSettings: n, aiChatSettings: l } = x(), { shouldBypassCaptcha: d, privacyPreferences: f } = n, { baseUrl: i, appId: m, apiKey: o } = l, C = w(), A = B(), b = I(), v = C?.isOpen ?? A?.isOpen ?? b?.isOpen ?? !0, { authToken: s, isLoading: a, refreshToken: k } = P(), g = !!n.getAuthToken, e = !!s, { getCaptchaHeader: r, invalidate: u } = R({
|
|
13
|
+
baseUrl: i,
|
|
14
|
+
shouldBypassCaptcha: d || !!o,
|
|
15
|
+
shouldMakeInitialRequest: v
|
|
16
|
+
}), { sessionToken: h, refreshSession: c } = L({
|
|
17
|
+
baseUrl: i,
|
|
18
|
+
appId: m,
|
|
19
|
+
getCaptchaHeader: r,
|
|
20
|
+
invalidateCaptcha: u,
|
|
21
|
+
optOutAllAnalytics: f?.optOutAllAnalytics,
|
|
22
|
+
enabled: !e && !a
|
|
23
|
+
}), O = {
|
|
24
|
+
authToken: s,
|
|
25
|
+
isAuthenticated: e,
|
|
26
|
+
isAuthLoading: a,
|
|
27
|
+
isAuthConfigured: g,
|
|
28
|
+
refreshAuthToken: k,
|
|
29
|
+
sessionToken: h,
|
|
30
|
+
refreshSession: c,
|
|
31
|
+
getCaptchaHeader: r,
|
|
32
|
+
invalidateCaptcha: u,
|
|
33
|
+
effectiveAuthToken: o ?? (e ? s : h),
|
|
34
|
+
applicableRefreshSession: o || e ? void 0 : c
|
|
35
|
+
};
|
|
36
|
+
return /* @__PURE__ */ T(p.Provider, { value: O, children: t });
|
|
37
|
+
}, N = () => {
|
|
38
|
+
const t = y(p);
|
|
39
|
+
if (!t)
|
|
40
|
+
throw new Error("useChatAuth must be used within a ChatAuthProvider");
|
|
41
|
+
return t;
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
J as ChatAuthProvider,
|
|
45
|
+
N as useChatAuth
|
|
46
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react/jsx-runtime"),g=require("react"),j=require("./config-provider.cjs"),B=require("./chat-auth-provider.cjs"),O=require("../hooks/use-events-api.cjs"),U=require("./base-events-provider.cjs"),x=({children:h})=>{const{baseSettings:n,aiChatSettings:y,componentType:c}=j.useInkeepConfig(),{tags:t,analyticsProperties:r,privacyPreferences:b,userProperties:o}=n,p="0.16.2",a=g.useMemo(()=>({widgetLibraryVersion:p,componentType:c}),[c,p]),{effectiveAuthToken:i,applicableRefreshSession:f,getCaptchaHeader:E,invalidateCaptcha:P}=B.useChatAuth(),{baseUrl:m,appId:A,analyticsApiBaseUrl:C}=y,l=b?.optOutAllAnalytics??!1,{logEvent:v}=O.useEventsApi({baseUrl:C??m,appId:A,authToken:i,getCaptchaHeader:E,invalidateCaptcha:P,refreshSession:f}),I={logEvent:g.useCallback(async s=>{const k={eventName:s.eventName,properties:{...a,...t?{tags:t}:{},...s.properties,...r}};if(!l&&i){const e=s.properties??{},u=typeof e.conversationId=="string"?e.conversationId:void 0,d=typeof e.messageId=="string"?e.messageId:void 0,q=!!o&&Object.keys(o).length>0,S={...t?{tags:t}:{},...r??{}},w={...a,...s.properties};v({body:{type:s.eventName,...u?{conversationId:u}:{},...d?{messageId:d}:{},...q?{userProperties:o}:{},properties:S,metadata:w}})}try{return await n.onEvent?.(k)}catch(e){console.warn("[events] onEvent callback threw",e)}},[n,a,t,r,v,l,i,o])};return T.jsx(U.BaseEventsContext.Provider,{value:I,children:h})};exports.ChatBaseEventsProvider=x;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-publishes BaseEventsContext for the chat subtree with an augmented logger
|
|
3
|
+
* that also POSTs to /run/v1/events. Outer BaseEventsProvider (search-side, no
|
|
4
|
+
* API) is unaffected — chat-tree consumers see this provider's logger, everyone
|
|
5
|
+
* else (widget triggers, search) sees the simple onEvent-only logger.
|
|
6
|
+
*
|
|
7
|
+
* Reads auth from ChatAuthProvider (parent), not useChat (child) — this is the
|
|
8
|
+
* direction-flip that breaks the previous cycle.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ChatBaseEventsProvider: React.FC<{
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as T } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as U, useCallback as x } from "react";
|
|
4
|
+
import { useInkeepConfig as B } from "./config-provider.js";
|
|
5
|
+
import { useChatAuth as N } from "./chat-auth-provider.js";
|
|
6
|
+
import { useEventsApi as O } from "../hooks/use-events-api.js";
|
|
7
|
+
import { BaseEventsContext as j } from "./base-events-provider.js";
|
|
8
|
+
const D = ({ children: g }) => {
|
|
9
|
+
const { baseSettings: n, aiChatSettings: f, componentType: c } = B(), { tags: t, analyticsProperties: r, privacyPreferences: u, userProperties: o } = n, p = "0.16.2", a = U(
|
|
10
|
+
() => ({
|
|
11
|
+
widgetLibraryVersion: p,
|
|
12
|
+
componentType: c
|
|
13
|
+
}),
|
|
14
|
+
[c, p]
|
|
15
|
+
), { effectiveAuthToken: i, applicableRefreshSession: h, getCaptchaHeader: y, invalidateCaptcha: b } = N(), { baseUrl: A, appId: E, analyticsApiBaseUrl: C } = f, l = u?.optOutAllAnalytics ?? !1, { logEvent: v } = O({
|
|
16
|
+
baseUrl: C ?? A,
|
|
17
|
+
appId: E,
|
|
18
|
+
authToken: i,
|
|
19
|
+
getCaptchaHeader: y,
|
|
20
|
+
invalidateCaptcha: b,
|
|
21
|
+
refreshSession: h
|
|
22
|
+
}), I = { logEvent: x(
|
|
23
|
+
async (s) => {
|
|
24
|
+
const P = {
|
|
25
|
+
eventName: s.eventName,
|
|
26
|
+
properties: {
|
|
27
|
+
...a,
|
|
28
|
+
...t ? { tags: t } : {},
|
|
29
|
+
...s.properties,
|
|
30
|
+
...r
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
if (!l && i) {
|
|
34
|
+
const e = s.properties ?? {}, m = typeof e.conversationId == "string" ? e.conversationId : void 0, d = typeof e.messageId == "string" ? e.messageId : void 0, k = !!o && Object.keys(o).length > 0, w = {
|
|
35
|
+
...t ? { tags: t } : {},
|
|
36
|
+
...r ?? {}
|
|
37
|
+
}, S = {
|
|
38
|
+
...a,
|
|
39
|
+
...s.properties
|
|
40
|
+
};
|
|
41
|
+
v({
|
|
42
|
+
body: {
|
|
43
|
+
type: s.eventName,
|
|
44
|
+
...m ? { conversationId: m } : {},
|
|
45
|
+
...d ? { messageId: d } : {},
|
|
46
|
+
...k ? { userProperties: o } : {},
|
|
47
|
+
properties: w,
|
|
48
|
+
metadata: S
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
return await n.onEvent?.(P);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
console.warn("[events] onEvent callback threw", e);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
[
|
|
59
|
+
n,
|
|
60
|
+
a,
|
|
61
|
+
t,
|
|
62
|
+
r,
|
|
63
|
+
v,
|
|
64
|
+
l,
|
|
65
|
+
i,
|
|
66
|
+
o
|
|
67
|
+
]
|
|
68
|
+
) };
|
|
69
|
+
return /* @__PURE__ */ T(j.Provider, { value: I, children: g });
|
|
70
|
+
};
|
|
71
|
+
export {
|
|
72
|
+
D as ChatBaseEventsProvider
|
|
73
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react/jsx-runtime"),a=require("react"),T=require("../components/embedded-chat/chat-provider.cjs"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react/jsx-runtime"),a=require("react"),T=require("../components/embedded-chat/chat-provider.cjs"),F=require("../utils/misc.cjs"),A=require("./config-provider.cjs"),E=require("./base-events-provider.cjs"),j=require("../hooks/use-feedback-api.cjs"),l=a.createContext(void 0);function y(){const{baseSettings:t,aiChatSettings:c}=A.useInkeepConfig(),[p,g]=a.useState(null),[f,C]=a.useState({}),{conversationId:o,messages:r,authToken:h,getCaptchaHeader:m,invalidateCaptcha:P,refreshSession:q}=T.useChat(),{analyticsProperties:d}=t,{logEvent:b}=E.useBaseEvents(),{submitFeedback:k}=j.useFeedbackApi({baseUrl:c.baseUrl,appId:c.appId,authToken:h,getCaptchaHeader:m,invalidateCaptcha:P,refreshSession:q}),i=a.useCallback(async(e,s,u)=>{C(n=>({...n,[e]:{type:s,messageId:e,details:u}})),t.onFeedback?t.onFeedback({type:s,messageId:e,details:u,properties:d}).catch(n=>console.warn("[feedback] onFeedback error:",n)):k({conversationId:o,messageId:e,type:s,details:u}).catch(n=>console.warn("[feedback] submitFeedbackToApi error:",n));const v=r.findIndex(n=>n.id===e),x=r[v],S={conversationId:o,question:F.getMessageContent(r[v-1]),answer:F.getMessageContent(x),messageId:e,details:u};b({eventName:s==="positive"?"assistant_positive_feedback_submitted":"assistant_negative_feedback_submitted",properties:S}),s==="negative"&&b({eventName:"user_escalation_indicated",properties:{escalationType:"downvote",conversationId:o,messageId:e}})},[r,o,d,t,b,k]),_=a.useCallback(async e=>{i(e,"positive")},[i]),w=a.useCallback(async(e,s)=>{i(e,"negative",s)},[i]);return{feedback:f,currentFeedback:p,setCurrentFeedback:g,submitPositiveFeedback:_,submitNegativeFeedback:w}}const N=({children:t})=>{const c=y();return M.jsx(l.Provider,{value:c,children:t})},R=()=>{const t=a.useContext(l);if(!t)throw new Error("useFeedback must be used within a FeedbackProvider");return t};exports.FeedbackProvider=N;exports.useMessageFeedback=R;
|
|
@@ -1,70 +1,76 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as E } from "react/jsx-runtime";
|
|
3
|
-
import { useContext as N, useState as
|
|
3
|
+
import { useContext as N, useState as m, useCallback as d, createContext as M } from "react";
|
|
4
4
|
import { useChat as U } from "../components/embedded-chat/chat-provider.js";
|
|
5
|
-
import { getMessageContent as
|
|
5
|
+
import { getMessageContent as v } from "../utils/misc.js";
|
|
6
6
|
import { useInkeepConfig as j } from "./config-provider.js";
|
|
7
7
|
import { useBaseEvents as q } from "./base-events-provider.js";
|
|
8
8
|
import { useFeedbackApi as y } from "../hooks/use-feedback-api.js";
|
|
9
|
-
const
|
|
9
|
+
const f = M(void 0);
|
|
10
10
|
function B() {
|
|
11
|
-
const { baseSettings: t, aiChatSettings: n } = j(), [
|
|
11
|
+
const { baseSettings: t, aiChatSettings: n } = j(), [F, l] = m(null), [C, h] = m({}), {
|
|
12
|
+
conversationId: a,
|
|
13
|
+
messages: c,
|
|
14
|
+
authToken: g,
|
|
15
|
+
getCaptchaHeader: _,
|
|
16
|
+
invalidateCaptcha: w,
|
|
17
|
+
refreshSession: x
|
|
18
|
+
} = U(), { analyticsProperties: u } = t, { logEvent: b } = q(), { submitFeedback: k } = y({
|
|
12
19
|
baseUrl: n.baseUrl,
|
|
13
20
|
appId: n.appId,
|
|
14
|
-
authToken:
|
|
15
|
-
getCaptchaHeader:
|
|
16
|
-
invalidateCaptcha:
|
|
17
|
-
refreshSession:
|
|
18
|
-
}), r =
|
|
19
|
-
async (e,
|
|
20
|
-
|
|
21
|
-
(
|
|
22
|
-
) : x({ conversationId: a, messageId: e, type: s, details: i }).catch(
|
|
23
|
-
(o) => console.warn("[feedback] submitFeedbackToApi error:", o)
|
|
21
|
+
authToken: g,
|
|
22
|
+
getCaptchaHeader: _,
|
|
23
|
+
invalidateCaptcha: w,
|
|
24
|
+
refreshSession: x
|
|
25
|
+
}), r = d(
|
|
26
|
+
async (e, o, i) => {
|
|
27
|
+
h((s) => ({ ...s, [e]: { type: o, messageId: e, details: i } })), t.onFeedback ? t.onFeedback({ type: o, messageId: e, details: i, properties: u }).catch((s) => console.warn("[feedback] onFeedback error:", s)) : k({ conversationId: a, messageId: e, type: o, details: i }).catch(
|
|
28
|
+
(s) => console.warn("[feedback] submitFeedbackToApi error:", s)
|
|
24
29
|
);
|
|
25
|
-
const
|
|
30
|
+
const p = c.findIndex((s) => s.id === e), T = c[p], A = {
|
|
26
31
|
conversationId: a,
|
|
27
|
-
question:
|
|
28
|
-
answer:
|
|
32
|
+
question: v(c[p - 1]),
|
|
33
|
+
answer: v(T),
|
|
29
34
|
messageId: e,
|
|
30
35
|
details: i
|
|
31
36
|
};
|
|
32
|
-
|
|
33
|
-
eventName:
|
|
37
|
+
b({
|
|
38
|
+
eventName: o === "positive" ? "assistant_positive_feedback_submitted" : "assistant_negative_feedback_submitted",
|
|
34
39
|
properties: A
|
|
35
|
-
}),
|
|
40
|
+
}), o === "negative" && b({
|
|
36
41
|
eventName: "user_escalation_indicated",
|
|
37
42
|
properties: {
|
|
38
43
|
escalationType: "downvote",
|
|
39
|
-
conversationId: a
|
|
44
|
+
conversationId: a,
|
|
45
|
+
messageId: e
|
|
40
46
|
}
|
|
41
47
|
});
|
|
42
48
|
},
|
|
43
|
-
[c, a]
|
|
44
|
-
), P =
|
|
49
|
+
[c, a, u, t, b, k]
|
|
50
|
+
), P = d(
|
|
45
51
|
async (e) => {
|
|
46
52
|
r(e, "positive");
|
|
47
53
|
},
|
|
48
54
|
[r]
|
|
49
|
-
), S =
|
|
50
|
-
async (e,
|
|
51
|
-
r(e, "negative",
|
|
55
|
+
), S = d(
|
|
56
|
+
async (e, o) => {
|
|
57
|
+
r(e, "negative", o);
|
|
52
58
|
},
|
|
53
59
|
[r]
|
|
54
60
|
);
|
|
55
61
|
return {
|
|
56
|
-
feedback:
|
|
57
|
-
currentFeedback:
|
|
58
|
-
setCurrentFeedback:
|
|
62
|
+
feedback: C,
|
|
63
|
+
currentFeedback: F,
|
|
64
|
+
setCurrentFeedback: l,
|
|
59
65
|
submitPositiveFeedback: P,
|
|
60
66
|
submitNegativeFeedback: S
|
|
61
67
|
};
|
|
62
68
|
}
|
|
63
69
|
const L = ({ children: t }) => {
|
|
64
70
|
const n = B();
|
|
65
|
-
return /* @__PURE__ */ E(
|
|
71
|
+
return /* @__PURE__ */ E(f.Provider, { value: n, children: t });
|
|
66
72
|
}, O = () => {
|
|
67
|
-
const t = N(
|
|
73
|
+
const t = N(f);
|
|
68
74
|
if (!t)
|
|
69
75
|
throw new Error("useFeedback must be used within a FeedbackProvider");
|
|
70
76
|
return t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./base-events-provider.cjs"),u=require("./chat-auth-provider.cjs"),b=require("./chat-base-events-provider.cjs"),o=require("./chat-form-provider.cjs"),d=require("./chat-history-provider.cjs"),i=require("./config-provider.cjs"),n=require("./feedback-provider.cjs"),v=require("./form-field-provider.cjs"),s=require("./help-menu-provider.cjs"),P=require("./markdown-provider.cjs"),a=require("./message-provider.cjs"),c=require("./root-provider.cjs"),h=require("./source-item-provider.cjs"),l=require("./theme-provider.cjs"),C=require("./widget-provider.cjs"),e=require("./sidebar-chat-provider.cjs"),r=require("./chat-bubble-provider.cjs");exports.BaseEventsContext=t.BaseEventsContext;exports.BaseEventsProvider=t.BaseEventsProvider;exports.useBaseEvents=t.useBaseEvents;exports.ChatAuthProvider=u.ChatAuthProvider;exports.useChatAuth=u.useChatAuth;exports.ChatBaseEventsProvider=b.ChatBaseEventsProvider;exports.ChatFormProvider=o.ChatFormProvider;exports.useChatForm=o.useChatForm;exports.useChatFormState=o.useChatFormState;exports.ChatHistoryProvider=d.ChatHistoryProvider;exports.useChatHistory=d.useChatHistory;exports.InkeepConfigProvider=i.InkeepConfigProvider;exports.WebWidgetInteractionType=i.WebWidgetInteractionType;exports.useInkeepConfig=i.useInkeepConfig;exports.FeedbackProvider=n.FeedbackProvider;exports.useMessageFeedback=n.useMessageFeedback;exports.FormFieldProvider=v.FormFieldProvider;exports.useFormField=v.useFormField;exports.HelpMenuProvider=s.HelpMenuProvider;exports.useHelpMenu=s.useHelpMenu;exports.useHelpMenuState=s.useHelpMenuState;exports.ChatMarkdownProvider=P.ChatMarkdownProvider;exports.useChatMarkdown=P.useChatMarkdown;exports.MessageProvider=a.MessageProvider;exports.useMessage=a.useMessage;exports.useOptionalMessage=a.useOptionalMessage;exports.RootProvider=c.RootProvider;exports.SourceItemProvider=h.SourceItemProvider;exports.useSourceItem=h.useSourceItem;exports.ThemeProvider=l.ThemeProvider;exports.WidgetProvider=C.WidgetProvider;exports.useWidget=C.useWidget;exports.SidebarChatProvider=e.SidebarChatProvider;exports.useInkeepSidebarChat=e.useInkeepSidebarChat;exports.useOptionalSidebarChat=e.useOptionalSidebarChat;exports.useSidebarChat=e.useSidebarChat;exports.ChatBubbleProvider=r.ChatBubbleProvider;exports.useChatBubble=r.useChatBubble;exports.useInkeepChatBubble=r.useInkeepChatBubble;exports.useOptionalChatBubble=r.useOptionalChatBubble;
|
|
@@ -1,53 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
1
|
+
import { BaseEventsContext as o, BaseEventsProvider as t, useBaseEvents as a } from "./base-events-provider.js";
|
|
2
|
+
import { ChatAuthProvider as i, useChatAuth as u } from "./chat-auth-provider.js";
|
|
3
|
+
import { ChatBaseEventsProvider as p } from "./chat-base-events-provider.js";
|
|
4
|
+
import { ChatFormProvider as h, useChatForm as n, useChatFormState as v } from "./chat-form-provider.js";
|
|
5
|
+
import { ChatHistoryProvider as f, useChatHistory as x } from "./chat-history-provider.js";
|
|
6
|
+
import { InkeepConfigProvider as b, WebWidgetInteractionType as l, useInkeepConfig as g } from "./config-provider.js";
|
|
7
|
+
import { FeedbackProvider as M, useMessageFeedback as k } from "./feedback-provider.js";
|
|
8
|
+
import { FormFieldProvider as S, useFormField as I } from "./form-field-provider.js";
|
|
9
|
+
import { HelpMenuProvider as H, useHelpMenu as E, useHelpMenuState as W } from "./help-menu-provider.js";
|
|
10
|
+
import { ChatMarkdownProvider as O, useChatMarkdown as w } from "./markdown-provider.js";
|
|
11
|
+
import { MessageProvider as T, useMessage as R, useOptionalMessage as j } from "./message-provider.js";
|
|
12
|
+
import { RootProvider as z } from "./root-provider.js";
|
|
13
|
+
import { SourceItemProvider as G, useSourceItem as J } from "./source-item-provider.js";
|
|
14
|
+
import { ThemeProvider as L } from "./theme-provider.js";
|
|
15
|
+
import { WidgetProvider as Q, useWidget as U } from "./widget-provider.js";
|
|
16
|
+
import { SidebarChatProvider as X, useInkeepSidebarChat as Y, useOptionalSidebarChat as Z, useSidebarChat as _ } from "./sidebar-chat-provider.js";
|
|
17
|
+
import { ChatBubbleProvider as ee, useChatBubble as re, useInkeepChatBubble as oe, useOptionalChatBubble as te } from "./chat-bubble-provider.js";
|
|
16
18
|
export {
|
|
17
|
-
o as
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
p as
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
z as
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
19
|
+
o as BaseEventsContext,
|
|
20
|
+
t as BaseEventsProvider,
|
|
21
|
+
i as ChatAuthProvider,
|
|
22
|
+
p as ChatBaseEventsProvider,
|
|
23
|
+
ee as ChatBubbleProvider,
|
|
24
|
+
h as ChatFormProvider,
|
|
25
|
+
f as ChatHistoryProvider,
|
|
26
|
+
O as ChatMarkdownProvider,
|
|
27
|
+
M as FeedbackProvider,
|
|
28
|
+
S as FormFieldProvider,
|
|
29
|
+
H as HelpMenuProvider,
|
|
30
|
+
b as InkeepConfigProvider,
|
|
31
|
+
T as MessageProvider,
|
|
32
|
+
z as RootProvider,
|
|
33
|
+
X as SidebarChatProvider,
|
|
34
|
+
G as SourceItemProvider,
|
|
35
|
+
L as ThemeProvider,
|
|
36
|
+
l as WebWidgetInteractionType,
|
|
37
|
+
Q as WidgetProvider,
|
|
38
|
+
a as useBaseEvents,
|
|
39
|
+
u as useChatAuth,
|
|
40
|
+
re as useChatBubble,
|
|
41
|
+
n as useChatForm,
|
|
42
|
+
v as useChatFormState,
|
|
43
|
+
x as useChatHistory,
|
|
44
|
+
w as useChatMarkdown,
|
|
45
|
+
I as useFormField,
|
|
46
|
+
E as useHelpMenu,
|
|
47
|
+
W as useHelpMenuState,
|
|
48
|
+
oe as useInkeepChatBubble,
|
|
49
|
+
g as useInkeepConfig,
|
|
50
|
+
Y as useInkeepSidebarChat,
|
|
51
|
+
R as useMessage,
|
|
52
|
+
k as useMessageFeedback,
|
|
53
|
+
te as useOptionalChatBubble,
|
|
54
|
+
j as useOptionalMessage,
|
|
55
|
+
Z as useOptionalSidebarChat,
|
|
56
|
+
_ as useSidebarChat,
|
|
57
|
+
J as useSourceItem,
|
|
58
|
+
U as useWidget
|
|
53
59
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("react"),s=require("../styled/components/embedded-chat.cjs"),a=require("../styled/components/chat-history.cjs"),C=require("../styled/components/modal.cjs"),H=require("../styled/components/shadow.cjs"),I=require("../styled/components/message.cjs"),A=require("../primitives/providers/chat-history-provider.cjs"),b=require("../primitives/providers/config-provider.cjs"),w=require("../primitives/providers/root-provider.cjs"),k=require("../primitives/providers/widget-provider.cjs"),M=require("../primitives/components/embedded-chat/chat-provider.cjs"),f=require("../primitives/components/modal/modal-provider.cjs"),p=require("../primitives/utils/misc.cjs"),E=require("../primitives/atoms/portal-with-theme.cjs"),P=require("../primitives/atoms/error-boundary.cjs"),B=require("./modal.cjs"),L=require("../primitives/providers/image-preview-provider.cjs"),q=require("./widget-toggle.cjs"),y=require("../primitives/components/embedded-chat/file-upload-input.cjs"),i=require("../styled/components/embedded-chat/file-upload-input.cjs"),m=require("../styled/components/embedded-chat/image-preview-modal.cjs");function D(r){const{baseSettings:t,aiChatSettings:n}=r;return e.jsx(P.ErrorBoundary,{children:e.jsx(H.Shadow,{wrapperStyles:{height:"inherit",width:"inherit"},children:e.jsx(w.RootProvider,{config:{baseSettings:t,aiChatSettings:n},componentType:b.WebWidgetInteractionType.EmbeddedChat,children:e.jsx(S,{...r})})})})}function T(r){const{children:t,onToggleView:n,isHidden:o,shouldAutoFocusInput:d=!n}=r;return e.jsx(s.Provider,{isHidden:o,shouldAutoFocusInput:d,children:t})}function S(r){return e.jsx(T,{...r,children:e.jsx(v,{...r})})}function v(r){const{onToggleView:t,variant:n,header:o=W}=r,d=f.useModal(),l=k.useWidget(),x=d&&!l?B.ModalContent:g.Fragment;return e.jsx(L.ImagePreviewProvider,{children:e.jsx(x,{children:e.jsxs(s.Wrapper,{variant:n??(t?"no-shadow":"container-with-shadow"),"data-composite":p.dataAttr(!!r.onToggleView||d?.isOpen),children:[e.jsx(Z,{}),e.jsxs(s.Root,{children:[o&&e.jsx(o,{...r}),e.jsx(N,{}),e.jsx(U,{})]}),e.jsx(z,{}),e.jsx(R,{}),e.jsx(J,{})]})})})}const W=r=>{const{onToggleView:t,askAILabel:n,searchLabel:o}=r,{aiChatSettings:d}=b.useInkeepConfig(),l=d.isChatHistoryButtonVisible,x=!!t||l;return e.jsx(s.Header,{"data-show-toolbar":p.dataAttr(x),children:x?e.jsxs(s.HeaderToolbar,{"data-show-widget-toggle":p.dataAttr(!!t),children:[e.jsx(s.HeaderToolbarWrapper,{children:l&&e.jsx(s.ChatHistoryTrigger,{})}),t&&e.jsx(q.WidgetToggle,{onToggleView:t,askAILabel:n,searchLabel:o,view:"chat"}),e.jsx(C.Close,{})]}):e.jsx(C.Close,{})})};function N(){const{isSessionLoading:r}=M.useChat();return e.jsx(s.Content,{children:e.jsxs(s.ContentScrollArea,{children:[e.jsx(s.ContentScrollAreaViewport,{children:r?e.jsx(s.MessagesSessionLoading,{}):e.jsx(V,{})}),e.jsx(s.ContentScrollAreaScrollbar,{children:e.jsx(s.ContentScrollAreaThumb,{})}),e.jsx(s.ContentScrollAreaCorner,{})]})})}function V(){const{aiChatSettings:{components:r}}=b.useInkeepConfig();return e.jsx(s.Messages,{children:({messages:t,isLoading:n,isStreaming:o})=>{const d=t.at(-1),l=(c,j)=>{const h=r?.[c];if(!h)return console.warn(`Component "${c}" not found in components config`),null;try{if(typeof h=="function"&&h.length<=1)return g.createElement(h,j);const u=h(j,document.createElement("div"),null);return g.isValidElement(u)||typeof u=="string"?u:null}catch(u){return console.error(`🔍 [renderComponent] Error rendering component "${c}":`,u),null}},x=c=>e.jsx(s.Markdown,{text:c});return e.jsxs(e.Fragment,{children:[e.jsx($,{}),t.map(c=>{const j=d?.id===c.id;return e.jsxs(s.MessageWrapper,{message:c,children:[e.jsx(F,{}),e.jsxs(s.MessageContentWrapper,{children:[e.jsx(s.MessageContent,{children:r?.IkpMessage?e.jsx(s.DynamicComponent,{name:"IkpMessage",props:{message:c,renderComponent:l,renderMarkdown:x},componentDef:r.IkpMessage}):e.jsxs(e.Fragment,{children:[e.jsx(I.EmbeddedChatMessagePart,{isLast:j}),(!o||!j)&&e.jsx(O,{})]})}),e.jsx(_,{}),e.jsx(Q,{})]})]},c.id)}),n&&d?.role==="user"&&d?.parts.length&&e.jsxs(s.MessageWrapper,{message:{id:"___loader___",role:"assistant",parts:[{type:"text",text:"Thinking..."}]},children:[e.jsx(F,{}),e.jsx(s.MessageLoading,{})]})]})}})}function $(){return e.jsxs(s.IntroMessageWrapper,{children:[e.jsxs(s.MessageHeader,{children:[e.jsx(s.MessageAvatar,{children:e.jsx(s.MessageAvatarContent,{children:e.jsx(s.MessageAvatarImage,{})})}),e.jsx(s.MessageName,{})]}),e.jsxs(s.MessageContentWrapper,{children:[e.jsx(s.MessageContent,{children:e.jsx(I.EmbeddedChatMessagePart,{isLast:!1})}),e.jsxs(s.Disclaimer,{children:[e.jsx(s.DisclaimerLabel,{}),e.jsx(s.DisclaimerTrigger,{}),e.jsxs(s.DisclaimerContent,{children:[e.jsx(s.DisclaimerText,{}),e.jsx(s.DisclaimerArrow,{})]})]}),e.jsxs(s.ExampleQuestions,{children:[e.jsx(s.ExampleQuestionsLabel,{}),e.jsx(s.ExampleQuestionsList,{children:r=>r.map(t=>e.jsx(s.ExampleQuestion,{children:e.jsx(s.ExampleQuestionButton,{question:t})},typeof t=="object"?t.label:t))})]})]})]})}function F(){return e.jsxs(s.MessageHeader,{children:[e.jsx(s.MessageAvatar,{children:e.jsx(s.MessageAvatarContent,{children:e.jsx(s.MessageAvatarImage,{})})}),e.jsx(s.MessageName,{})]})}function R(){return e.jsx(E.PortalWithTheme,{children:e.jsx(m.EmbeddedChatImagePreviewModal,{children:e.jsx(m.EmbeddedChatImagePreviewModalOverlay,{children:e.jsxs(m.EmbeddedChatImagePreviewModalContent,{children:[e.jsx(m.EmbeddedChatImagePreviewModalClose,{}),e.jsx(m.EmbeddedChatImagePreviewModalImage,{}),e.jsx(m.EmbeddedChatImagePreviewModalFooter,{children:e.jsx(m.EmbeddedChatImagePreviewModalFileName,{})})]})})})})}function _(){return e.jsx(i.EmbeddedChatMessageFiles,{children:r=>r.map((t,n)=>{const o=t.url,d=t.mediaType??"",l=d.split("/").pop(),x=t.filename??(l?`untitled.${l}`:"untitled"),c=y.isImageMimeType(d);return e.jsxs(i.EmbeddedChatMessageFile,{url:o,name:x,mediaType:d,children:[c?e.jsx(i.EmbeddedChatFileThumbnail,{}):e.jsx(i.EmbeddedChatFileTypeIcon,{}),e.jsx(i.EmbeddedChatFileName,{})]},o||n)})})}function Q(){return e.jsxs(s.MessageToolbar,{children:[e.jsx(s.MessageCustomActions,{children:r=>r.map((t,n)=>e.jsx(s.MessageCustomAction,{action:t},`action-${n}`))}),e.jsx(s.MessageAction,{action:"copy"}),e.jsx(s.MessageAction,{action:"upvote"}),e.jsx(s.MessageAction,{action:"downvote"})]})}function O(){return e.jsxs(s.MessageSources,{children:[e.jsx(s.MessageSourcesHeader,{}),e.jsx(s.MessageSourcesList,{children:r=>r.map((t,n)=>e.jsxs(s.MessageSourceItem,{href:t.url,source:t,children:[e.jsx(s.MessageSourceItemBreadcrumbs,{children:t.breadcrumbs?.map(o=>e.jsxs(g.Fragment,{children:[o,e.jsx(s.MessageSourceItemBreadcrumbIcon,{})]},o))}),e.jsx(s.MessageSourceItemIcon,{}),e.jsx(s.MessageSourceItemTitle,{}),e.jsx(s.MessageSourceItemTag,{}),e.jsx(s.MessageSourceItemDescription,{children:o=>o.map((d,l)=>e.jsx(s.MessageSourceItemDescriptionPart,{descriptionPart:d},`part-${l}`))}),e.jsx(s.MessageSourceItemIndicator,{})]},n))})]})}function U(){return e.jsxs(s.Footer,{children:[e.jsx(i.EmbeddedChatInputNotification,{children:e.jsxs(i.EmbeddedChatInputNotificationContent,{children:[e.jsxs(i.EmbeddedChatInputNotificationHeader,{children:[e.jsx(i.EmbeddedChatInputNotificationTitle,{}),e.jsx(i.EmbeddedChatInputNotificationClose,{})]}),e.jsx(i.EmbeddedChatInputNotificationMessage,{})]})}),e.jsx(G,{}),e.jsx(K,{})]})}function G(){return e.jsxs(s.InputFieldset,{children:[e.jsx(i.EmbeddedChatFileInput,{}),e.jsx(i.EmbeddedChatDropZone,{children:"Drop files here to add to chat"}),e.jsx(i.EmbeddedChatFileList,{children:r=>r.map((t,n)=>{const o=y.isImageMimeType(t.type);return e.jsxs(i.EmbeddedChatFileItem,{file:t,children:[o?e.jsxs(i.EmbeddedChatFilePreviewTrigger,{children:[e.jsx(i.EmbeddedChatFileThumbnail,{}),e.jsx(i.EmbeddedChatFileName,{})]}):e.jsxs(i.EmbeddedChatFileContent,{children:[e.jsx(i.EmbeddedChatFileTypeIcon,{}),e.jsx(i.EmbeddedChatFileName,{})]}),e.jsx(i.EmbeddedChatFileRemove,{})]},`${t.name}-${t.lastModified}-${n}`)})}),e.jsxs(s.InputGroup,{children:[e.jsx(i.EmbeddedChatFileUploadButton,{}),e.jsx(s.Input,{}),e.jsx(s.SendButton,{children:e.jsx(s.SendButtonIcon,{})})]})]})}function K(){return e.jsxs(s.ActionBar,{children:[e.jsxs(s.TaglineContainer,{children:[e.jsx(s.TaglineText,{}),e.jsx(s.TaglineLogo,{})]}),e.jsxs(s.Actions,{children:[e.jsx(s.HelpActions,{children:({pinned:r,unpinned:t})=>e.jsxs(e.Fragment,{children:[r.map(n=>e.jsx(s.HelpAction,{action:n},n.name)),t.length>0&&e.jsx(s.HelpActionsTrigger,{}),e.jsxs(s.HelpActionsMenu,{children:[e.jsx(s.HelpActionsMenuArrow,{}),t.map(n=>e.jsxs(s.HelpActionsMenuItem,{action:n,children:[e.jsx(s.HelpActionsMenuItemIcon,{action:n}),n.name]},n.name))]})]})}),e.jsxs(s.ChatAction,{action:"copy",children:[e.jsx(s.ChatActionLabel,{action:"copy"}),e.jsx(s.ChatActionFeedback,{action:"copy"})]}),e.jsx(s.ChatAction,{action:"clear"}),e.jsx(s.ChatAction,{action:"stop"})]})]})}function Z(){const{sessions:r}=A.useChatHistory(),{conversationId:t}=M.useChat();return e.jsxs(a.EmbeddedChatHistoryRoot,{children:[e.jsxs(a.EmbeddedChatHistoryHeader,{children:[e.jsxs(a.EmbeddedChatHistoryBackButton,{children:[e.jsx(a.EmbeddedChatHistoryBackButtonIcon,{iconKey:"backToChat"}),"Back to chat"]}),e.jsx(a.EmbeddedChatHistoryTitle,{}),e.jsx(C.Close,{})]}),e.jsxs(a.EmbeddedChatHistoryList,{children:[r.map(n=>e.jsxs(a.EmbeddedChatHistoryItem,{sessionId:n.id,"data-active":p.dataAttr(n.id===t),children:[e.jsx(a.EmbeddedChatHistoryItemTitle,{children:n.title}),e.jsx(a.EmbeddedChatHistoryItemDate,{children:a.formatSessionDate(n.updatedAt)})]},n.id)),e.jsx(a.EmbeddedChatHistoryEmptyState,{}),e.jsx(a.EmbeddedChatHistoryLoadingState,{})]}),e.jsx(a.EmbeddedChatHistoryFooter,{children:e.jsx(a.EmbeddedChatHistoryNewConversationButton,{})})]})}function z(){return e.jsx(E.PortalWithTheme,{children:e.jsx(s.FeedbackModal,{children:e.jsx(s.FeedbackModalOverlay,{children:e.jsxs(s.FeedbackModalContent,{children:[e.jsx(s.FeedbackModalHeader,{}),e.jsx(s.FeedbackModalClose,{}),e.jsx(s.FeedbackModalBody,{children:e.jsxs(s.FeedbackForm,{children:[e.jsxs(s.FeedbackField,{children:[e.jsx(s.FeedbackItemLabel,{}),e.jsx(s.FeedbackItemDescription,{})]}),e.jsx(s.FeedbackSubmitButton,{})]})})]})})})})}function J(){return e.jsxs(s.FormWrapper,{children:[e.jsx(s.FormClose,{}),e.jsxs(s.Form,{children:[e.jsxs(s.FormHeader,{children:[e.jsx(s.FormHeading,{}),e.jsx(s.FormDescription,{})]}),e.jsx(s.FormContent,{children:r=>e.jsxs(e.Fragment,{children:[r.map((t,n)=>e.jsxs(s.FormField,{field:t,autoFocus:n===0,children:[e.jsx(s.FormFieldLabel,{}),t.inputType==="text"&&e.jsx(s.FormFieldText,{}),t.inputType==="email"&&e.jsx(s.FormFieldEmail,{}),t.inputType==="file"&&e.jsx(s.FormFieldFile,{}),t.inputType==="textarea"&&e.jsx(s.FormFieldTextArea,{}),t.inputType==="checkbox"&&e.jsx(s.FormFieldCheckbox,{children:e.jsx(s.FormFieldCheckboxIndicator,{})}),t.inputType==="select"&&e.jsxs(s.FormFieldSelect,{children:[e.jsxs(s.FormFieldSelectTrigger,{children:[e.jsx(s.FormFieldSelectValue,{}),e.jsx(s.FormFieldSelectIcon,{})]}),e.jsx(s.FormFieldSelectContent,{children:e.jsx(s.FormFieldSelectViewport,{children:t.items.map(o=>e.jsxs(s.FormFieldSelectItem,{value:o.value,children:[e.jsx(s.FormFieldSelectItemText,{children:o.label}),e.jsx(s.FormFieldSelectItemIndicator,{})]},o.value))})})]}),t.inputType==="combobox"&&e.jsxs(s.FormFieldCombobox,{children:[e.jsxs(s.FormFieldComboboxControl,{children:["multiple"in t&&t.multiple&&e.jsx(s.FormFieldComboboxSelectedTags,{}),e.jsx(s.FormFieldComboboxInput,{}),e.jsx(s.FormFieldComboboxTrigger,{})]}),e.jsx(s.FormFieldComboboxPositioner,{children:e.jsx(s.FormFieldComboboxContent,{children:e.jsx(s.FormFieldComboboxList,{children:e.jsx(s.FormFieldComboboxListItems,{children:o=>o.length===0?e.jsx(s.FormFieldComboboxListEmpty,{}):o.map(d=>e.jsxs(s.FormFieldComboboxItem,{item:d,children:[e.jsx(s.FormFieldComboboxItemText,{children:d.label}),e.jsx(s.FormFieldComboboxItemIndicator,{})]},d.value))})})})})]}),e.jsx(s.FormFieldDescription,{}),e.jsx(s.FormFieldError,{})]},t.name)),e.jsx(s.FormError,{})]})}),e.jsxs(s.FormFooter,{children:[e.jsx(s.FormCancel,{}),e.jsx(s.FormSubmit,{})]})]}),e.jsxs(s.FormSuccess,{children:[e.jsx(s.FormSuccessHeading,{}),e.jsx(s.FormSuccessMessage,{}),e.jsx(s.FormSuccessButton,{})]})]})}exports.InkeepEmbeddedChat=D;exports.InkeepEmbeddedChatImpl=S;exports.InkeepEmbeddedChatImplContent=v;exports.InkeepEmbeddedChatProvider=T;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("react"),s=require("../styled/components/embedded-chat.cjs"),a=require("../styled/components/chat-history.cjs"),C=require("../styled/components/modal.cjs"),A=require("../styled/components/shadow.cjs"),I=require("../styled/components/message.cjs"),H=require("../primitives/providers/chat-auth-provider.cjs"),w=require("../primitives/providers/chat-base-events-provider.cjs"),k=require("../primitives/providers/chat-history-provider.cjs"),b=require("../primitives/providers/config-provider.cjs"),P=require("../primitives/providers/root-provider.cjs"),f=require("../primitives/providers/widget-provider.cjs"),M=require("../primitives/components/embedded-chat/chat-provider.cjs"),B=require("../primitives/components/modal/modal-provider.cjs"),p=require("../primitives/utils/misc.cjs"),E=require("../primitives/atoms/portal-with-theme.cjs"),q=require("../primitives/atoms/error-boundary.cjs"),L=require("./modal.cjs"),D=require("../primitives/providers/image-preview-provider.cjs"),W=require("./widget-toggle.cjs"),y=require("../primitives/components/embedded-chat/file-upload-input.cjs"),i=require("../styled/components/embedded-chat/file-upload-input.cjs"),m=require("../styled/components/embedded-chat/image-preview-modal.cjs");function N(r){const{baseSettings:t,aiChatSettings:n}=r;return e.jsx(q.ErrorBoundary,{children:e.jsx(A.Shadow,{wrapperStyles:{height:"inherit",width:"inherit"},children:e.jsx(P.RootProvider,{config:{baseSettings:t,aiChatSettings:n},componentType:b.WebWidgetInteractionType.EmbeddedChat,children:e.jsx(v,{...r})})})})}function T(r){const{children:t,onToggleView:n,isHidden:o,shouldAutoFocusInput:d=!n}=r;return e.jsx(H.ChatAuthProvider,{children:e.jsx(w.ChatBaseEventsProvider,{children:e.jsx(s.Provider,{isHidden:o,shouldAutoFocusInput:d,children:t})})})}function v(r){return e.jsx(T,{...r,children:e.jsx(S,{...r})})}function S(r){const{onToggleView:t,variant:n,header:o=V}=r,d=B.useModal(),l=f.useWidget(),x=d&&!l?L.ModalContent:g.Fragment;return e.jsx(D.ImagePreviewProvider,{children:e.jsx(x,{children:e.jsxs(s.Wrapper,{variant:n??(t?"no-shadow":"container-with-shadow"),"data-composite":p.dataAttr(!!r.onToggleView||d?.isOpen),children:[e.jsx(J,{}),e.jsxs(s.Root,{children:[o&&e.jsx(o,{...r}),e.jsx($,{}),e.jsx(K,{})]}),e.jsx(X,{}),e.jsx(Q,{}),e.jsx(Y,{})]})})})}const V=r=>{const{onToggleView:t,askAILabel:n,searchLabel:o}=r,{aiChatSettings:d}=b.useInkeepConfig(),l=d.isChatHistoryButtonVisible,x=!!t||l;return e.jsx(s.Header,{"data-show-toolbar":p.dataAttr(x),children:x?e.jsxs(s.HeaderToolbar,{"data-show-widget-toggle":p.dataAttr(!!t),children:[e.jsx(s.HeaderToolbarWrapper,{children:l&&e.jsx(s.ChatHistoryTrigger,{})}),t&&e.jsx(W.WidgetToggle,{onToggleView:t,askAILabel:n,searchLabel:o,view:"chat"}),e.jsx(C.Close,{})]}):e.jsx(C.Close,{})})};function $(){const{isSessionLoading:r}=M.useChat();return e.jsx(s.Content,{children:e.jsxs(s.ContentScrollArea,{children:[e.jsx(s.ContentScrollAreaViewport,{children:r?e.jsx(s.MessagesSessionLoading,{}):e.jsx(R,{})}),e.jsx(s.ContentScrollAreaScrollbar,{children:e.jsx(s.ContentScrollAreaThumb,{})}),e.jsx(s.ContentScrollAreaCorner,{})]})})}function R(){const{aiChatSettings:{components:r}}=b.useInkeepConfig();return e.jsx(s.Messages,{children:({messages:t,isLoading:n,isStreaming:o})=>{const d=t.at(-1),l=(c,h)=>{const j=r?.[c];if(!j)return console.warn(`Component "${c}" not found in components config`),null;try{if(typeof j=="function"&&j.length<=1)return g.createElement(j,h);const u=j(h,document.createElement("div"),null);return g.isValidElement(u)||typeof u=="string"?u:null}catch(u){return console.error(`🔍 [renderComponent] Error rendering component "${c}":`,u),null}},x=c=>e.jsx(s.Markdown,{text:c});return e.jsxs(e.Fragment,{children:[e.jsx(_,{}),t.map(c=>{const h=d?.id===c.id;return e.jsxs(s.MessageWrapper,{message:c,children:[e.jsx(F,{}),e.jsxs(s.MessageContentWrapper,{children:[e.jsx(s.MessageContent,{children:r?.IkpMessage?e.jsx(s.DynamicComponent,{name:"IkpMessage",props:{message:c,renderComponent:l,renderMarkdown:x},componentDef:r.IkpMessage}):e.jsxs(e.Fragment,{children:[e.jsx(I.EmbeddedChatMessagePart,{isLast:h}),(!o||!h)&&e.jsx(G,{})]})}),e.jsx(O,{}),e.jsx(U,{})]})]},c.id)}),n&&d?.role==="user"&&d?.parts.length&&e.jsxs(s.MessageWrapper,{message:{id:"___loader___",role:"assistant",parts:[{type:"text",text:"Thinking..."}]},children:[e.jsx(F,{}),e.jsx(s.MessageLoading,{})]})]})}})}function _(){return e.jsxs(s.IntroMessageWrapper,{children:[e.jsxs(s.MessageHeader,{children:[e.jsx(s.MessageAvatar,{children:e.jsx(s.MessageAvatarContent,{children:e.jsx(s.MessageAvatarImage,{})})}),e.jsx(s.MessageName,{})]}),e.jsxs(s.MessageContentWrapper,{children:[e.jsx(s.MessageContent,{children:e.jsx(I.EmbeddedChatMessagePart,{isLast:!1})}),e.jsxs(s.Disclaimer,{children:[e.jsx(s.DisclaimerLabel,{}),e.jsx(s.DisclaimerTrigger,{}),e.jsxs(s.DisclaimerContent,{children:[e.jsx(s.DisclaimerText,{}),e.jsx(s.DisclaimerArrow,{})]})]}),e.jsxs(s.ExampleQuestions,{children:[e.jsx(s.ExampleQuestionsLabel,{}),e.jsx(s.ExampleQuestionsList,{children:r=>r.map(t=>e.jsx(s.ExampleQuestion,{children:e.jsx(s.ExampleQuestionButton,{question:t})},typeof t=="object"?t.label:t))})]})]})]})}function F(){return e.jsxs(s.MessageHeader,{children:[e.jsx(s.MessageAvatar,{children:e.jsx(s.MessageAvatarContent,{children:e.jsx(s.MessageAvatarImage,{})})}),e.jsx(s.MessageName,{})]})}function Q(){return e.jsx(E.PortalWithTheme,{children:e.jsx(m.EmbeddedChatImagePreviewModal,{children:e.jsx(m.EmbeddedChatImagePreviewModalOverlay,{children:e.jsxs(m.EmbeddedChatImagePreviewModalContent,{children:[e.jsx(m.EmbeddedChatImagePreviewModalClose,{}),e.jsx(m.EmbeddedChatImagePreviewModalImage,{}),e.jsx(m.EmbeddedChatImagePreviewModalFooter,{children:e.jsx(m.EmbeddedChatImagePreviewModalFileName,{})})]})})})})}function O(){return e.jsx(i.EmbeddedChatMessageFiles,{children:r=>r.map((t,n)=>{const o=t.url,d=t.mediaType??"",l=d.split("/").pop(),x=t.filename??(l?`untitled.${l}`:"untitled"),c=y.isImageMimeType(d);return e.jsxs(i.EmbeddedChatMessageFile,{url:o,name:x,mediaType:d,children:[c?e.jsx(i.EmbeddedChatFileThumbnail,{}):e.jsx(i.EmbeddedChatFileTypeIcon,{}),e.jsx(i.EmbeddedChatFileName,{})]},o||n)})})}function U(){return e.jsxs(s.MessageToolbar,{children:[e.jsx(s.MessageCustomActions,{children:r=>r.map((t,n)=>e.jsx(s.MessageCustomAction,{action:t},`action-${n}`))}),e.jsx(s.MessageAction,{action:"copy"}),e.jsx(s.MessageAction,{action:"upvote"}),e.jsx(s.MessageAction,{action:"downvote"})]})}function G(){return e.jsxs(s.MessageSources,{children:[e.jsx(s.MessageSourcesHeader,{}),e.jsx(s.MessageSourcesList,{children:r=>r.map((t,n)=>e.jsxs(s.MessageSourceItem,{href:t.url,source:t,children:[e.jsx(s.MessageSourceItemBreadcrumbs,{children:t.breadcrumbs?.map(o=>e.jsxs(g.Fragment,{children:[o,e.jsx(s.MessageSourceItemBreadcrumbIcon,{})]},o))}),e.jsx(s.MessageSourceItemIcon,{}),e.jsx(s.MessageSourceItemTitle,{}),e.jsx(s.MessageSourceItemTag,{}),e.jsx(s.MessageSourceItemDescription,{children:o=>o.map((d,l)=>e.jsx(s.MessageSourceItemDescriptionPart,{descriptionPart:d},`part-${l}`))}),e.jsx(s.MessageSourceItemIndicator,{})]},n))})]})}function K(){return e.jsxs(s.Footer,{children:[e.jsx(i.EmbeddedChatInputNotification,{children:e.jsxs(i.EmbeddedChatInputNotificationContent,{children:[e.jsxs(i.EmbeddedChatInputNotificationHeader,{children:[e.jsx(i.EmbeddedChatInputNotificationTitle,{}),e.jsx(i.EmbeddedChatInputNotificationClose,{})]}),e.jsx(i.EmbeddedChatInputNotificationMessage,{})]})}),e.jsx(Z,{}),e.jsx(z,{})]})}function Z(){return e.jsxs(s.InputFieldset,{children:[e.jsx(i.EmbeddedChatFileInput,{}),e.jsx(i.EmbeddedChatDropZone,{children:"Drop files here to add to chat"}),e.jsx(i.EmbeddedChatFileList,{children:r=>r.map((t,n)=>{const o=y.isImageMimeType(t.type);return e.jsxs(i.EmbeddedChatFileItem,{file:t,children:[o?e.jsxs(i.EmbeddedChatFilePreviewTrigger,{children:[e.jsx(i.EmbeddedChatFileThumbnail,{}),e.jsx(i.EmbeddedChatFileName,{})]}):e.jsxs(i.EmbeddedChatFileContent,{children:[e.jsx(i.EmbeddedChatFileTypeIcon,{}),e.jsx(i.EmbeddedChatFileName,{})]}),e.jsx(i.EmbeddedChatFileRemove,{})]},`${t.name}-${t.lastModified}-${n}`)})}),e.jsxs(s.InputGroup,{children:[e.jsx(i.EmbeddedChatFileUploadButton,{}),e.jsx(s.Input,{}),e.jsx(s.SendButton,{children:e.jsx(s.SendButtonIcon,{})})]})]})}function z(){return e.jsxs(s.ActionBar,{children:[e.jsxs(s.TaglineContainer,{children:[e.jsx(s.TaglineText,{}),e.jsx(s.TaglineLogo,{})]}),e.jsxs(s.Actions,{children:[e.jsx(s.HelpActions,{children:({pinned:r,unpinned:t})=>e.jsxs(e.Fragment,{children:[r.map(n=>e.jsx(s.HelpAction,{action:n},n.name)),t.length>0&&e.jsx(s.HelpActionsTrigger,{}),e.jsxs(s.HelpActionsMenu,{children:[e.jsx(s.HelpActionsMenuArrow,{}),t.map(n=>e.jsxs(s.HelpActionsMenuItem,{action:n,children:[e.jsx(s.HelpActionsMenuItemIcon,{action:n}),n.name]},n.name))]})]})}),e.jsxs(s.ChatAction,{action:"copy",children:[e.jsx(s.ChatActionLabel,{action:"copy"}),e.jsx(s.ChatActionFeedback,{action:"copy"})]}),e.jsx(s.ChatAction,{action:"clear"}),e.jsx(s.ChatAction,{action:"stop"})]})]})}function J(){const{sessions:r}=k.useChatHistory(),{conversationId:t}=M.useChat();return e.jsxs(a.EmbeddedChatHistoryRoot,{children:[e.jsxs(a.EmbeddedChatHistoryHeader,{children:[e.jsxs(a.EmbeddedChatHistoryBackButton,{children:[e.jsx(a.EmbeddedChatHistoryBackButtonIcon,{iconKey:"backToChat"}),"Back to chat"]}),e.jsx(a.EmbeddedChatHistoryTitle,{}),e.jsx(C.Close,{})]}),e.jsxs(a.EmbeddedChatHistoryList,{children:[r.map(n=>e.jsxs(a.EmbeddedChatHistoryItem,{sessionId:n.id,"data-active":p.dataAttr(n.id===t),children:[e.jsx(a.EmbeddedChatHistoryItemTitle,{children:n.title}),e.jsx(a.EmbeddedChatHistoryItemDate,{children:a.formatSessionDate(n.updatedAt)})]},n.id)),e.jsx(a.EmbeddedChatHistoryEmptyState,{}),e.jsx(a.EmbeddedChatHistoryLoadingState,{})]}),e.jsx(a.EmbeddedChatHistoryFooter,{children:e.jsx(a.EmbeddedChatHistoryNewConversationButton,{})})]})}function X(){return e.jsx(E.PortalWithTheme,{children:e.jsx(s.FeedbackModal,{children:e.jsx(s.FeedbackModalOverlay,{children:e.jsxs(s.FeedbackModalContent,{children:[e.jsx(s.FeedbackModalHeader,{}),e.jsx(s.FeedbackModalClose,{}),e.jsx(s.FeedbackModalBody,{children:e.jsxs(s.FeedbackForm,{children:[e.jsxs(s.FeedbackField,{children:[e.jsx(s.FeedbackItemLabel,{}),e.jsx(s.FeedbackItemDescription,{})]}),e.jsx(s.FeedbackSubmitButton,{})]})})]})})})})}function Y(){return e.jsxs(s.FormWrapper,{children:[e.jsx(s.FormClose,{}),e.jsxs(s.Form,{children:[e.jsxs(s.FormHeader,{children:[e.jsx(s.FormHeading,{}),e.jsx(s.FormDescription,{})]}),e.jsx(s.FormContent,{children:r=>e.jsxs(e.Fragment,{children:[r.map((t,n)=>e.jsxs(s.FormField,{field:t,autoFocus:n===0,children:[e.jsx(s.FormFieldLabel,{}),t.inputType==="text"&&e.jsx(s.FormFieldText,{}),t.inputType==="email"&&e.jsx(s.FormFieldEmail,{}),t.inputType==="file"&&e.jsx(s.FormFieldFile,{}),t.inputType==="textarea"&&e.jsx(s.FormFieldTextArea,{}),t.inputType==="checkbox"&&e.jsx(s.FormFieldCheckbox,{children:e.jsx(s.FormFieldCheckboxIndicator,{})}),t.inputType==="select"&&e.jsxs(s.FormFieldSelect,{children:[e.jsxs(s.FormFieldSelectTrigger,{children:[e.jsx(s.FormFieldSelectValue,{}),e.jsx(s.FormFieldSelectIcon,{})]}),e.jsx(s.FormFieldSelectContent,{children:e.jsx(s.FormFieldSelectViewport,{children:t.items.map(o=>e.jsxs(s.FormFieldSelectItem,{value:o.value,children:[e.jsx(s.FormFieldSelectItemText,{children:o.label}),e.jsx(s.FormFieldSelectItemIndicator,{})]},o.value))})})]}),t.inputType==="combobox"&&e.jsxs(s.FormFieldCombobox,{children:[e.jsxs(s.FormFieldComboboxControl,{children:["multiple"in t&&t.multiple&&e.jsx(s.FormFieldComboboxSelectedTags,{}),e.jsx(s.FormFieldComboboxInput,{}),e.jsx(s.FormFieldComboboxTrigger,{})]}),e.jsx(s.FormFieldComboboxPositioner,{children:e.jsx(s.FormFieldComboboxContent,{children:e.jsx(s.FormFieldComboboxList,{children:e.jsx(s.FormFieldComboboxListItems,{children:o=>o.length===0?e.jsx(s.FormFieldComboboxListEmpty,{}):o.map(d=>e.jsxs(s.FormFieldComboboxItem,{item:d,children:[e.jsx(s.FormFieldComboboxItemText,{children:d.label}),e.jsx(s.FormFieldComboboxItemIndicator,{})]},d.value))})})})})]}),e.jsx(s.FormFieldDescription,{}),e.jsx(s.FormFieldError,{})]},t.name)),e.jsx(s.FormError,{})]})}),e.jsxs(s.FormFooter,{children:[e.jsx(s.FormCancel,{}),e.jsx(s.FormSubmit,{})]})]}),e.jsxs(s.FormSuccess,{children:[e.jsx(s.FormSuccessHeading,{}),e.jsx(s.FormSuccessMessage,{}),e.jsx(s.FormSuccessButton,{})]})]})}exports.InkeepEmbeddedChat=N;exports.InkeepEmbeddedChatImpl=v;exports.InkeepEmbeddedChatImplContent=S;exports.InkeepEmbeddedChatProvider=T;
|