@inkeep/cxkit-primitives 0.5.10 → 0.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +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
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),S=require("../../providers/config-provider.cjs"),T=require("../../utils/transform-source/index.cjs"),k=(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=T.transformInkeepSource({title:t.title,url:d,description:I(t),type:_(t.rootRecord.__typename),tag:D(t),breadcrumbs:t.rootRecord.pathBreadcrumbs??[],contentType:t.rootRecord.contentType},"searchResultItem",{organizationDisplayName:s,tabs:u,transformSource:r}),l={...a,id:t.id,isExternal:g||!!a.shouldOpenInNewTab},h=l.tabs||[];for(const f of h){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 I=e=>{switch(e.rootRecord.__typename){case"DocumentationRecord":{const o=m(e.pathHeadings?.at(-1)?.content||""),r=m(e.content?.content||"");return e.preview||r||o}case"GitHubIssueRecord":case"StackOverflowRecord":case"DiscourseRecord":return e.rootRecord.body;default:return e.preview}},D=e=>{switch(e.rootRecord.__typename){case"StackOverflowRecord":return e.rootRecord.markedAsCorrectAnswer?"Resolved":void 0;case"GitHubIssueRecord":return e.rootRecord.state==="CLOSED"?"Closed":void 0}},m=e=>{const o=/(https?:\/\/\S+)/g;return e.replace(o,r=>{const s=r.split("/");return s.length>3?`...${s.slice(-2).join("/")}`:r})},_=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=k;
@@ -1,31 +1,32 @@
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 A = (e, r) => {
4
+ import { transformInkeepSource as k } from "../../utils/transform-source/index.js";
5
+ const C = (e, o) => {
5
6
  const {
6
- baseSettings: { transformSource: o, organizationDisplayName: s },
7
+ baseSettings: { transformSource: r, organizationDisplayName: s },
7
8
  searchSettings: { tabs: u, searchQueryParamKey: b, shouldOpenLinksInNewTab: g }
8
9
  } = S();
9
10
  return w(() => {
10
- const R = u.length > 0 ? u : ["All"], n = {}, m = /* @__PURE__ */ new Set(), i = R.map((t) => typeof t == "string" ? t : t[0]);
11
+ const m = u.length > 0 ? u : ["All"], n = {}, R = /* @__PURE__ */ new Set(), i = m.map((t) => typeof t == "string" ? t : t[0]);
11
12
  for (const t of i)
12
13
  n[t] = [];
13
14
  for (const t of e) {
14
15
  const c = t.url || "";
15
- if (m.has(c)) continue;
16
- m.add(c);
17
- const d = T(c, r, b), a = o(
16
+ if (R.has(c)) continue;
17
+ R.add(c);
18
+ const d = I(c, o, b), a = k(
18
19
  {
19
20
  title: t.title,
20
21
  url: d,
21
- description: k(t),
22
- type: v(t.rootRecord.__typename),
23
- tag: I(t),
24
- breadcrumbs: t.rootRecord.pathBreadcrumbs,
22
+ description: T(t),
23
+ type: D(t.rootRecord.__typename),
24
+ tag: v(t),
25
+ breadcrumbs: t.rootRecord.pathBreadcrumbs ?? [],
25
26
  contentType: t.rootRecord.contentType
26
27
  },
27
28
  "searchResultItem",
28
- { organizationDisplayName: s, tabs: u }
29
+ { organizationDisplayName: s, tabs: u, transformSource: r }
29
30
  ), l = {
30
31
  ...a,
31
32
  id: t.id,
@@ -42,33 +43,33 @@ const A = (e, r) => {
42
43
  i.includes("All") && n.All.push(l);
43
44
  }
44
45
  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]?.isAlwaysVisible === !0 : !1;
46
+ const c = m.find((a) => typeof a == "string" ? a === t : a[0] === t), d = typeof c == "object" ? c[1]?.isAlwaysVisible === !0 : !1;
46
47
  n[t].length === 0 && !d && delete n[t];
47
48
  }
48
49
  return n;
49
50
  }, [
50
51
  e,
51
- o,
52
+ r,
52
53
  s,
53
54
  u,
54
- r,
55
+ o,
55
56
  b,
56
57
  g
57
58
  ]);
58
59
  };
59
- function T(e, r, o) {
60
+ function I(e, o, r) {
60
61
  try {
61
62
  const s = new URL(e);
62
- return s.searchParams.set(o, r), s.toString();
63
+ return s.searchParams.set(r, o), s.toString();
63
64
  } catch {
64
65
  return e;
65
66
  }
66
67
  }
67
- const k = (e) => {
68
+ const T = (e) => {
68
69
  switch (e.rootRecord.__typename) {
69
70
  case "DocumentationRecord": {
70
- const r = h(e.pathHeadings?.at(-1)?.content || ""), o = h(e.content?.content || "");
71
- return e.preview || o || r;
71
+ const o = h(e.pathHeadings?.at(-1)?.content || ""), r = h(e.content?.content || "");
72
+ return e.preview || r || o;
72
73
  }
73
74
  case "GitHubIssueRecord":
74
75
  case "StackOverflowRecord":
@@ -77,7 +78,7 @@ const k = (e) => {
77
78
  default:
78
79
  return e.preview;
79
80
  }
80
- }, I = (e) => {
81
+ }, v = (e) => {
81
82
  switch (e.rootRecord.__typename) {
82
83
  case "StackOverflowRecord":
83
84
  return e.rootRecord.markedAsCorrectAnswer ? "Resolved" : void 0;
@@ -85,12 +86,12 @@ const k = (e) => {
85
86
  return e.rootRecord.state === "CLOSED" ? "Closed" : void 0;
86
87
  }
87
88
  }, h = (e) => {
88
- const r = /(https?:\/\/\S+)/g;
89
- return e.replace(r, (o) => {
90
- const s = o.split("/");
91
- return s.length > 3 ? `...${s.slice(-2).join("/")}` : o;
89
+ const o = /(https?:\/\/\S+)/g;
90
+ return e.replace(o, (r) => {
91
+ const s = r.split("/");
92
+ return s.length > 3 ? `...${s.slice(-2).join("/")}` : r;
92
93
  });
93
- }, v = (e) => {
94
+ }, D = (e) => {
94
95
  switch (e) {
95
96
  case "DocumentationRecord":
96
97
  return "documentation";
@@ -109,5 +110,5 @@ const k = (e) => {
109
110
  }
110
111
  };
111
112
  export {
112
- A as useTransformResults
113
+ C as useTransformResults
113
114
  };
@@ -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:_,searchSettings:j}=W.useInkeepConfig(),{apiKey:p,aiApiBaseUrl:L,userAuthToken:l}=_,{maxResults:R,placeholder:S,defaultQuery:N,debounceTimeMs:Q,onQueryChange:O,searchFunctionsRef:x}=j,{logEvent:q}=X.useSearchEvents(),[c,C]=t.useState(N),T=t.useRef(null),[k,v]=t.useState(!1),[B,i]=t.useState(null),[F,a]=t.useState("NONE"),H=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,totalResults: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)})},Q)},[Q,I]),g=t.useMemo(()=>({searchQuery:c,filters:{limit:R}}),[c,R]);t.useEffect(()=>{O?.(g.searchQuery),U(g)},[U,g]);const D=t.useCallback(e=>C(e.target.value),[]),K=t.useMemo(()=>S||(y?"Search...":"Search for anything..."),[S,y]);return{results:s,resultsList:h,hasContent:h.length>0||k,loading:k,error:B,query:c,onInput:D,placeholder:K,tab:f,onTabChange:z,selectedItem:F,setSelectedItem:a,onSelectedItemChange:H,transitionsDisabled:$,inputRef:T,isMobile:y}};exports.useInkeepSearch=ee;
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:R,defaultQuery:N,debounceTimeMs:Q,onQueryChange:O,searchFunctionsRef:x}=j,{logEvent:q}=X.useSearchEvents(),[c,C]=t.useState(N),T=t.useRef(null),[k,v]=t.useState(!1),[B,i]=t.useState(null),[F,a]=t.useState("NONE"),H=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);const r=s[e][0].id;setTimeout(()=>{a(r)},0)},[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,totalResults: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)})},Q)},[Q,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(()=>R||(y?"Search...":"Search for anything..."),[R,y]);return{results:s,resultsList:h,hasContent:h.length>0||k,loading:k,error:B,query:c,onInput:D,placeholder:K,tab:f,onTabChange:z,selectedItem:F,setSelectedItem:a,onSelectedItemChange:H,transitionsDisabled:$,inputRef:T,isMobile:y}};exports.useInkeepSearch=ee;
@@ -11,7 +11,7 @@ export declare const useInkeepSearch: () => {
11
11
  onInput: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
12
12
  placeholder: string;
13
13
  tab: string;
14
- onTabChange: (value: string) => void;
14
+ onTabChange: (newTab: string) => void;
15
15
  selectedItem: string | undefined;
16
16
  setSelectedItem: Dispatch<SetStateAction<string | undefined>>;
17
17
  onSelectedItemChange: (value: string) => void;
@@ -11,7 +11,7 @@ export declare const useInkeepSearch: () => {
11
11
  onInput: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
12
12
  placeholder: string;
13
13
  tab: string;
14
- onTabChange: (value: string) => void;
14
+ onTabChange: (newTab: string) => void;
15
15
  selectedItem: string | undefined;
16
16
  setSelectedItem: Dispatch<SetStateAction<string | undefined>>;
17
17
  onSelectedItemChange: (value: string) => void;
@@ -12,29 +12,33 @@ const me = () => {
12
12
  maxResults: S,
13
13
  placeholder: C,
14
14
  defaultQuery: H,
15
- debounceTimeMs: k,
15
+ debounceTimeMs: v,
16
16
  onQueryChange: P,
17
17
  searchFunctionsRef: $
18
- } = B, { logEvent: v } = re(), [c, w] = s(H), A = l(null), [q, E] = s(!1), [z, f] = s(null), [D, a] = s("NONE"), K = n((e) => {
18
+ } = B, { logEvent: k } = re(), [c, w] = s(H), A = l(null), [q, E] = s(!1), [z, f] = s(null), [D, a] = s("NONE"), K = n((e) => {
19
19
  a(e);
20
- }, []), [m, d] = s([]), t = te(m, c), [p, _] = s("All"), { disableTransition: x, disabled: W } = se(), G = n(
20
+ }, []), [m, d] = s([]), t = te(m, c), [p, I] = s("All"), { disableTransition: _, disabled: W } = se(), G = n(
21
21
  (e) => {
22
- x(), _(e), a(t[e][0].id);
22
+ _(), I(e);
23
+ const r = t[e][0].id;
24
+ setTimeout(() => {
25
+ a(r);
26
+ }, 0);
23
27
  },
24
- [t, x]
28
+ [t, _]
25
29
  );
26
30
  j(() => {
27
31
  let e = p in t ? p : Object.keys(t)[0];
28
32
  if (!t[e]?.length) {
29
- const o = Object.keys(t).find((u) => t[u]?.length);
33
+ const o = Object.keys(t).find((i) => t[i]?.length);
30
34
  o ? e = o : e = "All";
31
35
  }
32
36
  if (!e) return;
33
- _(e);
37
+ I(e);
34
38
  const r = t[e]?.[0];
35
39
  r && a(r.id);
36
40
  }, [t]);
37
- const y = Z("(max-width: 768px)"), i = l({}), b = l(null), g = l(null);
41
+ const y = Z("(max-width: 768px)"), u = l({}), b = l(null), g = l(null);
38
42
  X($, () => ({
39
43
  updateQuery(e) {
40
44
  w(e);
@@ -43,7 +47,7 @@ const me = () => {
43
47
  A.current?.focus();
44
48
  }
45
49
  }));
46
- const I = `${F}/graphql`, L = R(
50
+ const x = `${F}/graphql`, L = R(
47
51
  () => ({
48
52
  Authorization: `Bearer ${T}`,
49
53
  "Content-Type": "application/json",
@@ -57,8 +61,8 @@ const me = () => {
57
61
  b.current = r;
58
62
  try {
59
63
  E(!0), f(null);
60
- const u = (await ne(I, ee, { searchInput: e }, L))?.search.searchHits;
61
- i.current[e.searchQuery] = u, d(u);
64
+ const i = (await ne(x, ee, { searchInput: e }, L))?.search.searchHits;
65
+ u.current[e.searchQuery] = i, d(i);
62
66
  } catch (o) {
63
67
  if (o.name === "AbortError")
64
68
  return;
@@ -66,10 +70,10 @@ const me = () => {
66
70
  }
67
71
  E(!1);
68
72
  },
69
- [I, L]
73
+ [x, L]
70
74
  ), N = n((e) => {
71
- const r = i.current[e.searchQuery];
72
- v({
75
+ const r = u.current[e.searchQuery];
76
+ k({
73
77
  eventName: "search_query_response_received",
74
78
  properties: {
75
79
  searchQuery: e.searchQuery,
@@ -83,17 +87,17 @@ const me = () => {
83
87
  return;
84
88
  }
85
89
  g.current = window.setTimeout(() => {
86
- v({
90
+ k({
87
91
  eventName: "search_query_submitted",
88
92
  properties: {
89
93
  searchQuery: e.searchQuery
90
94
  }
91
- }), i.current[e.searchQuery] ? (d(i.current[e.searchQuery]), N(e)) : M(e).then(() => {
95
+ }), u.current[e.searchQuery] ? (d(u.current[e.searchQuery]), N(e)) : M(e).then(() => {
92
96
  N(e);
93
97
  });
94
- }, k);
98
+ }, v);
95
99
  },
96
- [k, M]
100
+ [v, M]
97
101
  ), Q = R(
98
102
  () => ({
99
103
  searchQuery: c,
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),n=require("./factory.cjs"),F=require("react"),y=require("react-textarea-autosize"),je=require("@radix-ui/react-select"),Ae=require("@radix-ui/react-checkbox"),m=require("./intelligent-form/intelligent-form-provider.cjs"),Te=require("@radix-ui/react-scroll-area"),p=require("../atoms/icons/built-in-icon-renderer.cjs"),c=require("../utils/misc.cjs"),Be=require("react-hook-form"),I=require("../providers/intelligent-form-field-provider.cjs"),He=require("../atoms/icons/checkbox-icon.cjs"),x=require("../providers/config-provider.cjs"),h=require("../providers/source-item-provider.cjs"),Ee=require("../atoms/link.cjs"),Le=require("../atoms/markdown/index.cjs"),P=require("../utils/compose-refs.cjs"),u=require("../utils/compose-event-handlers.cjs");function b(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const g=b(je),R=b(Ae),S=b(Te),Ve=n.ikp("form",{_id:"intelligentForm__Root"}),w=i=>{const{onSubmit:e,...t}=i,{handleSubmit:r}=m.useIntelligentForm();return o.jsx(Ve,{onSubmit:u.composeEventHandlers(e,r),...t})},j=n.ikp("h2",{_id:"intelligentForm__Heading",children:"Contact Support"}),A=n.ikp("div",{_id:"intelligentForm__Content"}),T=n.ikp(S.Root,{_id:"intelligentForm__Content__ScrollArea"}),qe=n.ikp(S.Viewport,{_id:"intelligentForm__Content__ScrollAreaViewport"}),B=i=>{const{children:e,...t}=i;return o.jsx(qe,{children:o.jsx("div",{"data-part":"grid",style:{display:"grid"},children:e}),...t})},H=n.ikp(S.ScrollAreaScrollbar,{_id:"intelligentForm__Content__ScrollAreaScrollbar"}),E=n.ikp(S.ScrollAreaThumb,{_id:"intelligentForm__Content__ScrollAreaThumb"}),L=n.ikp(S.Corner,{_id:"intelligentForm__Content__ScrollAreaCorner"}),De=n.ikp("div",{_id:"intelligentForm__Success"}),V=i=>{const{children:e,...t}=i,{isSubmitSuccessful:r}=m.useIntelligentForm();return r?o.jsx(De,{...t,children:e}):null},Ne=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__SuccessIcon"}),q=i=>{const{formSettings:{successView:e}}=m.useIntelligentForm();return o.jsx(Ne,{iconSettings:e.icon??{builtIn:"LuCircleCheck"},...i})},Oe=n.ikp("h2",{_id:"intelligentForm__SuccessHeading"}),D=i=>{const{formSettings:{successView:e}}=m.useIntelligentForm();return o.jsx(Oe,{children:e.heading,...i})},Me=n.ikp("p",{_id:"intelligentForm__SuccessMessage"}),N=i=>{const{formSettings:{successView:e}}=m.useIntelligentForm();return o.jsx(Me,{children:e.message,...i})},O=n.ikp("div",{_id:"intelligentForm__PrimaryForm"}),ze=n.ikp("div",{_id:"intelligentForm__PrimaryFormFields"}),Ue=n.ikp("p",{_id:"intelligentForm__PrimaryForm__Description"}),M=i=>{const{formSettings:{primary:e}}=m.useIntelligentForm();return e.description?o.jsx(Ue,{children:e.description,...i}):null},z=i=>{const{children:e,...t}=i,{formSettings:{primary:r}}=m.useIntelligentForm();return o.jsx(ze,{children:c.maybeRender(e,r.fields),...t})},Qe=n.ikp("button",{_id:"intelligentForm__PrimaryFormSubmit",type:"button",children:"Next"}),U=i=>{const{onClick:e,...t}=i,{submittedPrimaryForm:r,handleSubmitPrimaryForm:l}=m.useIntelligentForm();return o.jsx(Qe,{"data-submitted":c.dataAttr(r),onClick:u.composeEventHandlers(e,l),...t})},We=n.ikp("div",{_id:"intelligentForm__Field"}),Q=i=>{const{field:e,autoFocus:t,...r}=i,{control:l,errors:s}=m.useIntelligentForm();return o.jsx(Be.Controller,{name:e.name,control:l,rules:{required:e.isRequired?`${e.label} is required.`:void 0},render:({field:d})=>{const a=d.value!==void 0||e.inputType==="file";return o.jsx(I.IntelligentFormFieldProvider,{"data-invalid":c.dataAttr(!!s[e.name]),field:e,fieldProps:d,autoFocus:t,children:a&&o.jsx(We,{"data-input-type":e.inputType,"data-hidden":c.dataAttr(e.isHidden),...r})})}})},$e=n.ikp("label",{_id:"intelligentForm__FieldLabel"}),W=i=>{const{field:e}=I.useIntelligentFormField();return o.jsx($e,{"data-required":c.dataAttr(e.isRequired),htmlFor:e.name,children:e.label,...i})},Ge=n.ikp("input",{_id:"intelligentForm__FieldText",type:"text"}),f=F.forwardRef((i,e)=>{const{field:t,error:r,fieldProps:{onChange:l,onBlur:s,ref:d,...a},autoFocus:v}=I.useIntelligentFormField(),_=P.useComposedRefs(e,d);return o.jsx(Ge,{asChild:t.inputType==="textarea",ref:_,id:t.name,autoFocus:v,placeholder:"placeholder"in t?t.placeholder:void 0,"data-invalid":c.dataAttr(!!r),onChange:u.composeEventHandlers(i.onChange,l),onBlur:u.composeEventHandlers(i.onBlur,s),...a,...i,children:t.inputType==="textarea"?o.jsx(y,{minRows:3,maxRows:10}):null})}),$=n.ikp(f,{_id:"intelligentForm__FieldEmail",type:"email"}),Je=n.ikp("input",{_id:"intelligentForm__FieldFile",type:"file",multiple:!0}),G=i=>{const{field:e,error:t,fieldProps:{value:r,onChange:l,onBlur:s,...d},autoFocus:a}=I.useIntelligentFormField(),{onChange:v,onBlur:_,...k}=i,C=Re=>{const we=Re.target.files;l(we)};return o.jsx(Je,{id:e.name,autoFocus:a,"data-value":r,"data-invalid":c.dataAttr(!!t),...k,...d,onChange:u.composeEventHandlers(v,C),onBlur:u.composeEventHandlers(_,s)})},J=n.ikp(f,{_id:"intelligentForm__FieldTextArea",type:"textarea",asChild:!0,children:o.jsx(y,{rows:1,maxRows:8})}),Ke=n.ikp(R.Root,{_id:"intelligentForm__FieldCheckbox"}),K=i=>{const{field:e,error:t,fieldProps:r,autoFocus:l}=I.useIntelligentFormField(),{onCheckedChange:s,...d}=i;return o.jsx(Ke,{id:e.name,name:e.name,autoFocus:l,"data-invalid":c.dataAttr(!!t),checked:r.value,onCheckedChange:u.composeEventHandlers(s,r.onChange),...d})},X=n.ikp(R.Indicator,{_id:"intelligentForm__FieldCheckboxIndicator",children:o.jsx(He.CheckboxIcon,{})}),Xe=n.ikp(g.Root,{_id:"intelligentForm__FieldSelect"}),Y=i=>{const{field:e,error:t,fieldProps:r}=I.useIntelligentFormField(),{onValueChange:l,...s}=i;return o.jsx(Xe,{name:e.name,"data-invalid":c.dataAttr(!!t),value:r.value,onValueChange:u.composeEventHandlers(l,r.onChange),...s})},Z=n.ikp(g.Trigger,{_id:"intelligentForm__FieldSelect__Trigger"}),Ye=n.ikp(g.Value,{_id:"intelligentForm__FieldSelect__Value"}),ee=i=>{const{field:e}=I.useIntelligentFormField();return o.jsx(Ye,{placeholder:"placeholder"in e?e.placeholder:void 0,...i})},ie=n.ikp(g.Icon,{_id:"intelligentForm__FieldSelect__Icon",asChild:!0,children:o.jsx(p.BuiltInIconRenderer,{iconSettings:{builtIn:"LuChevronDown"}})}),te=n.ikp(g.Content,{_id:"intelligentForm__FieldSelect__Content",position:"popper"}),ne=n.ikp(g.Viewport,{_id:"intelligentForm__FieldSelect__Viewport"}),re=n.ikp(g.Item,{_id:"intelligentForm__FieldSelect__Item"}),oe=n.ikp(g.ItemText,{_id:"intelligentForm__FieldSelect__ItemText"}),le=n.ikp(g.ItemIndicator,{_id:"intelligentForm__FieldSelect__ItemIndicator",asChild:!0,children:o.jsx(p.BuiltInIconRenderer,{iconSettings:{builtIn:"LuCheck"}})}),Ze=n.ikp("span",{_id:"intelligentForm__FieldError"}),me=i=>{const{error:e}=I.useIntelligentFormField();return e?o.jsx(Ze,{children:e.message?.toString(),...i}):null},se=n.ikp("div",{_id:"intelligentForm__BotHeading"}),ce=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__BotHeading__Icon",iconSettings:{builtIn:"LuSparkles"}}),ei=n.ikp("div",{_id:"intelligentForm__BotHeading__Name"}),de=i=>{const{baseSettings:e}=x.useInkeepConfig(),{organizationDisplayName:t}=e??{},{formSettings:{aiAssistantName:r}}=m.useIntelligentForm();return o.jsx(ei,{children:r??t,...i})},ii=n.ikp("div",{_id:"intelligentForm__Loading"}),Fe=F.forwardRef(({...i},e)=>{const{loading:t}=m.useIntelligentForm(),r=F.useRef(null),l=P.useComposedRefs(e,r);return F.useEffect(()=>{t&&r.current&&r.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[t]),t?o.jsx(ii,{ref:l,...i}):null}),ti=n.ikp("div",{_id:"intelligentForm__ConfidentResponse"}),ae=F.forwardRef(({...i},e)=>{const{aiResponse:t,loading:r}=m.useIntelligentForm(),l=F.useRef(null),s=P.useComposedRefs(e,l);return F.useEffect(()=>{!r&&t.answerConfidence&&l.current&&l.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[r,t.answerConfidence]),t.answerConfidence?o.jsx(ti,{ref:s,...i}):null}),ni=n.ikp(Le.Markdown,{_id:"intelligentForm__ConfidentAnswer"}),ue=i=>{const{aiResponse:e}=m.useIntelligentForm();return o.jsx(ni,{shouldOpenLinksInNewTab:!0,children:e.answer,...i})},ri=n.ikp("button",{_id:"intelligentForm__ConfidentResponseButton",type:"button"}),ge=i=>{const{onClick:e,...t}=i,{showSecondaryFields:r,setShowSecondaryFields:l}=m.useIntelligentForm(),s=()=>{l(!0)};return o.jsx(ri,{"data-escalated":c.dataAttr(r),onClick:u.composeEventHandlers(e,s),...t})},Ie=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__ConfidentResponseButton__Icon",iconSettings:{builtIn:"LuUser"}}),_e=n.ikp("span",{_id:"intelligentForm__ConfidentResponseButton__Label",children:"Escalate to human"}),oi=n.ikp("div",{_id:"intelligentForm__SecondaryForm"}),pe=F.forwardRef(({...i},e)=>{const{showSecondaryFields:t}=m.useIntelligentForm(),r=F.useRef(null),l=P.useComposedRefs(e,r);return F.useEffect(()=>{t&&r.current&&r.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[t]),t?o.jsx(oi,{ref:l,...i}):null}),li=n.ikp("p",{_id:"intelligentForm__SecondaryForm__Description"}),ve=i=>{const{formSettings:{secondary:e},aiResponse:{answerConfidence:t}}=m.useIntelligentForm();if(!e.description)return null;const r=typeof e.description=="string"?e.description:t?e.description.confident:e.description.default;return o.jsx(li,{children:r,...i})},mi=n.ikp("div",{_id:"intelligentForm__SecondaryFormFields"}),Se=i=>{const{children:e,...t}=i,{formSettings:{secondary:r}}=m.useIntelligentForm();return o.jsx(mi,{children:c.maybeRender(e,r.fields),...t})},si=n.ikp("button",{_id:"intelligentForm__SecondaryFormSubmit",type:"submit",children:"Submit"}),Pe=i=>{const{formSettings:e}=m.useIntelligentForm(),{label:t}=e.buttons.submit;return o.jsx(si,{children:t??"Submit",...i})},ci=n.ikp("span",{_id:"intelligentForm__Error"}),fe=i=>{const{formError:e}=m.useIntelligentForm();return e?o.jsx(ci,{children:e.message,...i}):null},Ce=n.ikp("div",{_id:"intelligentForm__Sources"}),he=n.ikp("p",{_id:"intelligentForm__SourcesCaption",children:"Here are the sources I considered:"}),di=n.ikp("div",{_id:"intelligentForm__SourcesList"}),be=i=>{const{children:e,...t}=i,{baseSettings:{transformSource:r,organizationDisplayName:l}}=x.useInkeepConfig(),{aiResponse:{recordsConsidered:s}}=m.useIntelligentForm();if(!s)return null;const d=s.reduce((a,v)=>{const _=r(v,"intelligentFormSource",{organizationDisplayName:l});return a.some(C=>C.url===_.url)||a.push(_),a},[]);return o.jsx(di,{children:c.maybeRender(e,d),...t})},Fi=n.ikp(Ee.LinkWithQueryParams,{_id:"intelligentForm__Source"}),ke=i=>{const{source:e,...t}=i;return o.jsx(h.SourceItemProvider,{source:{...e,isExternal:!!e.shouldOpenInNewTab},children:o.jsx(Fi,{"data-type":e.type,appendToUrl:e.appendToUrl,href:e.url,isExternal:e.shouldOpenInNewTab!==!1,...t})})},ai=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__SourceIcon"}),ye=i=>{const{source:e}=h.useSourceItem();return o.jsx(ai,{iconSettings:e.icon,"data-type":e.type,...i})},ui=n.ikp("span",{_id:"intelligentForm__SourceTitle"}),xe=i=>{const{source:e}=h.useSourceItem();return o.jsx(ui,{"data-type":e.type,children:e.title,...i})};exports.Provider=m.IntelligentFormProvider;exports.BotHeading=se;exports.BotHeadingIcon=ce;exports.BotHeadingName=de;exports.ConfidentAnswer=ue;exports.ConfidentResponse=ae;exports.ConfidentResponseButton=ge;exports.ConfidentResponseButtonIcon=Ie;exports.ConfidentResponseButtonLabel=_e;exports.Content=A;exports.ContentScrollArea=T;exports.ContentScrollAreaCorner=L;exports.ContentScrollAreaScrollbar=H;exports.ContentScrollAreaThumb=E;exports.ContentScrollAreaViewport=B;exports.Error=fe;exports.FormField=Q;exports.FormFieldCheckbox=K;exports.FormFieldCheckboxIndicator=X;exports.FormFieldEmail=$;exports.FormFieldError=me;exports.FormFieldFile=G;exports.FormFieldLabel=W;exports.FormFieldSelect=Y;exports.FormFieldSelectContent=te;exports.FormFieldSelectIcon=ie;exports.FormFieldSelectItem=re;exports.FormFieldSelectItemIndicator=le;exports.FormFieldSelectItemText=oe;exports.FormFieldSelectTrigger=Z;exports.FormFieldSelectValue=ee;exports.FormFieldSelectViewport=ne;exports.FormFieldText=f;exports.FormFieldTextArea=J;exports.Heading=j;exports.IntelligentFormPrimitiveBotHeading=se;exports.IntelligentFormPrimitiveBotHeadingIcon=ce;exports.IntelligentFormPrimitiveBotHeadingName=de;exports.IntelligentFormPrimitiveConfidentAnswer=ue;exports.IntelligentFormPrimitiveConfidentResponse=ae;exports.IntelligentFormPrimitiveConfidentResponseButton=ge;exports.IntelligentFormPrimitiveConfidentResponseButtonIcon=Ie;exports.IntelligentFormPrimitiveConfidentResponseButtonLabel=_e;exports.IntelligentFormPrimitiveContent=A;exports.IntelligentFormPrimitiveContentScrollArea=T;exports.IntelligentFormPrimitiveContentScrollAreaCorner=L;exports.IntelligentFormPrimitiveContentScrollAreaScrollbar=H;exports.IntelligentFormPrimitiveContentScrollAreaThumb=E;exports.IntelligentFormPrimitiveContentScrollAreaViewport=B;exports.IntelligentFormPrimitiveFormError=fe;exports.IntelligentFormPrimitiveFormField=Q;exports.IntelligentFormPrimitiveFormFieldCheckbox=K;exports.IntelligentFormPrimitiveFormFieldCheckboxIndicator=X;exports.IntelligentFormPrimitiveFormFieldEmail=$;exports.IntelligentFormPrimitiveFormFieldError=me;exports.IntelligentFormPrimitiveFormFieldFile=G;exports.IntelligentFormPrimitiveFormFieldLabel=W;exports.IntelligentFormPrimitiveFormFieldSelect=Y;exports.IntelligentFormPrimitiveFormFieldSelectContent=te;exports.IntelligentFormPrimitiveFormFieldSelectIcon=ie;exports.IntelligentFormPrimitiveFormFieldSelectItem=re;exports.IntelligentFormPrimitiveFormFieldSelectItemIndicator=le;exports.IntelligentFormPrimitiveFormFieldSelectItemText=oe;exports.IntelligentFormPrimitiveFormFieldSelectTrigger=Z;exports.IntelligentFormPrimitiveFormFieldSelectValue=ee;exports.IntelligentFormPrimitiveFormFieldSelectViewport=ne;exports.IntelligentFormPrimitiveFormFieldText=f;exports.IntelligentFormPrimitiveFormFieldTextArea=J;exports.IntelligentFormPrimitiveHeading=j;exports.IntelligentFormPrimitiveLoading=Fe;exports.IntelligentFormPrimitivePrimaryForm=O;exports.IntelligentFormPrimitivePrimaryFormDescription=M;exports.IntelligentFormPrimitivePrimaryFormFields=z;exports.IntelligentFormPrimitivePrimaryFormSubmit=U;exports.IntelligentFormPrimitiveRoot=w;exports.IntelligentFormPrimitiveSecondaryForm=pe;exports.IntelligentFormPrimitiveSecondaryFormDescription=ve;exports.IntelligentFormPrimitiveSecondaryFormFields=Se;exports.IntelligentFormPrimitiveSecondaryFormSubmit=Pe;exports.IntelligentFormPrimitiveSource=ke;exports.IntelligentFormPrimitiveSourceIcon=ye;exports.IntelligentFormPrimitiveSourceTitle=xe;exports.IntelligentFormPrimitiveSources=Ce;exports.IntelligentFormPrimitiveSourcesCaption=he;exports.IntelligentFormPrimitiveSourcesList=be;exports.IntelligentFormPrimitiveSuccess=V;exports.IntelligentFormPrimitiveSuccessHeading=D;exports.IntelligentFormPrimitiveSuccessIcon=q;exports.IntelligentFormPrimitiveSuccessMessage=N;exports.Loading=Fe;exports.PrimaryForm=O;exports.PrimaryFormDescription=M;exports.PrimaryFormFields=z;exports.PrimaryFormSubmit=U;exports.Root=w;exports.SecondaryForm=pe;exports.SecondaryFormDescription=ve;exports.SecondaryFormFields=Se;exports.SecondaryFormSubmit=Pe;exports.Source=ke;exports.SourceIcon=ye;exports.SourceTitle=xe;exports.Sources=Ce;exports.SourcesCaption=he;exports.SourcesList=be;exports.Success=V;exports.SuccessHeading=D;exports.SuccessIcon=q;exports.SuccessMessage=N;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),n=require("./factory.cjs"),F=require("react"),y=require("react-textarea-autosize"),je=require("@radix-ui/react-select"),Ae=require("@radix-ui/react-checkbox"),m=require("./intelligent-form/intelligent-form-provider.cjs"),Te=require("@radix-ui/react-scroll-area"),p=require("../atoms/icons/built-in-icon-renderer.cjs"),c=require("../utils/misc.cjs"),Be=require("react-hook-form"),I=require("../providers/intelligent-form-field-provider.cjs"),He=require("../atoms/icons/checkbox-icon.cjs"),x=require("../providers/config-provider.cjs"),h=require("../providers/source-item-provider.cjs"),Ee=require("../atoms/link.cjs"),Le=require("../atoms/markdown/index.cjs"),P=require("../utils/compose-refs.cjs"),u=require("../utils/compose-event-handlers.cjs"),qe=require("../utils/transform-source/index.cjs");function b(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const g=b(je),R=b(Ae),S=b(Te),Ve=n.ikp("form",{_id:"intelligentForm__Root"}),w=i=>{const{onSubmit:e,...t}=i,{handleSubmit:r}=m.useIntelligentForm();return o.jsx(Ve,{onSubmit:u.composeEventHandlers(e,r),...t})},j=n.ikp("h2",{_id:"intelligentForm__Heading",children:"Contact Support"}),A=n.ikp("div",{_id:"intelligentForm__Content"}),T=n.ikp(S.Root,{_id:"intelligentForm__Content__ScrollArea"}),De=n.ikp(S.Viewport,{_id:"intelligentForm__Content__ScrollAreaViewport"}),B=i=>{const{children:e,...t}=i;return o.jsx(De,{children:o.jsx("div",{"data-part":"grid",style:{display:"grid"},children:e}),...t})},H=n.ikp(S.ScrollAreaScrollbar,{_id:"intelligentForm__Content__ScrollAreaScrollbar"}),E=n.ikp(S.ScrollAreaThumb,{_id:"intelligentForm__Content__ScrollAreaThumb"}),L=n.ikp(S.Corner,{_id:"intelligentForm__Content__ScrollAreaCorner"}),Ne=n.ikp("div",{_id:"intelligentForm__Success"}),q=i=>{const{children:e,...t}=i,{isSubmitSuccessful:r}=m.useIntelligentForm();return r?o.jsx(Ne,{...t,children:e}):null},Oe=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__SuccessIcon"}),V=i=>{const{formSettings:{successView:e}}=m.useIntelligentForm();return o.jsx(Oe,{iconSettings:e.icon??{builtIn:"LuCircleCheck"},...i})},Me=n.ikp("h2",{_id:"intelligentForm__SuccessHeading"}),D=i=>{const{formSettings:{successView:e}}=m.useIntelligentForm();return o.jsx(Me,{children:e.heading,...i})},ze=n.ikp("p",{_id:"intelligentForm__SuccessMessage"}),N=i=>{const{formSettings:{successView:e}}=m.useIntelligentForm();return o.jsx(ze,{children:e.message,...i})},O=n.ikp("div",{_id:"intelligentForm__PrimaryForm"}),Ue=n.ikp("div",{_id:"intelligentForm__PrimaryFormFields"}),$e=n.ikp("p",{_id:"intelligentForm__PrimaryForm__Description"}),M=i=>{const{formSettings:{primary:e}}=m.useIntelligentForm();return e.description?o.jsx($e,{children:e.description,...i}):null},z=i=>{const{children:e,...t}=i,{formSettings:{primary:r}}=m.useIntelligentForm();return o.jsx(Ue,{children:c.maybeRender(e,r.fields),...t})},Qe=n.ikp("button",{_id:"intelligentForm__PrimaryFormSubmit",type:"button",children:"Next"}),U=i=>{const{onClick:e,...t}=i,{submittedPrimaryForm:r,handleSubmitPrimaryForm:l}=m.useIntelligentForm();return o.jsx(Qe,{"data-submitted":c.dataAttr(r),onClick:u.composeEventHandlers(e,l),...t})},We=n.ikp("div",{_id:"intelligentForm__Field"}),$=i=>{const{field:e,autoFocus:t,...r}=i,{control:l,errors:s}=m.useIntelligentForm();return o.jsx(Be.Controller,{name:e.name,control:l,rules:{required:e.isRequired?`${e.label} is required.`:void 0},render:({field:d})=>{const a=d.value!==void 0||e.inputType==="file";return o.jsx(I.IntelligentFormFieldProvider,{"data-invalid":c.dataAttr(!!s[e.name]),field:e,fieldProps:d,autoFocus:t,children:a&&o.jsx(We,{"data-input-type":e.inputType,"data-hidden":c.dataAttr(e.isHidden),...r})})}})},Ge=n.ikp("label",{_id:"intelligentForm__FieldLabel"}),Q=i=>{const{field:e}=I.useIntelligentFormField();return o.jsx(Ge,{"data-required":c.dataAttr(e.isRequired),htmlFor:e.name,children:e.label,...i})},Je=n.ikp("input",{_id:"intelligentForm__FieldText",type:"text"}),f=F.forwardRef((i,e)=>{const{field:t,error:r,fieldProps:{onChange:l,onBlur:s,ref:d,...a},autoFocus:v}=I.useIntelligentFormField(),_=P.useComposedRefs(e,d);return o.jsx(Je,{asChild:t.inputType==="textarea",ref:_,id:t.name,autoFocus:v,placeholder:"placeholder"in t?t.placeholder:void 0,"data-invalid":c.dataAttr(!!r),onChange:u.composeEventHandlers(i.onChange,l),onBlur:u.composeEventHandlers(i.onBlur,s),...a,...i,children:t.inputType==="textarea"?o.jsx(y,{minRows:3,maxRows:10}):null})}),W=n.ikp(f,{_id:"intelligentForm__FieldEmail",type:"email"}),Ke=n.ikp("input",{_id:"intelligentForm__FieldFile",type:"file",multiple:!0}),G=i=>{const{field:e,error:t,fieldProps:{value:r,onChange:l,onBlur:s,...d},autoFocus:a}=I.useIntelligentFormField(),{onChange:v,onBlur:_,...k}=i,C=Re=>{const we=Re.target.files;l(we)};return o.jsx(Ke,{id:e.name,autoFocus:a,"data-value":r,"data-invalid":c.dataAttr(!!t),...k,...d,onChange:u.composeEventHandlers(v,C),onBlur:u.composeEventHandlers(_,s)})},J=n.ikp(f,{_id:"intelligentForm__FieldTextArea",type:"textarea",asChild:!0,children:o.jsx(y,{rows:1,maxRows:8})}),Xe=n.ikp(R.Root,{_id:"intelligentForm__FieldCheckbox"}),K=i=>{const{field:e,error:t,fieldProps:r,autoFocus:l}=I.useIntelligentFormField(),{onCheckedChange:s,...d}=i;return o.jsx(Xe,{id:e.name,name:e.name,autoFocus:l,"data-invalid":c.dataAttr(!!t),checked:r.value,onCheckedChange:u.composeEventHandlers(s,r.onChange),...d})},X=n.ikp(R.Indicator,{_id:"intelligentForm__FieldCheckboxIndicator",children:o.jsx(He.CheckboxIcon,{})}),Ye=n.ikp(g.Root,{_id:"intelligentForm__FieldSelect"}),Y=i=>{const{field:e,error:t,fieldProps:r}=I.useIntelligentFormField(),{onValueChange:l,...s}=i;return o.jsx(Ye,{name:e.name,"data-invalid":c.dataAttr(!!t),value:r.value,onValueChange:u.composeEventHandlers(l,r.onChange),...s})},Z=n.ikp(g.Trigger,{_id:"intelligentForm__FieldSelect__Trigger"}),Ze=n.ikp(g.Value,{_id:"intelligentForm__FieldSelect__Value"}),ee=i=>{const{field:e}=I.useIntelligentFormField();return o.jsx(Ze,{placeholder:"placeholder"in e?e.placeholder:void 0,...i})},ie=n.ikp(g.Icon,{_id:"intelligentForm__FieldSelect__Icon",asChild:!0,children:o.jsx(p.BuiltInIconRenderer,{iconSettings:{builtIn:"LuChevronDown"}})}),te=n.ikp(g.Content,{_id:"intelligentForm__FieldSelect__Content",position:"popper"}),ne=n.ikp(g.Viewport,{_id:"intelligentForm__FieldSelect__Viewport"}),re=n.ikp(g.Item,{_id:"intelligentForm__FieldSelect__Item"}),oe=n.ikp(g.ItemText,{_id:"intelligentForm__FieldSelect__ItemText"}),le=n.ikp(g.ItemIndicator,{_id:"intelligentForm__FieldSelect__ItemIndicator",asChild:!0,children:o.jsx(p.BuiltInIconRenderer,{iconSettings:{builtIn:"LuCheck"}})}),ei=n.ikp("span",{_id:"intelligentForm__FieldError"}),me=i=>{const{error:e}=I.useIntelligentFormField();return e?o.jsx(ei,{children:e.message?.toString(),...i}):null},se=n.ikp("div",{_id:"intelligentForm__BotHeading"}),ce=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__BotHeading__Icon",iconSettings:{builtIn:"LuSparkles"}}),ii=n.ikp("div",{_id:"intelligentForm__BotHeading__Name"}),de=i=>{const{baseSettings:e}=x.useInkeepConfig(),{organizationDisplayName:t}=e??{},{formSettings:{aiAssistantName:r}}=m.useIntelligentForm();return o.jsx(ii,{children:r??t,...i})},ti=n.ikp("div",{_id:"intelligentForm__Loading"}),Fe=F.forwardRef(({...i},e)=>{const{loading:t}=m.useIntelligentForm(),r=F.useRef(null),l=P.useComposedRefs(e,r);return F.useEffect(()=>{t&&r.current&&r.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[t]),t?o.jsx(ti,{ref:l,...i}):null}),ni=n.ikp("div",{_id:"intelligentForm__ConfidentResponse"}),ae=F.forwardRef(({...i},e)=>{const{aiResponse:t,loading:r}=m.useIntelligentForm(),l=F.useRef(null),s=P.useComposedRefs(e,l);return F.useEffect(()=>{!r&&t.answerConfidence&&l.current&&l.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[r,t.answerConfidence]),t.answerConfidence?o.jsx(ni,{ref:s,...i}):null}),ri=n.ikp(Le.Markdown,{_id:"intelligentForm__ConfidentAnswer"}),ue=i=>{const{aiResponse:e}=m.useIntelligentForm();return o.jsx(ri,{shouldOpenLinksInNewTab:!0,children:e.answer,...i})},oi=n.ikp("button",{_id:"intelligentForm__ConfidentResponseButton",type:"button"}),ge=i=>{const{onClick:e,...t}=i,{showSecondaryFields:r,setShowSecondaryFields:l}=m.useIntelligentForm(),s=()=>{l(!0)};return o.jsx(oi,{"data-escalated":c.dataAttr(r),onClick:u.composeEventHandlers(e,s),...t})},Ie=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__ConfidentResponseButton__Icon",iconSettings:{builtIn:"LuUser"}}),_e=n.ikp("span",{_id:"intelligentForm__ConfidentResponseButton__Label",children:"Escalate to human"}),li=n.ikp("div",{_id:"intelligentForm__SecondaryForm"}),pe=F.forwardRef(({...i},e)=>{const{showSecondaryFields:t}=m.useIntelligentForm(),r=F.useRef(null),l=P.useComposedRefs(e,r);return F.useEffect(()=>{t&&r.current&&r.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[t]),t?o.jsx(li,{ref:l,...i}):null}),mi=n.ikp("p",{_id:"intelligentForm__SecondaryForm__Description"}),ve=i=>{const{formSettings:{secondary:e},aiResponse:{answerConfidence:t}}=m.useIntelligentForm();if(!e.description)return null;const r=typeof e.description=="string"?e.description:t?e.description.confident:e.description.default;return o.jsx(mi,{children:r,...i})},si=n.ikp("div",{_id:"intelligentForm__SecondaryFormFields"}),Se=i=>{const{children:e,...t}=i,{formSettings:{secondary:r}}=m.useIntelligentForm();return o.jsx(si,{children:c.maybeRender(e,r.fields),...t})},ci=n.ikp("button",{_id:"intelligentForm__SecondaryFormSubmit",type:"submit",children:"Submit"}),Pe=i=>{const{formSettings:e}=m.useIntelligentForm(),{label:t}=e.buttons.submit;return o.jsx(ci,{children:t??"Submit",...i})},di=n.ikp("span",{_id:"intelligentForm__Error"}),fe=i=>{const{formError:e}=m.useIntelligentForm();return e?o.jsx(di,{children:e.message,...i}):null},Ce=n.ikp("div",{_id:"intelligentForm__Sources"}),he=n.ikp("p",{_id:"intelligentForm__SourcesCaption",children:"Here are the sources I considered:"}),Fi=n.ikp("div",{_id:"intelligentForm__SourcesList"}),be=i=>{const{children:e,...t}=i,{baseSettings:{transformSource:r,organizationDisplayName:l}}=x.useInkeepConfig(),{aiResponse:{recordsConsidered:s}}=m.useIntelligentForm();if(!s)return null;const d=s.reduce((a,v)=>{const _=qe.transformInkeepSource(v,"intelligentFormSource",{organizationDisplayName:l,transformSource:r});return a.some(C=>C.url===_.url)||a.push(_),a},[]);return o.jsx(Fi,{children:c.maybeRender(e,d),...t})},ai=n.ikp(Ee.LinkWithQueryParams,{_id:"intelligentForm__Source"}),ke=i=>{const{source:e,...t}=i;return o.jsx(h.SourceItemProvider,{source:{...e,isExternal:!!e.shouldOpenInNewTab},children:o.jsx(ai,{"data-type":e.type,appendToUrl:e.appendToUrl,href:e.url,isExternal:e.shouldOpenInNewTab!==!1,...t})})},ui=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__SourceIcon"}),ye=i=>{const{source:e}=h.useSourceItem();return o.jsx(ui,{iconSettings:e.icon,"data-type":e.type,...i})},gi=n.ikp("span",{_id:"intelligentForm__SourceTitle"}),xe=i=>{const{source:e}=h.useSourceItem();return o.jsx(gi,{"data-type":e.type,children:e.title,...i})};exports.Provider=m.IntelligentFormProvider;exports.BotHeading=se;exports.BotHeadingIcon=ce;exports.BotHeadingName=de;exports.ConfidentAnswer=ue;exports.ConfidentResponse=ae;exports.ConfidentResponseButton=ge;exports.ConfidentResponseButtonIcon=Ie;exports.ConfidentResponseButtonLabel=_e;exports.Content=A;exports.ContentScrollArea=T;exports.ContentScrollAreaCorner=L;exports.ContentScrollAreaScrollbar=H;exports.ContentScrollAreaThumb=E;exports.ContentScrollAreaViewport=B;exports.Error=fe;exports.FormField=$;exports.FormFieldCheckbox=K;exports.FormFieldCheckboxIndicator=X;exports.FormFieldEmail=W;exports.FormFieldError=me;exports.FormFieldFile=G;exports.FormFieldLabel=Q;exports.FormFieldSelect=Y;exports.FormFieldSelectContent=te;exports.FormFieldSelectIcon=ie;exports.FormFieldSelectItem=re;exports.FormFieldSelectItemIndicator=le;exports.FormFieldSelectItemText=oe;exports.FormFieldSelectTrigger=Z;exports.FormFieldSelectValue=ee;exports.FormFieldSelectViewport=ne;exports.FormFieldText=f;exports.FormFieldTextArea=J;exports.Heading=j;exports.IntelligentFormPrimitiveBotHeading=se;exports.IntelligentFormPrimitiveBotHeadingIcon=ce;exports.IntelligentFormPrimitiveBotHeadingName=de;exports.IntelligentFormPrimitiveConfidentAnswer=ue;exports.IntelligentFormPrimitiveConfidentResponse=ae;exports.IntelligentFormPrimitiveConfidentResponseButton=ge;exports.IntelligentFormPrimitiveConfidentResponseButtonIcon=Ie;exports.IntelligentFormPrimitiveConfidentResponseButtonLabel=_e;exports.IntelligentFormPrimitiveContent=A;exports.IntelligentFormPrimitiveContentScrollArea=T;exports.IntelligentFormPrimitiveContentScrollAreaCorner=L;exports.IntelligentFormPrimitiveContentScrollAreaScrollbar=H;exports.IntelligentFormPrimitiveContentScrollAreaThumb=E;exports.IntelligentFormPrimitiveContentScrollAreaViewport=B;exports.IntelligentFormPrimitiveFormError=fe;exports.IntelligentFormPrimitiveFormField=$;exports.IntelligentFormPrimitiveFormFieldCheckbox=K;exports.IntelligentFormPrimitiveFormFieldCheckboxIndicator=X;exports.IntelligentFormPrimitiveFormFieldEmail=W;exports.IntelligentFormPrimitiveFormFieldError=me;exports.IntelligentFormPrimitiveFormFieldFile=G;exports.IntelligentFormPrimitiveFormFieldLabel=Q;exports.IntelligentFormPrimitiveFormFieldSelect=Y;exports.IntelligentFormPrimitiveFormFieldSelectContent=te;exports.IntelligentFormPrimitiveFormFieldSelectIcon=ie;exports.IntelligentFormPrimitiveFormFieldSelectItem=re;exports.IntelligentFormPrimitiveFormFieldSelectItemIndicator=le;exports.IntelligentFormPrimitiveFormFieldSelectItemText=oe;exports.IntelligentFormPrimitiveFormFieldSelectTrigger=Z;exports.IntelligentFormPrimitiveFormFieldSelectValue=ee;exports.IntelligentFormPrimitiveFormFieldSelectViewport=ne;exports.IntelligentFormPrimitiveFormFieldText=f;exports.IntelligentFormPrimitiveFormFieldTextArea=J;exports.IntelligentFormPrimitiveHeading=j;exports.IntelligentFormPrimitiveLoading=Fe;exports.IntelligentFormPrimitivePrimaryForm=O;exports.IntelligentFormPrimitivePrimaryFormDescription=M;exports.IntelligentFormPrimitivePrimaryFormFields=z;exports.IntelligentFormPrimitivePrimaryFormSubmit=U;exports.IntelligentFormPrimitiveRoot=w;exports.IntelligentFormPrimitiveSecondaryForm=pe;exports.IntelligentFormPrimitiveSecondaryFormDescription=ve;exports.IntelligentFormPrimitiveSecondaryFormFields=Se;exports.IntelligentFormPrimitiveSecondaryFormSubmit=Pe;exports.IntelligentFormPrimitiveSource=ke;exports.IntelligentFormPrimitiveSourceIcon=ye;exports.IntelligentFormPrimitiveSourceTitle=xe;exports.IntelligentFormPrimitiveSources=Ce;exports.IntelligentFormPrimitiveSourcesCaption=he;exports.IntelligentFormPrimitiveSourcesList=be;exports.IntelligentFormPrimitiveSuccess=q;exports.IntelligentFormPrimitiveSuccessHeading=D;exports.IntelligentFormPrimitiveSuccessIcon=V;exports.IntelligentFormPrimitiveSuccessMessage=N;exports.Loading=Fe;exports.PrimaryForm=O;exports.PrimaryFormDescription=M;exports.PrimaryFormFields=z;exports.PrimaryFormSubmit=U;exports.Root=w;exports.SecondaryForm=pe;exports.SecondaryFormDescription=ve;exports.SecondaryFormFields=Se;exports.SecondaryFormSubmit=Pe;exports.Source=ke;exports.SourceIcon=ye;exports.SourceTitle=xe;exports.Sources=Ce;exports.SourcesCaption=he;exports.SourcesList=be;exports.Success=q;exports.SuccessHeading=D;exports.SuccessIcon=V;exports.SuccessMessage=N;