@k2b/ui 0.18.0 → 0.19.0

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 (178) hide show
  1. package/README.md +3 -2
  2. package/dist/browser/actions/ContextMenu.js +3 -1
  3. package/dist/browser/actions/ContextMenu.js.map +1 -1
  4. package/dist/browser/actions/Dropdown.js +91 -46
  5. package/dist/browser/actions/Dropdown.js.map +1 -1
  6. package/dist/browser/actions/FilterChip.js +4 -1
  7. package/dist/browser/actions/FilterChip.js.map +1 -1
  8. package/dist/browser/chat/ChatComposer.js +1293 -534
  9. package/dist/browser/chat/ChatComposer.js.map +1 -1
  10. package/dist/browser/chat/chat-behavior.js +9 -0
  11. package/dist/browser/chat/chat-behavior.js.map +1 -1
  12. package/dist/browser/chat/index.js.map +1 -1
  13. package/dist/browser/chat/types.js.map +1 -1
  14. package/dist/browser/content/Calendar.js +579 -533
  15. package/dist/browser/content/Calendar.js.map +1 -1
  16. package/dist/browser/content/Lightbox.js +76 -40
  17. package/dist/browser/content/Lightbox.js.map +1 -1
  18. package/dist/browser/content/PdfPreview.js +146 -79
  19. package/dist/browser/content/PdfPreview.js.map +1 -1
  20. package/dist/browser/content/Timeline.js +1038 -0
  21. package/dist/browser/content/Timeline.js.map +1 -0
  22. package/dist/browser/content/VideoPlayer.js +29 -9
  23. package/dist/browser/content/VideoPlayer.js.map +1 -1
  24. package/dist/browser/content/chart-inspection.js +7 -2
  25. package/dist/browser/content/chart-inspection.js.map +1 -1
  26. package/dist/browser/content/index.js +1 -0
  27. package/dist/browser/content/index.js.map +1 -1
  28. package/dist/browser/content/timeline-model.js +579 -0
  29. package/dist/browser/content/timeline-model.js.map +1 -0
  30. package/dist/browser/feedback/dialog-core.js +26 -14
  31. package/dist/browser/feedback/dialog-core.js.map +1 -1
  32. package/dist/browser/inputs/ChoiceChips.js +66 -0
  33. package/dist/browser/inputs/ChoiceChips.js.map +1 -0
  34. package/dist/browser/inputs/ChoiceGroups.js +53 -12
  35. package/dist/browser/inputs/ChoiceGroups.js.map +1 -1
  36. package/dist/browser/inputs/FileInputs.js +48 -33
  37. package/dist/browser/inputs/FileInputs.js.map +1 -1
  38. package/dist/browser/inputs/SignatureInput.js +558 -0
  39. package/dist/browser/inputs/SignatureInput.js.map +1 -0
  40. package/dist/browser/inputs/emoji/EmojiPicker.js +841 -0
  41. package/dist/browser/inputs/emoji/EmojiPicker.js.map +1 -0
  42. package/dist/browser/inputs/emoji/emoji-data.js +1903 -0
  43. package/dist/browser/inputs/emoji/emoji-data.js.map +1 -0
  44. package/dist/browser/inputs/emoji/emoji-index.js +209 -0
  45. package/dist/browser/inputs/emoji/emoji-index.js.map +1 -0
  46. package/dist/browser/inputs/emoji/emoji-messages.js +64 -0
  47. package/dist/browser/inputs/emoji/emoji-messages.js.map +1 -0
  48. package/dist/browser/inputs/index.js +5 -0
  49. package/dist/browser/inputs/index.js.map +1 -1
  50. package/dist/browser/inputs/markdown/actions.js +48 -2
  51. package/dist/browser/inputs/markdown/actions.js.map +1 -1
  52. package/dist/browser/inputs/markdown/code-zone.js +38 -2
  53. package/dist/browser/inputs/markdown/code-zone.js.map +1 -1
  54. package/dist/browser/inputs/signature-messages.js +39 -0
  55. package/dist/browser/inputs/signature-messages.js.map +1 -0
  56. package/dist/browser/inputs/signature.js +208 -0
  57. package/dist/browser/inputs/signature.js.map +1 -0
  58. package/dist/browser/internal/render-error.js +49 -0
  59. package/dist/browser/internal/render-error.js.map +1 -0
  60. package/dist/browser/intl/messages.js +108 -0
  61. package/dist/browser/intl/messages.js.map +1 -1
  62. package/dist/browser/layout/AppWorkspace.js +321 -222
  63. package/dist/browser/layout/AppWorkspace.js.map +1 -1
  64. package/dist/browser/layout/FloatingWindow.js +4 -1
  65. package/dist/browser/layout/FloatingWindow.js.map +1 -1
  66. package/dist/browser/layout/SidebarItemPreview.js +5 -1
  67. package/dist/browser/layout/SidebarItemPreview.js.map +1 -1
  68. package/dist/browser/layout/index.js.map +1 -1
  69. package/dist/browser/surfaces/ResourceCard.js +212 -0
  70. package/dist/browser/surfaces/ResourceCard.js.map +1 -0
  71. package/dist/browser/surfaces/index.js +1 -0
  72. package/dist/browser/surfaces/index.js.map +1 -1
  73. package/dist/licenses/emojibase-data.txt +21 -0
  74. package/dist/ssr/actions/ContextMenu.js +3 -1
  75. package/dist/ssr/actions/ContextMenu.js.map +1 -1
  76. package/dist/ssr/actions/Dropdown.js +49 -12
  77. package/dist/ssr/actions/Dropdown.js.map +1 -1
  78. package/dist/ssr/actions/FilterChip.js +4 -1
  79. package/dist/ssr/actions/FilterChip.js.map +1 -1
  80. package/dist/ssr/chat/ChatComposer.js +805 -214
  81. package/dist/ssr/chat/ChatComposer.js.map +1 -1
  82. package/dist/ssr/chat/chat-behavior.js +9 -0
  83. package/dist/ssr/chat/chat-behavior.js.map +1 -1
  84. package/dist/ssr/chat/index.js.map +1 -1
  85. package/dist/ssr/chat/types.js.map +1 -1
  86. package/dist/ssr/content/Calendar.js +183 -142
  87. package/dist/ssr/content/Calendar.js.map +1 -1
  88. package/dist/ssr/content/Lightbox.js +19 -5
  89. package/dist/ssr/content/Lightbox.js.map +1 -1
  90. package/dist/ssr/content/PdfPreview.js +77 -36
  91. package/dist/ssr/content/PdfPreview.js.map +1 -1
  92. package/dist/ssr/content/Timeline.js +804 -0
  93. package/dist/ssr/content/Timeline.js.map +1 -0
  94. package/dist/ssr/content/VideoPlayer.js +29 -9
  95. package/dist/ssr/content/VideoPlayer.js.map +1 -1
  96. package/dist/ssr/content/chart-inspection.js +7 -2
  97. package/dist/ssr/content/chart-inspection.js.map +1 -1
  98. package/dist/ssr/content/index.js +1 -0
  99. package/dist/ssr/content/index.js.map +1 -1
  100. package/dist/ssr/content/timeline-model.js +579 -0
  101. package/dist/ssr/content/timeline-model.js.map +1 -0
  102. package/dist/ssr/feedback/dialog-core.js +26 -14
  103. package/dist/ssr/feedback/dialog-core.js.map +1 -1
  104. package/dist/ssr/inputs/ChoiceChips.js +66 -0
  105. package/dist/ssr/inputs/ChoiceChips.js.map +1 -0
  106. package/dist/ssr/inputs/ChoiceGroups.js +12 -4
  107. package/dist/ssr/inputs/ChoiceGroups.js.map +1 -1
  108. package/dist/ssr/inputs/FileInputs.js +19 -4
  109. package/dist/ssr/inputs/FileInputs.js.map +1 -1
  110. package/dist/ssr/inputs/SignatureInput.js +404 -0
  111. package/dist/ssr/inputs/SignatureInput.js.map +1 -0
  112. package/dist/ssr/inputs/emoji/EmojiPicker.js +551 -0
  113. package/dist/ssr/inputs/emoji/EmojiPicker.js.map +1 -0
  114. package/dist/ssr/inputs/emoji/emoji-data.js +1903 -0
  115. package/dist/ssr/inputs/emoji/emoji-data.js.map +1 -0
  116. package/dist/ssr/inputs/emoji/emoji-index.js +209 -0
  117. package/dist/ssr/inputs/emoji/emoji-index.js.map +1 -0
  118. package/dist/ssr/inputs/emoji/emoji-messages.js +64 -0
  119. package/dist/ssr/inputs/emoji/emoji-messages.js.map +1 -0
  120. package/dist/ssr/inputs/index.js +5 -0
  121. package/dist/ssr/inputs/index.js.map +1 -1
  122. package/dist/ssr/inputs/markdown/actions.js +48 -2
  123. package/dist/ssr/inputs/markdown/actions.js.map +1 -1
  124. package/dist/ssr/inputs/markdown/code-zone.js +38 -2
  125. package/dist/ssr/inputs/markdown/code-zone.js.map +1 -1
  126. package/dist/ssr/inputs/signature-messages.js +39 -0
  127. package/dist/ssr/inputs/signature-messages.js.map +1 -0
  128. package/dist/ssr/inputs/signature.js +208 -0
  129. package/dist/ssr/inputs/signature.js.map +1 -0
  130. package/dist/ssr/internal/render-error.js +49 -0
  131. package/dist/ssr/internal/render-error.js.map +1 -0
  132. package/dist/ssr/intl/messages.js +108 -0
  133. package/dist/ssr/intl/messages.js.map +1 -1
  134. package/dist/ssr/layout/AppWorkspace.js +112 -41
  135. package/dist/ssr/layout/AppWorkspace.js.map +1 -1
  136. package/dist/ssr/layout/FloatingWindow.js +4 -1
  137. package/dist/ssr/layout/FloatingWindow.js.map +1 -1
  138. package/dist/ssr/layout/SidebarItemPreview.js +5 -1
  139. package/dist/ssr/layout/SidebarItemPreview.js.map +1 -1
  140. package/dist/ssr/layout/index.js.map +1 -1
  141. package/dist/ssr/surfaces/ResourceCard.js +115 -0
  142. package/dist/ssr/surfaces/ResourceCard.js.map +1 -0
  143. package/dist/ssr/surfaces/index.js +1 -0
  144. package/dist/ssr/surfaces/index.js.map +1 -1
  145. package/dist/styles.css +1 -1
  146. package/dist/types/actions/Dropdown.d.ts +13 -1
  147. package/dist/types/actions/FilterChip.d.ts +5 -0
  148. package/dist/types/chat/ChatComposer.d.ts +24 -1
  149. package/dist/types/chat/chat-behavior.d.ts +15 -0
  150. package/dist/types/chat/index.d.ts +1 -1
  151. package/dist/types/chat/types.d.ts +34 -0
  152. package/dist/types/content/Calendar.d.ts +28 -8
  153. package/dist/types/content/Lightbox.d.ts +8 -0
  154. package/dist/types/content/Timeline.d.ts +49 -0
  155. package/dist/types/content/index.d.ts +4 -2
  156. package/dist/types/content/timeline-model.d.ts +148 -0
  157. package/dist/types/feedback/dialog-core.d.ts +1 -1
  158. package/dist/types/inputs/ChoiceChips.d.ts +20 -0
  159. package/dist/types/inputs/ChoiceGroups.d.ts +11 -2
  160. package/dist/types/inputs/FileInputs.d.ts +6 -0
  161. package/dist/types/inputs/SignatureInput.d.ts +22 -0
  162. package/dist/types/inputs/emoji/EmojiPicker.d.ts +42 -0
  163. package/dist/types/inputs/emoji/emoji-data.d.ts +2 -0
  164. package/dist/types/inputs/emoji/emoji-index.d.ts +109 -0
  165. package/dist/types/inputs/emoji/emoji-messages.d.ts +30 -0
  166. package/dist/types/inputs/index.d.ts +10 -0
  167. package/dist/types/inputs/markdown/actions.d.ts +4 -0
  168. package/dist/types/inputs/markdown/code-zone.d.ts +7 -0
  169. package/dist/types/inputs/signature-messages.d.ts +11 -0
  170. package/dist/types/inputs/signature.d.ts +72 -0
  171. package/dist/types/internal/render-error.d.ts +13 -0
  172. package/dist/types/intl/messages.d.ts +54 -0
  173. package/dist/types/layout/AppWorkspace.d.ts +17 -0
  174. package/dist/types/layout/SidebarItemPreview.d.ts +2 -0
  175. package/dist/types/layout/index.d.ts +1 -1
  176. package/dist/types/surfaces/ResourceCard.d.ts +31 -0
  177. package/dist/types/surfaces/index.d.ts +2 -0
  178. package/package.json +5 -4
@@ -1,66 +1,166 @@
1
1
  import { template as _$template } from "solid-js/web";
2
2
  import { delegateEvents as _$delegateEvents } from "solid-js/web";
3
3
  import { mergeProps as _$mergeProps } from "solid-js/web";
4
- import { className as _$className } from "solid-js/web";
5
- import { runHydrationEvents as _$runHydrationEvents } from "solid-js/web";
6
- import { setProperty as _$setProperty } from "solid-js/web";
7
4
  import { setStyleProperty as _$setStyleProperty } from "solid-js/web";
5
+ import { runHydrationEvents as _$runHydrationEvents } from "solid-js/web";
8
6
  import { getNextMarker as _$getNextMarker } from "solid-js/web";
7
+ import { memo as _$memo } from "solid-js/web";
8
+ import { className as _$className } from "solid-js/web";
9
9
  import { createComponent as _$createComponent } from "solid-js/web";
10
+ import { setProperty as _$setProperty } from "solid-js/web";
10
11
  import { use as _$use } from "solid-js/web";
11
- import { memo as _$memo } from "solid-js/web";
12
12
  import { setAttribute as _$setAttribute } from "solid-js/web";
13
13
  import { effect as _$effect } from "solid-js/web";
14
14
  import { getNextElement as _$getNextElement } from "solid-js/web";
15
15
  import { insert as _$insert } from "solid-js/web";
16
16
  var _tmpl$ = /*#__PURE__*/_$template(`<span><strong>`),
17
- _tmpl$2 = /*#__PURE__*/_$template(`<div role=status class=k2b-chat-composer__loading><i class="ti ti-loader-2 k2b-spin"aria-hidden=true></i><strong>`),
18
- _tmpl$3 = /*#__PURE__*/_$template(`<div role=status><i class="ti ti-alert-circle"></i> <!$><!/>`),
19
- _tmpl$4 = /*#__PURE__*/_$template(`<div role=status>`),
20
- _tmpl$5 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer-accessory><div class=k2b-chat-composer__commands role=listbox><!$><!/><!$><!/><!$><!/><!$><!/>`),
21
- _tmpl$6 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer-slot><div></div><!$><!/>`),
22
- _tmpl$7 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__attachments role=list tabindex=0>`),
23
- _tmpl$8 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__highlight aria-hidden=true><!$><!/>\n`),
24
- _tmpl$9 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__error role=alert><i class="ti ti-alert-circle"aria-hidden=true></i><!$><!/>`),
25
- _tmpl$0 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer-shell><!$><!/><section role=group><!$><!/><div class=k2b-chat-composer__input role=group><!$><!/><textarea rows=1></textarea></div><!$><!/><footer class=k2b-chat-composer__footer></footer><!$><!/>`),
26
- _tmpl$1 = /*#__PURE__*/_$template(`<button type=button role=option tabindex=-1><i aria-hidden=true></i><strong></strong><small>`),
27
- _tmpl$10 = /*#__PURE__*/_$template(`<button type=button class=k2b-chat-composer__attachment-remove><i class="ti ti-x"aria-hidden=true>`),
28
- _tmpl$11 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__attachment role=listitem><div class=k2b-chat-composer__attachment-content><!$><!/><!$><!/></div><!$><!/>`),
29
- _tmpl$12 = /*#__PURE__*/_$template(`<img>`),
30
- _tmpl$13 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__attachment-identity><!$><!/><!$><!/>`),
31
- _tmpl$14 = /*#__PURE__*/_$template(`<i aria-hidden=true>`),
32
- _tmpl$15 = /*#__PURE__*/_$template(`<a class=k2b-chat-composer__attachment-link target=_blank rel="noopener noreferrer"><!$><!/><!$><!/>`),
33
- _tmpl$16 = /*#__PURE__*/_$template(`<button type=button class=k2b-chat-composer__attachment-action><!$><!/><!$><!/>`),
34
- _tmpl$17 = /*#__PURE__*/_$template(`<span>`),
35
- _tmpl$18 = /*#__PURE__*/_$template(`<i class="ti ti-plus"aria-hidden=true>`),
36
- _tmpl$19 = /*#__PURE__*/_$template(`<input class=k2b-sr-only type=file tabindex=-1 aria-hidden=true>`),
37
- _tmpl$20 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__tools><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/>`),
38
- _tmpl$21 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__submit><!$><!/><!$><!/><!$><!/><!$><!/>`);
17
+ _tmpl$2 = /*#__PURE__*/_$template(`<input class=k2b-sr-only type=file tabindex=-1 aria-hidden=true>`),
18
+ _tmpl$3 = /*#__PURE__*/_$template(`<i aria-hidden=true>`),
19
+ _tmpl$4 = /*#__PURE__*/_$template(`<i class="ti ti-letter-case"aria-hidden=true>`),
20
+ _tmpl$5 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__format role=group>`),
21
+ _tmpl$6 = /*#__PURE__*/_$template(`<i class="ti ti-mood-smile"aria-hidden=true>`),
22
+ _tmpl$7 = /*#__PURE__*/_$template(`<i class="ti ti-chevron-up"aria-hidden=true>`),
23
+ _tmpl$8 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__microphone><!$><!/><!$><!/>`),
24
+ _tmpl$9 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__highlight aria-hidden=true><!$><!/>\n`),
25
+ _tmpl$0 = /*#__PURE__*/_$template(`<textarea class=k2b-chat-composer__measure rows=1 tabindex=-1 aria-hidden=true readonly>`),
26
+ _tmpl$1 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__input role=group><!$><!/><textarea rows=1></textarea><!$><!/>`),
27
+ _tmpl$10 = /*#__PURE__*/_$template(`<span>`),
28
+ _tmpl$11 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer-accessory><div class=k2b-chat-composer__commands role=listbox>`),
29
+ _tmpl$12 = /*#__PURE__*/_$template(`<div role=status class=k2b-chat-composer__loading><i class="ti ti-loader-2 k2b-spin"aria-hidden=true></i><strong>`),
30
+ _tmpl$13 = /*#__PURE__*/_$template(`<div role=status><i class="ti ti-alert-circle"></i> <!$><!/>`),
31
+ _tmpl$14 = /*#__PURE__*/_$template(`<div role=status>`),
32
+ _tmpl$15 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer-accessory><div class=k2b-chat-composer__commands role=listbox><!$><!/><!$><!/><!$><!/><!$><!/>`),
33
+ _tmpl$16 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer-slot><div></div><!$><!/><!$><!/>`),
34
+ _tmpl$17 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__hint aria-live=polite>`),
35
+ _tmpl$18 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__attachments role=list tabindex=0>`),
36
+ _tmpl$19 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__error role=alert><i class="ti ti-alert-circle"aria-hidden=true></i><!$><!/>`),
37
+ _tmpl$20 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__row><!$><!/><!$><!/><div class=k2b-chat-composer__field><!$><!/><div class=k2b-chat-composer__field-tools><!$><!/><!$><!/><!$><!/></div></div><!$><!/>`),
38
+ _tmpl$21 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer-shell><!$><!/><section role=group><!$><!/><!$><!/><!$><!/><!$><!/>`),
39
+ _tmpl$22 = /*#__PURE__*/_$template(`<button type=button role=option tabindex=-1><span class=k2b-chat-composer__emoji-glyph aria-hidden=true></span><strong></strong><!$><!/>`),
40
+ _tmpl$23 = /*#__PURE__*/_$template(`<small>:<!$><!/>:`),
41
+ _tmpl$24 = /*#__PURE__*/_$template(`<button type=button role=option tabindex=-1><i aria-hidden=true></i><strong></strong><small>`),
42
+ _tmpl$25 = /*#__PURE__*/_$template(`<span class=k2b-chat-composer__hint-text>`),
43
+ _tmpl$26 = /*#__PURE__*/_$template(`<span class=k2b-chat-composer__dictation><i aria-hidden=true></i><span>`),
44
+ _tmpl$27 = /*#__PURE__*/_$template(`<button type=button class=k2b-chat-composer__hint-action>`),
45
+ _tmpl$28 = /*#__PURE__*/_$template(`<button type=button class=k2b-chat-composer__attachment-remove><i class="ti ti-x"aria-hidden=true>`),
46
+ _tmpl$29 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__attachment role=listitem><div class=k2b-chat-composer__attachment-content><!$><!/><!$><!/></div><!$><!/>`),
47
+ _tmpl$30 = /*#__PURE__*/_$template(`<img>`),
48
+ _tmpl$31 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__attachment-identity><!$><!/><!$><!/>`),
49
+ _tmpl$32 = /*#__PURE__*/_$template(`<a class=k2b-chat-composer__attachment-link target=_blank rel="noopener noreferrer"><!$><!/><!$><!/>`),
50
+ _tmpl$33 = /*#__PURE__*/_$template(`<button type=button class=k2b-chat-composer__attachment-action><!$><!/><!$><!/>`),
51
+ _tmpl$34 = /*#__PURE__*/_$template(`<footer class=k2b-chat-composer__footer>`),
52
+ _tmpl$35 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__tools><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/>`),
53
+ _tmpl$36 = /*#__PURE__*/_$template(`<div class=k2b-chat-composer__submit><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/>`);
39
54
  import { children, createEffect, createMemo, createSignal, createUniqueId, For, onCleanup, onMount, Show, untrack } from "solid-js";
40
55
  import { Dropdown } from "../actions/Dropdown";
41
56
  import { Tooltip } from "../feedback/Tooltip";
57
+ import { replaceTextareaRange } from "../inputs/editor-dom";
58
+ import { completedEmojiShortcode, emojiInTone, emojiName, emojiShortcodeQuery, loadEmojiIndex, suggestEmoji } from "../inputs/emoji/emoji-index";
42
59
  import { FileDropTarget } from "../inputs/FileDropTarget";
60
+ import { toggleBulletList, toggleCodeBlock, toggleInlineMarker, toggleQuote } from "../inputs/markdown/actions";
61
+ import { openCodeFence } from "../inputs/markdown/code-zone";
43
62
  import { SelectChip } from "../inputs/SelectChip";
63
+ import { useLocale } from "../intl/locale";
44
64
  import { useUiMessages } from "../intl/messages";
45
65
  import { ChatContextUsage as ContextUsage } from "./ChatPrimitives";
46
- import { executeChatAction, nextChatCommandIndex, reportChatFailure, runChatSubmission } from "./chat-behavior";
66
+ import { conversationEnterAction, executeChatAction, nextChatCommandIndex, reportChatFailure, runChatSubmission } from "./chat-behavior";
47
67
  import { chatCommandQuery, chatMentionSegments, reconcileChatMentions } from "./composer-document";
48
68
  const composerMaxInputHeight = 309;
69
+ /** Emoji suggestions for a `:shortcode`, as many as fit the list without scrolling on a phone. */
70
+ const emojiSuggestionLimit = 8;
49
71
  // Keep editor undo text within approximately 2 MiB, plus the current edit.
50
72
  const composerUndoBudgetChars = 1_000_000;
73
+ const insertComposerLink = textarea => {
74
+ const {
75
+ value,
76
+ selectionStart,
77
+ selectionEnd
78
+ } = textarea;
79
+ const label = value.slice(selectionStart, selectionEnd);
80
+ replaceTextareaRange(textarea, selectionStart, selectionEnd, `[${label}]()`);
81
+ // Without a selection the label comes first, otherwise the address.
82
+ const caret = label ? selectionStart + label.length + 3 : selectionStart + 1;
83
+ textarea.setSelectionRange(caret, caret);
84
+ };
85
+ const formatTools = [{
86
+ id: "bold",
87
+ icon: "ti ti-bold",
88
+ label: m => m.boldShortcut,
89
+ run: textarea => toggleInlineMarker(textarea, "**"),
90
+ key: "b"
91
+ }, {
92
+ id: "italic",
93
+ icon: "ti ti-italic",
94
+ label: m => m.italicShortcut,
95
+ run: textarea => toggleInlineMarker(textarea, "*"),
96
+ key: "i"
97
+ }, {
98
+ id: "strikethrough",
99
+ icon: "ti ti-strikethrough",
100
+ label: m => m.strikethroughShortcut,
101
+ run: textarea => toggleInlineMarker(textarea, "~~"),
102
+ shiftCode: "KeyX"
103
+ }, {
104
+ id: "code",
105
+ icon: "ti ti-code",
106
+ label: m => m.inlineCodeShortcut,
107
+ run: textarea => toggleInlineMarker(textarea, "`"),
108
+ key: "e"
109
+ }, {
110
+ id: "code-block",
111
+ icon: "ti ti-source-code",
112
+ label: m => m.codeBlock,
113
+ run: toggleCodeBlock
114
+ }, {
115
+ id: "bullet-list",
116
+ icon: "ti ti-list",
117
+ label: m => m.bulletListShortcut,
118
+ run: toggleBulletList,
119
+ shiftCode: "Digit8"
120
+ }, {
121
+ id: "quote",
122
+ icon: "ti ti-quote",
123
+ label: m => m.quote,
124
+ run: toggleQuote
125
+ }, {
126
+ id: "link",
127
+ icon: "ti ti-link",
128
+ label: m => m.insertLink,
129
+ run: insertComposerLink
130
+ }];
131
+ const formatShortcut = event => {
132
+ if (event.altKey || !(event.ctrlKey || event.metaKey)) return undefined;
133
+ return formatTools.find(tool => event.shiftKey ? tool.shiftCode === event.code : tool.key === event.key.toLowerCase());
134
+ };
135
+ const touchOnlyQuery = "(any-pointer: coarse) and (not (any-pointer: fine))";
136
+ const isTouchOnly = () => typeof matchMedia === "function" && matchMedia(touchOnlyQuery).matches;
137
+ /** How long a press on the microphone lasts before it asks for a voice message instead of dictation. */
138
+ const microphoneHoldMs = 500;
139
+ /** Keeps the field focused (and a phone's keyboard open) when a composer button is pressed with a mouse or finger. */
140
+ const keepFieldFocus = event => event.preventDefault();
51
141
  const attachmentIcon = attachment => attachment.icon ?? (attachment.kind === "image" ? "ti ti-photo" : attachment.kind === "resource" ? "ti ti-link" : "ti ti-file");
142
+ const hasContent = items => items.some(item => item != null && typeof item !== "boolean" && item !== "");
52
143
  export function ChatComposer(props) {
53
144
  const accessory = children(() => props.accessory);
54
- const hasAccessory = () => accessory.toArray().some(item => item != null && typeof item !== "boolean" && item !== "");
145
+ const hasAccessory = () => hasContent(accessory.toArray());
146
+ const hint = children(() => props.hint);
55
147
  const messages = useUiMessages();
56
148
  const commandListId = `k2b-chat-commands-${createUniqueId().replace(/[^A-Za-z0-9_-]/g, "-")}`;
149
+ const formatGroupId = `${commandListId}-format`;
57
150
  const [selectedCommandIndex, setSelectedCommandIndex] = createSignal(0);
58
151
  const [addingFiles, setAddingFiles] = createSignal(false);
59
152
  const [submitting, setSubmitting] = createSignal(false);
60
153
  let composerRef;
61
154
  let textareaRef;
62
155
  let fileInputRef;
156
+ let measureRef;
157
+ let microphoneRef;
63
158
  let sawRunning = props.state === "running";
159
+ const conversation = () => props.variant === "conversation";
160
+ const [formattingOpen, setFormattingOpen] = createSignal(false);
161
+ const [microphoneMenuOpen, setMicrophoneMenuOpen] = createSignal(false);
162
+ const dictation = () => props.microphone?.dictation ?? null;
163
+ const showHint = () => conversation() || dictation() !== null || hasContent(hint.toArray());
64
164
  const state = () => props.state ?? "idle";
65
165
  const running = () => state() === "running";
66
166
  const stopping = () => state() === "stopping";
@@ -77,15 +177,29 @@ export function ChatComposer(props) {
77
177
  let highlightRef;
78
178
  let commandListRef;
79
179
  const mentions = () => props.mentions ?? [];
180
+ const locale = useLocale();
181
+ const [emojiIndex, setEmojiIndex] = createSignal();
182
+ const emojiQuery = createMemo(() => !props.emoji || dismissed() || composing() ? null : emojiShortcodeQuery(props.value, caret(), selectionEnd()));
183
+ // The emoji data loads with the first `:shortcode`; a failed load only means no suggestions.
184
+ createEffect(() => {
185
+ if (emojiQuery() && !emojiIndex()) loadEmojiIndex().then(setEmojiIndex, () => undefined);
186
+ });
187
+ const emojiMatches = createMemo(() => {
188
+ const token = emojiQuery();
189
+ const index = emojiIndex();
190
+ return token && index ? suggestEmoji(index, token.query, emojiSuggestionLimit) : [];
191
+ });
192
+ const emojiOpen = () => emojiMatches().length > 0;
80
193
  const commandQuery = createMemo(() => dismissed() || composing() ? null : chatCommandQuery(props.value, caret(), selectionEnd()));
81
194
  const commandMatches = createMemo(() => {
82
195
  const token = commandQuery();
83
196
  if (!token) return [];
84
197
  return [...(props.commands ?? []).filter(command => command.name.toLowerCase().includes(token.query.toLowerCase())), ...searchResults()];
85
198
  });
86
- const commandsOpen = () => Boolean(commandQuery() && (props.commands?.length || props.searchCommands));
199
+ const commandsOpen = () => Boolean(!emojiOpen() && commandQuery() && (props.commands?.length || props.searchCommands));
200
+ const suggestionsOpen = () => commandsOpen() || emojiOpen();
87
201
  createEffect(() => {
88
- if (!commandsOpen()) return;
202
+ if (!suggestionsOpen()) return;
89
203
  let disposed = false;
90
204
  const measure = () => {
91
205
  if (disposed || !commandListRef) return;
@@ -182,7 +296,10 @@ export function ChatComposer(props) {
182
296
  setSelectionEnd(textareaRef?.selectionEnd ?? props.value.length);
183
297
  };
184
298
  const selectedCommand = () => commandMatches()[selectedCommandIndex()];
185
- const blocked = () => Boolean(props.disabled || stopping() || state() === "submitting" || executing() || addingFiles() || submitting());
299
+ const busy = () => Boolean(props.disabled || stopping() || state() === "submitting" || executing() || addingFiles());
300
+ const blocked = () => busy() || submitting();
301
+ /** The conversation field stays editable while a message is sent, so it keeps the focus and a phone its keyboard. */
302
+ const editBlocked = () => conversation() ? busy() : blocked();
186
303
  const hasDraft = () => Boolean(props.value.trim() || !running() && attachments().length > 0);
187
304
  const canSubmit = () => !blocked() && hasDraft() && !(running() && runningSubmitIntent() === "steer" && mentions().length);
188
305
  const canSelectFiles = () => Boolean(props.fileSelection && !props.fileSelection.disabled && !running() && !blocked());
@@ -202,7 +319,7 @@ export function ChatComposer(props) {
202
319
  icon: addingFiles() ? "ti ti-loader-2 k2b-spin" : "ti ti-paperclip",
203
320
  label: props.fileSelection.label ?? messages().attachFiles,
204
321
  disabled: !canSelectFiles(),
205
- action: () => fileInputRef?.click()
322
+ action: () => chooseFiles()
206
323
  });
207
324
  }
208
325
  for (const action of props.menuActions ?? []) {
@@ -218,6 +335,14 @@ export function ChatComposer(props) {
218
335
  };
219
336
  const autoResize = () => {
220
337
  if (!textareaRef) return;
338
+ if (conversation()) {
339
+ // A hidden copy measures the text. Collapsing the field itself would shrink the composer for a frame, and
340
+ // WebKit then clamps the scroll position of the conversation above it. CSS caps the height.
341
+ if (!measureRef) return;
342
+ measureRef.value = textareaRef.value;
343
+ textareaRef.style.height = `${measureRef.scrollHeight}px`;
344
+ return;
345
+ }
221
346
  textareaRef.style.height = "auto";
222
347
  textareaRef.style.height = `${Math.min(textareaRef.scrollHeight, composerMaxInputHeight)}px`;
223
348
  };
@@ -225,14 +350,22 @@ export function ChatComposer(props) {
225
350
  onMount(() => {
226
351
  autoResize();
227
352
  if (props.focusToken !== undefined) focus();
353
+ // The copy follows the field's width, so a narrower composer measures more lines.
354
+ if (measureRef && typeof ResizeObserver === "function") {
355
+ const observer = new ResizeObserver(() => autoResize());
356
+ observer.observe(measureRef);
357
+ onCleanup(() => observer.disconnect());
358
+ }
228
359
  });
229
360
  createEffect(() => {
230
361
  commandMatches();
362
+ emojiMatches();
231
363
  setSelectedCommandIndex(0);
232
364
  });
233
365
  createEffect(() => {
234
366
  const index = selectedCommandIndex();
235
367
  commandMatches();
368
+ emojiMatches();
236
369
  queueMicrotask(() => {
237
370
  const list = commandListRef;
238
371
  const item = list?.querySelector(`[id="${commandListId}-${index}"]`);
@@ -268,6 +401,13 @@ export function ChatComposer(props) {
268
401
  _$effect(() => _$setAttribute(_el$2, "title", attachment.name));
269
402
  return _el$;
270
403
  })();
404
+ const chooseFiles = () => {
405
+ const selection = props.fileSelection;
406
+ if (!selection?.choose) return fileInputRef?.click();
407
+ selection.choose().then(
408
+ // A single-file composer keeps the first chosen file, as its file dialog and drops do.
409
+ files => void runFiles(selection.multiple === false ? files.slice(0, 1) : files), error => (props.fileSelection?.onError ?? props.onError)?.(error));
410
+ };
271
411
  const runFiles = async files => {
272
412
  if (!canSelectFiles()) return;
273
413
  const selected = Array.from(files);
@@ -305,8 +445,17 @@ export function ChatComposer(props) {
305
445
  },
306
446
  perform: () => props.onSubmit(input),
307
447
  restore: () => {
308
- props.onValueChange(previousValue);
309
- props.onMentionsChange?.(previousMentions);
448
+ // Text typed while the submission ran stays, after the returned draft. Its mentions are read first, because
449
+ // an application may already move them when the text changes.
450
+ const typed = props.value;
451
+ const typedMentions = mentions();
452
+ const shift = previousValue.length + 1;
453
+ props.onValueChange(typed ? `${previousValue}\n${typed}` : previousValue);
454
+ props.onMentionsChange?.(typed ? [...previousMentions, ...typedMentions.map(mention => ({
455
+ ...mention,
456
+ start: mention.start + shift,
457
+ end: mention.end + shift
458
+ }))] : previousMentions);
310
459
  if (intent !== "steer") setAttachments(previousAttachments);
311
460
  },
312
461
  onError: props.onError
@@ -363,13 +512,74 @@ export function ChatComposer(props) {
363
512
  focus();
364
513
  });
365
514
  };
515
+
516
+ /** Replaces `start`–`end` with the emoji through the editing path, so the browser's undo restores the shortcode. */
517
+ const insertEmoji = (start, end, emoji) => {
518
+ if (!textareaRef || editBlocked()) return;
519
+ replaceTextareaRange(textareaRef, start, end, emoji);
520
+ syncCaret();
521
+ reportChatFailure(() => props.emoji?.onPick?.(emoji), props.onError);
522
+ };
523
+ const pickEmojiSuggestion = position => {
524
+ const token = emojiQuery();
525
+ const entry = emojiMatches()[position];
526
+ if (!token || !entry) return;
527
+ insertEmoji(token.start, token.end, emojiInTone(entry, props.emoji?.skinTone ?? 0));
528
+ };
529
+ /**
530
+ * A typed colon loads the emoji data, and the closing colon of a known `:shortcode:` turns it into its emoji. A
531
+ * shortcode closed before the data arrived turns when it arrives, as long as nothing changed in the meantime.
532
+ */
533
+ const completeShortcode = () => {
534
+ const textarea = textareaRef;
535
+ if (!props.emoji || !textarea) return;
536
+ const {
537
+ value,
538
+ selectionStart: caret
539
+ } = textarea;
540
+ const completed = completedEmojiShortcode(value, caret);
541
+ const convert = index => {
542
+ const entry = completed && index.byShortcode.get(completed.shortcode.toLowerCase());
543
+ if (completed && entry) insertEmoji(completed.start, completed.end, emojiInTone(entry, props.emoji?.skinTone ?? 0));
544
+ };
545
+ const index = emojiIndex();
546
+ if (index) {
547
+ convert(index);
548
+ return;
549
+ }
550
+ loadEmojiIndex().then(loaded => {
551
+ setEmojiIndex(loaded);
552
+ const untouched = textarea.value === value && textarea.selectionStart === caret && textarea.selectionEnd === caret;
553
+ if (untouched && textarea.matches(":focus")) convert(loaded);
554
+ }, () => undefined);
555
+ };
366
556
  const onKeyDown = event => {
367
- if (event.isComposing || composing()) return;
557
+ // WebKit ends the composition before the keydown of the Enter that confirms it; that keydown keeps keyCode 229.
558
+ if (event.isComposing || event.keyCode === 229 || composing()) return;
368
559
  if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "z") {
369
560
  event.preventDefault();
370
561
  restoreHistory(event.shiftKey ? 1 : -1);
371
562
  return;
372
563
  }
564
+ if (emojiOpen()) {
565
+ if (event.key === "ArrowUp" || event.key === "ArrowDown") {
566
+ event.preventDefault();
567
+ setSelectedCommandIndex(index => nextChatCommandIndex(index, emojiMatches().length, event.key === "ArrowUp" ? -1 : 1));
568
+ return;
569
+ }
570
+ // Only a plain Enter or Tab picks: Shift+Enter still breaks the line, Shift+Tab still moves the focus back.
571
+ const plain = !event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey;
572
+ if (plain && (event.key === "Enter" || event.key === "Tab")) {
573
+ event.preventDefault();
574
+ pickEmojiSuggestion(selectedCommandIndex());
575
+ return;
576
+ }
577
+ if (event.key === "Escape") {
578
+ event.preventDefault();
579
+ setDismissed(true);
580
+ return;
581
+ }
582
+ }
373
583
  const matches = commandMatches();
374
584
  if (commandsOpen()) {
375
585
  if (event.key === "ArrowUp" || event.key === "ArrowDown") {
@@ -377,7 +587,8 @@ export function ChatComposer(props) {
377
587
  setSelectedCommandIndex(index => nextChatCommandIndex(index, matches.length, event.key === "ArrowUp" ? -1 : 1));
378
588
  return;
379
589
  }
380
- if ((event.key === "Enter" || event.key === "Tab") && matches.length > 0) {
590
+ // Ctrl/⌘+Enter sends, also while suggestions are open.
591
+ if ((event.key === "Tab" || event.key === "Enter" && !event.ctrlKey && !event.metaKey) && matches.length > 0) {
381
592
  event.preventDefault();
382
593
  const command = selectedCommand();
383
594
  if (command) void executeCommand(command);
@@ -389,79 +600,700 @@ export function ChatComposer(props) {
389
600
  return;
390
601
  }
391
602
  }
392
- if (event.key === "Enter" && !event.shiftKey && !event.isComposing) {
603
+ const format = props.formatting && textareaRef ? formatShortcut(event) : undefined;
604
+ if (format && textareaRef) {
605
+ event.preventDefault();
606
+ format.run(textareaRef);
607
+ return;
608
+ }
609
+ if (event.key !== "Enter") return;
610
+ if (conversation()) {
611
+ const action = conversationEnterAction(event, {
612
+ sendKey: props.sendKey ?? "enter",
613
+ touchOnly: isTouchOnly(),
614
+ inCodeBlock: openCodeFence(props.value, textareaRef?.selectionStart ?? props.value.length) !== null
615
+ });
616
+ if (action === "send") {
617
+ event.preventDefault();
618
+ void submit();
619
+ }
620
+ return;
621
+ }
622
+ const send = props.sendKey === "mod-enter" ? event.ctrlKey || event.metaKey : !event.shiftKey;
623
+ if (send && !event.isComposing) {
393
624
  event.preventDefault();
394
625
  void submit();
395
626
  }
396
627
  };
628
+ const insertText = text => {
629
+ if (!textareaRef || editBlocked()) return;
630
+ replaceTextareaRange(textareaRef, textareaRef.selectionStart, textareaRef.selectionEnd, text);
631
+ };
632
+ let holdTimer;
633
+ let held = false;
634
+ const releaseHold = () => {
635
+ clearTimeout(holdTimer);
636
+ holdTimer = undefined;
637
+ };
638
+ onCleanup(releaseHold);
639
+ const microphoneDisabled = () => Boolean(props.microphone?.disabled || blocked() || dictation() === "refining");
640
+ const microphoneItems = () => {
641
+ const microphone = props.microphone;
642
+ const items = [];
643
+ if (microphone?.onDictate) {
644
+ const dictate = microphone.onDictate;
645
+ items.push({
646
+ icon: "ti ti-microphone",
647
+ label: messages().dictate,
648
+ action: () => reportChatFailure(dictate, props.onError)
649
+ });
650
+ }
651
+ if (microphone?.onVoiceMessage) {
652
+ const record = microphone.onVoiceMessage;
653
+ items.push({
654
+ icon: "ti ti-player-record",
655
+ label: messages().recordVoiceMessage,
656
+ action: () => reportChatFailure(record, props.onError)
657
+ });
658
+ }
659
+ return items;
660
+ };
661
+ const dictationStatus = () => {
662
+ switch (dictation()) {
663
+ case "listening":
664
+ return {
665
+ icon: "ti ti-microphone",
666
+ text: messages().dictationListening
667
+ };
668
+ case "refining":
669
+ return {
670
+ icon: "ti ti-loader-2 k2b-spin",
671
+ text: messages().dictationRefining
672
+ };
673
+ case "refined":
674
+ return {
675
+ icon: "ti ti-sparkles",
676
+ text: messages().dictationRefined
677
+ };
678
+ case "unrefined":
679
+ return {
680
+ icon: "ti ti-microphone",
681
+ text: messages().dictationUnrefined
682
+ };
683
+ case "interrupted":
684
+ return {
685
+ icon: "ti ti-alert-triangle",
686
+ text: messages().dictationInterrupted
687
+ };
688
+ default:
689
+ return null;
690
+ }
691
+ };
692
+ const fileInput = () => _$createComponent(Show, {
693
+ get when() {
694
+ return props.fileSelection;
695
+ },
696
+ get children() {
697
+ var _el$3 = _$getNextElement(_tmpl$2);
698
+ _el$3.addEventListener("change", event => {
699
+ if (event.currentTarget.files?.length) void runFiles(event.currentTarget.files);
700
+ });
701
+ var _ref$ = fileInputRef;
702
+ typeof _ref$ === "function" ? _$use(_ref$, _el$3) : fileInputRef = _el$3;
703
+ _$effect(_p$ => {
704
+ var _v$ = props.fileSelection?.accept,
705
+ _v$2 = props.fileSelection?.multiple ?? true;
706
+ _v$ !== _p$.e && _$setAttribute(_el$3, "accept", _p$.e = _v$);
707
+ _v$2 !== _p$.t && _$setProperty(_el$3, "multiple", _p$.t = _v$2);
708
+ return _p$;
709
+ }, {
710
+ e: undefined,
711
+ t: undefined
712
+ });
713
+ return _el$3;
714
+ }
715
+ });
716
+ const addMenu = (icon, extraClass = "") => _$createComponent(Dropdown.Root, {
717
+ position: "top-right",
718
+ get label() {
719
+ return messages().addToChat;
720
+ },
721
+ get items() {
722
+ return menuItems();
723
+ },
724
+ get disabled() {
725
+ return blocked();
726
+ },
727
+ get children() {
728
+ return _$createComponent(Dropdown.Trigger, {
729
+ appearance: "plain",
730
+ "class": `k2b-chat-composer__icon-action${extraClass}`,
731
+ get label() {
732
+ return messages().addToChat;
733
+ },
734
+ get tooltip() {
735
+ return messages().addToChat;
736
+ },
737
+ get children() {
738
+ var _el$4 = _$getNextElement(_tmpl$3);
739
+ _$className(_el$4, icon);
740
+ return _el$4;
741
+ }
742
+ });
743
+ }
744
+ });
745
+
746
+ /** The conversation's attach button opens the file choice directly; other actions turn it into the add menu. */
747
+ const attachControl = () => _$createComponent(Show, {
748
+ get when() {
749
+ return props.menuActions?.length;
750
+ },
751
+ get fallback() {
752
+ return _$createComponent(Show, {
753
+ get when() {
754
+ return props.fileSelection;
755
+ },
756
+ children: selection => _$createComponent(Tooltip.Trigger, {
757
+ type: "button",
758
+ "class": "k2b-chat-composer__icon-action k2b-chat-composer__attach",
759
+ get ["aria-label"]() {
760
+ return selection().label ?? messages().attachFiles;
761
+ },
762
+ get content() {
763
+ return selection().label ?? messages().attachFiles;
764
+ },
765
+ get disabled() {
766
+ return !canSelectFiles();
767
+ },
768
+ onClick: chooseFiles,
769
+ get children() {
770
+ var _el$5 = _$getNextElement(_tmpl$3);
771
+ _$effect(() => _$className(_el$5, addingFiles() ? "ti ti-loader-2 k2b-spin" : "ti ti-paperclip"));
772
+ return _el$5;
773
+ }
774
+ })
775
+ });
776
+ },
777
+ get children() {
778
+ return addMenu("ti ti-plus", " k2b-chat-composer__attach");
779
+ }
780
+ });
781
+ const formatToggle = () => _$createComponent(Show, {
782
+ get when() {
783
+ return props.formatting;
784
+ },
785
+ get children() {
786
+ return _$createComponent(Tooltip.Trigger, {
787
+ type: "button",
788
+ "class": "k2b-chat-composer__icon-action k2b-chat-composer__format-toggle",
789
+ get ["aria-label"]() {
790
+ return messages().composerFormatting;
791
+ },
792
+ get ["aria-pressed"]() {
793
+ return formattingOpen();
794
+ },
795
+ get ["aria-controls"]() {
796
+ return formattingOpen() ? formatGroupId : undefined;
797
+ },
798
+ get content() {
799
+ return messages().composerFormatting;
800
+ },
801
+ onMouseDown: keepFieldFocus,
802
+ onClick: () => setFormattingOpen(open => !open),
803
+ get children() {
804
+ return _$getNextElement(_tmpl$4);
805
+ }
806
+ });
807
+ }
808
+ });
809
+
810
+ /** One row of fixed height. It shows every button at once, also on a phone, so nothing hides behind a scroll. */
811
+ const formatRow = () => _$createComponent(Show, {
812
+ get when() {
813
+ return _$memo(() => !!props.formatting)() && formattingOpen();
814
+ },
815
+ get children() {
816
+ var _el$7 = _$getNextElement(_tmpl$5);
817
+ _$setAttribute(_el$7, "id", formatGroupId);
818
+ _$insert(_el$7, _$createComponent(For, {
819
+ each: formatTools,
820
+ children: tool => _$createComponent(Tooltip.Trigger, {
821
+ type: "button",
822
+ "class": "k2b-chat-composer__icon-action",
823
+ get ["aria-label"]() {
824
+ return tool.label(messages());
825
+ },
826
+ get content() {
827
+ return tool.label(messages());
828
+ },
829
+ get disabled() {
830
+ return editBlocked();
831
+ },
832
+ onMouseDown: keepFieldFocus,
833
+ onClick: () => {
834
+ if (textareaRef) tool.run(textareaRef);
835
+ },
836
+ get children() {
837
+ var _el$8 = _$getNextElement(_tmpl$3);
838
+ _$effect(() => _$className(_el$8, tool.icon));
839
+ return _el$8;
840
+ }
841
+ })
842
+ }));
843
+ _$effect(() => _$setAttribute(_el$7, "aria-label", messages().composerFormatting));
844
+ return _el$7;
845
+ }
846
+ });
847
+ const emojiButton = () => _$createComponent(Show, {
848
+ get when() {
849
+ return props.emoji;
850
+ },
851
+ children: emoji => _$createComponent(Tooltip.Trigger, {
852
+ type: "button",
853
+ "class": "k2b-chat-composer__icon-action k2b-chat-composer__emoji",
854
+ get ["aria-label"]() {
855
+ return messages().insertEmoji;
856
+ },
857
+ get content() {
858
+ return messages().insertEmoji;
859
+ },
860
+ get disabled() {
861
+ return editBlocked();
862
+ },
863
+ onMouseDown: keepFieldFocus,
864
+ onClick: event => {
865
+ const anchor = event.currentTarget;
866
+ reportChatFailure(() => emoji().onOpen({
867
+ anchor,
868
+ insert: insertText
869
+ }), props.onError);
870
+ },
871
+ get children() {
872
+ return _$getNextElement(_tmpl$6);
873
+ }
874
+ })
875
+ });
876
+ const microphoneControl = () => _$createComponent(Show, {
877
+ get when() {
878
+ return _$memo(() => !!(props.microphone?.onDictate || props.microphone?.onVoiceMessage))() ? props.microphone : undefined;
879
+ },
880
+ children: microphone => (() => {
881
+ var _el$0 = _$getNextElement(_tmpl$8),
882
+ _el$11 = _el$0.firstChild,
883
+ [_el$12, _co$] = _$getNextMarker(_el$11.nextSibling),
884
+ _el$13 = _el$12.nextSibling,
885
+ [_el$14, _co$2] = _$getNextMarker(_el$13.nextSibling);
886
+ var _ref$2 = microphoneRef;
887
+ typeof _ref$2 === "function" ? _$use(_ref$2, _el$0) : microphoneRef = _el$0;
888
+ _$insert(_el$0, _$createComponent(Tooltip.Trigger, {
889
+ type: "button",
890
+ "class": "k2b-chat-composer__icon-action k2b-chat-composer__microphone-button",
891
+ get ["data-state"]() {
892
+ return dictation() ?? undefined;
893
+ },
894
+ get disabled() {
895
+ return microphoneDisabled();
896
+ },
897
+ get ["aria-pressed"]() {
898
+ return _$memo(() => !!microphone().onDictate)() ? dictation() === "listening" : undefined;
899
+ },
900
+ get ["aria-haspopup"]() {
901
+ return microphone().onDictate ? undefined : "menu";
902
+ },
903
+ get ["aria-expanded"]() {
904
+ return _$memo(() => !!microphone().onDictate)() ? undefined : microphoneMenuOpen();
905
+ },
906
+ get ["aria-label"]() {
907
+ return _$memo(() => !!microphone().onDictate)() ? messages().dictate : messages().recordVoiceMessage;
908
+ },
909
+ get content() {
910
+ return _$memo(() => dictation() === "listening")() ? messages().stopDictation : _$memo(() => !!microphone().onDictate)() ? _$memo(() => !!microphone().onVoiceMessage)() ? messages().dictateOrHold : messages().dictate : messages().recordVoiceMessage;
911
+ },
912
+ onMouseDown: keepFieldFocus,
913
+ onContextMenu: event => event.preventDefault(),
914
+ onPointerDown: event => {
915
+ held = false;
916
+ releaseHold();
917
+ const record = microphone().onVoiceMessage;
918
+ if (event.button !== 0 || !record || dictation() === "listening") return;
919
+ holdTimer = setTimeout(() => {
920
+ // The composer may have become blocked, or recording withdrawn, during the press.
921
+ const current = props.microphone?.onVoiceMessage;
922
+ if (!current || microphoneDisabled()) return;
923
+ held = true;
924
+ reportChatFailure(current, props.onError);
925
+ }, microphoneHoldMs);
926
+ },
927
+ onPointerUp: releaseHold,
928
+ onPointerCancel: releaseHold,
929
+ onPointerLeave: releaseHold,
930
+ onClick: event => {
931
+ // A press that already asked for a voice message ends here; a key press never holds.
932
+ if (held) {
933
+ held = false;
934
+ if (event.detail > 0) return;
935
+ }
936
+ const dictate = microphone().onDictate;
937
+ if (dictate) {
938
+ reportChatFailure(dictate, props.onError);
939
+ return;
940
+ }
941
+ setMicrophoneMenuOpen(true);
942
+ // From the keyboard it opens the menu like a menu button: the focus moves to the first item.
943
+ if (event.detail === 0) {
944
+ queueMicrotask(() => microphoneRef?.querySelector('[role="menuitem"]:not(:disabled)')?.focus());
945
+ }
946
+ },
947
+ get children() {
948
+ var _el$1 = _$getNextElement(_tmpl$3);
949
+ _$effect(() => _$className(_el$1, dictation() === "listening" ? "ti ti-player-stop" : dictation() === "refining" ? "ti ti-loader-2 k2b-spin" : "ti ti-microphone"));
950
+ return _el$1;
951
+ }
952
+ }), _el$12, _co$);
953
+ _$insert(_el$0, _$createComponent(Show, {
954
+ get when() {
955
+ return microphone().onVoiceMessage;
956
+ },
957
+ get children() {
958
+ return _$createComponent(Dropdown.Root, {
959
+ position: "top-left",
960
+ get label() {
961
+ return messages().microphoneOptions;
962
+ },
963
+ get items() {
964
+ return microphoneItems();
965
+ },
966
+ get disabled() {
967
+ return microphoneDisabled();
968
+ },
969
+ get open() {
970
+ return microphoneMenuOpen();
971
+ },
972
+ onOpenChange: setMicrophoneMenuOpen,
973
+ get children() {
974
+ return _$createComponent(Dropdown.Trigger, {
975
+ appearance: "plain",
976
+ "class": "k2b-chat-composer__icon-action k2b-chat-composer__microphone-menu",
977
+ get label() {
978
+ return messages().microphoneOptions;
979
+ },
980
+ get tooltip() {
981
+ return messages().microphoneOptions;
982
+ },
983
+ get children() {
984
+ return _$getNextElement(_tmpl$7);
985
+ }
986
+ });
987
+ }
988
+ });
989
+ }
990
+ }), _el$14, _co$2);
991
+ return _el$0;
992
+ })()
993
+ });
994
+ const sendControl = () => _$createComponent(Show, {
995
+ get when() {
996
+ return _$memo(() => !!(running() && !hasDraft()))() && props.onStop;
997
+ },
998
+ get fallback() {
999
+ return _$createComponent(Tooltip.Trigger, {
1000
+ type: "button",
1001
+ "class": "k2b-chat-composer__send",
1002
+ get disabled() {
1003
+ return !canSubmit();
1004
+ },
1005
+ onMouseDown: event => {
1006
+ if (conversation()) keepFieldFocus(event);
1007
+ },
1008
+ get ["aria-label"]() {
1009
+ return _$memo(() => !!submitting())() ? _$memo(() => !!running())() ? _$memo(() => runningSubmitIntent() === "queue")() ? messages().queueing : messages().steering : messages().sending : _$memo(() => !!running())() ? _$memo(() => runningSubmitIntent() === "queue")() ? messages().queueMessage : messages().steerResponse : messages().sendMessage;
1010
+ },
1011
+ get content() {
1012
+ return _$memo(() => !!running())() ? _$memo(() => runningSubmitIntent() === "queue")() ? messages().queueMessage : messages().steerResponse : messages().sendMessage;
1013
+ },
1014
+ onClick: () => void submit(),
1015
+ get children() {
1016
+ var _el$16 = _$getNextElement(_tmpl$3);
1017
+ _$effect(() => _$className(_el$16, submitting() ? "ti ti-loader-2 k2b-spin" : conversation() ? "ti ti-send" : "ti ti-arrow-up"));
1018
+ return _el$16;
1019
+ }
1020
+ });
1021
+ },
1022
+ get children() {
1023
+ return _$createComponent(Tooltip.Trigger, {
1024
+ type: "button",
1025
+ "class": "k2b-chat-composer__stop",
1026
+ get disabled() {
1027
+ return stopping();
1028
+ },
1029
+ get ["aria-label"]() {
1030
+ return _$memo(() => !!stopping())() ? messages().stopping : messages().stopResponse;
1031
+ },
1032
+ get content() {
1033
+ return messages().stopResponse;
1034
+ },
1035
+ onClick: () => reportChatFailure(() => props.onStop?.(), props.onError),
1036
+ get children() {
1037
+ var _el$15 = _$getNextElement(_tmpl$3);
1038
+ _$effect(() => _$className(_el$15, stopping() ? "ti ti-loader-2 k2b-spin" : "ti ti-player-stop"));
1039
+ return _el$15;
1040
+ }
1041
+ });
1042
+ }
1043
+ });
1044
+ const field = () => (() => {
1045
+ var _el$17 = _$getNextElement(_tmpl$1),
1046
+ _el$24 = _el$17.firstChild,
1047
+ [_el$25, _co$4] = _$getNextMarker(_el$24.nextSibling),
1048
+ _el$22 = _el$25.nextSibling,
1049
+ _el$26 = _el$22.nextSibling,
1050
+ [_el$27, _co$5] = _$getNextMarker(_el$26.nextSibling);
1051
+ _$insert(_el$17, _$createComponent(Show, {
1052
+ get when() {
1053
+ return mentions().length > 0;
1054
+ },
1055
+ get children() {
1056
+ var _el$18 = _$getNextElement(_tmpl$9),
1057
+ _el$20 = _el$18.firstChild,
1058
+ [_el$21, _co$3] = _$getNextMarker(_el$20.nextSibling),
1059
+ _el$19 = _el$21.nextSibling;
1060
+ var _ref$3 = highlightRef;
1061
+ typeof _ref$3 === "function" ? _$use(_ref$3, _el$18) : highlightRef = _el$18;
1062
+ _$insert(_el$18, _$createComponent(For, {
1063
+ get each() {
1064
+ return chatMentionSegments(props.value, mentions());
1065
+ },
1066
+ children: part => (() => {
1067
+ var _el$28 = _$getNextElement(_tmpl$10);
1068
+ _$insert(_el$28, () => part.text);
1069
+ _$effect(() => _el$28.classList.toggle("k2b-chat-composer__mention", !!Boolean(part.mention)));
1070
+ return _el$28;
1071
+ })()
1072
+ }), _el$21, _co$3);
1073
+ return _el$18;
1074
+ }
1075
+ }), _el$25, _co$4);
1076
+ _el$22.$$keydown = onKeyDown;
1077
+ _el$22.$$beforeinput = event => {
1078
+ if (event.inputType === "historyUndo" || event.inputType === "historyRedo") {
1079
+ event.preventDefault();
1080
+ restoreHistory(event.inputType === "historyUndo" ? -1 : 1);
1081
+ }
1082
+ };
1083
+ _el$22.addEventListener("scroll", () => {
1084
+ if (highlightRef && textareaRef) highlightRef.scrollTop = textareaRef.scrollTop;
1085
+ });
1086
+ _el$22.addEventListener("compositionend", () => {
1087
+ setComposing(false);
1088
+ syncCaret();
1089
+ });
1090
+ _el$22.addEventListener("compositionstart", () => setComposing(true));
1091
+ _el$22.$$keyup = syncCaret;
1092
+ _el$22.$$click = () => {
1093
+ setDismissed(false);
1094
+ syncCaret();
1095
+ };
1096
+ _el$22.addEventListener("blur", () => setDismissed(true));
1097
+ _el$22.addEventListener("select", syncCaret);
1098
+ _el$22.addEventListener("paste", event => {
1099
+ const clipboardData = event.clipboardData;
1100
+ if (canSelectFiles() && clipboardData?.files.length) {
1101
+ event.preventDefault();
1102
+ void runFiles(clipboardData.files);
1103
+ return;
1104
+ }
1105
+ props.onPaste?.(event);
1106
+ });
1107
+ _el$22.$$input = event => {
1108
+ edit(event.currentTarget.value);
1109
+ syncCaret();
1110
+ autoResize();
1111
+ const input = event;
1112
+ if (input.inputType === "insertText" && input.data === ":") queueMicrotask(completeShortcode);
1113
+ };
1114
+ var _ref$4 = textareaRef;
1115
+ typeof _ref$4 === "function" ? _$use(_ref$4, _el$22) : textareaRef = _el$22;
1116
+ _$insert(_el$17, _$createComponent(Show, {
1117
+ get when() {
1118
+ return conversation();
1119
+ },
1120
+ get children() {
1121
+ var _el$23 = _$getNextElement(_tmpl$0);
1122
+ var _ref$5 = measureRef;
1123
+ typeof _ref$5 === "function" ? _$use(_ref$5, _el$23) : measureRef = _el$23;
1124
+ return _el$23;
1125
+ }
1126
+ }), _el$27, _co$5);
1127
+ _$effect(_p$ => {
1128
+ var _v$3 = messages().messageInput,
1129
+ _v$4 = !!(mentions().length > 0),
1130
+ _v$5 = editBlocked(),
1131
+ _v$6 = conversation() ? "enter" : undefined,
1132
+ _v$7 = props.placeholder ?? (running() ? messages().addGuidance : conversation() ? messages().writeConversationMessage : messages().writeMessage),
1133
+ _v$8 = props.inputLabel ?? messages().message,
1134
+ _v$9 = suggestionsOpen() ? "combobox" : undefined,
1135
+ _v$0 = suggestionsOpen() ? "list" : undefined,
1136
+ _v$1 = suggestionsOpen() ? commandListId : undefined,
1137
+ _v$10 = suggestionsOpen() ? "true" : undefined,
1138
+ _v$11 = (emojiOpen() ? emojiMatches()[selectedCommandIndex()] : selectedCommand()) ? `${commandListId}-${selectedCommandIndex()}` : undefined;
1139
+ _v$3 !== _p$.e && _$setAttribute(_el$17, "aria-label", _p$.e = _v$3);
1140
+ _v$4 !== _p$.t && _el$22.classList.toggle("k2b-chat-composer__textarea--highlighted", _p$.t = _v$4);
1141
+ _v$5 !== _p$.a && _$setProperty(_el$22, "disabled", _p$.a = _v$5);
1142
+ _v$6 !== _p$.o && _$setAttribute(_el$22, "enterkeyhint", _p$.o = _v$6);
1143
+ _v$7 !== _p$.i && _$setAttribute(_el$22, "placeholder", _p$.i = _v$7);
1144
+ _v$8 !== _p$.n && _$setAttribute(_el$22, "aria-label", _p$.n = _v$8);
1145
+ _v$9 !== _p$.s && _$setAttribute(_el$22, "role", _p$.s = _v$9);
1146
+ _v$0 !== _p$.h && _$setAttribute(_el$22, "aria-autocomplete", _p$.h = _v$0);
1147
+ _v$1 !== _p$.r && _$setAttribute(_el$22, "aria-controls", _p$.r = _v$1);
1148
+ _v$10 !== _p$.d && _$setAttribute(_el$22, "aria-expanded", _p$.d = _v$10);
1149
+ _v$11 !== _p$.l && _$setAttribute(_el$22, "aria-activedescendant", _p$.l = _v$11);
1150
+ return _p$;
1151
+ }, {
1152
+ e: undefined,
1153
+ t: undefined,
1154
+ a: undefined,
1155
+ o: undefined,
1156
+ i: undefined,
1157
+ n: undefined,
1158
+ s: undefined,
1159
+ h: undefined,
1160
+ r: undefined,
1161
+ d: undefined,
1162
+ l: undefined
1163
+ });
1164
+ _$effect(() => _$setProperty(_el$22, "value", props.value));
1165
+ _$runHydrationEvents();
1166
+ return _el$17;
1167
+ })();
397
1168
  return (() => {
398
- var _el$3 = _$getNextElement(_tmpl$0),
399
- _el$46 = _el$3.firstChild,
400
- [_el$47, _co$11] = _$getNextMarker(_el$46.nextSibling),
401
- _el$25 = _el$47.nextSibling,
402
- _el$40 = _el$25.firstChild,
403
- [_el$41, _co$0] = _$getNextMarker(_el$40.nextSibling),
404
- _el$27 = _el$41.nextSibling,
405
- _el$33 = _el$27.firstChild,
406
- [_el$34, _co$8] = _$getNextMarker(_el$33.nextSibling),
407
- _el$32 = _el$34.nextSibling,
408
- _el$42 = _el$27.nextSibling,
409
- [_el$43, _co$1] = _$getNextMarker(_el$42.nextSibling),
410
- _el$39 = _el$43.nextSibling,
411
- _el$44 = _el$39.nextSibling,
412
- [_el$45, _co$10] = _$getNextMarker(_el$44.nextSibling);
413
- _$insert(_el$3, _$createComponent(Show, {
1169
+ var _el$29 = _$getNextElement(_tmpl$21),
1170
+ _el$89 = _el$29.firstChild,
1171
+ [_el$90, _co$23] = _$getNextMarker(_el$89.nextSibling),
1172
+ _el$57 = _el$90.nextSibling,
1173
+ _el$81 = _el$57.firstChild,
1174
+ [_el$82, _co$19] = _$getNextMarker(_el$81.nextSibling),
1175
+ _el$83 = _el$82.nextSibling,
1176
+ [_el$84, _co$20] = _$getNextMarker(_el$83.nextSibling),
1177
+ _el$85 = _el$84.nextSibling,
1178
+ [_el$86, _co$21] = _$getNextMarker(_el$85.nextSibling),
1179
+ _el$87 = _el$86.nextSibling,
1180
+ [_el$88, _co$22] = _$getNextMarker(_el$87.nextSibling);
1181
+ _$insert(_el$29, _$createComponent(Show, {
414
1182
  get when() {
415
- return commandsOpen() || hasAccessory();
1183
+ return suggestionsOpen() || hasAccessory();
416
1184
  },
417
1185
  get children() {
418
- var _el$4 = _$getNextElement(_tmpl$6),
419
- _el$5 = _el$4.firstChild,
420
- _el$23 = _el$5.nextSibling,
421
- [_el$24, _co$6] = _$getNextMarker(_el$23.nextSibling);
422
- _$insert(_el$5, accessory);
423
- _$insert(_el$4, _$createComponent(Show, {
1186
+ var _el$30 = _$getNextElement(_tmpl$16),
1187
+ _el$31 = _el$30.firstChild,
1188
+ _el$53 = _el$31.nextSibling,
1189
+ [_el$54, _co$1] = _$getNextMarker(_el$53.nextSibling),
1190
+ _el$55 = _el$54.nextSibling,
1191
+ [_el$56, _co$10] = _$getNextMarker(_el$55.nextSibling);
1192
+ _$insert(_el$31, accessory);
1193
+ _$insert(_el$30, _$createComponent(Show, {
1194
+ get when() {
1195
+ return emojiOpen();
1196
+ },
1197
+ get children() {
1198
+ var _el$32 = _$getNextElement(_tmpl$11),
1199
+ _el$33 = _el$32.firstChild;
1200
+ var _ref$6 = commandListRef;
1201
+ typeof _ref$6 === "function" ? _$use(_ref$6, _el$33) : commandListRef = _el$33;
1202
+ _$setAttribute(_el$33, "id", commandListId);
1203
+ _$insert(_el$33, _$createComponent(For, {
1204
+ get each() {
1205
+ return emojiMatches();
1206
+ },
1207
+ children: (entry, index) => (() => {
1208
+ var _el$91 = _$getNextElement(_tmpl$22),
1209
+ _el$92 = _el$91.firstChild,
1210
+ _el$93 = _el$92.nextSibling,
1211
+ _el$94 = _el$93.nextSibling,
1212
+ [_el$95, _co$24] = _$getNextMarker(_el$94.nextSibling);
1213
+ _el$91.$$click = () => pickEmojiSuggestion(index());
1214
+ _el$91.$$pointerdown = event => event.preventDefault();
1215
+ _$insert(_el$92, () => emojiInTone(entry, props.emoji?.skinTone ?? 0));
1216
+ _$insert(_el$93, () => emojiName(entry, locale()));
1217
+ _$insert(_el$91, _$createComponent(Show, {
1218
+ get when() {
1219
+ return entry.shortcodes[0];
1220
+ },
1221
+ children: code => (() => {
1222
+ var _el$96 = _$getNextElement(_tmpl$23),
1223
+ _el$97 = _el$96.firstChild,
1224
+ _el$99 = _el$97.nextSibling,
1225
+ [_el$100, _co$25] = _$getNextMarker(_el$99.nextSibling),
1226
+ _el$98 = _el$100.nextSibling;
1227
+ _$insert(_el$96, code, _el$100, _co$25);
1228
+ return _el$96;
1229
+ })()
1230
+ }), _el$95, _co$24);
1231
+ _$effect(_p$ => {
1232
+ var _v$19 = `${commandListId}-${index()}`,
1233
+ _v$20 = index() === selectedCommandIndex(),
1234
+ _v$21 = emojiName(entry, locale()),
1235
+ _v$22 = index() === selectedCommandIndex() ? "true" : undefined;
1236
+ _v$19 !== _p$.e && _$setAttribute(_el$91, "id", _p$.e = _v$19);
1237
+ _v$20 !== _p$.t && _$setAttribute(_el$91, "aria-selected", _p$.t = _v$20);
1238
+ _v$21 !== _p$.a && _$setAttribute(_el$91, "aria-label", _p$.a = _v$21);
1239
+ _v$22 !== _p$.o && _$setAttribute(_el$91, "data-active", _p$.o = _v$22);
1240
+ return _p$;
1241
+ }, {
1242
+ e: undefined,
1243
+ t: undefined,
1244
+ a: undefined,
1245
+ o: undefined
1246
+ });
1247
+ _$runHydrationEvents();
1248
+ return _el$91;
1249
+ })()
1250
+ }));
1251
+ _$effect(() => _$setAttribute(_el$33, "aria-label", messages().emojiSuggestions));
1252
+ return _el$32;
1253
+ }
1254
+ }), _el$54, _co$1);
1255
+ _$insert(_el$30, _$createComponent(Show, {
424
1256
  get when() {
425
1257
  return commandsOpen();
426
1258
  },
427
1259
  get children() {
428
- var _el$6 = _$getNextElement(_tmpl$5),
429
- _el$7 = _el$6.firstChild,
430
- _el$15 = _el$7.firstChild,
431
- [_el$16, _co$2] = _$getNextMarker(_el$15.nextSibling),
432
- _el$17 = _el$16.nextSibling,
433
- [_el$18, _co$3] = _$getNextMarker(_el$17.nextSibling),
434
- _el$19 = _el$18.nextSibling,
435
- [_el$20, _co$4] = _$getNextMarker(_el$19.nextSibling),
436
- _el$21 = _el$20.nextSibling,
437
- [_el$22, _co$5] = _$getNextMarker(_el$21.nextSibling);
438
- var _ref$ = commandListRef;
439
- typeof _ref$ === "function" ? _$use(_ref$, _el$7) : commandListRef = _el$7;
440
- _$setAttribute(_el$7, "id", commandListId);
441
- _$insert(_el$7, _$createComponent(For, {
1260
+ var _el$34 = _$getNextElement(_tmpl$15),
1261
+ _el$35 = _el$34.firstChild,
1262
+ _el$45 = _el$35.firstChild,
1263
+ [_el$46, _co$7] = _$getNextMarker(_el$45.nextSibling),
1264
+ _el$47 = _el$46.nextSibling,
1265
+ [_el$48, _co$8] = _$getNextMarker(_el$47.nextSibling),
1266
+ _el$49 = _el$48.nextSibling,
1267
+ [_el$50, _co$9] = _$getNextMarker(_el$49.nextSibling),
1268
+ _el$51 = _el$50.nextSibling,
1269
+ [_el$52, _co$0] = _$getNextMarker(_el$51.nextSibling);
1270
+ var _ref$7 = commandListRef;
1271
+ typeof _ref$7 === "function" ? _$use(_ref$7, _el$35) : commandListRef = _el$35;
1272
+ _$setAttribute(_el$35, "id", commandListId);
1273
+ _$insert(_el$35, _$createComponent(For, {
442
1274
  get each() {
443
1275
  return commandMatches();
444
1276
  },
445
1277
  children: (command, index) => (() => {
446
- var _el$48 = _$getNextElement(_tmpl$1),
447
- _el$49 = _el$48.firstChild,
448
- _el$50 = _el$49.nextSibling,
449
- _el$51 = _el$50.nextSibling;
450
- _el$48.$$click = () => void executeCommand(command);
451
- _el$48.$$pointerdown = event => event.preventDefault();
452
- _$insert(_el$50, () => command.label ?? `/${command.name}`);
453
- _$insert(_el$51, () => command.description);
1278
+ var _el$101 = _$getNextElement(_tmpl$24),
1279
+ _el$102 = _el$101.firstChild,
1280
+ _el$103 = _el$102.nextSibling,
1281
+ _el$104 = _el$103.nextSibling;
1282
+ _el$101.$$click = () => void executeCommand(command);
1283
+ _el$101.$$pointerdown = event => event.preventDefault();
1284
+ _$insert(_el$103, () => command.label ?? `/${command.name}`);
1285
+ _$insert(_el$104, () => command.description);
454
1286
  _$effect(_p$ => {
455
- var _v$14 = `${commandListId}-${index()}`,
456
- _v$15 = index() === selectedCommandIndex(),
457
- _v$16 = command.disabled,
458
- _v$17 = index() === selectedCommandIndex() ? "true" : undefined,
459
- _v$18 = command.icon ?? "ti ti-slash";
460
- _v$14 !== _p$.e && _$setAttribute(_el$48, "id", _p$.e = _v$14);
461
- _v$15 !== _p$.t && _$setAttribute(_el$48, "aria-selected", _p$.t = _v$15);
462
- _v$16 !== _p$.a && _$setAttribute(_el$48, "aria-disabled", _p$.a = _v$16);
463
- _v$17 !== _p$.o && _$setAttribute(_el$48, "data-active", _p$.o = _v$17);
464
- _v$18 !== _p$.i && _$className(_el$49, _p$.i = _v$18);
1287
+ var _v$23 = `${commandListId}-${index()}`,
1288
+ _v$24 = index() === selectedCommandIndex(),
1289
+ _v$25 = command.disabled,
1290
+ _v$26 = index() === selectedCommandIndex() ? "true" : undefined,
1291
+ _v$27 = command.icon ?? "ti ti-slash";
1292
+ _v$23 !== _p$.e && _$setAttribute(_el$101, "id", _p$.e = _v$23);
1293
+ _v$24 !== _p$.t && _$setAttribute(_el$101, "aria-selected", _p$.t = _v$24);
1294
+ _v$25 !== _p$.a && _$setAttribute(_el$101, "aria-disabled", _p$.a = _v$25);
1295
+ _v$26 !== _p$.o && _$setAttribute(_el$101, "data-active", _p$.o = _v$26);
1296
+ _v$27 !== _p$.i && _$className(_el$102, _p$.i = _v$27);
465
1297
  return _p$;
466
1298
  }, {
467
1299
  e: undefined,
@@ -471,526 +1303,482 @@ export function ChatComposer(props) {
471
1303
  i: undefined
472
1304
  });
473
1305
  _$runHydrationEvents();
474
- return _el$48;
1306
+ return _el$101;
475
1307
  })()
476
- }), _el$16, _co$2);
477
- _$insert(_el$7, _$createComponent(Show, {
1308
+ }), _el$46, _co$7);
1309
+ _$insert(_el$35, _$createComponent(Show, {
478
1310
  get when() {
479
1311
  return searching();
480
1312
  },
481
1313
  get children() {
482
- var _el$8 = _$getNextElement(_tmpl$2),
483
- _el$9 = _el$8.firstChild,
484
- _el$0 = _el$9.nextSibling;
485
- _$insert(_el$0, () => messages().loading);
486
- return _el$8;
1314
+ var _el$36 = _$getNextElement(_tmpl$12),
1315
+ _el$37 = _el$36.firstChild,
1316
+ _el$38 = _el$37.nextSibling;
1317
+ _$insert(_el$38, () => messages().loading);
1318
+ return _el$36;
487
1319
  }
488
- }), _el$18, _co$3);
489
- _$insert(_el$7, _$createComponent(Show, {
1320
+ }), _el$48, _co$8);
1321
+ _$insert(_el$35, _$createComponent(Show, {
490
1322
  get when() {
491
1323
  return searchError();
492
1324
  },
493
1325
  get children() {
494
- var _el$1 = _$getNextElement(_tmpl$3),
495
- _el$10 = _el$1.firstChild,
496
- _el$11 = _el$10.nextSibling,
497
- _el$12 = _el$11.nextSibling,
498
- [_el$13, _co$] = _$getNextMarker(_el$12.nextSibling);
499
- _$insert(_el$1, () => messages().error, _el$13, _co$);
500
- return _el$1;
1326
+ var _el$39 = _$getNextElement(_tmpl$13),
1327
+ _el$40 = _el$39.firstChild,
1328
+ _el$41 = _el$40.nextSibling,
1329
+ _el$42 = _el$41.nextSibling,
1330
+ [_el$43, _co$6] = _$getNextMarker(_el$42.nextSibling);
1331
+ _$insert(_el$39, () => messages().error, _el$43, _co$6);
1332
+ return _el$39;
501
1333
  }
502
- }), _el$20, _co$4);
503
- _$insert(_el$7, _$createComponent(Show, {
1334
+ }), _el$50, _co$9);
1335
+ _$insert(_el$35, _$createComponent(Show, {
504
1336
  get when() {
505
1337
  return _$memo(() => !!(!searching() && !searchError()))() && commandMatches().length === 0;
506
1338
  },
507
1339
  get children() {
508
- var _el$14 = _$getNextElement(_tmpl$4);
509
- _$insert(_el$14, () => messages().noResults);
510
- return _el$14;
1340
+ var _el$44 = _$getNextElement(_tmpl$14);
1341
+ _$insert(_el$44, () => messages().noResults);
1342
+ return _el$44;
511
1343
  }
512
- }), _el$22, _co$5);
513
- _$effect(() => _$setAttribute(_el$7, "aria-label", messages().commands));
514
- return _el$6;
1344
+ }), _el$52, _co$0);
1345
+ _$effect(() => _$setAttribute(_el$35, "aria-label", messages().commands));
1346
+ return _el$34;
515
1347
  }
516
- }), _el$24, _co$6);
1348
+ }), _el$56, _co$10);
517
1349
  _$effect(_p$ => {
518
- var _v$ = commandsOpen() ? "hidden" : undefined,
519
- _v$2 = commandsOpen();
520
- _v$ !== _p$.e && _$setStyleProperty(_el$5, "visibility", _p$.e = _v$);
521
- _v$2 !== _p$.t && _$setProperty(_el$5, "inert", _p$.t = _v$2);
1350
+ var _v$12 = hasAccessory() ? undefined : "true",
1351
+ _v$13 = suggestionsOpen() ? "hidden" : undefined,
1352
+ _v$14 = suggestionsOpen();
1353
+ _v$12 !== _p$.e && _$setAttribute(_el$30, "data-overlay", _p$.e = _v$12);
1354
+ _v$13 !== _p$.t && _$setStyleProperty(_el$31, "visibility", _p$.t = _v$13);
1355
+ _v$14 !== _p$.a && _$setProperty(_el$31, "inert", _p$.a = _v$14);
522
1356
  return _p$;
523
1357
  }, {
524
1358
  e: undefined,
525
- t: undefined
1359
+ t: undefined,
1360
+ a: undefined
526
1361
  });
527
- return _el$4;
1362
+ return _el$30;
1363
+ }
1364
+ }), _el$90, _co$23);
1365
+ var _ref$8 = composerRef;
1366
+ typeof _ref$8 === "function" ? _$use(_ref$8, _el$57) : composerRef = _el$57;
1367
+ _$insert(_el$57, _$createComponent(Show, {
1368
+ get when() {
1369
+ return showHint();
1370
+ },
1371
+ get children() {
1372
+ var _el$58 = _$getNextElement(_tmpl$17);
1373
+ _$insert(_el$58, _$createComponent(Show, {
1374
+ get when() {
1375
+ return dictationStatus();
1376
+ },
1377
+ get fallback() {
1378
+ return (() => {
1379
+ var _el$105 = _$getNextElement(_tmpl$25);
1380
+ _$insert(_el$105, hint);
1381
+ return _el$105;
1382
+ })();
1383
+ },
1384
+ children: status => [(() => {
1385
+ var _el$106 = _$getNextElement(_tmpl$26),
1386
+ _el$107 = _el$106.firstChild,
1387
+ _el$108 = _el$107.nextSibling;
1388
+ _$insert(_el$108, () => status().text);
1389
+ _$effect(_p$ => {
1390
+ var _v$28 = dictation() ?? undefined,
1391
+ _v$29 = status().icon;
1392
+ _v$28 !== _p$.e && _$setAttribute(_el$106, "data-state", _p$.e = _v$28);
1393
+ _v$29 !== _p$.t && _$className(_el$107, _p$.t = _v$29);
1394
+ return _p$;
1395
+ }, {
1396
+ e: undefined,
1397
+ t: undefined
1398
+ });
1399
+ return _el$106;
1400
+ })(), _$createComponent(Show, {
1401
+ get when() {
1402
+ return _$memo(() => dictation() === "refined")() ? props.microphone?.onRestoreOriginal : undefined;
1403
+ },
1404
+ children: restore => (() => {
1405
+ var _el$109 = _$getNextElement(_tmpl$27);
1406
+ _el$109.$$click = () => reportChatFailure(restore(), props.onError);
1407
+ _el$109.$$mousedown = keepFieldFocus;
1408
+ _$insert(_el$109, () => messages().restoreOriginal);
1409
+ _$effect(() => _$setProperty(_el$109, "disabled", microphoneDisabled()));
1410
+ _$runHydrationEvents();
1411
+ return _el$109;
1412
+ })()
1413
+ })]
1414
+ }));
1415
+ return _el$58;
528
1416
  }
529
- }), _el$47, _co$11);
530
- var _ref$2 = composerRef;
531
- typeof _ref$2 === "function" ? _$use(_ref$2, _el$25) : composerRef = _el$25;
532
- _$insert(_el$25, _$createComponent(Show, {
1417
+ }), _el$82, _co$19);
1418
+ _$insert(_el$57, _$createComponent(Show, {
533
1419
  get when() {
534
1420
  return attachments().length > 0;
535
1421
  },
536
1422
  get children() {
537
- var _el$26 = _$getNextElement(_tmpl$7);
538
- _$insert(_el$26, _$createComponent(For, {
1423
+ var _el$59 = _$getNextElement(_tmpl$18);
1424
+ _$insert(_el$59, _$createComponent(For, {
539
1425
  get each() {
540
1426
  return attachments();
541
1427
  },
542
1428
  children: attachment => (() => {
543
- var _el$52 = _$getNextElement(_tmpl$11),
544
- _el$53 = _el$52.firstChild,
545
- _el$54 = _el$53.firstChild,
546
- [_el$55, _co$12] = _$getNextMarker(_el$54.nextSibling),
547
- _el$56 = _el$55.nextSibling,
548
- [_el$57, _co$13] = _$getNextMarker(_el$56.nextSibling),
549
- _el$59 = _el$53.nextSibling,
550
- [_el$60, _co$14] = _$getNextMarker(_el$59.nextSibling);
551
- _$insert(_el$53, _$createComponent(Show, {
1429
+ var _el$110 = _$getNextElement(_tmpl$29),
1430
+ _el$111 = _el$110.firstChild,
1431
+ _el$112 = _el$111.firstChild,
1432
+ [_el$113, _co$26] = _$getNextMarker(_el$112.nextSibling),
1433
+ _el$114 = _el$113.nextSibling,
1434
+ [_el$115, _co$27] = _$getNextMarker(_el$114.nextSibling),
1435
+ _el$117 = _el$111.nextSibling,
1436
+ [_el$118, _co$28] = _$getNextMarker(_el$117.nextSibling);
1437
+ _$insert(_el$111, _$createComponent(Show, {
552
1438
  get when() {
553
1439
  return attachment.href;
554
1440
  },
555
1441
  get fallback() {
556
1442
  return (() => {
557
- var _el$61 = _$getNextElement(_tmpl$13),
558
- _el$63 = _el$61.firstChild,
559
- [_el$64, _co$15] = _$getNextMarker(_el$63.nextSibling),
560
- _el$65 = _el$64.nextSibling,
561
- [_el$66, _co$16] = _$getNextMarker(_el$65.nextSibling);
562
- _$insert(_el$61, _$createComponent(Show, {
1443
+ var _el$119 = _$getNextElement(_tmpl$31),
1444
+ _el$121 = _el$119.firstChild,
1445
+ [_el$122, _co$29] = _$getNextMarker(_el$121.nextSibling),
1446
+ _el$123 = _el$122.nextSibling,
1447
+ [_el$124, _co$30] = _$getNextMarker(_el$123.nextSibling);
1448
+ _$insert(_el$119, _$createComponent(Show, {
563
1449
  get when() {
564
1450
  return _$memo(() => attachment.kind === "image")() && attachment.previewUrl;
565
1451
  },
566
1452
  get fallback() {
567
1453
  return (() => {
568
- var _el$67 = _$getNextElement(_tmpl$14);
569
- _$effect(() => _$className(_el$67, attachmentIcon(attachment)));
570
- return _el$67;
1454
+ var _el$125 = _$getNextElement(_tmpl$3);
1455
+ _$effect(() => _$className(_el$125, attachmentIcon(attachment)));
1456
+ return _el$125;
571
1457
  })();
572
1458
  },
573
1459
  get children() {
574
- var _el$62 = _$getNextElement(_tmpl$12);
1460
+ var _el$120 = _$getNextElement(_tmpl$30);
575
1461
  _$effect(_p$ => {
576
- var _v$21 = attachment.previewUrl,
577
- _v$22 = attachment.alt ?? "";
578
- _v$21 !== _p$.e && _$setAttribute(_el$62, "src", _p$.e = _v$21);
579
- _v$22 !== _p$.t && _$setAttribute(_el$62, "alt", _p$.t = _v$22);
1462
+ var _v$32 = attachment.previewUrl,
1463
+ _v$33 = attachment.alt ?? "";
1464
+ _v$32 !== _p$.e && _$setAttribute(_el$120, "src", _p$.e = _v$32);
1465
+ _v$33 !== _p$.t && _$setAttribute(_el$120, "alt", _p$.t = _v$33);
580
1466
  return _p$;
581
1467
  }, {
582
1468
  e: undefined,
583
1469
  t: undefined
584
1470
  });
585
- return _el$62;
1471
+ return _el$120;
586
1472
  }
587
- }), _el$64, _co$15);
588
- _$insert(_el$61, () => renderAttachmentCopy(attachment), _el$66, _co$16);
589
- return _el$61;
1473
+ }), _el$122, _co$29);
1474
+ _$insert(_el$119, () => renderAttachmentCopy(attachment), _el$124, _co$30);
1475
+ return _el$119;
590
1476
  })();
591
1477
  },
592
1478
  children: href => (() => {
593
- var _el$68 = _$getNextElement(_tmpl$15),
594
- _el$70 = _el$68.firstChild,
595
- [_el$71, _co$17] = _$getNextMarker(_el$70.nextSibling),
596
- _el$72 = _el$71.nextSibling,
597
- [_el$73, _co$18] = _$getNextMarker(_el$72.nextSibling);
598
- _$insert(_el$68, _$createComponent(Show, {
1479
+ var _el$126 = _$getNextElement(_tmpl$32),
1480
+ _el$128 = _el$126.firstChild,
1481
+ [_el$129, _co$31] = _$getNextMarker(_el$128.nextSibling),
1482
+ _el$130 = _el$129.nextSibling,
1483
+ [_el$131, _co$32] = _$getNextMarker(_el$130.nextSibling);
1484
+ _$insert(_el$126, _$createComponent(Show, {
599
1485
  get when() {
600
1486
  return _$memo(() => attachment.kind === "image")() && attachment.previewUrl;
601
1487
  },
602
1488
  get fallback() {
603
1489
  return (() => {
604
- var _el$74 = _$getNextElement(_tmpl$14);
605
- _$effect(() => _$className(_el$74, attachmentIcon(attachment)));
606
- return _el$74;
1490
+ var _el$132 = _$getNextElement(_tmpl$3);
1491
+ _$effect(() => _$className(_el$132, attachmentIcon(attachment)));
1492
+ return _el$132;
607
1493
  })();
608
1494
  },
609
1495
  get children() {
610
- var _el$69 = _$getNextElement(_tmpl$12);
1496
+ var _el$127 = _$getNextElement(_tmpl$30);
611
1497
  _$effect(_p$ => {
612
- var _v$23 = attachment.previewUrl,
613
- _v$24 = attachment.alt ?? "";
614
- _v$23 !== _p$.e && _$setAttribute(_el$69, "src", _p$.e = _v$23);
615
- _v$24 !== _p$.t && _$setAttribute(_el$69, "alt", _p$.t = _v$24);
1498
+ var _v$34 = attachment.previewUrl,
1499
+ _v$35 = attachment.alt ?? "";
1500
+ _v$34 !== _p$.e && _$setAttribute(_el$127, "src", _p$.e = _v$34);
1501
+ _v$35 !== _p$.t && _$setAttribute(_el$127, "alt", _p$.t = _v$35);
616
1502
  return _p$;
617
1503
  }, {
618
1504
  e: undefined,
619
1505
  t: undefined
620
1506
  });
621
- return _el$69;
1507
+ return _el$127;
622
1508
  }
623
- }), _el$71, _co$17);
624
- _$insert(_el$68, () => renderAttachmentCopy(attachment), _el$73, _co$18);
1509
+ }), _el$129, _co$31);
1510
+ _$insert(_el$126, () => renderAttachmentCopy(attachment), _el$131, _co$32);
625
1511
  _$effect(_p$ => {
626
- var _v$25 = href(),
627
- _v$26 = messages().openInNewTab({
1512
+ var _v$36 = href(),
1513
+ _v$37 = messages().openInNewTab({
628
1514
  name: attachment.name
629
1515
  });
630
- _v$25 !== _p$.e && _$setAttribute(_el$68, "href", _p$.e = _v$25);
631
- _v$26 !== _p$.t && _$setAttribute(_el$68, "aria-label", _p$.t = _v$26);
1516
+ _v$36 !== _p$.e && _$setAttribute(_el$126, "href", _p$.e = _v$36);
1517
+ _v$37 !== _p$.t && _$setAttribute(_el$126, "aria-label", _p$.t = _v$37);
632
1518
  return _p$;
633
1519
  }, {
634
1520
  e: undefined,
635
1521
  t: undefined
636
1522
  });
637
- return _el$68;
1523
+ return _el$126;
638
1524
  })()
639
- }), _el$55, _co$12);
640
- _$insert(_el$53, _$createComponent(Show, {
1525
+ }), _el$113, _co$26);
1526
+ _$insert(_el$111, _$createComponent(Show, {
641
1527
  get when() {
642
1528
  return attachment.action;
643
1529
  },
644
1530
  children: action => (() => {
645
- var _el$75 = _$getNextElement(_tmpl$16),
646
- _el$76 = _el$75.firstChild,
647
- [_el$77, _co$19] = _$getNextMarker(_el$76.nextSibling),
648
- _el$78 = _el$77.nextSibling,
649
- [_el$79, _co$20] = _$getNextMarker(_el$78.nextSibling);
650
- _el$75.$$click = () => reportChatFailure(() => executeChatAction(action()), props.onError);
651
- _$insert(_el$75, _$createComponent(Show, {
1531
+ var _el$133 = _$getNextElement(_tmpl$33),
1532
+ _el$134 = _el$133.firstChild,
1533
+ [_el$135, _co$33] = _$getNextMarker(_el$134.nextSibling),
1534
+ _el$136 = _el$135.nextSibling,
1535
+ [_el$137, _co$34] = _$getNextMarker(_el$136.nextSibling);
1536
+ _el$133.$$click = () => reportChatFailure(() => executeChatAction(action()), props.onError);
1537
+ _$insert(_el$133, _$createComponent(Show, {
652
1538
  get when() {
653
1539
  return action().icon;
654
1540
  },
655
1541
  children: icon => (() => {
656
- var _el$80 = _$getNextElement(_tmpl$14);
657
- _$effect(() => _$className(_el$80, icon()));
658
- return _el$80;
1542
+ var _el$138 = _$getNextElement(_tmpl$3);
1543
+ _$effect(() => _$className(_el$138, icon()));
1544
+ return _el$138;
659
1545
  })()
660
- }), _el$77, _co$19);
661
- _$insert(_el$75, () => action().label, _el$79, _co$20);
662
- _$effect(() => _$setProperty(_el$75, "disabled", blocked() || action().disabled));
1546
+ }), _el$135, _co$33);
1547
+ _$insert(_el$133, () => action().label, _el$137, _co$34);
1548
+ _$effect(() => _$setProperty(_el$133, "disabled", blocked() || action().disabled));
663
1549
  _$runHydrationEvents();
664
- return _el$75;
1550
+ return _el$133;
665
1551
  })()
666
- }), _el$57, _co$13);
667
- _$insert(_el$52, _$createComponent(Show, {
1552
+ }), _el$115, _co$27);
1553
+ _$insert(_el$110, _$createComponent(Show, {
668
1554
  get when() {
669
1555
  return props.onAttachmentsChange;
670
1556
  },
671
1557
  get children() {
672
- var _el$58 = _$getNextElement(_tmpl$10);
673
- _el$58.$$click = () => setAttachments(attachments().filter(candidate => candidate.id !== attachment.id));
1558
+ var _el$116 = _$getNextElement(_tmpl$28);
1559
+ _el$116.$$click = () => setAttachments(attachments().filter(candidate => candidate.id !== attachment.id));
674
1560
  _$effect(_p$ => {
675
- var _v$19 = messages().removeNamed({
1561
+ var _v$30 = messages().removeNamed({
676
1562
  name: attachment.name
677
1563
  }),
678
- _v$20 = blocked();
679
- _v$19 !== _p$.e && _$setAttribute(_el$58, "aria-label", _p$.e = _v$19);
680
- _v$20 !== _p$.t && _$setProperty(_el$58, "disabled", _p$.t = _v$20);
1564
+ _v$31 = blocked();
1565
+ _v$30 !== _p$.e && _$setAttribute(_el$116, "aria-label", _p$.e = _v$30);
1566
+ _v$31 !== _p$.t && _$setProperty(_el$116, "disabled", _p$.t = _v$31);
681
1567
  return _p$;
682
1568
  }, {
683
1569
  e: undefined,
684
1570
  t: undefined
685
1571
  });
686
1572
  _$runHydrationEvents();
687
- return _el$58;
1573
+ return _el$116;
688
1574
  }
689
- }), _el$60, _co$14);
690
- _$effect(() => _el$53.classList.toggle("k2b-chat-composer__attachment-content--action", !!Boolean(attachment.action)));
691
- return _el$52;
1575
+ }), _el$118, _co$28);
1576
+ _$effect(() => _el$111.classList.toggle("k2b-chat-composer__attachment-content--action", !!Boolean(attachment.action)));
1577
+ return _el$110;
692
1578
  })()
693
1579
  }));
694
- _$effect(() => _$setAttribute(_el$26, "aria-label", messages().attachments));
695
- return _el$26;
1580
+ _$effect(() => _$setAttribute(_el$59, "aria-label", messages().attachments));
1581
+ return _el$59;
696
1582
  }
697
- }), _el$41, _co$0);
698
- _$insert(_el$27, _$createComponent(Show, {
1583
+ }), _el$84, _co$20);
1584
+ _$insert(_el$57, _$createComponent(Show, {
699
1585
  get when() {
700
- return mentions().length > 0;
701
- },
702
- get children() {
703
- var _el$28 = _$getNextElement(_tmpl$8),
704
- _el$30 = _el$28.firstChild,
705
- [_el$31, _co$7] = _$getNextMarker(_el$30.nextSibling),
706
- _el$29 = _el$31.nextSibling;
707
- var _ref$3 = highlightRef;
708
- typeof _ref$3 === "function" ? _$use(_ref$3, _el$28) : highlightRef = _el$28;
709
- _$insert(_el$28, _$createComponent(For, {
710
- get each() {
711
- return chatMentionSegments(props.value, mentions());
712
- },
713
- children: part => (() => {
714
- var _el$81 = _$getNextElement(_tmpl$17);
715
- _$insert(_el$81, () => part.text);
716
- _$effect(() => _el$81.classList.toggle("k2b-chat-composer__mention", !!Boolean(part.mention)));
717
- return _el$81;
718
- })()
719
- }), _el$31, _co$7);
720
- return _el$28;
721
- }
722
- }), _el$34, _co$8);
723
- _el$32.$$keydown = onKeyDown;
724
- _el$32.$$beforeinput = event => {
725
- if (event.inputType === "historyUndo" || event.inputType === "historyRedo") {
726
- event.preventDefault();
727
- restoreHistory(event.inputType === "historyUndo" ? -1 : 1);
728
- }
729
- };
730
- _el$32.addEventListener("scroll", () => {
731
- if (highlightRef && textareaRef) highlightRef.scrollTop = textareaRef.scrollTop;
732
- });
733
- _el$32.addEventListener("compositionend", () => {
734
- setComposing(false);
735
- syncCaret();
736
- });
737
- _el$32.addEventListener("compositionstart", () => setComposing(true));
738
- _el$32.$$keyup = syncCaret;
739
- _el$32.$$click = () => {
740
- setDismissed(false);
741
- syncCaret();
742
- };
743
- _el$32.addEventListener("blur", () => setDismissed(true));
744
- _el$32.addEventListener("select", syncCaret);
745
- _el$32.addEventListener("paste", event => {
746
- const clipboardData = event.clipboardData;
747
- if (canSelectFiles() && clipboardData?.files.length) {
748
- event.preventDefault();
749
- void runFiles(clipboardData.files);
750
- return;
751
- }
752
- props.onPaste?.(event);
753
- });
754
- _el$32.$$input = event => {
755
- edit(event.currentTarget.value);
756
- syncCaret();
757
- autoResize();
758
- };
759
- var _ref$4 = textareaRef;
760
- typeof _ref$4 === "function" ? _$use(_ref$4, _el$32) : textareaRef = _el$32;
761
- _$insert(_el$25, _$createComponent(Show, {
762
- get when() {
763
- return props.error;
764
- },
765
- get children() {
766
- var _el$35 = _$getNextElement(_tmpl$9),
767
- _el$36 = _el$35.firstChild,
768
- _el$37 = _el$36.nextSibling,
769
- [_el$38, _co$9] = _$getNextMarker(_el$37.nextSibling);
770
- _$insert(_el$35, () => props.error, _el$38, _co$9);
771
- return _el$35;
772
- }
773
- }), _el$43, _co$1);
774
- _$insert(_el$39, _$createComponent(Show, {
775
- get when() {
776
- return props.footerContent;
1586
+ return conversation();
777
1587
  },
778
1588
  get fallback() {
779
- return [(() => {
780
- var _el$82 = _$getNextElement(_tmpl$20),
781
- _el$85 = _el$82.firstChild,
782
- [_el$86, _co$21] = _$getNextMarker(_el$85.nextSibling),
783
- _el$87 = _el$86.nextSibling,
784
- [_el$88, _co$22] = _$getNextMarker(_el$87.nextSibling),
785
- _el$89 = _el$88.nextSibling,
786
- [_el$90, _co$23] = _$getNextMarker(_el$89.nextSibling),
787
- _el$91 = _el$90.nextSibling,
788
- [_el$92, _co$24] = _$getNextMarker(_el$91.nextSibling),
789
- _el$93 = _el$92.nextSibling,
790
- [_el$94, _co$25] = _$getNextMarker(_el$93.nextSibling);
791
- _$insert(_el$82, () => props.footerTools, _el$86, _co$21);
792
- _$insert(_el$82, _$createComponent(Show, {
1589
+ return [_$memo(field), _$createComponent(Show, {
1590
+ get when() {
1591
+ return props.error;
1592
+ },
1593
+ get children() {
1594
+ var _el$139 = _$getNextElement(_tmpl$19),
1595
+ _el$140 = _el$139.firstChild,
1596
+ _el$141 = _el$140.nextSibling,
1597
+ [_el$142, _co$35] = _$getNextMarker(_el$141.nextSibling);
1598
+ _$insert(_el$139, () => props.error, _el$142, _co$35);
1599
+ return _el$139;
1600
+ }
1601
+ }), _$memo(formatRow), (() => {
1602
+ var _el$143 = _$getNextElement(_tmpl$34);
1603
+ _$insert(_el$143, _$createComponent(Show, {
793
1604
  get when() {
794
- return hasAddMenu();
1605
+ return props.footerContent;
795
1606
  },
796
- get children() {
797
- return _$createComponent(Dropdown.Root, {
798
- position: "top-right",
799
- get label() {
800
- return messages().addToChat;
801
- },
802
- get items() {
803
- return menuItems();
804
- },
805
- get disabled() {
806
- return blocked();
807
- },
808
- get children() {
809
- return _$createComponent(Dropdown.Trigger, {
810
- appearance: "plain",
1607
+ get fallback() {
1608
+ return [(() => {
1609
+ var _el$144 = _$getNextElement(_tmpl$35),
1610
+ _el$145 = _el$144.firstChild,
1611
+ [_el$146, _co$36] = _$getNextMarker(_el$145.nextSibling),
1612
+ _el$147 = _el$146.nextSibling,
1613
+ [_el$148, _co$37] = _$getNextMarker(_el$147.nextSibling),
1614
+ _el$149 = _el$148.nextSibling,
1615
+ [_el$150, _co$38] = _$getNextMarker(_el$149.nextSibling),
1616
+ _el$151 = _el$150.nextSibling,
1617
+ [_el$152, _co$39] = _$getNextMarker(_el$151.nextSibling),
1618
+ _el$153 = _el$152.nextSibling,
1619
+ [_el$154, _co$40] = _$getNextMarker(_el$153.nextSibling),
1620
+ _el$155 = _el$154.nextSibling,
1621
+ [_el$156, _co$41] = _$getNextMarker(_el$155.nextSibling),
1622
+ _el$157 = _el$156.nextSibling,
1623
+ [_el$158, _co$42] = _$getNextMarker(_el$157.nextSibling);
1624
+ _$insert(_el$144, () => props.footerTools, _el$146, _co$36);
1625
+ _$insert(_el$144, _$createComponent(Show, {
1626
+ get when() {
1627
+ return hasAddMenu();
1628
+ },
1629
+ get children() {
1630
+ return addMenu("ti ti-plus");
1631
+ }
1632
+ }), _el$148, _co$37);
1633
+ _$insert(_el$144, fileInput, _el$150, _co$38);
1634
+ _$insert(_el$144, formatToggle, _el$152, _co$39);
1635
+ _$insert(_el$144, emojiButton, _el$154, _co$40);
1636
+ _$insert(_el$144, _$createComponent(Show, {
1637
+ get when() {
1638
+ return (props.models?.length ?? 0) > 0;
1639
+ },
1640
+ get children() {
1641
+ return _$createComponent(SelectChip, {
1642
+ get ["aria-label"]() {
1643
+ return messages().chooseModel;
1644
+ },
1645
+ position: "top-right",
1646
+ "class": "k2b-chat-composer__model",
1647
+ menuWidth: "15rem",
1648
+ get placeholder() {
1649
+ return messages().model;
1650
+ },
1651
+ value: () => props.selectedModelId ?? "",
1652
+ get options() {
1653
+ return (props.models ?? []).map(model => ({
1654
+ value: model.id,
1655
+ label: model.label,
1656
+ description: model.description,
1657
+ icon: model.icon,
1658
+ image: model.image
1659
+ }));
1660
+ },
1661
+ get disabled() {
1662
+ return blocked() || running() || !props.onModelChange;
1663
+ },
1664
+ onValueChange: modelId => {
1665
+ props.onModelChange?.(modelId);
1666
+ queueMicrotask(focus);
1667
+ }
1668
+ });
1669
+ }
1670
+ }), _el$156, _co$41);
1671
+ _$insert(_el$144, () => props.modelDetails, _el$158, _co$42);
1672
+ return _el$144;
1673
+ })(), (() => {
1674
+ var _el$159 = _$getNextElement(_tmpl$36),
1675
+ _el$160 = _el$159.firstChild,
1676
+ [_el$161, _co$43] = _$getNextMarker(_el$160.nextSibling),
1677
+ _el$162 = _el$161.nextSibling,
1678
+ [_el$163, _co$44] = _$getNextMarker(_el$162.nextSibling),
1679
+ _el$164 = _el$163.nextSibling,
1680
+ [_el$165, _co$45] = _$getNextMarker(_el$164.nextSibling),
1681
+ _el$166 = _el$165.nextSibling,
1682
+ [_el$167, _co$46] = _$getNextMarker(_el$166.nextSibling),
1683
+ _el$168 = _el$167.nextSibling,
1684
+ [_el$169, _co$47] = _$getNextMarker(_el$168.nextSibling);
1685
+ _$insert(_el$159, _$createComponent(For, {
1686
+ get each() {
1687
+ return props.contextActions;
1688
+ },
1689
+ children: action => _$createComponent(Tooltip.Trigger, {
1690
+ type: "button",
811
1691
  "class": "k2b-chat-composer__icon-action",
812
- get label() {
813
- return messages().addToChat;
1692
+ get ["data-tone"]() {
1693
+ return action.variant === "danger" ? "danger" : undefined;
1694
+ },
1695
+ get disabled() {
1696
+ return action.disabled;
1697
+ },
1698
+ get ["aria-pressed"]() {
1699
+ return action.pressed;
814
1700
  },
815
- get tooltip() {
816
- return messages().addToChat;
1701
+ get ["aria-label"]() {
1702
+ return action.label;
817
1703
  },
1704
+ get content() {
1705
+ return action.label;
1706
+ },
1707
+ onClick: () => reportChatFailure(() => executeChatAction(action), props.onError),
818
1708
  get children() {
819
- return _$getNextElement(_tmpl$18);
1709
+ var _el$170 = _$getNextElement(_tmpl$3);
1710
+ _$effect(() => _$className(_el$170, action.icon ?? "ti ti-dots"));
1711
+ return _el$170;
820
1712
  }
821
- });
822
- }
823
- });
824
- }
825
- }), _el$88, _co$22);
826
- _$insert(_el$82, _$createComponent(Show, {
827
- get when() {
828
- return props.fileSelection;
829
- },
830
- get children() {
831
- var _el$84 = _$getNextElement(_tmpl$19);
832
- _el$84.addEventListener("change", event => {
833
- if (event.currentTarget.files?.length) void runFiles(event.currentTarget.files);
834
- });
835
- var _ref$5 = fileInputRef;
836
- typeof _ref$5 === "function" ? _$use(_ref$5, _el$84) : fileInputRef = _el$84;
837
- _$effect(_p$ => {
838
- var _v$27 = props.fileSelection?.accept,
839
- _v$28 = props.fileSelection?.multiple ?? true;
840
- _v$27 !== _p$.e && _$setAttribute(_el$84, "accept", _p$.e = _v$27);
841
- _v$28 !== _p$.t && _$setProperty(_el$84, "multiple", _p$.t = _v$28);
842
- return _p$;
843
- }, {
844
- e: undefined,
845
- t: undefined
846
- });
847
- return _el$84;
848
- }
849
- }), _el$90, _co$23);
850
- _$insert(_el$82, _$createComponent(Show, {
851
- get when() {
852
- return (props.models?.length ?? 0) > 0;
853
- },
854
- get children() {
855
- return _$createComponent(SelectChip, {
856
- get ["aria-label"]() {
857
- return messages().chooseModel;
858
- },
859
- position: "top-right",
860
- "class": "k2b-chat-composer__model",
861
- menuWidth: "15rem",
862
- get placeholder() {
863
- return messages().model;
864
- },
865
- value: () => props.selectedModelId ?? "",
866
- get options() {
867
- return (props.models ?? []).map(model => ({
868
- value: model.id,
869
- label: model.label,
870
- description: model.description,
871
- icon: model.icon,
872
- image: model.image
873
- }));
874
- },
875
- get disabled() {
876
- return blocked() || running() || !props.onModelChange;
877
- },
878
- onValueChange: modelId => {
879
- props.onModelChange?.(modelId);
880
- queueMicrotask(focus);
881
- }
882
- });
883
- }
884
- }), _el$92, _co$24);
885
- _$insert(_el$82, () => props.modelDetails, _el$94, _co$25);
886
- return _el$82;
887
- })(), (() => {
888
- var _el$95 = _$getNextElement(_tmpl$21),
889
- _el$97 = _el$95.firstChild,
890
- [_el$98, _co$26] = _$getNextMarker(_el$97.nextSibling),
891
- _el$99 = _el$98.nextSibling,
892
- [_el$100, _co$27] = _$getNextMarker(_el$99.nextSibling),
893
- _el$101 = _el$100.nextSibling,
894
- [_el$102, _co$28] = _$getNextMarker(_el$101.nextSibling),
895
- _el$103 = _el$102.nextSibling,
896
- [_el$104, _co$29] = _$getNextMarker(_el$103.nextSibling);
897
- _$insert(_el$95, _$createComponent(For, {
898
- get each() {
899
- return props.contextActions;
900
- },
901
- children: action => _$createComponent(Tooltip.Trigger, {
902
- type: "button",
903
- "class": "k2b-chat-composer__icon-action",
904
- get ["data-tone"]() {
905
- return action.variant === "danger" ? "danger" : undefined;
906
- },
907
- get disabled() {
908
- return action.disabled;
909
- },
910
- get ["aria-pressed"]() {
911
- return action.pressed;
912
- },
913
- get ["aria-label"]() {
914
- return action.label;
915
- },
916
- get content() {
917
- return action.label;
918
- },
919
- onClick: () => reportChatFailure(() => executeChatAction(action), props.onError),
920
- get children() {
921
- var _el$105 = _$getNextElement(_tmpl$14);
922
- _$effect(() => _$className(_el$105, action.icon ?? "ti ti-dots"));
923
- return _el$105;
924
- }
925
- })
926
- }), _el$98, _co$26);
927
- _$insert(_el$95, _$createComponent(Show, {
928
- get when() {
929
- return _$memo(() => !!hasContextUsage())() ? props.contextUsage ?? {} : undefined;
930
- },
931
- children: usage => _$createComponent(ContextUsage, _$mergeProps(usage, {
932
- get action() {
933
- return props.contextPopupAction;
934
- },
935
- get onActionError() {
936
- return props.onError;
937
- }
938
- }))
939
- }), _el$100, _co$27);
940
- _$insert(_el$95, () => props.submitTools, _el$102, _co$28);
941
- _$insert(_el$95, _$createComponent(Show, {
942
- get when() {
943
- return _$memo(() => !!(running() && !hasDraft()))() && props.onStop;
944
- },
945
- get fallback() {
946
- return _$createComponent(Tooltip.Trigger, {
947
- type: "button",
948
- "class": "k2b-chat-composer__send",
949
- get disabled() {
950
- return !canSubmit();
951
- },
952
- get ["aria-label"]() {
953
- return _$memo(() => !!submitting())() ? _$memo(() => !!running())() ? _$memo(() => runningSubmitIntent() === "queue")() ? messages().queueing : messages().steering : messages().sending : _$memo(() => !!running())() ? _$memo(() => runningSubmitIntent() === "queue")() ? messages().queueMessage : messages().steerResponse : messages().sendMessage;
954
- },
955
- get content() {
956
- return _$memo(() => !!running())() ? _$memo(() => runningSubmitIntent() === "queue")() ? messages().queueMessage : messages().steerResponse : messages().sendMessage;
957
- },
958
- onClick: () => void submit(),
959
- get children() {
960
- var _el$106 = _$getNextElement(_tmpl$14);
961
- _$effect(() => _$className(_el$106, submitting() ? "ti ti-loader-2 k2b-spin" : "ti ti-arrow-up"));
962
- return _el$106;
963
- }
964
- });
1713
+ })
1714
+ }), _el$161, _co$43);
1715
+ _$insert(_el$159, _$createComponent(Show, {
1716
+ get when() {
1717
+ return _$memo(() => !!hasContextUsage())() ? props.contextUsage ?? {} : undefined;
1718
+ },
1719
+ children: usage => _$createComponent(ContextUsage, _$mergeProps(usage, {
1720
+ get action() {
1721
+ return props.contextPopupAction;
1722
+ },
1723
+ get onActionError() {
1724
+ return props.onError;
1725
+ }
1726
+ }))
1727
+ }), _el$163, _co$44);
1728
+ _$insert(_el$159, () => props.submitTools, _el$165, _co$45);
1729
+ _$insert(_el$159, microphoneControl, _el$167, _co$46);
1730
+ _$insert(_el$159, sendControl, _el$169, _co$47);
1731
+ return _el$159;
1732
+ })()];
965
1733
  },
966
- get children() {
967
- return _$createComponent(Tooltip.Trigger, {
968
- type: "button",
969
- "class": "k2b-chat-composer__stop",
970
- get disabled() {
971
- return stopping();
972
- },
973
- get ["aria-label"]() {
974
- return _$memo(() => !!stopping())() ? messages().stopping : messages().stopResponse;
975
- },
976
- get content() {
977
- return messages().stopResponse;
978
- },
979
- onClick: () => reportChatFailure(() => props.onStop?.(), props.onError),
980
- get children() {
981
- var _el$96 = _$getNextElement(_tmpl$14);
982
- _$effect(() => _$className(_el$96, stopping() ? "ti ti-loader-2 k2b-spin" : "ti ti-player-stop"));
983
- return _el$96;
984
- }
985
- });
986
- }
987
- }), _el$104, _co$29);
988
- return _el$95;
1734
+ children: content => content()
1735
+ }));
1736
+ return _el$143;
989
1737
  })()];
990
1738
  },
991
- children: content => content()
992
- }));
993
- _$insert(_el$25, _$createComponent(Show, {
1739
+ get children() {
1740
+ return [_$createComponent(Show, {
1741
+ get when() {
1742
+ return props.error;
1743
+ },
1744
+ get children() {
1745
+ var _el$60 = _$getNextElement(_tmpl$19),
1746
+ _el$61 = _el$60.firstChild,
1747
+ _el$62 = _el$61.nextSibling,
1748
+ [_el$63, _co$11] = _$getNextMarker(_el$62.nextSibling);
1749
+ _$insert(_el$60, () => props.error, _el$63, _co$11);
1750
+ return _el$60;
1751
+ }
1752
+ }), _$memo(() => formatRow()), (() => {
1753
+ var _el$64 = _$getNextElement(_tmpl$20),
1754
+ _el$75 = _el$64.firstChild,
1755
+ [_el$76, _co$16] = _$getNextMarker(_el$75.nextSibling),
1756
+ _el$77 = _el$76.nextSibling,
1757
+ [_el$78, _co$17] = _$getNextMarker(_el$77.nextSibling),
1758
+ _el$65 = _el$78.nextSibling,
1759
+ _el$73 = _el$65.firstChild,
1760
+ [_el$74, _co$15] = _$getNextMarker(_el$73.nextSibling),
1761
+ _el$66 = _el$74.nextSibling,
1762
+ _el$67 = _el$66.firstChild,
1763
+ [_el$68, _co$12] = _$getNextMarker(_el$67.nextSibling),
1764
+ _el$69 = _el$68.nextSibling,
1765
+ [_el$70, _co$13] = _$getNextMarker(_el$69.nextSibling),
1766
+ _el$71 = _el$70.nextSibling,
1767
+ [_el$72, _co$14] = _$getNextMarker(_el$71.nextSibling),
1768
+ _el$79 = _el$65.nextSibling,
1769
+ [_el$80, _co$18] = _$getNextMarker(_el$79.nextSibling);
1770
+ _$insert(_el$64, attachControl, _el$76, _co$16);
1771
+ _$insert(_el$64, fileInput, _el$78, _co$17);
1772
+ _$insert(_el$65, field, _el$74, _co$15);
1773
+ _$insert(_el$66, formatToggle, _el$68, _co$12);
1774
+ _$insert(_el$66, emojiButton, _el$70, _co$13);
1775
+ _$insert(_el$66, microphoneControl, _el$72, _co$14);
1776
+ _$insert(_el$64, sendControl, _el$80, _co$18);
1777
+ return _el$64;
1778
+ })()];
1779
+ }
1780
+ }), _el$86, _co$21);
1781
+ _$insert(_el$57, _$createComponent(Show, {
994
1782
  get when() {
995
1783
  return props.fileSelection;
996
1784
  },
@@ -1009,54 +1797,25 @@ export function ChatComposer(props) {
1009
1797
  },
1010
1798
  onDrop: files => void runFiles(files)
1011
1799
  })
1012
- }), _el$45, _co$10);
1800
+ }), _el$88, _co$22);
1013
1801
  _$effect(_p$ => {
1014
- var _v$3 = `k2b-chat-composer ${props.class ?? ""}`,
1015
- _v$4 = running() ? "true" : undefined,
1016
- _v$5 = props.label ?? messages().messageComposer,
1017
- _v$6 = messages().messageInput,
1018
- _v$7 = !!(mentions().length > 0),
1019
- _v$8 = blocked(),
1020
- _v$9 = props.placeholder ?? (running() ? messages().addGuidance : messages().writeMessage),
1021
- _v$0 = props.inputLabel ?? messages().message,
1022
- _v$1 = commandsOpen() ? "combobox" : undefined,
1023
- _v$10 = commandsOpen() ? "list" : undefined,
1024
- _v$11 = commandsOpen() ? commandListId : undefined,
1025
- _v$12 = commandsOpen() ? "true" : undefined,
1026
- _v$13 = selectedCommand() ? `${commandListId}-${selectedCommandIndex()}` : undefined;
1027
- _v$3 !== _p$.e && _$className(_el$25, _p$.e = _v$3);
1028
- _v$4 !== _p$.t && _$setAttribute(_el$25, "data-running", _p$.t = _v$4);
1029
- _v$5 !== _p$.a && _$setAttribute(_el$25, "aria-label", _p$.a = _v$5);
1030
- _v$6 !== _p$.o && _$setAttribute(_el$27, "aria-label", _p$.o = _v$6);
1031
- _v$7 !== _p$.i && _el$32.classList.toggle("k2b-chat-composer__textarea--highlighted", _p$.i = _v$7);
1032
- _v$8 !== _p$.n && _$setProperty(_el$32, "disabled", _p$.n = _v$8);
1033
- _v$9 !== _p$.s && _$setAttribute(_el$32, "placeholder", _p$.s = _v$9);
1034
- _v$0 !== _p$.h && _$setAttribute(_el$32, "aria-label", _p$.h = _v$0);
1035
- _v$1 !== _p$.r && _$setAttribute(_el$32, "role", _p$.r = _v$1);
1036
- _v$10 !== _p$.d && _$setAttribute(_el$32, "aria-autocomplete", _p$.d = _v$10);
1037
- _v$11 !== _p$.l && _$setAttribute(_el$32, "aria-controls", _p$.l = _v$11);
1038
- _v$12 !== _p$.u && _$setAttribute(_el$32, "aria-expanded", _p$.u = _v$12);
1039
- _v$13 !== _p$.c && _$setAttribute(_el$32, "aria-activedescendant", _p$.c = _v$13);
1802
+ var _v$15 = `k2b-chat-composer ${props.class ?? ""}`,
1803
+ _v$16 = running() ? "true" : undefined,
1804
+ _v$17 = conversation() ? "conversation" : undefined,
1805
+ _v$18 = props.label ?? messages().messageComposer;
1806
+ _v$15 !== _p$.e && _$className(_el$57, _p$.e = _v$15);
1807
+ _v$16 !== _p$.t && _$setAttribute(_el$57, "data-running", _p$.t = _v$16);
1808
+ _v$17 !== _p$.a && _$setAttribute(_el$57, "data-variant", _p$.a = _v$17);
1809
+ _v$18 !== _p$.o && _$setAttribute(_el$57, "aria-label", _p$.o = _v$18);
1040
1810
  return _p$;
1041
1811
  }, {
1042
1812
  e: undefined,
1043
1813
  t: undefined,
1044
1814
  a: undefined,
1045
- o: undefined,
1046
- i: undefined,
1047
- n: undefined,
1048
- s: undefined,
1049
- h: undefined,
1050
- r: undefined,
1051
- d: undefined,
1052
- l: undefined,
1053
- u: undefined,
1054
- c: undefined
1815
+ o: undefined
1055
1816
  });
1056
- _$effect(() => _$setProperty(_el$32, "value", props.value));
1057
- _$runHydrationEvents();
1058
- return _el$3;
1817
+ return _el$29;
1059
1818
  })();
1060
1819
  }
1061
- _$delegateEvents(["input", "click", "keyup", "beforeinput", "keydown", "pointerdown"]);
1820
+ _$delegateEvents(["input", "click", "keyup", "beforeinput", "keydown", "pointerdown", "mousedown"]);
1062
1821
  //# sourceMappingURL=ChatComposer.js.map