@inkeep/cxkit-primitives 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/atoms/link.cjs +1 -1
- package/dist/atoms/link.js +5 -5
- package/dist/components/chat-button.cjs +1 -1
- package/dist/components/chat-button.js +21 -21
- package/dist/components/embedded-chat/use-captcha.cjs +1 -1
- package/dist/components/embedded-chat/use-captcha.d.cts +2 -2
- package/dist/components/embedded-chat/use-captcha.d.ts +2 -2
- package/dist/components/embedded-chat/use-captcha.js +1 -1
- package/dist/components/embedded-chat/use-chat-action.cjs +1 -1
- package/dist/components/embedded-chat/use-chat-action.js +9 -9
- package/dist/components/embedded-chat/use-inkeep-chat.cjs +3 -3
- package/dist/components/embedded-chat/use-inkeep-chat.js +39 -39
- package/dist/components/embedded-chat.cjs +4 -4
- package/dist/components/embedded-chat.d.cts +6 -6
- package/dist/components/embedded-chat.d.ts +6 -6
- package/dist/components/embedded-chat.js +707 -708
- package/dist/components/embedded-search/transform-results.cjs +1 -1
- package/dist/components/embedded-search/transform-results.js +3 -3
- package/dist/components/embedded-search/use-inkeep-search.cjs +1 -1
- package/dist/components/embedded-search/use-inkeep-search.js +36 -36
- package/dist/components/embedded-search.cjs +1 -1
- package/dist/components/embedded-search.js +60 -60
- package/dist/components/intelligent-form/use-inkeep-intelligent-form.cjs +1 -1
- package/dist/components/intelligent-form/use-inkeep-intelligent-form.js +35 -35
- package/dist/components/intelligent-form.cjs +1 -1
- package/dist/components/intelligent-form.d.cts +3 -3
- package/dist/components/intelligent-form.d.ts +3 -3
- package/dist/components/intelligent-form.js +106 -106
- package/dist/components/modal/modal-provider.d.cts +1 -1
- package/dist/components/modal/modal-provider.d.ts +1 -1
- package/dist/components/modal/use-inkeep-modal.cjs +1 -1
- package/dist/components/modal/use-inkeep-modal.d.cts +1 -1
- package/dist/components/modal/use-inkeep-modal.d.ts +1 -1
- package/dist/components/modal/use-inkeep-modal.js +4 -4
- package/dist/components/modal.cjs +1 -1
- package/dist/components/modal.js +5 -5
- package/dist/hooks/use-browser-storage.cjs +1 -1
- package/dist/hooks/use-browser-storage.js +6 -6
- package/dist/providers/base-events-provider.cjs +1 -1
- package/dist/providers/base-events-provider.js +22 -22
- package/dist/providers/chat-events-provider.cjs +1 -1
- package/dist/providers/chat-events-provider.js +46 -39
- package/dist/providers/chat-form-provider.cjs +1 -1
- package/dist/providers/chat-form-provider.js +40 -40
- package/dist/providers/config-provider.cjs +1 -1
- package/dist/providers/config-provider.d.cts +7 -7
- package/dist/providers/config-provider.d.ts +7 -7
- package/dist/providers/config-provider.js +24 -24
- package/dist/providers/feedback-provider.cjs +1 -1
- package/dist/providers/feedback-provider.js +10 -10
- package/dist/providers/root-provider.cjs +1 -1
- package/dist/providers/root-provider.d.cts +1 -1
- package/dist/providers/root-provider.d.ts +1 -1
- package/dist/providers/root-provider.js +2 -2
- package/dist/providers/theme-provider.cjs +1 -1
- package/dist/providers/theme-provider.js +32 -30
- package/dist/providers/user-provider.cjs +1 -1
- package/dist/providers/user-provider.js +14 -14
- package/dist/utils/default-settings.cjs +1 -1
- package/dist/utils/default-settings.d.cts +20 -20
- package/dist/utils/default-settings.d.ts +20 -20
- package/dist/utils/default-settings.js +32 -31
- package/dist/utils/form.cjs +1 -1
- package/dist/utils/form.js +11 -11
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),S=require("../../providers/config-provider.cjs"),T=(e,o)=>{const{baseSettings:{transformSource:r,organizationDisplayName:s},searchSettings:{tabs:u,searchQueryParamKey:p,shouldOpenLinksInNewTab:g}}=S.useInkeepConfig();return w.useMemo(()=>{const R=u.length>0?u:["All"],n={},y=new Set,i=R.map(t=>typeof t=="string"?t:t[0]);for(const t of i)n[t]=[];for(const t of e){const c=t.url||"";if(y.has(c))continue;y.add(c);const d=v(c,o,p),a=r({title:t.title,url:d,description:k(t),type:D(t.rootRecord.__typename),tag:I(t),breadcrumbs:t.rootRecord.pathBreadcrumbs,contentType:t.rootRecord.contentType},"searchResultItem",{organizationDisplayName:s,tabs:u}),l={...a,id:t.id,isExternal:g||!!a.shouldOpenInNewTab},m=l.tabs||[];for(const f of m){const b=typeof f=="string"?f:f[0];if(!i.includes(b)){console.warn(`Tab "${b}" found in item but not configured in tabs`);continue}n[b].push(l)}i.includes("All")&&n.All.push(l)}for(const t of Object.keys(n)){const c=R.find(a=>typeof a=="string"?a===t:a[0]===t),d=typeof c=="object"?c[1]?.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),S=require("../../providers/config-provider.cjs"),T=(e,o)=>{const{baseSettings:{transformSource:r,organizationDisplayName:s},searchSettings:{tabs:u,searchQueryParamKey:p,shouldOpenLinksInNewTab:g}}=S.useInkeepConfig();return w.useMemo(()=>{const R=u.length>0?u:["All"],n={},y=new Set,i=R.map(t=>typeof t=="string"?t:t[0]);for(const t of i)n[t]=[];for(const t of e){const c=t.url||"";if(y.has(c))continue;y.add(c);const d=v(c,o,p),a=r({title:t.title,url:d,description:k(t),type:D(t.rootRecord.__typename),tag:I(t),breadcrumbs:t.rootRecord.pathBreadcrumbs,contentType:t.rootRecord.contentType},"searchResultItem",{organizationDisplayName:s,tabs:u}),l={...a,id:t.id,isExternal:g||!!a.shouldOpenInNewTab},m=l.tabs||[];for(const f of m){const b=typeof f=="string"?f:f[0];if(!i.includes(b)){console.warn(`Tab "${b}" found in item but not configured in tabs`);continue}n[b].push(l)}i.includes("All")&&n.All.push(l)}for(const t of Object.keys(n)){const c=R.find(a=>typeof a=="string"?a===t:a[0]===t),d=typeof c=="object"?c[1]?.isAlwaysVisible===!0:!1;n[t].length===0&&!d&&delete n[t]}return n},[e,r,s,u,o,p,g])};function v(e,o,r){try{const s=new URL(e);return s.searchParams.set(r,o),s.toString()}catch{return e}}const k=e=>{switch(e.rootRecord.__typename){case"DocumentationRecord":{const o=h(e.pathHeadings?.at(-1)?.content||""),r=h(e.content?.content||"");return e.preview||r||o}case"GitHubIssueRecord":case"StackOverflowRecord":case"DiscourseRecord":return e.rootRecord.body;default:return e.preview}},I=e=>{switch(e.rootRecord.__typename){case"StackOverflowRecord":return e.rootRecord.markedAsCorrectAnswer?"Resolved":void 0;case"GitHubIssueRecord":return e.rootRecord.state==="CLOSED"?"Closed":void 0}},h=e=>{const o=/(https?:\/\/\S+)/g;return e.replace(o,r=>{const s=r.split("/");return s.length>3?`...${s.slice(-2).join("/")}`:r})},D=e=>{switch(e){case"DocumentationRecord":return"documentation";case"GitHubIssueRecord":return"github_issue";case"DiscourseRecord":return"discourse";case"DiscordRecord":return"discord";case"StackOverflowRecord":return"stackoverflow";case"SlackEntry":return"slack_message";default:return"site"}};exports.useTransformResults=T;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useMemo as w } from "react";
|
|
3
3
|
import { useInkeepConfig as S } from "../../providers/config-provider.js";
|
|
4
|
-
const
|
|
4
|
+
const A = (e, r) => {
|
|
5
5
|
const {
|
|
6
6
|
baseSettings: { transformSource: o, organizationDisplayName: s },
|
|
7
7
|
searchSettings: { tabs: u, searchQueryParamKey: b, shouldOpenLinksInNewTab: g }
|
|
@@ -42,7 +42,7 @@ const O = (e, r) => {
|
|
|
42
42
|
i.includes("All") && n.All.push(l);
|
|
43
43
|
}
|
|
44
44
|
for (const t of Object.keys(n)) {
|
|
45
|
-
const c = R.find((a) => typeof a == "string" ? a === t : a[0] === t), d = typeof c == "object" ? c[1]?.
|
|
45
|
+
const c = R.find((a) => typeof a == "string" ? a === t : a[0] === t), d = typeof c == "object" ? c[1]?.isAlwaysVisible === !0 : !1;
|
|
46
46
|
n[t].length === 0 && !d && delete n[t];
|
|
47
47
|
}
|
|
48
48
|
return n;
|
|
@@ -109,5 +109,5 @@ const k = (e) => {
|
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
export {
|
|
112
|
-
|
|
112
|
+
A as useTransformResults
|
|
113
113
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),W=require("../../providers/config-provider.cjs"),G=require("../../hooks/use-media-query.cjs"),J=require("./search-query.graphql.cjs"),V=require("./transform-results.cjs"),X=require("../../providers/search-events-provider.cjs"),Y=require("../../hooks/use-instant-update.cjs"),Z=require("../../utils/graphql-client.cjs"),ee=()=>{const{baseSettings:
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),W=require("../../providers/config-provider.cjs"),G=require("../../hooks/use-media-query.cjs"),J=require("./search-query.graphql.cjs"),V=require("./transform-results.cjs"),X=require("../../providers/search-events-provider.cjs"),Y=require("../../hooks/use-instant-update.cjs"),Z=require("../../utils/graphql-client.cjs"),ee=()=>{const{baseSettings:_,searchSettings:j}=W.useInkeepConfig(),{apiKey:p,aiApiBaseUrl:L,userAuthToken:l}=_,{maxResults:S,placeholder:Q,defaultQuery:N,debounceTimeMs:R,onQueryChange:O,searchFunctionsRef:x}=j,{logEvent:q}=X.useSearchEvents(),[c,C]=t.useState(N),T=t.useRef(null),[k,v]=t.useState(!1),[H,i]=t.useState(null),[B,a]=t.useState("NONE"),F=t.useCallback(e=>{a(e)},[]),[h,d]=t.useState([]),s=V.useTransformResults(h,c),[f,E]=t.useState("All"),{disableTransition:M,disabled:$}=Y.useInstantUpdate(),z=t.useCallback(e=>{M(),E(e),a(s[e][0].id)},[s,M]);t.useEffect(()=>{let e=f in s?f:Object.keys(s)[0];if(!s[e]?.length){const n=Object.keys(s).find(u=>s[u]?.length);n?e=n:e="All"}if(!e)return;E(e);const r=s[e]?.[0];r&&a(r.id)},[s]);const y=G.useMediaQuery("(max-width: 768px)"),o=t.useRef({}),b=t.useRef(null),m=t.useRef(null);t.useImperativeHandle(x,()=>({updateQuery(e){C(e)},focusInput:()=>{T.current?.focus()}}));const w=`${L}/graphql`,A=t.useMemo(()=>({Authorization:`Bearer ${p}`,"Content-Type":"application/json",...l?{"User-Token":l}:{}}),[p,l]),I=t.useCallback(async e=>{b.current&&b.current.abort();const r=new AbortController;b.current=r;try{v(!0),i(null);const u=(await Z.graphqlRequest(w,J.default,{searchInput:e},A))?.search.searchHits;o.current[e.searchQuery]=u,d(u)}catch(n){if(n.name==="AbortError")return;i("Failed to fetch search results. Please try again.")}v(!1)},[w,A]),P=t.useCallback(e=>{const r=o.current[e.searchQuery];q({eventName:"search_query_response_received",properties:{searchQuery:e.searchQuery,totalHits:r?.length}})},[]),U=t.useCallback(e=>{if(m.current&&window.clearTimeout(m.current),!e.searchQuery){d([]),i(null);return}m.current=window.setTimeout(()=>{q({eventName:"search_query_submitted",properties:{searchQuery:e.searchQuery}}),o.current[e.searchQuery]?(d(o.current[e.searchQuery]),P(e)):I(e).then(()=>{P(e)})},R)},[R,I]),g=t.useMemo(()=>({searchQuery:c,filters:{limit:S}}),[c,S]);t.useEffect(()=>{O?.(g.searchQuery),U(g)},[U,g]);const D=t.useCallback(e=>C(e.target.value),[]),K=t.useMemo(()=>Q||(y?"Search...":"Search for anything..."),[Q,y]);return{results:s,resultsList:h,hasContent:h.length>0||k,loading:k,error:H,query:c,onInput:D,placeholder:K,tab:f,onTabChange:z,selectedItem:B,setSelectedItem:a,onSelectedItemChange:F,transitionsDisabled:$,inputRef:T,isMobile:y}};exports.useInkeepSearch=ee;
|
|
@@ -7,66 +7,66 @@ import { useTransformResults as te } from "./transform-results.js";
|
|
|
7
7
|
import { useSearchEvents as re } from "../../providers/search-events-provider.js";
|
|
8
8
|
import { useInstantUpdate as se } from "../../hooks/use-instant-update.js";
|
|
9
9
|
import { graphqlRequest as ne } from "../../utils/graphql-client.js";
|
|
10
|
-
const
|
|
11
|
-
const { baseSettings:
|
|
12
|
-
|
|
10
|
+
const me = () => {
|
|
11
|
+
const { baseSettings: H, searchSettings: O } = Y(), { apiKey: R, aiApiBaseUrl: B, userAuthToken: h } = H, {
|
|
12
|
+
maxResults: S,
|
|
13
13
|
placeholder: C,
|
|
14
|
-
defaultQuery:
|
|
15
|
-
|
|
16
|
-
onQueryChange:
|
|
17
|
-
searchFunctionsRef:
|
|
18
|
-
} = O, { logEvent: v } = re(), [c, w] = s(
|
|
14
|
+
defaultQuery: F,
|
|
15
|
+
debounceTimeMs: k,
|
|
16
|
+
onQueryChange: P,
|
|
17
|
+
searchFunctionsRef: $
|
|
18
|
+
} = O, { logEvent: v } = re(), [c, w] = s(F), A = l(null), [q, E] = s(!1), [z, f] = s(null), [D, a] = s("NONE"), K = n((e) => {
|
|
19
19
|
a(e);
|
|
20
|
-
}, []), [
|
|
20
|
+
}, []), [m, d] = s([]), t = te(m, c), [p, _] = s("All"), { disableTransition: x, disabled: W } = se(), G = n(
|
|
21
21
|
(e) => {
|
|
22
|
-
|
|
22
|
+
x(), _(e), a(t[e][0].id);
|
|
23
23
|
},
|
|
24
|
-
[t,
|
|
24
|
+
[t, x]
|
|
25
25
|
);
|
|
26
26
|
j(() => {
|
|
27
|
-
let e =
|
|
27
|
+
let e = p in t ? p : Object.keys(t)[0];
|
|
28
28
|
if (!t[e]?.length) {
|
|
29
29
|
const o = Object.keys(t).find((u) => t[u]?.length);
|
|
30
30
|
o ? e = o : e = "All";
|
|
31
31
|
}
|
|
32
32
|
if (!e) return;
|
|
33
|
-
|
|
33
|
+
_(e);
|
|
34
34
|
const r = t[e]?.[0];
|
|
35
35
|
r && a(r.id);
|
|
36
36
|
}, [t]);
|
|
37
|
-
const
|
|
38
|
-
X(
|
|
37
|
+
const y = Z("(max-width: 768px)"), i = l({}), b = l(null), g = l(null);
|
|
38
|
+
X($, () => ({
|
|
39
39
|
updateQuery(e) {
|
|
40
40
|
w(e);
|
|
41
41
|
},
|
|
42
42
|
focusInput: () => {
|
|
43
|
-
|
|
43
|
+
A.current?.focus();
|
|
44
44
|
}
|
|
45
45
|
}));
|
|
46
|
-
const
|
|
46
|
+
const I = `${B}/graphql`, L = T(
|
|
47
47
|
() => ({
|
|
48
48
|
Authorization: `Bearer ${R}`,
|
|
49
49
|
"Content-Type": "application/json",
|
|
50
50
|
...h ? { "User-Token": h } : {}
|
|
51
51
|
}),
|
|
52
52
|
[R, h]
|
|
53
|
-
),
|
|
53
|
+
), M = n(
|
|
54
54
|
async (e) => {
|
|
55
55
|
b.current && b.current.abort();
|
|
56
56
|
const r = new AbortController();
|
|
57
57
|
b.current = r;
|
|
58
58
|
try {
|
|
59
|
-
E(!0),
|
|
60
|
-
const u = (await ne(
|
|
59
|
+
E(!0), f(null);
|
|
60
|
+
const u = (await ne(I, ee, { searchInput: e }, L))?.search.searchHits;
|
|
61
61
|
i.current[e.searchQuery] = u, d(u);
|
|
62
62
|
} catch (o) {
|
|
63
63
|
if (o.name === "AbortError")
|
|
64
64
|
return;
|
|
65
|
-
|
|
65
|
+
f("Failed to fetch search results. Please try again.");
|
|
66
66
|
}
|
|
67
67
|
E(!1);
|
|
68
68
|
},
|
|
69
|
-
[
|
|
69
|
+
[I, L]
|
|
70
70
|
), N = n((e) => {
|
|
71
71
|
const r = i.current[e.searchQuery];
|
|
72
72
|
v({
|
|
@@ -79,7 +79,7 @@ const fe = () => {
|
|
|
79
79
|
}, []), U = n(
|
|
80
80
|
(e) => {
|
|
81
81
|
if (g.current && window.clearTimeout(g.current), !e.searchQuery) {
|
|
82
|
-
d([]),
|
|
82
|
+
d([]), f(null);
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
g.current = window.setTimeout(() => {
|
|
@@ -88,12 +88,12 @@ const fe = () => {
|
|
|
88
88
|
properties: {
|
|
89
89
|
searchQuery: e.searchQuery
|
|
90
90
|
}
|
|
91
|
-
}), i.current[e.searchQuery] ? (d(i.current[e.searchQuery]), N(e)) :
|
|
91
|
+
}), i.current[e.searchQuery] ? (d(i.current[e.searchQuery]), N(e)) : M(e).then(() => {
|
|
92
92
|
N(e);
|
|
93
93
|
});
|
|
94
94
|
}, k);
|
|
95
95
|
},
|
|
96
|
-
[k,
|
|
96
|
+
[k, M]
|
|
97
97
|
), Q = T(
|
|
98
98
|
() => ({
|
|
99
99
|
searchQuery: c,
|
|
@@ -104,34 +104,34 @@ const fe = () => {
|
|
|
104
104
|
[c, S]
|
|
105
105
|
);
|
|
106
106
|
j(() => {
|
|
107
|
-
|
|
107
|
+
P?.(Q.searchQuery), U(Q);
|
|
108
108
|
}, [U, Q]);
|
|
109
109
|
const J = n(
|
|
110
110
|
(e) => w(e.target.value),
|
|
111
111
|
[]
|
|
112
112
|
), V = T(
|
|
113
|
-
() => C || (
|
|
114
|
-
[C,
|
|
113
|
+
() => C || (y ? "Search..." : "Search for anything..."),
|
|
114
|
+
[C, y]
|
|
115
115
|
);
|
|
116
116
|
return {
|
|
117
117
|
results: t,
|
|
118
|
-
resultsList:
|
|
119
|
-
hasContent:
|
|
120
|
-
loading:
|
|
121
|
-
error:
|
|
118
|
+
resultsList: m,
|
|
119
|
+
hasContent: m.length > 0 || q,
|
|
120
|
+
loading: q,
|
|
121
|
+
error: z,
|
|
122
122
|
query: c,
|
|
123
123
|
onInput: J,
|
|
124
124
|
placeholder: V,
|
|
125
|
-
tab:
|
|
125
|
+
tab: p,
|
|
126
126
|
onTabChange: G,
|
|
127
127
|
selectedItem: D,
|
|
128
128
|
setSelectedItem: a,
|
|
129
129
|
onSelectedItemChange: K,
|
|
130
130
|
transitionsDisabled: W,
|
|
131
|
-
inputRef:
|
|
132
|
-
isMobile:
|
|
131
|
+
inputRef: A,
|
|
132
|
+
isMobile: y
|
|
133
133
|
};
|
|
134
134
|
};
|
|
135
135
|
export {
|
|
136
|
-
|
|
136
|
+
me as useInkeepSearch
|
|
137
137
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),S=require("cmdk"),i=require("./factory.cjs"),l=require("../utils/misc.cjs"),m=require("react"),o=require("./embedded-search/search-provider.cjs"),ae=require("./tagline-logo-icon.cjs"),v=require("../atoms/icons/custom-icon.cjs"),ne=require("react-textarea-autosize"),ce=require("@radix-ui/react-scroll-area"),oe=require("@radix-ui/react-tabs"),P=require("../providers/config-provider.cjs"),de=require("../providers/search-events-provider.cjs"),le=require("../atoms/link.cjs"),h=require("../providers/source-item-provider.cjs"),A=require("../atoms/icons/built-in-icon-renderer.cjs"),ue=require("../utils/highlight-emphasis.cjs"),me=require("../hooks/use-scrolling-fades.cjs"),he=require("@inkeep/cxkit-color-mode"),Se=require("../atoms/avatars/ai.cjs"),T=require("./modal/modal-provider.cjs"),_=require("../utils/compose-refs.cjs"),I=require("../utils/compose-event-handlers.cjs");function f(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const b=f(ce),g=f(oe),pe=i.ikp("div",{_id:"aiSearchWrapper"}),L=t=>{const{isHidden:e,hasContent:r,isMobile:s}=o.useSearch(),n=T.useModal();return a.jsx(pe,{"data-hidden":l.dataAttr(e),"data-has-content":l.dataAttr(r),"data-in-modal":l.dataAttr(!!n),"data-mobile":l.dataAttr(s),...t})},be=i.ikp(S.Command,{_id:"aiSearchRoot"}),y=t=>{const{isHidden:e,selectedItem:r,onSelectedItemChange:s}=o.useSearch();return a.jsx(be,{"data-hidden":l.dataAttr(e),shouldFilter:!1,loop:!1,value:r,onValueChange:s,...t})},C=i.ikp(S.Command.List,{_id:"aiSearchContent"}),x=i.ikp("div",{_id:"aiSearchInputGroup"}),j=i.ikp(v.CustomIcon,{_id:"aiSearchInputIcon",iconKey:"search"}),Ie=i.ikp(S.Command.Input,{_id:"aiSearchInput"}),q=m.forwardRef(({onInput:t,...e},r)=>{const{query:s,onInput:n,placeholder:c,inputRef:d,shouldAutoFocusInput:u}=o.useSearch(),p=_.useComposedRefs(r,d),R=T.useModal();return m.useEffect(()=>{requestAnimationFrame(()=>{u&&d?.current&&(d.current.focus(),d.current.selectionStart=d.current.value.length)})},[u,d,R?.open]),a.jsx(Ie,{asChild:!0,ref:p,placeholder:c,value:s,onInput:I.composeEventHandlers(t,n),...e,children:a.jsx(ne,{minRows:1,maxLength:1e3})})}),ve=i.ikp(A.BuiltInIconRenderer,{_id:"aiSearchLoading",iconSettings:{builtIn:"LuLoaderCircle"}}),w=t=>{const{loading:e,resultsList:r}=o.useSearch();return!e||r.length===0?null:a.jsx(ve,{...t})},ge=i.ikp(S.Command.Item,{_id:"aiAskAITrigger",value:"__ask_ai__"}),B=t=>{const{setSelectedItem:e,results:r,tab:s}=o.useSearch(),n=r[s]?.[0]?.id??"NONE";return a.jsx(ge,{...t,onPointerLeave:()=>e(n)})},Re=i.ikp("img",{_id:"aiAskAITrigger__Icon"}),D=t=>{const{aiChatSettings:e}=P.useInkeepConfig(),{botAvatarSrcUrl:r,botAvatarDarkSrcUrl:s}=e??{},n=s??r,c=he.useColorModeValue(r,n),[d,u]=m.useState(c);m.useEffect(()=>{u(c)},[c]);const p=()=>{u(null)};return a.jsx(Re,{asChild:!0,...t,children:d?a.jsx("img",{src:d,alt:"AI Avatar","data-type":"image",onError:I.composeEventHandlers(p),...t}):a.jsx(Se.default,{"data-type":"icon",...t})})},N=i.ikp("span",{_id:"aiAskAITrigger__Label"}),F=i.ikp(v.CustomIcon,{_id:"aiAskAITrigger__Indicator",iconKey:"openLinkInSameTab"}),Pe=i.ikp(g.Root,{_id:"aiSearchResults"}),O=t=>{const{tab:e,onTabChange:r,hasContent:s}=o.useSearch();return a.jsx(Pe,{value:e,onValueChange:r,"data-has-content":l.dataAttr(s),...t})},_e=i.ikp("div",{_id:"aiSearchResults__Loading"}),M=t=>{const{loading:e,resultsList:r}=o.useSearch();return!e||r.length>0?null:a.jsx(_e,{...t})},Ee=i.ikp(S.Command.Empty,{_id:"aiSearchResults__Empty"}),V=t=>{const{query:e,loading:r,results:s,tab:n}=o.useSearch(),c=s[n]?.length;return r||!e||c?null:a.jsx(Ee,{children:"No results found.",...t})},ke=i.ikp(g.List,{_id:"aiSearchResults__TabList"}),H=t=>{const{children:e,...r}=t,{searchSettings:{tabs:s}}=P.useInkeepConfig(),{results:n,loading:c,resultsList:d}=o.useSearch();if(c&&d.length===0)return null;const u=Object.keys(n);return!s.length||!u.length?null:a.jsx(ke,{children:l.maybeRender(e,u),...r})},Ae=i.ikp(g.Trigger,{_id:"aiSearchResults__Tab"}),U=t=>{const{tab:e,...r}=t,{results:s}=o.useSearch(),n=s[e].length;return a.jsx(Ae,{value:e,children:`${e} (${n})`,...r})},Te=i.ikp(b.Root,{_id:"aiSearchResults__ScrollArea"}),W=t=>{const{loading:e,resultsList:r}=o.useSearch();return e&&r.length===0?null:a.jsx(Te,{...t})},fe=i.ikp(b.Viewport,{_id:"aiSearchResults__ScrollAreaViewport"}),G=m.forwardRef(({children:t,...e},r)=>{const s=me.useScrollingFades(),n=_.useComposedRefs(r,s),{tab:c}=o.useSearch();return m.useEffect(()=>{c&&s.current?.scrollTo({top:0,behavior:"auto"})},[c]),a.jsx(fe,{ref:n,children:a.jsx("div",{style:{display:"grid"},children:t}),...e})}),Le=i.ikp(b.ScrollAreaScrollbar,{_id:"aiSearchResults__ScrollAreaScrollbar"}),ye=i.ikp(b.ScrollAreaThumb,{_id:"aiSearchResults__ScrollAreaThumb"}),Ce=i.ikp(b.Corner,{_id:"aiSearchResults__ScrollAreaCorner"}),xe=i.ikp(g.Content,{_id:"aiSearchResults__List"}),K=t=>{const{children:e,...r}=t,{results:s,tab:n}=o.useSearch(),c=s[n]??[];return a.jsx(xe,{value:n,"data-has-results":l.dataAttr(c.length>0),"aria-label":"Search results",children:l.maybeRender(e,c),...r})},je=i.ikp(S.Command.Item,{_id:"aiSearchResults__Item",asChild:!0}),z=m.forwardRef(({item:t,onClick:e,onSelect:r,children:s,...n},c)=>{const{searchSettings:{shouldOpenLinksInNewTab:d}}=P.useInkeepConfig(),{logEvent:u}=de.useSearchEvents(),{query:p,transitionsDisabled:R}=o.useSearch(),E=m.useRef(null),re=_.useComposedRefs(c,E),ie=()=>{E.current?.click()},se=()=>{u({eventName:"search_result_clicked",properties:{searchQuery:p,title:t.title,url:t.url}})},k=d||!!t.shouldOpenInNewTab;return a.jsx(h.SourceItemProvider,{source:{...t,isExternal:k},children:a.jsx(je,{ref:re,value:t.id,"data-type":t.type,"data-breadcrumbs":!!t.breadcrumbs?.length,"data-disable-transitions":l.dataAttr(R),onSelect:I.composeEventHandlers(r,ie),onClick:I.composeEventHandlers(e,se),...n,children:a.jsx(le.LinkWithQueryParams,{href:t.url,isExternal:k,appendToUrl:t.appendToUrl,children:s})})})}),qe=i.ikp("div",{_id:"aiSearchResults__ItemBreadcrumbs"}),Q=t=>{const{source:e}=h.useSourceItem(),{tab:r}=o.useSearch();if(!e.breadcrumbs?.length)return null;const{children:s,...n}=t,d=e.tabs?.find(u=>typeof u!="string"&&u[0]===r)?.[1]?.breadcrumbs??e.breadcrumbs??[];return a.jsx(qe,{children:l.maybeRender(s,d),...n})},we=i.ikp(v.CustomIcon,{_id:"aiSearchResults__ItemBreadcrumbIcon",iconKey:"breadcrumbSeparator"}),Be=i.ikp(A.BuiltInIconRenderer,{_id:"aiSearchResults__ItemIcon"}),$=t=>{const{source:e}=h.useSourceItem();return a.jsx(Be,{iconSettings:e.icon,"data-type":e.type,...t})},De=i.ikp("span",{_id:"aiSearchResults__ItemTitle"}),J=t=>{const{source:e}=h.useSourceItem();return a.jsx(De,{"data-type":e.type,children:e.title,...t})},Ne=i.ikp("span",{_id:"aiSearchResults__ItemTag"}),X=t=>{const{source:e}=h.useSourceItem();return a.jsx(Ne,{"data-type":e.type,children:e.tag,...t})},Fe=i.ikp("span",{_id:"aiSearchResults__ItemDescription"}),Y=t=>{const{source:e}=h.useSourceItem(),{children:r,...s}=t,n=m.useMemo(()=>e.description?ue.highlightEmphasis(e.description):[],[e.description]);return n.length?a.jsx(Fe,{"data-type":e.type,children:l.maybeRender(r,n),...s}):null},Oe=i.ikp("span",{_id:"aiSearchResults__ItemDescriptionPart"}),Z=t=>{const{part:e,...r}=t,{source:s}=h.useSourceItem();return typeof e=="string"?e:a.jsx(Oe,{"data-type":s.type,children:e.content,"data-highlighted":l.dataAttr(e.highlighted),...r})},Me=i.ikp(v.CustomIcon,{_id:"aiSearchResults__ItemIndicator"}),ee=t=>{const{source:e}=h.useSourceItem();return a.jsx(Me,{iconKey:e.isExternal?"openLinkInNewTab":"openLinkInSameTab",...t})},Ve=i.ikp("div",{_id:"aiSearchFooter"}),te=t=>{const{resultsList:e}=o.useSearch();return a.jsx(Ve,{"data-has-results":l.dataAttr(e.length>0),...t})},He=i.ikp("div",{_id:"aiSearchTagline__Container"}),Ue=i.ikp("span",{_id:"aiSearchTagline__Text",children:"Powered by"}),We=i.ikp(ae.default,{_id:"aiSearchTagline__Logo"}),Ge=i.ikp("a",{_id:"aiSearchTagline__BrandName",children:"inkeep",href:"https://www.inkeep.com/",target:"_blank",rel:"noopener noreferrer"});exports.Provider=o.SearchProvider;exports.AskAITrigger=B;exports.AskAITriggerIcon=D;exports.AskAITriggerIndicator=F;exports.AskAITriggerLabel=N;exports.Content=C;exports.EmbeddedSearchInputIcon=j;exports.EmbeddedSearchPrimitiveAskAITrigger=B;exports.EmbeddedSearchPrimitiveAskAITriggerIcon=D;exports.EmbeddedSearchPrimitiveAskAITriggerIndicator=F;exports.EmbeddedSearchPrimitiveAskAITriggerLabel=N;exports.EmbeddedSearchPrimitiveContent=C;exports.EmbeddedSearchPrimitiveFooter=te;exports.EmbeddedSearchPrimitiveInput=q;exports.EmbeddedSearchPrimitiveInputGroup=x;exports.EmbeddedSearchPrimitiveLoading=w;exports.EmbeddedSearchPrimitiveResults=O;exports.EmbeddedSearchPrimitiveResultsEmpty=V;exports.EmbeddedSearchPrimitiveResultsItem=z;exports.EmbeddedSearchPrimitiveResultsItemBreadcrumbs=Q;exports.EmbeddedSearchPrimitiveResultsItemDescription=Y;exports.EmbeddedSearchPrimitiveResultsItemDescriptionPart=Z;exports.EmbeddedSearchPrimitiveResultsItemIcon=$;exports.EmbeddedSearchPrimitiveResultsItemIndicator=ee;exports.EmbeddedSearchPrimitiveResultsItemTag=X;exports.EmbeddedSearchPrimitiveResultsItemTitle=J;exports.EmbeddedSearchPrimitiveResultsList=K;exports.EmbeddedSearchPrimitiveResultsLoading=M;exports.EmbeddedSearchPrimitiveResultsScrollArea=W;exports.EmbeddedSearchPrimitiveResultsScrollAreaViewport=G;exports.EmbeddedSearchPrimitiveResultsTab=U;exports.EmbeddedSearchPrimitiveResultsTabList=H;exports.EmbeddedSearchPrimitiveRoot=y;exports.EmbeddedSearchPrimitiveWrapper=L;exports.Footer=te;exports.Input=q;exports.InputGroup=x;exports.InputIcon=j;exports.Loading=w;exports.Results=O;exports.ResultsEmpty=V;exports.ResultsItem=z;exports.ResultsItemBreadcrumbIcon=we;exports.ResultsItemBreadcrumbs=Q;exports.ResultsItemDescription=Y;exports.ResultsItemDescriptionPart=Z;exports.ResultsItemIcon=$;exports.ResultsItemIndicator=ee;exports.ResultsItemTag=X;exports.ResultsItemTitle=J;exports.ResultsList=K;exports.ResultsLoading=M;exports.ResultsScrollArea=W;exports.ResultsScrollAreaCorner=Ce;exports.ResultsScrollAreaScrollbar=Le;exports.ResultsScrollAreaThumb=ye;exports.ResultsScrollAreaViewport=G;exports.ResultsTab=U;exports.ResultsTabList=H;exports.Root=y;exports.TaglineBrandName=Ge;exports.TaglineContainer=He;exports.TaglineLogo=We;exports.TaglineText=Ue;exports.Wrapper=L;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),S=require("cmdk"),i=require("./factory.cjs"),l=require("../utils/misc.cjs"),m=require("react"),o=require("./embedded-search/search-provider.cjs"),ne=require("./tagline-logo-icon.cjs"),g=require("../atoms/icons/custom-icon.cjs"),ae=require("react-textarea-autosize"),ce=require("@radix-ui/react-scroll-area"),oe=require("@radix-ui/react-tabs"),P=require("../providers/config-provider.cjs"),de=require("../providers/search-events-provider.cjs"),le=require("../atoms/link.cjs"),h=require("../providers/source-item-provider.cjs"),A=require("../atoms/icons/built-in-icon-renderer.cjs"),ue=require("../utils/highlight-emphasis.cjs"),me=require("../hooks/use-scrolling-fades.cjs"),he=require("@inkeep/cxkit-color-mode"),Se=require("../atoms/avatars/ai.cjs"),T=require("./modal/modal-provider.cjs"),_=require("../utils/compose-refs.cjs"),I=require("../utils/compose-event-handlers.cjs");function f(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const b=f(ce),v=f(oe),pe=i.ikp("div",{_id:"aiSearchWrapper"}),y=t=>{const{isHidden:e,hasContent:r,isMobile:s}=o.useSearch(),a=T.useModal();return n.jsx(pe,{"data-hidden":l.dataAttr(e),"data-has-content":l.dataAttr(r),"data-in-modal":l.dataAttr(!!a),"data-mobile":l.dataAttr(s),...t})},be=i.ikp(S.Command,{_id:"aiSearchRoot"}),L=t=>{const{isHidden:e,selectedItem:r,onSelectedItemChange:s}=o.useSearch();return n.jsx(be,{"data-hidden":l.dataAttr(e),shouldFilter:!1,loop:!1,value:r,onValueChange:s,...t})},C=i.ikp(S.Command.List,{_id:"aiSearchContent"}),x=i.ikp("div",{_id:"aiSearchInputGroup"}),j=i.ikp(g.CustomIcon,{_id:"aiSearchInputIcon",iconKey:"search"}),Ie=i.ikp(S.Command.Input,{_id:"aiSearchInput"}),q=m.forwardRef(({onInput:t,...e},r)=>{const{query:s,onInput:a,placeholder:c,inputRef:d,shouldAutoFocusInput:u}=o.useSearch(),p=_.useComposedRefs(r,d),R=T.useModal();return m.useEffect(()=>{requestAnimationFrame(()=>{u&&d?.current&&(d.current.focus(),d.current.selectionStart=d.current.value.length)})},[u,d,R?.isOpen]),n.jsx(Ie,{asChild:!0,ref:p,placeholder:c,value:s,onInput:I.composeEventHandlers(t,a),...e,children:n.jsx(ae,{minRows:1,maxLength:1e3})})}),ge=i.ikp(A.BuiltInIconRenderer,{_id:"aiSearchLoading",iconSettings:{builtIn:"LuLoaderCircle"}}),w=t=>{const{loading:e,resultsList:r}=o.useSearch();return!e||r.length===0?null:n.jsx(ge,{...t})},ve=i.ikp(S.Command.Item,{_id:"aiAskAITrigger",value:"__ask_ai__"}),B=t=>{const{setSelectedItem:e,results:r,tab:s}=o.useSearch(),a=r[s]?.[0]?.id??"NONE";return n.jsx(ve,{...t,onPointerLeave:()=>e(a)})},Re=i.ikp("img",{_id:"aiAskAITrigger__Icon"}),D=t=>{const{aiChatSettings:e}=P.useInkeepConfig(),{aiAssistantAvatar:r}=e??{},s=typeof r=="string"?r:r?.light,a=(typeof r=="string"?r:r?.dark)??s,c=he.useColorModeValue(s,a),[d,u]=m.useState(c);m.useEffect(()=>{u(c)},[c]);const p=()=>{u(null)};return n.jsx(Re,{asChild:!0,...t,children:d?n.jsx("img",{src:d,alt:"AI Avatar","data-type":"image",onError:I.composeEventHandlers(p),...t}):n.jsx(Se.default,{"data-type":"icon",...t})})},N=i.ikp("span",{_id:"aiAskAITrigger__Label"}),O=i.ikp(g.CustomIcon,{_id:"aiAskAITrigger__Indicator",iconKey:"openLinkInSameTab"}),Pe=i.ikp(v.Root,{_id:"aiSearchResults"}),F=t=>{const{tab:e,onTabChange:r,hasContent:s}=o.useSearch();return n.jsx(Pe,{value:e,onValueChange:r,"data-has-content":l.dataAttr(s),...t})},_e=i.ikp("div",{_id:"aiSearchResults__Loading"}),M=t=>{const{loading:e,resultsList:r}=o.useSearch();return!e||r.length>0?null:n.jsx(_e,{...t})},Ee=i.ikp(S.Command.Empty,{_id:"aiSearchResults__Empty"}),V=t=>{const{query:e,loading:r,results:s,tab:a}=o.useSearch(),c=s[a]?.length;return r||!e||c?null:n.jsx(Ee,{children:"No results found.",...t})},ke=i.ikp(v.List,{_id:"aiSearchResults__TabList"}),H=t=>{const{children:e,...r}=t,{searchSettings:{tabs:s}}=P.useInkeepConfig(),{results:a,loading:c,resultsList:d}=o.useSearch();if(c&&d.length===0)return null;const u=Object.keys(a);return!s.length||!u.length?null:n.jsx(ke,{children:l.maybeRender(e,u),...r})},Ae=i.ikp(v.Trigger,{_id:"aiSearchResults__Tab"}),U=t=>{const{tab:e,...r}=t,{results:s}=o.useSearch(),a=s[e].length;return n.jsx(Ae,{value:e,children:`${e} (${a})`,...r})},Te=i.ikp(b.Root,{_id:"aiSearchResults__ScrollArea"}),W=t=>{const{loading:e,resultsList:r}=o.useSearch();return e&&r.length===0?null:n.jsx(Te,{...t})},fe=i.ikp(b.Viewport,{_id:"aiSearchResults__ScrollAreaViewport"}),G=m.forwardRef(({children:t,...e},r)=>{const s=me.useScrollingFades(),a=_.useComposedRefs(r,s),{tab:c}=o.useSearch();return m.useEffect(()=>{c&&s.current?.scrollTo({top:0,behavior:"auto"})},[c]),n.jsx(fe,{ref:a,children:n.jsx("div",{style:{display:"grid"},children:t}),...e})}),ye=i.ikp(b.ScrollAreaScrollbar,{_id:"aiSearchResults__ScrollAreaScrollbar"}),Le=i.ikp(b.ScrollAreaThumb,{_id:"aiSearchResults__ScrollAreaThumb"}),Ce=i.ikp(b.Corner,{_id:"aiSearchResults__ScrollAreaCorner"}),xe=i.ikp(v.Content,{_id:"aiSearchResults__List"}),K=t=>{const{children:e,...r}=t,{results:s,tab:a}=o.useSearch(),c=s[a]??[];return n.jsx(xe,{value:a,"data-has-results":l.dataAttr(c.length>0),"aria-label":"Search results",children:l.maybeRender(e,c),...r})},je=i.ikp(S.Command.Item,{_id:"aiSearchResults__Item",asChild:!0}),z=m.forwardRef(({item:t,onClick:e,onSelect:r,children:s,...a},c)=>{const{searchSettings:{shouldOpenLinksInNewTab:d}}=P.useInkeepConfig(),{logEvent:u}=de.useSearchEvents(),{query:p,transitionsDisabled:R}=o.useSearch(),E=m.useRef(null),re=_.useComposedRefs(c,E),ie=()=>{E.current?.click()},se=()=>{u({eventName:"search_result_clicked",properties:{searchQuery:p,title:t.title,url:t.url}})},k=d||!!t.shouldOpenInNewTab;return n.jsx(h.SourceItemProvider,{source:{...t,isExternal:k},children:n.jsx(je,{ref:re,value:t.id,"data-type":t.type,"data-breadcrumbs":!!t.breadcrumbs?.length,"data-disable-transitions":l.dataAttr(R),onSelect:I.composeEventHandlers(r,ie),onClick:I.composeEventHandlers(e,se),...a,children:n.jsx(le.LinkWithQueryParams,{href:t.url,isExternal:k,appendToUrl:t.appendToUrl,children:s})})})}),qe=i.ikp("div",{_id:"aiSearchResults__ItemBreadcrumbs"}),Q=t=>{const{source:e}=h.useSourceItem(),{tab:r}=o.useSearch();if(!e.breadcrumbs?.length)return null;const{children:s,...a}=t,d=e.tabs?.find(u=>typeof u!="string"&&u[0]===r)?.[1]?.breadcrumbs??e.breadcrumbs??[];return n.jsx(qe,{children:l.maybeRender(s,d),...a})},we=i.ikp(g.CustomIcon,{_id:"aiSearchResults__ItemBreadcrumbIcon",iconKey:"breadcrumbSeparator"}),Be=i.ikp(A.BuiltInIconRenderer,{_id:"aiSearchResults__ItemIcon"}),$=t=>{const{source:e}=h.useSourceItem();return n.jsx(Be,{iconSettings:e.icon,"data-type":e.type,...t})},De=i.ikp("span",{_id:"aiSearchResults__ItemTitle"}),J=t=>{const{source:e}=h.useSourceItem();return n.jsx(De,{"data-type":e.type,children:e.title,...t})},Ne=i.ikp("span",{_id:"aiSearchResults__ItemTag"}),X=t=>{const{source:e}=h.useSourceItem();return n.jsx(Ne,{"data-type":e.type,children:e.tag,...t})},Oe=i.ikp("span",{_id:"aiSearchResults__ItemDescription"}),Y=t=>{const{source:e}=h.useSourceItem(),{children:r,...s}=t,a=m.useMemo(()=>e.description?ue.highlightEmphasis(e.description):[],[e.description]);return a.length?n.jsx(Oe,{"data-type":e.type,children:l.maybeRender(r,a),...s}):null},Fe=i.ikp("span",{_id:"aiSearchResults__ItemDescriptionPart"}),Z=t=>{const{part:e,...r}=t,{source:s}=h.useSourceItem();return typeof e=="string"?e:n.jsx(Fe,{"data-type":s.type,children:e.content,"data-highlighted":l.dataAttr(e.highlighted),...r})},Me=i.ikp(g.CustomIcon,{_id:"aiSearchResults__ItemIndicator"}),ee=t=>{const{source:e}=h.useSourceItem();return n.jsx(Me,{iconKey:e.isExternal?"openLinkInNewTab":"openLinkInSameTab",...t})},Ve=i.ikp("div",{_id:"aiSearchFooter"}),te=t=>{const{resultsList:e}=o.useSearch();return n.jsx(Ve,{"data-has-results":l.dataAttr(e.length>0),...t})},He=i.ikp("div",{_id:"aiSearchTagline__Container"}),Ue=i.ikp("span",{_id:"aiSearchTagline__Text",children:"Powered by"}),We=i.ikp(ne.default,{_id:"aiSearchTagline__Logo"}),Ge=i.ikp("a",{_id:"aiSearchTagline__BrandName",children:"inkeep",href:"https://www.inkeep.com/",target:"_blank",rel:"noopener noreferrer"});exports.Provider=o.SearchProvider;exports.AskAITrigger=B;exports.AskAITriggerIcon=D;exports.AskAITriggerIndicator=O;exports.AskAITriggerLabel=N;exports.Content=C;exports.EmbeddedSearchInputIcon=j;exports.EmbeddedSearchPrimitiveAskAITrigger=B;exports.EmbeddedSearchPrimitiveAskAITriggerIcon=D;exports.EmbeddedSearchPrimitiveAskAITriggerIndicator=O;exports.EmbeddedSearchPrimitiveAskAITriggerLabel=N;exports.EmbeddedSearchPrimitiveContent=C;exports.EmbeddedSearchPrimitiveFooter=te;exports.EmbeddedSearchPrimitiveInput=q;exports.EmbeddedSearchPrimitiveInputGroup=x;exports.EmbeddedSearchPrimitiveLoading=w;exports.EmbeddedSearchPrimitiveResults=F;exports.EmbeddedSearchPrimitiveResultsEmpty=V;exports.EmbeddedSearchPrimitiveResultsItem=z;exports.EmbeddedSearchPrimitiveResultsItemBreadcrumbs=Q;exports.EmbeddedSearchPrimitiveResultsItemDescription=Y;exports.EmbeddedSearchPrimitiveResultsItemDescriptionPart=Z;exports.EmbeddedSearchPrimitiveResultsItemIcon=$;exports.EmbeddedSearchPrimitiveResultsItemIndicator=ee;exports.EmbeddedSearchPrimitiveResultsItemTag=X;exports.EmbeddedSearchPrimitiveResultsItemTitle=J;exports.EmbeddedSearchPrimitiveResultsList=K;exports.EmbeddedSearchPrimitiveResultsLoading=M;exports.EmbeddedSearchPrimitiveResultsScrollArea=W;exports.EmbeddedSearchPrimitiveResultsScrollAreaViewport=G;exports.EmbeddedSearchPrimitiveResultsTab=U;exports.EmbeddedSearchPrimitiveResultsTabList=H;exports.EmbeddedSearchPrimitiveRoot=L;exports.EmbeddedSearchPrimitiveWrapper=y;exports.Footer=te;exports.Input=q;exports.InputGroup=x;exports.InputIcon=j;exports.Loading=w;exports.Results=F;exports.ResultsEmpty=V;exports.ResultsItem=z;exports.ResultsItemBreadcrumbIcon=we;exports.ResultsItemBreadcrumbs=Q;exports.ResultsItemDescription=Y;exports.ResultsItemDescriptionPart=Z;exports.ResultsItemIcon=$;exports.ResultsItemIndicator=ee;exports.ResultsItemTag=X;exports.ResultsItemTitle=J;exports.ResultsList=K;exports.ResultsLoading=M;exports.ResultsScrollArea=W;exports.ResultsScrollAreaCorner=Ce;exports.ResultsScrollAreaScrollbar=ye;exports.ResultsScrollAreaThumb=Le;exports.ResultsScrollAreaViewport=G;exports.ResultsTab=U;exports.ResultsTabList=H;exports.Root=L;exports.TaglineBrandName=Ge;exports.TaglineContainer=He;exports.TaglineLogo=We;exports.TaglineText=Ue;exports.Wrapper=y;
|
|
@@ -2,33 +2,33 @@
|
|
|
2
2
|
import { jsx as a } from "react/jsx-runtime";
|
|
3
3
|
import { Command as h } from "cmdk";
|
|
4
4
|
import { ikp as i } from "./factory.js";
|
|
5
|
-
import { dataAttr as u, maybeRender as
|
|
6
|
-
import { forwardRef as v, useEffect as P, useState as B, useRef as x, useMemo as
|
|
5
|
+
import { dataAttr as u, maybeRender as b } from "../utils/misc.js";
|
|
6
|
+
import { forwardRef as v, useEffect as P, useState as B, useRef as x, useMemo as N } from "react";
|
|
7
7
|
import { useSearch as c } from "./embedded-search/search-provider.js";
|
|
8
8
|
import { SearchProvider as It } from "./embedded-search/search-provider.js";
|
|
9
|
-
import
|
|
9
|
+
import D from "./tagline-logo-icon.js";
|
|
10
10
|
import { CustomIcon as I } from "../atoms/icons/custom-icon.js";
|
|
11
|
-
import
|
|
11
|
+
import F from "react-textarea-autosize";
|
|
12
12
|
import * as p from "@radix-ui/react-scroll-area";
|
|
13
13
|
import * as _ from "@radix-ui/react-tabs";
|
|
14
14
|
import { useInkeepConfig as T } from "../providers/config-provider.js";
|
|
15
|
-
import { useSearchEvents as
|
|
16
|
-
import { LinkWithQueryParams as
|
|
15
|
+
import { useSearchEvents as V } from "../providers/search-events-provider.js";
|
|
16
|
+
import { LinkWithQueryParams as U } from "../atoms/link.js";
|
|
17
17
|
import { SourceItemProvider as M, useSourceItem as m } from "../providers/source-item-provider.js";
|
|
18
18
|
import { BuiltInIconRenderer as L } from "../atoms/icons/built-in-icon-renderer.js";
|
|
19
|
-
import { highlightEmphasis as
|
|
20
|
-
import { useScrollingFades as
|
|
21
|
-
import { useColorModeValue as
|
|
22
|
-
import
|
|
19
|
+
import { highlightEmphasis as O } from "../utils/highlight-emphasis.js";
|
|
20
|
+
import { useScrollingFades as W } from "../hooks/use-scrolling-fades.js";
|
|
21
|
+
import { useColorModeValue as q } from "@inkeep/cxkit-color-mode";
|
|
22
|
+
import H from "../atoms/avatars/ai.js";
|
|
23
23
|
import { useModal as y } from "./modal/modal-provider.js";
|
|
24
24
|
import { useComposedRefs as f } from "../utils/compose-refs.js";
|
|
25
|
-
import { composeEventHandlers as
|
|
26
|
-
const
|
|
25
|
+
import { composeEventHandlers as g } from "../utils/compose-event-handlers.js";
|
|
26
|
+
const K = i("div", {
|
|
27
27
|
_id: "aiSearchWrapper"
|
|
28
|
-
}),
|
|
28
|
+
}), Ne = (t) => {
|
|
29
29
|
const { isHidden: e, hasContent: r, isMobile: s } = c(), n = y();
|
|
30
30
|
return /* @__PURE__ */ a(
|
|
31
|
-
|
|
31
|
+
K,
|
|
32
32
|
{
|
|
33
33
|
"data-hidden": u(e),
|
|
34
34
|
"data-has-content": u(r),
|
|
@@ -39,7 +39,7 @@ const O = i("div", {
|
|
|
39
39
|
);
|
|
40
40
|
}, G = i(h, {
|
|
41
41
|
_id: "aiSearchRoot"
|
|
42
|
-
}),
|
|
42
|
+
}), De = (t) => {
|
|
43
43
|
const { isHidden: e, selectedItem: r, onSelectedItemChange: s } = c();
|
|
44
44
|
return /* @__PURE__ */ a(
|
|
45
45
|
G,
|
|
@@ -52,11 +52,11 @@ const O = i("div", {
|
|
|
52
52
|
...t
|
|
53
53
|
}
|
|
54
54
|
);
|
|
55
|
-
},
|
|
55
|
+
}, Fe = i(h.List, {
|
|
56
56
|
_id: "aiSearchContent"
|
|
57
|
-
}),
|
|
57
|
+
}), Ve = i("div", {
|
|
58
58
|
_id: "aiSearchInputGroup"
|
|
59
|
-
}),
|
|
59
|
+
}), Ue = i(I, {
|
|
60
60
|
_id: "aiSearchInputIcon",
|
|
61
61
|
iconKey: "search"
|
|
62
62
|
}), j = i(h.Input, {
|
|
@@ -67,16 +67,16 @@ const O = i("div", {
|
|
|
67
67
|
requestAnimationFrame(() => {
|
|
68
68
|
d && l?.current && (l.current.focus(), l.current.selectionStart = l.current.value.length);
|
|
69
69
|
});
|
|
70
|
-
}, [d, l, R?.
|
|
70
|
+
}, [d, l, R?.isOpen]), /* @__PURE__ */ a(
|
|
71
71
|
j,
|
|
72
72
|
{
|
|
73
73
|
asChild: !0,
|
|
74
74
|
ref: S,
|
|
75
75
|
placeholder: o,
|
|
76
76
|
value: s,
|
|
77
|
-
onInput:
|
|
77
|
+
onInput: g(t, n),
|
|
78
78
|
...e,
|
|
79
|
-
children: /* @__PURE__ */ a(
|
|
79
|
+
children: /* @__PURE__ */ a(F, { minRows: 1, maxLength: 1e3 })
|
|
80
80
|
}
|
|
81
81
|
);
|
|
82
82
|
}), Q = i(L, {
|
|
@@ -84,19 +84,19 @@ const O = i("div", {
|
|
|
84
84
|
iconSettings: {
|
|
85
85
|
builtIn: "LuLoaderCircle"
|
|
86
86
|
}
|
|
87
|
-
}),
|
|
87
|
+
}), Oe = (t) => {
|
|
88
88
|
const { loading: e, resultsList: r } = c();
|
|
89
89
|
return !e || r.length === 0 ? null : /* @__PURE__ */ a(Q, { ...t });
|
|
90
90
|
}, $ = i(h.Item, {
|
|
91
91
|
_id: "aiAskAITrigger",
|
|
92
92
|
value: "__ask_ai__"
|
|
93
|
-
}),
|
|
93
|
+
}), We = (t) => {
|
|
94
94
|
const { setSelectedItem: e, results: r, tab: s } = c(), n = r[s]?.[0]?.id ?? "NONE";
|
|
95
95
|
return /* @__PURE__ */ a($, { ...t, onPointerLeave: () => e(n) });
|
|
96
96
|
}, z = i("img", {
|
|
97
97
|
_id: "aiAskAITrigger__Icon"
|
|
98
|
-
}),
|
|
99
|
-
const { aiChatSettings: e } = T(), {
|
|
98
|
+
}), qe = (t) => {
|
|
99
|
+
const { aiChatSettings: e } = T(), { aiAssistantAvatar: r } = e ?? {}, s = typeof r == "string" ? r : r?.light, n = (typeof r == "string" ? r : r?.dark) ?? s, o = q(s, n), [l, d] = B(o);
|
|
100
100
|
return P(() => {
|
|
101
101
|
d(o);
|
|
102
102
|
}, [o]), /* @__PURE__ */ a(z, { asChild: !0, ...t, children: l ? (
|
|
@@ -107,16 +107,16 @@ const O = i("div", {
|
|
|
107
107
|
src: l,
|
|
108
108
|
alt: "AI Avatar",
|
|
109
109
|
"data-type": "image",
|
|
110
|
-
onError:
|
|
110
|
+
onError: g(() => {
|
|
111
111
|
d(null);
|
|
112
112
|
}),
|
|
113
113
|
...t
|
|
114
114
|
}
|
|
115
115
|
)
|
|
116
|
-
) : /* @__PURE__ */ a(
|
|
117
|
-
},
|
|
116
|
+
) : /* @__PURE__ */ a(H, { "data-type": "icon", ...t }) });
|
|
117
|
+
}, He = i("span", {
|
|
118
118
|
_id: "aiAskAITrigger__Label"
|
|
119
|
-
}),
|
|
119
|
+
}), Ke = i(I, {
|
|
120
120
|
_id: "aiAskAITrigger__Indicator",
|
|
121
121
|
iconKey: "openLinkInSameTab"
|
|
122
122
|
}), J = i(_.Root, {
|
|
@@ -150,7 +150,7 @@ const O = i("div", {
|
|
|
150
150
|
} = T(), { results: n, loading: o, resultsList: l } = c();
|
|
151
151
|
if (o && l.length === 0) return null;
|
|
152
152
|
const d = Object.keys(n);
|
|
153
|
-
return !s.length || !d.length ? null : /* @__PURE__ */ a(Z, { children:
|
|
153
|
+
return !s.length || !d.length ? null : /* @__PURE__ */ a(Z, { children: b(e, d), ...r });
|
|
154
154
|
}, ee = i(_.Trigger, {
|
|
155
155
|
_id: "aiSearchResults__Tab"
|
|
156
156
|
}), ze = (t) => {
|
|
@@ -164,7 +164,7 @@ const O = i("div", {
|
|
|
164
164
|
}, re = i(p.Viewport, {
|
|
165
165
|
_id: "aiSearchResults__ScrollAreaViewport"
|
|
166
166
|
}), Xe = v(({ children: t, ...e }, r) => {
|
|
167
|
-
const s =
|
|
167
|
+
const s = W(), n = f(r, s), { tab: o } = c();
|
|
168
168
|
return P(() => {
|
|
169
169
|
o && s.current?.scrollTo({ top: 0, behavior: "auto" });
|
|
170
170
|
}, [o]), /* @__PURE__ */ a(
|
|
@@ -197,7 +197,7 @@ const O = i("div", {
|
|
|
197
197
|
value: n,
|
|
198
198
|
"data-has-results": u(o.length > 0),
|
|
199
199
|
"aria-label": "Search results",
|
|
200
|
-
children:
|
|
200
|
+
children: b(e, o),
|
|
201
201
|
...r
|
|
202
202
|
}
|
|
203
203
|
);
|
|
@@ -207,7 +207,7 @@ const O = i("div", {
|
|
|
207
207
|
}), rt = v(({ item: t, onClick: e, onSelect: r, children: s, ...n }, o) => {
|
|
208
208
|
const {
|
|
209
209
|
searchSettings: { shouldOpenLinksInNewTab: l }
|
|
210
|
-
} = T(), { logEvent: d } =
|
|
210
|
+
} = T(), { logEvent: d } = V(), { query: S, transitionsDisabled: R } = c(), A = x(null), k = f(o, A), C = () => {
|
|
211
211
|
A.current?.click();
|
|
212
212
|
}, w = () => {
|
|
213
213
|
d({
|
|
@@ -227,11 +227,11 @@ const O = i("div", {
|
|
|
227
227
|
"data-type": t.type,
|
|
228
228
|
"data-breadcrumbs": !!t.breadcrumbs?.length,
|
|
229
229
|
"data-disable-transitions": u(R),
|
|
230
|
-
onSelect:
|
|
231
|
-
onClick:
|
|
230
|
+
onSelect: g(r, C),
|
|
231
|
+
onClick: g(e, w),
|
|
232
232
|
...n,
|
|
233
233
|
children: /* @__PURE__ */ a(
|
|
234
|
-
|
|
234
|
+
U,
|
|
235
235
|
{
|
|
236
236
|
href: t.url,
|
|
237
237
|
isExternal: E,
|
|
@@ -247,7 +247,7 @@ const O = i("div", {
|
|
|
247
247
|
const { source: e } = m(), { tab: r } = c();
|
|
248
248
|
if (!e.breadcrumbs?.length) return null;
|
|
249
249
|
const { children: s, ...n } = t, l = e.tabs?.find((d) => typeof d != "string" && d[0] === r)?.[1]?.breadcrumbs ?? e.breadcrumbs ?? [];
|
|
250
|
-
return /* @__PURE__ */ a(ae, { children:
|
|
250
|
+
return /* @__PURE__ */ a(ae, { children: b(s, l), ...n });
|
|
251
251
|
}, st = i(I, {
|
|
252
252
|
_id: "aiSearchResults__ItemBreadcrumbIcon",
|
|
253
253
|
iconKey: "breadcrumbSeparator"
|
|
@@ -269,12 +269,12 @@ const O = i("div", {
|
|
|
269
269
|
}, le = i("span", {
|
|
270
270
|
_id: "aiSearchResults__ItemDescription"
|
|
271
271
|
}), ct = (t) => {
|
|
272
|
-
const { source: e } = m(), { children: r, ...s } = t, n =
|
|
272
|
+
const { source: e } = m(), { children: r, ...s } = t, n = N(() => e.description ? O(e.description) : [], [e.description]);
|
|
273
273
|
return n.length ? /* @__PURE__ */ a(
|
|
274
274
|
le,
|
|
275
275
|
{
|
|
276
276
|
"data-type": e.type,
|
|
277
|
-
children:
|
|
277
|
+
children: b(r, n),
|
|
278
278
|
...s
|
|
279
279
|
}
|
|
280
280
|
) : null;
|
|
@@ -312,7 +312,7 @@ const O = i("div", {
|
|
|
312
312
|
}), ht = i("span", {
|
|
313
313
|
_id: "aiSearchTagline__Text",
|
|
314
314
|
children: "Powered by"
|
|
315
|
-
}), pt = i(
|
|
315
|
+
}), pt = i(D, {
|
|
316
316
|
_id: "aiSearchTagline__Logo"
|
|
317
317
|
}), St = i("a", {
|
|
318
318
|
_id: "aiSearchTagline__BrandName",
|
|
@@ -322,21 +322,21 @@ const O = i("div", {
|
|
|
322
322
|
rel: "noopener noreferrer"
|
|
323
323
|
});
|
|
324
324
|
export {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
325
|
+
We as AskAITrigger,
|
|
326
|
+
qe as AskAITriggerIcon,
|
|
327
|
+
Ke as AskAITriggerIndicator,
|
|
328
|
+
He as AskAITriggerLabel,
|
|
329
|
+
Fe as Content,
|
|
330
|
+
Ue as EmbeddedSearchInputIcon,
|
|
331
|
+
We as EmbeddedSearchPrimitiveAskAITrigger,
|
|
332
|
+
qe as EmbeddedSearchPrimitiveAskAITriggerIcon,
|
|
333
|
+
Ke as EmbeddedSearchPrimitiveAskAITriggerIndicator,
|
|
334
|
+
He as EmbeddedSearchPrimitiveAskAITriggerLabel,
|
|
335
|
+
Fe as EmbeddedSearchPrimitiveContent,
|
|
336
336
|
ut as EmbeddedSearchPrimitiveFooter,
|
|
337
337
|
Me as EmbeddedSearchPrimitiveInput,
|
|
338
|
-
|
|
339
|
-
|
|
338
|
+
Ve as EmbeddedSearchPrimitiveInputGroup,
|
|
339
|
+
Oe as EmbeddedSearchPrimitiveLoading,
|
|
340
340
|
Ge as EmbeddedSearchPrimitiveResults,
|
|
341
341
|
Qe as EmbeddedSearchPrimitiveResultsEmpty,
|
|
342
342
|
rt as EmbeddedSearchPrimitiveResultsItem,
|
|
@@ -353,13 +353,13 @@ export {
|
|
|
353
353
|
Xe as EmbeddedSearchPrimitiveResultsScrollAreaViewport,
|
|
354
354
|
ze as EmbeddedSearchPrimitiveResultsTab,
|
|
355
355
|
$e as EmbeddedSearchPrimitiveResultsTabList,
|
|
356
|
-
|
|
357
|
-
|
|
356
|
+
De as EmbeddedSearchPrimitiveRoot,
|
|
357
|
+
Ne as EmbeddedSearchPrimitiveWrapper,
|
|
358
358
|
ut as Footer,
|
|
359
359
|
Me as Input,
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
360
|
+
Ve as InputGroup,
|
|
361
|
+
Ue as InputIcon,
|
|
362
|
+
Oe as Loading,
|
|
363
363
|
It as Provider,
|
|
364
364
|
Ge as Results,
|
|
365
365
|
Qe as ResultsEmpty,
|
|
@@ -381,10 +381,10 @@ export {
|
|
|
381
381
|
Xe as ResultsScrollAreaViewport,
|
|
382
382
|
ze as ResultsTab,
|
|
383
383
|
$e as ResultsTabList,
|
|
384
|
-
|
|
384
|
+
De as Root,
|
|
385
385
|
St as TaglineBrandName,
|
|
386
386
|
mt as TaglineContainer,
|
|
387
387
|
pt as TaglineLogo,
|
|
388
388
|
ht as TaglineText,
|
|
389
|
-
|
|
389
|
+
Ne as Wrapper
|
|
390
390
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("openai"),t=require("react"),J=require("react-hook-form"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("openai"),t=require("react"),J=require("react-hook-form"),W=require("../../utils/form.cjs"),X=require("./actions/qa-model-response.cjs"),z=require("./actions/context-model-response.cjs"),Y=require("../../providers/config-provider.cjs"),Z=require("../../providers/conversation-provider.cjs"),ee=require("../../providers/chat-events-provider.cjs"),se=require("./actions/qa-model-messages.cjs"),re=require("../embedded-chat/use-captcha.cjs"),ne="root.serverError",q=async(g,r)=>{if(r)return;const i=await re.fetchAndSolveChallenge(`${g}/v1/challenge`);if(i)return{"X-INKEEP-CHALLENGE-SOLUTION":btoa(JSON.stringify(i))}},oe=g=>{const{formConfig:r}=g,{baseSettings:i}=Y.useInkeepConfig(),{conversation:n}=Z.useInkeepConversation(),{logEvent:a}=ee.useChatEvents(),{aiApiBaseUrl:d,shouldBypassCaptcha:v}=i,y=t.useMemo(()=>new D({baseURL:`${d}/v1`,apiKey:i.apiKey,dangerouslyAllowBrowser:!0}),[i.apiKey,d]),[R,S]=t.useState(!1),[M,V]=t.useState(!1),[A,p]=t.useState(!1),[F,h]=t.useState({}),l=t.useMemo(()=>{const{primary:o,secondary:u}=r;return W.getFormDefaultValues([...o.fields,...u.fields])},[r]),{control:_,handleSubmit:N,formState:{errors:C,isSubmitting:P,isSubmitSuccessful:O},reset:b,trigger:k,setValue:x,setError:H}=J.useForm({defaultValues:l});t.useEffect(()=>{l&&b(l)},[b,l]);const L=async o=>{const u=typeof window>"u"?"":window.location.href;try{await r.onSubmit({values:o,conversation:n,client:{currentUrl:u}}),a({eventName:"intelligent_form_submitted",properties:{conversationId:n.id,values:o}})}catch(c){H(ne,{message:c instanceof Error?c.message:"Something went wrong."}),a({eventName:"intelligent_form_submission_error",properties:{conversationId:n.id,error:c instanceof Error?c.message:"Something went wrong."}})}},K=async()=>{const o=r.primary.fields.map(e=>e.name);if(!await k(o))return;V(!0),S(!0);const c=_._formValues,E=r.primary.fields.reduce((e,m)=>(e[m.name]=c[m.name],e),{}),B=r.secondary.fields.filter(e=>e.shouldPrefillWithAI!==!1),I=se.getQAModelMessages(E);a({eventName:"intelligent_form_primary_submitted",properties:{conversationId:n.id,fields:o,messages:I}});try{const e=await q(d,v),m=await q(d,v),[s,f]=await Promise.all([X.generateQAModelResponse(I,y,e),z.generateContextModelResponse({primaryFieldValues:E,fieldsToGenerate:B},y,m)]);if(a({eventName:"intelligent_form_qa_response",properties:{conversationId:n.id,messages:s.messages,answer:s.answer??"",confidence:s.aiAnnotations?.answerConfidence,recordsConsidered:s.recordsConsidered}}),f.suggestedValues){for(const[Q,$]of Object.entries(f.suggestedValues))x(Q,$);a({eventName:"intelligent_form_context_suggestions",properties:{conversationId:n.id,suggestedFields:Object.keys(f.suggestedValues)}})}const w=s.aiAnnotations?.answerConfidence,T=w&&["very_confident","somewhat_confident"].includes(w),G=s.recordsConsidered&&s.recordsConsidered.length>0;T&&G&&s.answer?h({answer:s.answer,answerConfidence:w,recordsConsidered:s.recordsConsidered}):(p(!0),h({answer:null,recordsConsidered:s.recordsConsidered,suggestedValues:f.suggestedValues}))}catch(e){console.error(e),p(!0),a({eventName:"intelligent_form_ai_error",properties:{conversationId:n.id,error:e instanceof Error?e.message:"Something went wrong."}})}finally{S(!1)}},U=N(L),j=C?.root?.serverError;return{formConfig:r,control:_,errors:C,isSubmitSuccessful:O,isSubmitting:P,handleSubmit:U,loading:R,formError:j,submittedPrimaryForm:M,handleSubmitPrimaryForm:K,aiResponse:F,showSecondaryFields:A,setShowSecondaryFields:p}};exports.useInkeepIntelligentForm=oe;
|