@copilotkit/react-ui 1.7.2-next.1 → 1.8.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/{chunk-QXTRFMPM.mjs → chunk-2LRE4W6A.mjs} +13 -11
  3. package/dist/chunk-2LRE4W6A.mjs.map +1 -0
  4. package/dist/{chunk-2C3ANQCY.mjs → chunk-5GNYGURH.mjs} +53 -42
  5. package/dist/chunk-5GNYGURH.mjs.map +1 -0
  6. package/dist/{chunk-CBBFRI3Q.mjs → chunk-5JY5QJ2W.mjs} +9 -5
  7. package/dist/chunk-5JY5QJ2W.mjs.map +1 -0
  8. package/dist/{chunk-OFYI4UU4.mjs → chunk-7RIBDD4K.mjs} +19 -3
  9. package/dist/chunk-7RIBDD4K.mjs.map +1 -0
  10. package/dist/{chunk-YAGE7RCE.mjs → chunk-CGVOCLHN.mjs} +2 -2
  11. package/dist/chunk-EJG6RRSX.mjs +138 -0
  12. package/dist/chunk-EJG6RRSX.mjs.map +1 -0
  13. package/dist/chunk-FBYETUFL.mjs +118 -0
  14. package/dist/chunk-FBYETUFL.mjs.map +1 -0
  15. package/dist/chunk-GDJAAFIK.mjs +24 -0
  16. package/dist/chunk-GDJAAFIK.mjs.map +1 -0
  17. package/dist/{chunk-6FTRYYR5.mjs → chunk-GJME6MK4.mjs} +72 -62
  18. package/dist/chunk-GJME6MK4.mjs.map +1 -0
  19. package/dist/{chunk-AZU4QOV5.mjs → chunk-KG6DW6R2.mjs} +12 -12
  20. package/dist/{chunk-3PJA5MFR.mjs → chunk-LKCAF2HG.mjs} +2 -2
  21. package/dist/{chunk-ADTTDBLB.mjs → chunk-LXCH2BIB.mjs} +2 -2
  22. package/dist/chunk-MCO235PS.mjs +164 -0
  23. package/dist/chunk-MCO235PS.mjs.map +1 -0
  24. package/dist/chunk-MWC5OV7Z.mjs +1 -0
  25. package/dist/chunk-N7LTE54T.mjs +1 -0
  26. package/dist/chunk-N7LTE54T.mjs.map +1 -0
  27. package/dist/chunk-ORSMX3SE.mjs +244 -0
  28. package/dist/chunk-ORSMX3SE.mjs.map +1 -0
  29. package/dist/{chunk-UPTB2MVO.mjs → chunk-PCTCOQK2.mjs} +4 -10
  30. package/dist/chunk-PCTCOQK2.mjs.map +1 -0
  31. package/dist/{chunk-22K5DDPF.mjs → chunk-QGK5GOSC.mjs} +31 -60
  32. package/dist/chunk-QGK5GOSC.mjs.map +1 -0
  33. package/dist/{chunk-WGAZXTUA.mjs → chunk-TOQ7P4DO.mjs} +6 -9
  34. package/dist/chunk-TOQ7P4DO.mjs.map +1 -0
  35. package/dist/chunk-UCVCAGU7.mjs +1 -0
  36. package/dist/chunk-UCVCAGU7.mjs.map +1 -0
  37. package/dist/{chunk-3XAXY2Z3.mjs → chunk-UZTZXMYS.mjs} +2 -2
  38. package/dist/{chunk-RQNJNK2W.mjs → chunk-VC4NO5QZ.mjs} +2 -2
  39. package/dist/{chunk-YQ3D5IQV.mjs → chunk-XNQO5AZZ.mjs} +2 -5
  40. package/dist/chunk-XNQO5AZZ.mjs.map +1 -0
  41. package/dist/chunk-YC4NBUGE.mjs +97 -0
  42. package/dist/chunk-YC4NBUGE.mjs.map +1 -0
  43. package/dist/components/chat/Button.js.map +1 -1
  44. package/dist/components/chat/Button.mjs +3 -3
  45. package/dist/components/chat/Chat.d.ts +17 -1
  46. package/dist/components/chat/Chat.js +378 -905
  47. package/dist/components/chat/Chat.js.map +1 -1
  48. package/dist/components/chat/Chat.mjs +12 -19
  49. package/dist/components/chat/ChatContext.d.ts +20 -0
  50. package/dist/components/chat/ChatContext.js +44 -74
  51. package/dist/components/chat/ChatContext.js.map +1 -1
  52. package/dist/components/chat/ChatContext.mjs +2 -2
  53. package/dist/components/chat/CodeBlock.js +58 -82
  54. package/dist/components/chat/CodeBlock.js.map +1 -1
  55. package/dist/components/chat/CodeBlock.mjs +2 -2
  56. package/dist/components/chat/Header.js +516 -4
  57. package/dist/components/chat/Header.js.map +1 -1
  58. package/dist/components/chat/Header.mjs +10 -3
  59. package/dist/components/chat/Icons.d.ts +10 -9
  60. package/dist/components/chat/Icons.js +125 -164
  61. package/dist/components/chat/Icons.js.map +1 -1
  62. package/dist/components/chat/Icons.mjs +9 -5
  63. package/dist/components/chat/Input.d.ts +1 -1
  64. package/dist/components/chat/Input.js +11 -9
  65. package/dist/components/chat/Input.js.map +1 -1
  66. package/dist/components/chat/Input.mjs +3 -3
  67. package/dist/components/chat/Markdown.js +58 -56
  68. package/dist/components/chat/Markdown.js.map +1 -1
  69. package/dist/components/chat/Markdown.mjs +3 -3
  70. package/dist/components/chat/Messages.d.ts +1 -1
  71. package/dist/components/chat/Messages.js +70 -60
  72. package/dist/components/chat/Messages.js.map +1 -1
  73. package/dist/components/chat/Messages.mjs +3 -3
  74. package/dist/components/chat/Modal.js +1708 -1749
  75. package/dist/components/chat/Modal.js.map +1 -1
  76. package/dist/components/chat/Modal.mjs +23 -23
  77. package/dist/components/chat/Popup.js +1708 -1749
  78. package/dist/components/chat/Popup.js.map +1 -1
  79. package/dist/components/chat/Popup.mjs +24 -24
  80. package/dist/components/chat/Response.js.map +1 -1
  81. package/dist/components/chat/Response.mjs +3 -3
  82. package/dist/components/chat/Sidebar.js +1710 -1751
  83. package/dist/components/chat/Sidebar.js.map +1 -1
  84. package/dist/components/chat/Sidebar.mjs +24 -24
  85. package/dist/components/chat/Suggestion.js +4 -40
  86. package/dist/components/chat/Suggestion.js.map +1 -1
  87. package/dist/components/chat/Suggestion.mjs +2 -2
  88. package/dist/components/chat/Window.js.map +1 -1
  89. package/dist/components/chat/Window.mjs +3 -3
  90. package/dist/components/chat/index.js +1710 -1751
  91. package/dist/components/chat/index.js.map +1 -1
  92. package/dist/components/chat/index.mjs +27 -27
  93. package/dist/components/chat/messages/AssistantMessage.js +211 -59
  94. package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
  95. package/dist/components/chat/messages/AssistantMessage.mjs +5 -5
  96. package/dist/components/chat/messages/RenderTextMessage.js +18 -2
  97. package/dist/components/chat/messages/RenderTextMessage.js.map +1 -1
  98. package/dist/components/chat/messages/RenderTextMessage.mjs +1 -1
  99. package/dist/components/chat/props.d.ts +53 -0
  100. package/dist/components/chat/props.js.map +1 -1
  101. package/dist/components/crew/DefaultResponseRenderer.d.ts +110 -0
  102. package/dist/components/crew/DefaultResponseRenderer.js +175 -0
  103. package/dist/components/crew/DefaultResponseRenderer.js.map +1 -0
  104. package/dist/components/crew/DefaultResponseRenderer.mjs +10 -0
  105. package/dist/components/crew/DefaultResponseRenderer.mjs.map +1 -0
  106. package/dist/components/crew/DefaultStateRenderer.d.ts +88 -0
  107. package/dist/components/crew/DefaultStateRenderer.js +198 -0
  108. package/dist/components/crew/DefaultStateRenderer.js.map +1 -0
  109. package/dist/components/crew/DefaultStateRenderer.mjs +8 -0
  110. package/dist/components/crew/DefaultStateRenderer.mjs.map +1 -0
  111. package/dist/components/crew/index.d.ts +4 -0
  112. package/dist/components/crew/index.js +335 -0
  113. package/dist/components/crew/index.js.map +1 -0
  114. package/dist/components/crew/index.mjs +16 -0
  115. package/dist/components/crew/index.mjs.map +1 -0
  116. package/dist/components/crew/types.d.ts +340 -0
  117. package/dist/components/crew/types.js +19 -0
  118. package/dist/components/crew/types.js.map +1 -0
  119. package/dist/components/crew/types.mjs +2 -0
  120. package/dist/components/crew/types.mjs.map +1 -0
  121. package/dist/components/dev-console/console.js +51 -233
  122. package/dist/components/dev-console/console.js.map +1 -1
  123. package/dist/components/dev-console/console.mjs +5 -5
  124. package/dist/components/dev-console/index.js +51 -233
  125. package/dist/components/dev-console/index.js.map +1 -1
  126. package/dist/components/dev-console/index.mjs +5 -5
  127. package/dist/components/help-modal/index.js +29 -147
  128. package/dist/components/help-modal/index.js.map +1 -1
  129. package/dist/components/help-modal/index.mjs +1 -1
  130. package/dist/components/help-modal/modal.js +29 -147
  131. package/dist/components/help-modal/modal.js.map +1 -1
  132. package/dist/components/help-modal/modal.mjs +1 -1
  133. package/dist/components/index.d.ts +3 -0
  134. package/dist/components/index.js +2191 -1942
  135. package/dist/components/index.js.map +1 -1
  136. package/dist/components/index.mjs +43 -31
  137. package/dist/index.css +481 -90
  138. package/dist/index.css.map +1 -1
  139. package/dist/index.d.ts +3 -0
  140. package/dist/index.js +2192 -1943
  141. package/dist/index.js.map +1 -1
  142. package/dist/index.mjs +43 -31
  143. package/dist/types/css.d.ts +7 -1
  144. package/dist/types/css.js.map +1 -1
  145. package/package.json +4 -4
  146. package/src/components/chat/Chat.tsx +59 -22
  147. package/src/components/chat/ChatContext.tsx +29 -1
  148. package/src/components/chat/CodeBlock.tsx +2 -4
  149. package/src/components/chat/Header.tsx +8 -3
  150. package/src/components/chat/Icons.tsx +108 -108
  151. package/src/components/chat/Input.tsx +42 -38
  152. package/src/components/chat/Markdown.tsx +0 -3
  153. package/src/components/chat/Messages.tsx +68 -56
  154. package/src/components/chat/Suggestion.tsx +2 -3
  155. package/src/components/chat/messages/AssistantMessage.tsx +95 -3
  156. package/src/components/chat/messages/RenderTextMessage.tsx +17 -1
  157. package/src/components/chat/props.ts +66 -0
  158. package/src/components/crew/DefaultResponseRenderer.tsx +298 -0
  159. package/src/components/crew/DefaultStateRenderer.tsx +326 -0
  160. package/src/components/crew/index.ts +3 -0
  161. package/src/components/crew/types.ts +398 -0
  162. package/src/components/dev-console/console.tsx +16 -54
  163. package/src/components/help-modal/modal.tsx +38 -101
  164. package/src/components/index.ts +1 -0
  165. package/src/css/button.css +15 -4
  166. package/src/css/colors.css +27 -6
  167. package/src/css/console.css +46 -39
  168. package/src/css/crew.css +277 -0
  169. package/src/css/header.css +22 -5
  170. package/src/css/input.css +24 -17
  171. package/src/css/markdown.css +2 -1
  172. package/src/css/messages.css +125 -15
  173. package/src/css/panel.css +1 -0
  174. package/src/css/suggestions.css +14 -6
  175. package/src/styles.css +1 -0
  176. package/src/types/css.ts +7 -1
  177. package/dist/chunk-22K5DDPF.mjs.map +0 -1
  178. package/dist/chunk-2C3ANQCY.mjs.map +0 -1
  179. package/dist/chunk-3VNMQWGT.mjs +0 -25
  180. package/dist/chunk-3VNMQWGT.mjs.map +0 -1
  181. package/dist/chunk-6FTRYYR5.mjs.map +0 -1
  182. package/dist/chunk-CBBFRI3Q.mjs.map +0 -1
  183. package/dist/chunk-FZC7X5PK.mjs +0 -262
  184. package/dist/chunk-FZC7X5PK.mjs.map +0 -1
  185. package/dist/chunk-MMVDU6DF.mjs +0 -1
  186. package/dist/chunk-OFYI4UU4.mjs.map +0 -1
  187. package/dist/chunk-QXTRFMPM.mjs.map +0 -1
  188. package/dist/chunk-TI7SY2RI.mjs +0 -164
  189. package/dist/chunk-TI7SY2RI.mjs.map +0 -1
  190. package/dist/chunk-UPTB2MVO.mjs.map +0 -1
  191. package/dist/chunk-VEC45H6Q.mjs +0 -18
  192. package/dist/chunk-VEC45H6Q.mjs.map +0 -1
  193. package/dist/chunk-WGAZXTUA.mjs.map +0 -1
  194. package/dist/chunk-YQ3D5IQV.mjs.map +0 -1
  195. /package/dist/{chunk-YAGE7RCE.mjs.map → chunk-CGVOCLHN.mjs.map} +0 -0
  196. /package/dist/{chunk-AZU4QOV5.mjs.map → chunk-KG6DW6R2.mjs.map} +0 -0
  197. /package/dist/{chunk-3PJA5MFR.mjs.map → chunk-LKCAF2HG.mjs.map} +0 -0
  198. /package/dist/{chunk-ADTTDBLB.mjs.map → chunk-LXCH2BIB.mjs.map} +0 -0
  199. /package/dist/{chunk-MMVDU6DF.mjs.map → chunk-MWC5OV7Z.mjs.map} +0 -0
  200. /package/dist/{chunk-3XAXY2Z3.mjs.map → chunk-UZTZXMYS.mjs.map} +0 -0
  201. /package/dist/{chunk-RQNJNK2W.mjs.map → chunk-VC4NO5QZ.mjs.map} +0 -0
@@ -1,33 +1,33 @@
1
1
  import {
2
2
  CopilotSidebar
3
- } from "../../chunk-3PJA5MFR.mjs";
4
- import "../../chunk-AZU4QOV5.mjs";
5
- import "../../chunk-YAGE7RCE.mjs";
6
- import "../../chunk-VEC45H6Q.mjs";
7
- import "../../chunk-RQNJNK2W.mjs";
8
- import "../../chunk-2C3ANQCY.mjs";
9
- import "../../chunk-UWWMAJ7R.mjs";
10
- import "../../chunk-WEYDZBT7.mjs";
11
- import "../../chunk-OFYI4UU4.mjs";
12
- import "../../chunk-HEIDCT7I.mjs";
3
+ } from "../../chunk-LKCAF2HG.mjs";
4
+ import "../../chunk-KG6DW6R2.mjs";
5
+ import "../../chunk-CGVOCLHN.mjs";
6
+ import "../../chunk-GDJAAFIK.mjs";
13
7
  import "../../chunk-V7W6IM2V.mjs";
14
- import "../../chunk-3VNMQWGT.mjs";
15
- import "../../chunk-XB6QCUPB.mjs";
16
- import "../../chunk-WGAZXTUA.mjs";
17
- import "../../chunk-22K5DDPF.mjs";
18
- import "../../chunk-6TCUJ3B7.mjs";
8
+ import "../../chunk-QGK5GOSC.mjs";
19
9
  import "../../chunk-KXE2JCUH.mjs";
20
- import "../../chunk-TI7SY2RI.mjs";
21
- import "../../chunk-BH6PCAAL.mjs";
10
+ import "../../chunk-YC4NBUGE.mjs";
22
11
  import "../../chunk-OTPAZXVR.mjs";
23
- import "../../chunk-QXTRFMPM.mjs";
12
+ import "../../chunk-6TCUJ3B7.mjs";
13
+ import "../../chunk-BH6PCAAL.mjs";
14
+ import "../../chunk-VC4NO5QZ.mjs";
15
+ import "../../chunk-5GNYGURH.mjs";
16
+ import "../../chunk-FBYETUFL.mjs";
17
+ import "../../chunk-XB6QCUPB.mjs";
18
+ import "../../chunk-UWWMAJ7R.mjs";
19
+ import "../../chunk-WEYDZBT7.mjs";
20
+ import "../../chunk-7RIBDD4K.mjs";
21
+ import "../../chunk-HEIDCT7I.mjs";
22
+ import "../../chunk-TOQ7P4DO.mjs";
23
+ import "../../chunk-2LRE4W6A.mjs";
24
24
  import "../../chunk-YQFVRDNC.mjs";
25
- import "../../chunk-YQ3D5IQV.mjs";
26
- import "../../chunk-6FTRYYR5.mjs";
27
- import "../../chunk-3XAXY2Z3.mjs";
28
- import "../../chunk-CBBFRI3Q.mjs";
29
- import "../../chunk-UPTB2MVO.mjs";
30
- import "../../chunk-FZC7X5PK.mjs";
25
+ import "../../chunk-XNQO5AZZ.mjs";
26
+ import "../../chunk-GJME6MK4.mjs";
27
+ import "../../chunk-UZTZXMYS.mjs";
28
+ import "../../chunk-5JY5QJ2W.mjs";
29
+ import "../../chunk-PCTCOQK2.mjs";
30
+ import "../../chunk-ORSMX3SE.mjs";
31
31
  import "../../chunk-54JAUBUJ.mjs";
32
32
  import "../../chunk-S5MBUNGN.mjs";
33
33
  import "../../chunk-MRXNTQOX.mjs";
@@ -48,47 +48,14 @@ var import_react_core = require("@copilotkit/react-core");
48
48
 
49
49
  // src/components/chat/Icons.tsx
50
50
  var import_jsx_runtime = require("react/jsx-runtime");
51
- var SmallSpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
52
- "svg",
53
- {
54
- style: {
55
- animation: "copilotKitSpinAnimation 1s linear infinite"
56
- },
57
- width: "13",
58
- height: "13",
59
- xmlns: "http://www.w3.org/2000/svg",
60
- fill: "none",
61
- viewBox: "0 0 24 24",
62
- children: [
63
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
64
- "circle",
65
- {
66
- style: { opacity: 0.25 },
67
- cx: "12",
68
- cy: "12",
69
- r: "10",
70
- stroke: "currentColor",
71
- strokeWidth: "4"
72
- }
73
- ),
74
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
75
- "path",
76
- {
77
- style: { opacity: 0.75 },
78
- fill: "currentColor",
79
- d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
80
- }
81
- )
82
- ]
83
- }
84
- );
51
+ var SmallSpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitSpinner", style: { width: "13px", height: "13px" } });
85
52
 
86
53
  // src/components/chat/Suggestion.tsx
87
54
  var import_shared = require("@copilotkit/shared");
88
55
  var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
89
56
  var import_jsx_runtime2 = require("react/jsx-runtime");
90
57
  function Suggestion({ title, message, onClick, partial, className }) {
91
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
58
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
92
59
  "button",
93
60
  {
94
61
  disabled: partial,
@@ -96,12 +63,9 @@ function Suggestion({ title, message, onClick, partial, className }) {
96
63
  e.preventDefault();
97
64
  onClick(message);
98
65
  },
99
- className: className || "suggestion",
66
+ className: className || (partial ? "suggestion loading" : "suggestion"),
100
67
  "data-test-id": "suggestion",
101
- children: [
102
- partial && SmallSpinnerIcon,
103
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: title })
104
- ]
68
+ children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: title })
105
69
  }
106
70
  );
107
71
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/chat/Suggestion.tsx","../../../src/components/chat/Icons.tsx"],"sourcesContent":["import {\n CopilotContextParams,\n extract,\n CopilotChatSuggestionConfiguration,\n CopilotMessagesContextParams,\n} from \"@copilotkit/react-core\";\nimport { SuggestionsProps } from \"./props\";\nimport { SmallSpinnerIcon } from \"./Icons\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { actionParametersToJsonSchema } from \"@copilotkit/shared\";\nimport { CopilotRequestType } from \"@copilotkit/runtime-client-gql\";\n\nexport function Suggestion({ title, message, onClick, partial, className }: SuggestionsProps) {\n return (\n <button\n disabled={partial}\n onClick={(e) => {\n e.preventDefault();\n onClick(message);\n }}\n className={className || \"suggestion\"}\n data-test-id=\"suggestion\"\n >\n {partial && SmallSpinnerIcon}\n <span>{title}</span>\n </button>\n );\n}\n\nexport const reloadSuggestions = async (\n context: CopilotContextParams & CopilotMessagesContextParams,\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration },\n setCurrentSuggestions: (suggestions: { title: string; message: string }[]) => void,\n abortControllerRef: React.MutableRefObject<AbortController | null>,\n) => {\n const abortController = abortControllerRef.current;\n\n const tools = JSON.stringify(\n Object.values(context.actions).map((action) => ({\n name: action.name,\n description: action.description,\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters)),\n })),\n );\n\n const allSuggestions: CopilotChatSuggestion[] = [];\n\n for (const config of Object.values(chatSuggestionConfiguration)) {\n try {\n const numOfSuggestionsInstructions =\n config.minSuggestions === 0\n ? `Produce up to ${config.maxSuggestions} suggestions. ` +\n `If there are no highly relevant suggestions you can think of, provide an empty array.`\n : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;\n\n const result = await extract({\n context,\n instructions:\n \"Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. \",\n data:\n config.instructions +\n \"\\n\\n\" +\n numOfSuggestionsInstructions +\n \"\\n\\n\" +\n \"Available tools: \" +\n tools +\n \"\\n\\n\",\n requestType: CopilotRequestType.Task,\n parameters: [\n {\n name: \"suggestions\",\n type: \"object[]\",\n attributes: [\n {\n name: \"title\",\n description:\n \"The title of the suggestion. This is shown as a button and should be short.\",\n type: \"string\",\n },\n {\n name: \"message\",\n description:\n \"The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.\",\n type: \"string\",\n },\n ],\n },\n ],\n include: {\n messages: true,\n readable: true,\n },\n abortSignal: abortController?.signal,\n stream: ({ status, args }) => {\n const suggestions = args.suggestions || [];\n const newSuggestions: CopilotChatSuggestion[] = [];\n for (let i = 0; i < suggestions.length; i++) {\n // if GPT provides too many suggestions, limit the number of suggestions\n if (config.maxSuggestions !== undefined && i >= config.maxSuggestions) {\n break;\n }\n const { title, message } = suggestions[i];\n\n // If this is the last suggestion and the status is not complete, mark it as partial\n const partial = i == suggestions.length - 1 && status !== \"complete\";\n\n newSuggestions.push({\n title,\n message,\n partial,\n className: config.className,\n });\n }\n setCurrentSuggestions([...allSuggestions, ...newSuggestions]);\n },\n });\n allSuggestions.push(...result.suggestions);\n } catch (error) {\n console.error(\"Error loading suggestions\", error);\n }\n }\n\n if (abortControllerRef.current === abortController) {\n abortControllerRef.current = null;\n }\n};\n","import React from \"react\";\n\nexport const OpenIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <g transform=\"translate(24, 0) scale(-1, 1)\">\n <path\n fillRule=\"evenodd\"\n d=\"M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z\"\n clipRule=\"evenodd\"\n />\n </g>\n </svg>\n);\n\nexport const CloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M19.5 8.25l-7.5 7.5-7.5-7.5\" />\n </svg>\n);\n\nexport const HeaderCloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n);\n\nexport const SendIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth={1.5}\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5\"\n />\n </svg>\n);\n\nexport const SpinnerIcon = (\n <svg\n style={{\n animation: \"copilotKitSpinAnimation 1s linear infinite\",\n color: \"rgb(107 114 128)\",\n }}\n width=\"24\"\n height=\"24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n >\n <circle\n style={{ opacity: 0.25 }}\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n ></circle>\n <path\n style={{ opacity: 0.75 }}\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n ></path>\n </svg>\n);\n\nexport const SmallSpinnerIcon = (\n <svg\n style={{\n animation: \"copilotKitSpinAnimation 1s linear infinite\",\n }}\n width=\"13\"\n height=\"13\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n >\n <circle\n style={{ opacity: 0.25 }}\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n ></circle>\n <path\n style={{ opacity: 0.75 }}\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n ></path>\n </svg>\n);\n\nexport const ActivityIcon = (\n <svg\n style={{\n display: \"inline-block\",\n marginLeft: \"0.25rem\",\n marginRight: \"0.25rem\",\n }}\n height=\"24\"\n width=\"24\"\n viewBox=\"0 0 27 27\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"currentColor\"\n >\n <circle className=\"copilotKitActivityDot1\" cx=\"4\" cy=\"12\" r=\"3\" />\n <circle className=\"copilotKitActivityDot1 copilotKitActivityDot2\" cx=\"12\" cy=\"12\" r=\"3\" />\n <circle className=\"copilotKitActivityDot1 copilotKitActivityDot3\" cx=\"20\" cy=\"12\" r=\"3\" />\n </svg>\n);\n\nexport function CheckIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path d=\"m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z\" />\n </svg>\n );\n}\n\nexport function DownloadIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path d=\"M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z\" />\n </svg>\n );\n}\n\nexport function CopyIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path d=\"M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z\" />\n </svg>\n );\n}\n\nexport const StopIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n >\n <path d=\"M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z\" />\n </svg>\n);\n\nexport const RegenerateIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n >\n <path d=\"M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z\" />\n </svg>\n);\n\nexport const PushToTalkIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth={1.5}\n stroke=\"currentColor\"\n className=\"w-6 h-6\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M12 18.75a6 6 0 0 0 6-6v-1.5m-6 7.5a6 6 0 0 1-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AAA,YACpB,CAAC;AAAA,UACH;AACA,gCAAsB,CAAC,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAAA,QAC9D;AAAA,MACF,CAAC;AACD,qBAAe,KAAK,GAAG,OAAO,WAAW;AAAA,IAC3C,SAAS,OAAP;AACA,cAAQ,MAAM,6BAA6B,KAAK;AAAA,IAClD;AAAA,EACF;AAEA,MAAI,mBAAmB,YAAY,iBAAiB;AAClD,uBAAmB,UAAU;AAAA,EAC/B;AACF;","names":["import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../../src/components/chat/Suggestion.tsx","../../../src/components/chat/Icons.tsx"],"sourcesContent":["import {\n CopilotContextParams,\n extract,\n CopilotChatSuggestionConfiguration,\n CopilotMessagesContextParams,\n} from \"@copilotkit/react-core\";\nimport { SuggestionsProps } from \"./props\";\nimport { SmallSpinnerIcon } from \"./Icons\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { actionParametersToJsonSchema } from \"@copilotkit/shared\";\nimport { CopilotRequestType } from \"@copilotkit/runtime-client-gql\";\n\nexport function Suggestion({ title, message, onClick, partial, className }: SuggestionsProps) {\n return (\n <button\n disabled={partial}\n onClick={(e) => {\n e.preventDefault();\n onClick(message);\n }}\n className={className || (partial ? \"suggestion loading\" : \"suggestion\")}\n data-test-id=\"suggestion\"\n >\n {partial ? SmallSpinnerIcon : <span>{title}</span>}\n </button>\n );\n}\n\nexport const reloadSuggestions = async (\n context: CopilotContextParams & CopilotMessagesContextParams,\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration },\n setCurrentSuggestions: (suggestions: { title: string; message: string }[]) => void,\n abortControllerRef: React.MutableRefObject<AbortController | null>,\n) => {\n const abortController = abortControllerRef.current;\n\n const tools = JSON.stringify(\n Object.values(context.actions).map((action) => ({\n name: action.name,\n description: action.description,\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters)),\n })),\n );\n\n const allSuggestions: CopilotChatSuggestion[] = [];\n\n for (const config of Object.values(chatSuggestionConfiguration)) {\n try {\n const numOfSuggestionsInstructions =\n config.minSuggestions === 0\n ? `Produce up to ${config.maxSuggestions} suggestions. ` +\n `If there are no highly relevant suggestions you can think of, provide an empty array.`\n : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;\n\n const result = await extract({\n context,\n instructions:\n \"Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. \",\n data:\n config.instructions +\n \"\\n\\n\" +\n numOfSuggestionsInstructions +\n \"\\n\\n\" +\n \"Available tools: \" +\n tools +\n \"\\n\\n\",\n requestType: CopilotRequestType.Task,\n parameters: [\n {\n name: \"suggestions\",\n type: \"object[]\",\n attributes: [\n {\n name: \"title\",\n description:\n \"The title of the suggestion. This is shown as a button and should be short.\",\n type: \"string\",\n },\n {\n name: \"message\",\n description:\n \"The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.\",\n type: \"string\",\n },\n ],\n },\n ],\n include: {\n messages: true,\n readable: true,\n },\n abortSignal: abortController?.signal,\n stream: ({ status, args }) => {\n const suggestions = args.suggestions || [];\n const newSuggestions: CopilotChatSuggestion[] = [];\n for (let i = 0; i < suggestions.length; i++) {\n // if GPT provides too many suggestions, limit the number of suggestions\n if (config.maxSuggestions !== undefined && i >= config.maxSuggestions) {\n break;\n }\n const { title, message } = suggestions[i];\n\n // If this is the last suggestion and the status is not complete, mark it as partial\n const partial = i == suggestions.length - 1 && status !== \"complete\";\n\n newSuggestions.push({\n title,\n message,\n partial,\n className: config.className,\n });\n }\n setCurrentSuggestions([...allSuggestions, ...newSuggestions]);\n },\n });\n allSuggestions.push(...result.suggestions);\n } catch (error) {\n console.error(\"Error loading suggestions\", error);\n }\n }\n\n if (abortControllerRef.current === abortController) {\n abortControllerRef.current = null;\n }\n};\n","import React from \"react\";\n\nexport const OpenIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <g transform=\"translate(24, 0) scale(-1, 1)\">\n <path\n fillRule=\"evenodd\"\n d=\"M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z\"\n clipRule=\"evenodd\"\n />\n </g>\n </svg>\n);\n\nexport const CloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M19.5 8.25l-7.5 7.5-7.5-7.5\" />\n </svg>\n);\n\nexport const HeaderCloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n);\n\nexport const SendIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M12 19V5m0 0l-7 7m7-7l7 7\" />\n </svg>\n);\n\nexport const MicrophoneIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M12 18.75a6 6 0 006-6v-1.5m-6 7.5a6 6 0 01-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 01-3-3V4.5a3 3 0 116 0v8.25a3 3 0 01-3 3z\"\n />\n </svg>\n);\n\nexport const StopIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z\"\n />\n </svg>\n);\n\nexport const RegenerateIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99\"\n />\n </svg>\n);\n\nexport const CopyIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75\"\n />\n </svg>\n);\n\nexport const SmallSpinnerIcon = (\n <span className=\"copilotKitSpinner\" style={{ width: \"13px\", height: \"13px\" }}></span>\n);\n\nexport const SpinnerIcon = (\n <span className=\"copilotKitSpinner\" style={{ width: \"24px\", height: \"24px\" }}></span>\n);\n\nexport const ActivityIcon = (\n <div style={{ display: \"flex\", alignItems: \"center\", gap: \"4px\" }}>\n <span className=\"copilotKitActivityDot\" style={{ animationDelay: \"0s\" }}></span>\n <span className=\"copilotKitActivityDot\" style={{ animationDelay: \"0.2s\" }}></span>\n <span className=\"copilotKitActivityDot\" style={{ animationDelay: \"0.4s\" }}></span>\n </div>\n);\n\nexport const ThumbsUpIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M6.633 10.5c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 012.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 00.322-1.672V3a.75.75 0 01.75-.75A2.25 2.25 0 0116.5 4.5c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 01-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 00-1.423-.23H5.904M14.25 9h2.25M5.904 18.75c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 01-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 10.203 4.167 9.75 5 9.75h1.053c.472 0 .745.556.5.96a8.958 8.958 0 00-1.302 4.665c0 1.194.232 2.333.654 3.375z\"\n />\n </svg>\n);\n\nexport const ThumbsDownIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M7.5 15h2.25m8.024-9.75c.011.05.028.1.052.148.591 1.2.924 2.55.924 3.977a8.96 8.96 0 01-.999 4.125m.023-8.25c-.076-.365.183-.75.575-.75h.908c.889 0 1.713.518 1.972 1.368.339 1.11.521 2.287.521 3.507 0 1.553-.295 3.036-.831 4.398C20.613 14.547 19.833 15 19 15h-1.053c-.472 0-.745-.556-.5-.96a8.95 8.95 0 00.303-.54m.023-8.25H16.48a4.5 4.5 0 01-1.423-.23l-3.114-1.04a4.5 4.5 0 00-1.423-.23H6.504c-.618 0-1.217.247-1.605.729A11.95 11.95 0 002.25 12c0 .434.023.863.068 1.285C2.427 14.306 3.346 15 4.372 15h3.126c.618 0 .991.724.725 1.282A7.471 7.471 0 007.5 19.5a2.25 2.25 0 002.25 2.25.75.75 0 00.75-.75v-.633c0-.573.11-1.14.322-1.672.304-.76.93-1.33 1.653-1.715a9.04 9.04 0 002.86-2.4c.498-.634 1.226-1.08 2.032-1.08h.384\"\n />\n </svg>\n);\n\nexport const DownloadIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3\"\n />\n </svg>\n);\n\nexport const CheckIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n width=\"16\"\n height=\"16\"\n style={{ minWidth: \"16px\", minHeight: \"16px\" }}\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\" />\n </svg>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAKO;;;ACMD;AA6HC,IAAM,mBACX,4CAAC,UAAK,WAAU,qBAAoB,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAO,GAAG;;;ADhIhF,oBAA6C;AAC7C,gCAAmC;AAaC,IAAAA,sBAAA;AAX7B,SAAS,WAAW,EAAE,OAAO,SAAS,SAAS,SAAS,UAAU,GAAqB;AAC5F,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,SAAS,CAAC,MAAM;AACd,UAAE,eAAe;AACjB,gBAAQ,OAAO;AAAA,MACjB;AAAA,MACA,WAAW,cAAc,UAAU,uBAAuB;AAAA,MAC1D,gBAAa;AAAA,MAEZ,oBAAU,mBAAmB,6CAAC,UAAM,iBAAM;AAAA;AAAA,EAC7C;AAEJ;AAEO,IAAM,oBAAoB,CAC/B,SACA,6BACA,uBACA,uBACG;AACH,QAAM,kBAAkB,mBAAmB;AAE3C,QAAM,QAAQ,KAAK;AAAA,IACjB,OAAO,OAAO,QAAQ,OAAO,EAAE,IAAI,CAA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B,CAAC;AAAA,UACH;AACA,gCAAsB,CAAC,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAAA,QAC9D;AAAA,MACF,CAAC;AACD,qBAAe,KAAK,GAAG,OAAO,WAAW;AAAA,IAC3C,SAAS,OAAP;AACA,cAAQ,MAAM,6BAA6B,KAAK;AAAA,IAClD;AAAA,EACF;AAEA,MAAI,mBAAmB,YAAY,iBAAiB;AAClD,uBAAmB,UAAU;AAAA,EAC/B;AACF;","names":["import_jsx_runtime"]}
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Suggestion,
3
3
  reloadSuggestions
4
- } from "../../chunk-WGAZXTUA.mjs";
5
- import "../../chunk-FZC7X5PK.mjs";
4
+ } from "../../chunk-TOQ7P4DO.mjs";
5
+ import "../../chunk-ORSMX3SE.mjs";
6
6
  import "../../chunk-MRXNTQOX.mjs";
7
7
  export {
8
8
  Suggestion,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/chat/Window.tsx","../../../src/components/chat/ChatContext.tsx"],"sourcesContent":["import React, { useCallback, useEffect } from \"react\";\nimport { WindowProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\n\nexport const Window = ({\n children,\n clickOutsideToClose,\n shortcut,\n hitEscapeToClose,\n}: WindowProps) => {\n const windowRef = React.useRef<HTMLDivElement>(null);\n\n const { open, setOpen } = useChatContext();\n\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (!clickOutsideToClose) {\n return;\n }\n\n const parentElement = windowRef.current?.parentElement;\n\n let className = \"\";\n if (event.target instanceof HTMLElement) {\n className = event.target.className;\n }\n\n if (\n open &&\n parentElement &&\n !parentElement.contains(event.target as any) &&\n // prevent closing the window when clicking on the debug menu\n !className.includes(\"copilotKitDebugMenu\")\n ) {\n setOpen(false);\n }\n },\n [clickOutsideToClose, open, setOpen],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const isInput =\n target.tagName === \"INPUT\" ||\n target.tagName === \"SELECT\" ||\n target.tagName === \"TEXTAREA\" ||\n target.isContentEditable;\n\n const isDescendantOfWrapper = windowRef.current?.contains(target);\n\n if (\n open &&\n event.key === \"Escape\" &&\n (!isInput || isDescendantOfWrapper) &&\n hitEscapeToClose\n ) {\n setOpen(false);\n } else if (\n event.key === shortcut &&\n ((isMacOS() && event.metaKey) || (!isMacOS() && event.ctrlKey)) &&\n (!isInput || isDescendantOfWrapper)\n ) {\n setOpen(!open);\n }\n },\n [hitEscapeToClose, shortcut, open, setOpen],\n );\n\n const adjustForMobile = useCallback(() => {\n const copilotKitWindow = windowRef.current;\n const vv = window.visualViewport;\n if (!copilotKitWindow || !vv) {\n return;\n }\n\n if (window.innerWidth < 640 && open) {\n copilotKitWindow.style.height = `${vv.height}px`;\n copilotKitWindow.style.left = `${vv.offsetLeft}px`;\n copilotKitWindow.style.top = `${vv.offsetTop}px`;\n\n document.body.style.position = \"fixed\";\n document.body.style.width = \"100%\";\n document.body.style.height = `${window.innerHeight}px`;\n document.body.style.overflow = \"hidden\";\n document.body.style.touchAction = \"none\";\n\n // Prevent scrolling on iOS\n document.body.addEventListener(\"touchmove\", preventScroll, {\n passive: false,\n });\n } else {\n copilotKitWindow.style.height = \"\";\n copilotKitWindow.style.left = \"\";\n copilotKitWindow.style.top = \"\";\n document.body.style.position = \"\";\n document.body.style.height = \"\";\n document.body.style.width = \"\";\n document.body.style.overflow = \"\";\n document.body.style.top = \"\";\n document.body.style.touchAction = \"\";\n\n document.body.removeEventListener(\"touchmove\", preventScroll);\n }\n }, [open]);\n\n useEffect(() => {\n document.addEventListener(\"mousedown\", handleClickOutside);\n document.addEventListener(\"keydown\", handleKeyDown);\n if (window.visualViewport) {\n window.visualViewport.addEventListener(\"resize\", adjustForMobile);\n adjustForMobile();\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n document.removeEventListener(\"keydown\", handleKeyDown);\n if (window.visualViewport) {\n window.visualViewport.removeEventListener(\"resize\", adjustForMobile);\n }\n };\n }, [adjustForMobile, handleClickOutside, handleKeyDown]);\n\n return (\n <div className={`copilotKitWindow${open ? \" open\" : \"\"}`} ref={windowRef}>\n {children}\n </div>\n );\n};\n\nconst preventScroll = (event: TouchEvent): void => {\n let targetElement = event.target as Element;\n\n // Function to check if the target has the parent with a given class\n const hasParentWithClass = (element: Element, className: string): boolean => {\n while (element && element !== document.body) {\n if (element.classList.contains(className)) {\n return true;\n }\n element = element.parentElement!;\n }\n return false;\n };\n\n // Check if the target of the touch event is inside an element with the 'copilotKitMessages' class\n if (!hasParentWithClass(targetElement, \"copilotKitMessages\")) {\n event.preventDefault();\n }\n};\n\nfunction isMacOS() {\n return /Mac|iMac|Macintosh/i.test(navigator.userAgent);\n}\n","import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n}: ChatContextProps) => {\n const memoizedLabels = useMemo(\n () => ({\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n },\n ...labels,\n }),\n [labels],\n );\n\n const memoizedIcons = useMemo(\n () => ({\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n pushToTalkIcon: DefaultIcons.PushToTalkIcon,\n },\n ...icons,\n }),\n [icons],\n );\n\n const context = useMemo(\n () => ({\n labels: memoizedLabels,\n icons: memoizedIcons,\n open,\n setOpen,\n }),\n [memoizedLabels, memoizedIcons, open, setOpen],\n );\n\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA8C;;;ACA9C,mBAAyC;AA0LhC;AA5EF,IAAM,cAAc,aAAAC,QAAM,cAAuC,MAAS;AAE1E,SAAS,iBAA8B;AAC5C,QAAM,UAAU,aAAAA,QAAM,WAAW,WAAW;AAC5C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;ADII,IAAAC,sBAAA;AAxHG,IAAM,SAAS,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAmB;AACjB,QAAM,YAAY,cAAAC,QAAM,OAAuB,IAAI;AAEnD,QAAM,EAAE,MAAM,QAAQ,IAAI,eAAe;AAEzC,QAAM,yBAAqB;AAAA,IACzB,CAAC,UAAsB;AAf3B;AAgBM,UAAI,CAAC,qBAAqB;AACxB;AAAA,MACF;AAEA,YAAM,iBAAgB,eAAU,YAAV,mBAAmB;AAEzC,UAAI,YAAY;AAChB,UAAI,MAAM,kBAAkB,aAAa;AACvC,oBAAY,MAAM,OAAO;AAAA,MAC3B;AAEA,UACE,QACA,iBACA,CAAC,cAAc,SAAS,MAAM,MAAa;AAAA,MAE3C,CAAC,UAAU,SAAS,qBAAqB,GACzC;AACA,gBAAQ,KAAK;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,qBAAqB,MAAM,OAAO;AAAA,EACrC;AAEA,QAAM,oBAAgB;AAAA,IACpB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S,KAAK,MAAM,MAAM;AAC1B,eAAS,KAAK,MAAM,cAAc;AAElC,eAAS,KAAK,oBAAoB,aAAa,aAAa;AAAA,IAC9D;AAAA,EACF,GAAG,CAAC,IAAI,CAAC;AAET,+BAAU,MAAM;AACd,aAAS,iBAAiB,aAAa,kBAAkB;AACzD,aAAS,iBAAiB,WAAW,aAAa;AAClD,QAAI,OAAO,gBAAgB;AACzB,aAAO,eAAe,iBAAiB,UAAU,eAAe;AAChE,sBAAgB;AAAA,IAClB;AAEA,WAAO,MAAM;AACX,eAAS,oBAAoB,aAAa,kBAAkB;AAC5D,eAAS,oBAAoB,WAAW,aAAa;AACrD,UAAI,OAAO,gBAAgB;AACzB,eAAO,eAAe,oBAAoB,UAAU,eAAe;AAAA,MACrE;AAAA,IACF;AAAA,EACF,GAAG,CAAC,iBAAiB,oBAAoB,aAAa,CAAC;AAEvD,SACE,6CAAC,SAAI,WAAW,mBAAmB,OAAO,UAAU,MAAM,KAAK,WAC5D,UACH;AAEJ;AAEA,IAAM,gBAAgB,CAAC,UAA4B;AACjD,MAAI,gBAAgB,MAAM;AAG1B,QAAM,qBAAqB,CAAC,SAAkB,cAA+B;AAC3E,WAAO,WAAW,YAAY,SAAS,MAAM;AAC3C,UAAI,QAAQ,UAAU,SAAS,SAAS,GAAG;AACzC,eAAO;AAAA,MACT;AACA,gBAAU,QAAQ;AAAA,IACpB;AACA,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,mBAAmB,eAAe,oBAAoB,GAAG;AAC5D,UAAM,eAAe;AAAA,EACvB;AACF;AAEA,SAAS,UAAU;AACjB,SAAO,sBAAsB,KAAK,UAAU,SAAS;AACvD;","names":["import_react","React","import_jsx_runtime","React"]}
1
+ {"version":3,"sources":["../../../src/components/chat/Window.tsx","../../../src/components/chat/ChatContext.tsx"],"sourcesContent":["import React, { useCallback, useEffect } from \"react\";\nimport { WindowProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\n\nexport const Window = ({\n children,\n clickOutsideToClose,\n shortcut,\n hitEscapeToClose,\n}: WindowProps) => {\n const windowRef = React.useRef<HTMLDivElement>(null);\n\n const { open, setOpen } = useChatContext();\n\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (!clickOutsideToClose) {\n return;\n }\n\n const parentElement = windowRef.current?.parentElement;\n\n let className = \"\";\n if (event.target instanceof HTMLElement) {\n className = event.target.className;\n }\n\n if (\n open &&\n parentElement &&\n !parentElement.contains(event.target as any) &&\n // prevent closing the window when clicking on the debug menu\n !className.includes(\"copilotKitDebugMenu\")\n ) {\n setOpen(false);\n }\n },\n [clickOutsideToClose, open, setOpen],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const isInput =\n target.tagName === \"INPUT\" ||\n target.tagName === \"SELECT\" ||\n target.tagName === \"TEXTAREA\" ||\n target.isContentEditable;\n\n const isDescendantOfWrapper = windowRef.current?.contains(target);\n\n if (\n open &&\n event.key === \"Escape\" &&\n (!isInput || isDescendantOfWrapper) &&\n hitEscapeToClose\n ) {\n setOpen(false);\n } else if (\n event.key === shortcut &&\n ((isMacOS() && event.metaKey) || (!isMacOS() && event.ctrlKey)) &&\n (!isInput || isDescendantOfWrapper)\n ) {\n setOpen(!open);\n }\n },\n [hitEscapeToClose, shortcut, open, setOpen],\n );\n\n const adjustForMobile = useCallback(() => {\n const copilotKitWindow = windowRef.current;\n const vv = window.visualViewport;\n if (!copilotKitWindow || !vv) {\n return;\n }\n\n if (window.innerWidth < 640 && open) {\n copilotKitWindow.style.height = `${vv.height}px`;\n copilotKitWindow.style.left = `${vv.offsetLeft}px`;\n copilotKitWindow.style.top = `${vv.offsetTop}px`;\n\n document.body.style.position = \"fixed\";\n document.body.style.width = \"100%\";\n document.body.style.height = `${window.innerHeight}px`;\n document.body.style.overflow = \"hidden\";\n document.body.style.touchAction = \"none\";\n\n // Prevent scrolling on iOS\n document.body.addEventListener(\"touchmove\", preventScroll, {\n passive: false,\n });\n } else {\n copilotKitWindow.style.height = \"\";\n copilotKitWindow.style.left = \"\";\n copilotKitWindow.style.top = \"\";\n document.body.style.position = \"\";\n document.body.style.height = \"\";\n document.body.style.width = \"\";\n document.body.style.overflow = \"\";\n document.body.style.top = \"\";\n document.body.style.touchAction = \"\";\n\n document.body.removeEventListener(\"touchmove\", preventScroll);\n }\n }, [open]);\n\n useEffect(() => {\n document.addEventListener(\"mousedown\", handleClickOutside);\n document.addEventListener(\"keydown\", handleKeyDown);\n if (window.visualViewport) {\n window.visualViewport.addEventListener(\"resize\", adjustForMobile);\n adjustForMobile();\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n document.removeEventListener(\"keydown\", handleKeyDown);\n if (window.visualViewport) {\n window.visualViewport.removeEventListener(\"resize\", adjustForMobile);\n }\n };\n }, [adjustForMobile, handleClickOutside, handleKeyDown]);\n\n return (\n <div className={`copilotKitWindow${open ? \" open\" : \"\"}`} ref={windowRef}>\n {children}\n </div>\n );\n};\n\nconst preventScroll = (event: TouchEvent): void => {\n let targetElement = event.target as Element;\n\n // Function to check if the target has the parent with a given class\n const hasParentWithClass = (element: Element, className: string): boolean => {\n while (element && element !== document.body) {\n if (element.classList.contains(className)) {\n return true;\n }\n element = element.parentElement!;\n }\n return false;\n };\n\n // Check if the target of the touch event is inside an element with the 'copilotKitMessages' class\n if (!hasParentWithClass(targetElement, \"copilotKitMessages\")) {\n event.preventDefault();\n }\n};\n\nfunction isMacOS() {\n return /Mac|iMac|Macintosh/i.test(navigator.userAgent);\n}\n","import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n\n /**\n * The label for the copy button.\n * @default \"Copy to clipboard\"\n */\n copyToClipboard?: string;\n\n /**\n * The label for the thumbs up button.\n * @default \"Thumbs up\"\n */\n thumbsUp?: string;\n\n /**\n * The label for the thumbs down button.\n * @default \"Thumbs down\"\n */\n thumbsDown?: string;\n\n /**\n * The text to display when content is copied.\n * @default \"Copied!\"\n */\n copied?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n}: ChatContextProps) => {\n const memoizedLabels = useMemo(\n () => ({\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n copyToClipboard: \"Copy to clipboard\",\n thumbsUp: \"Thumbs up\",\n thumbsDown: \"Thumbs down\",\n copied: \"Copied!\",\n },\n ...labels,\n }),\n [labels],\n );\n\n const memoizedIcons = useMemo(\n () => ({\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n pushToTalkIcon: DefaultIcons.MicrophoneIcon,\n },\n ...icons,\n }),\n [icons],\n );\n\n const context = useMemo(\n () => ({\n labels: memoizedLabels,\n icons: memoizedIcons,\n open,\n setOpen,\n }),\n [memoizedLabels, memoizedIcons, open, setOpen],\n );\n\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA8C;;;ACA9C,mBAAyC;AAsNhC;AAhFF,IAAM,cAAc,aAAAC,QAAM,cA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AAgB;AACzB,eAAO,eAAe,oBAAoB,UAAU,eAAe;AAAA,MACrE;AAAA,IACF;AAAA,EACF,GAAG,CAAC,iBAAiB,oBAAoB,aAAa,CAAC;AAEvD,SACE,6CAAC,SAAI,WAAW,mBAAmB,OAAO,UAAU,MAAM,KAAK,WAC5D,UACH;AAEJ;AAEA,IAAM,gBAAgB,CAAC,UAA4B;AACjD,MAAI,gBAAgB,MAAM;AAG1B,QAAM,qBAAqB,CAAC,SAAkB,cAA+B;AAC3E,WAAO,WAAW,YAAY,SAAS,MAAM;AAC3C,UAAI,QAAQ,UAAU,SAAS,SAAS,GAAG;AACzC,eAAO;AAAA,MACT;AACA,gBAAU,QAAQ;AAAA,IACpB;AACA,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,mBAAmB,eAAe,oBAAoB,GAAG;AAC5D,UAAM,eAAe;AAAA,EACvB;AACF;AAEA,SAAS,UAAU;AACjB,SAAO,sBAAsB,KAAK,UAAU,SAAS;AACvD;","names":["import_react","React","import_jsx_runtime","React"]}
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Window
3
- } from "../../chunk-YAGE7RCE.mjs";
4
- import "../../chunk-CBBFRI3Q.mjs";
5
- import "../../chunk-FZC7X5PK.mjs";
3
+ } from "../../chunk-CGVOCLHN.mjs";
4
+ import "../../chunk-5JY5QJ2W.mjs";
5
+ import "../../chunk-ORSMX3SE.mjs";
6
6
  import "../../chunk-MRXNTQOX.mjs";
7
7
  export {
8
8
  Window