@chat-leo/chatleo 0.0.0-stage → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/LICENSE +21 -0
  2. package/dist/chatleo/chatleo.esm.js +1 -0
  3. package/dist/chatleo/index.esm.js +1 -0
  4. package/dist/chatleo/p-43ada232.entry.js +1 -0
  5. package/dist/chatleo/p-4485e141.entry.js +1 -0
  6. package/dist/chatleo/p-BnCPdbII.js +1 -0
  7. package/dist/chatleo/p-C-l90Wre.js +1 -0
  8. package/dist/chatleo/p-DQuL1Twl.js +1 -0
  9. package/dist/chatleo/p-DmL518NK.js +3 -0
  10. package/dist/chatleo/p-aed60255.entry.js +1 -0
  11. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  12. package/dist/cjs/chatleo-avatar_13.cjs.entry.js +2986 -0
  13. package/dist/cjs/chatleo-call-adapter-B2OfC0VZ.js +35 -0
  14. package/dist/cjs/chatleo-chat-input.cjs.entry.js +67 -0
  15. package/dist/cjs/chatleo.cjs.js +25 -0
  16. package/dist/cjs/index-DkSDLR0y.js +56 -0
  17. package/dist/cjs/index-Dxw4YCA_.js +1741 -0
  18. package/dist/cjs/index.cjs.js +7 -0
  19. package/dist/cjs/loader.cjs.js +13 -0
  20. package/dist/cjs/my-component.cjs.entry.js +33 -0
  21. package/dist/collection/__mocks__/stencil-core.js +26 -0
  22. package/dist/collection/collection-manifest.json +27 -0
  23. package/dist/collection/components/chatleo-avatar/chatleo-avatar.css +40 -0
  24. package/dist/collection/components/chatleo-avatar/chatleo-avatar.js +116 -0
  25. package/dist/collection/components/chatleo-chat/chatleo-chat.css +108 -0
  26. package/dist/collection/components/chatleo-chat/chatleo-chat.js +459 -0
  27. package/dist/collection/components/chatleo-chat-header/chatleo-chat-header.css +22 -0
  28. package/dist/collection/components/chatleo-chat-header/chatleo-chat-header.js +105 -0
  29. package/dist/collection/components/chatleo-chat-input/chatleo-chat-input.css +84 -0
  30. package/dist/collection/components/chatleo-chat-input/chatleo-chat-input.js +141 -0
  31. package/dist/collection/components/chatleo-chat-message/chatleo-chat-message.css +149 -0
  32. package/dist/collection/components/chatleo-chat-message/chatleo-chat-message.js +259 -0
  33. package/dist/collection/components/chatleo-component/chatleo-component.css +271 -0
  34. package/dist/collection/components/chatleo-component/chatleo-component.js +1366 -0
  35. package/dist/collection/components/chatleo-new-message-selector/chatleo-new-message-selector.css +96 -0
  36. package/dist/collection/components/chatleo-new-message-selector/chatleo-new-message-selector.js +231 -0
  37. package/dist/collection/components/chatleo-rich-input/chatleo-rich-input.css +352 -0
  38. package/dist/collection/components/chatleo-rich-input/chatleo-rich-input.js +976 -0
  39. package/dist/collection/components/chatleo-rich-message-renderer/chatleo-rich-message-renderer.css +169 -0
  40. package/dist/collection/components/chatleo-rich-message-renderer/chatleo-rich-message-renderer.js +400 -0
  41. package/dist/collection/components/chatleo-room-list/chatleo-room-list.css +111 -0
  42. package/dist/collection/components/chatleo-room-list/chatleo-room-list.js +180 -0
  43. package/dist/collection/components/chatleo-room-tile-component/chatleo-room-tile-component.css +110 -0
  44. package/dist/collection/components/chatleo-room-tile-component/chatleo-room-tile-component.js +241 -0
  45. package/dist/collection/components/chatleo-room-view/chatleo-room-view.css +93 -0
  46. package/dist/collection/components/chatleo-room-view/chatleo-room-view.js +593 -0
  47. package/dist/collection/components/chatleo-tray-component/chatleo-tray-component.css +284 -0
  48. package/dist/collection/components/chatleo-tray-component/chatleo-tray-component.js +391 -0
  49. package/dist/collection/components/chatleo-user-tile/chatleo-user-tile.css +56 -0
  50. package/dist/collection/components/chatleo-user-tile/chatleo-user-tile.js +149 -0
  51. package/dist/collection/components/my-component/my-component.css +4 -0
  52. package/dist/collection/components/my-component/my-component.js +95 -0
  53. package/dist/collection/index.js +10 -0
  54. package/dist/collection/utils/call-entry.js +34 -0
  55. package/dist/collection/utils/delivery.js +7 -0
  56. package/dist/collection/utils/utils.js +51 -0
  57. package/dist/components/chatleo-avatar.d.ts +11 -0
  58. package/dist/components/chatleo-avatar.js +1 -0
  59. package/dist/components/chatleo-chat-header.d.ts +11 -0
  60. package/dist/components/chatleo-chat-header.js +1 -0
  61. package/dist/components/chatleo-chat-input.d.ts +11 -0
  62. package/dist/components/chatleo-chat-input.js +1 -0
  63. package/dist/components/chatleo-chat-message.d.ts +11 -0
  64. package/dist/components/chatleo-chat-message.js +1 -0
  65. package/dist/components/chatleo-chat.d.ts +11 -0
  66. package/dist/components/chatleo-chat.js +1 -0
  67. package/dist/components/chatleo-component.d.ts +11 -0
  68. package/dist/components/chatleo-component.js +1 -0
  69. package/dist/components/chatleo-new-message-selector.d.ts +11 -0
  70. package/dist/components/chatleo-new-message-selector.js +1 -0
  71. package/dist/components/chatleo-rich-input.d.ts +11 -0
  72. package/dist/components/chatleo-rich-input.js +1 -0
  73. package/dist/components/chatleo-rich-message-renderer.d.ts +11 -0
  74. package/dist/components/chatleo-rich-message-renderer.js +1 -0
  75. package/dist/components/chatleo-room-list.d.ts +11 -0
  76. package/dist/components/chatleo-room-list.js +1 -0
  77. package/dist/components/chatleo-room-tile-component.d.ts +11 -0
  78. package/dist/components/chatleo-room-tile-component.js +1 -0
  79. package/dist/components/chatleo-room-view.d.ts +11 -0
  80. package/dist/components/chatleo-room-view.js +1 -0
  81. package/dist/components/chatleo-tray-component.d.ts +11 -0
  82. package/dist/components/chatleo-tray-component.js +1 -0
  83. package/dist/components/chatleo-user-tile.d.ts +11 -0
  84. package/dist/components/chatleo-user-tile.js +1 -0
  85. package/dist/components/index.d.ts +35 -0
  86. package/dist/components/index.js +1 -0
  87. package/dist/components/my-component.d.ts +11 -0
  88. package/dist/components/my-component.js +1 -0
  89. package/dist/components/p-8kvQ-Uh-.js +1 -0
  90. package/dist/components/p-B7cdqAgv.js +1 -0
  91. package/dist/components/p-BdiOcOYZ.js +1 -0
  92. package/dist/components/p-BlbDSb7D.js +1 -0
  93. package/dist/components/p-BnCPdbII.js +1 -0
  94. package/dist/components/p-C-v19aUJ.js +1 -0
  95. package/dist/components/p-C1mF0s8g.js +1 -0
  96. package/dist/components/p-CRtBdzP3.js +1 -0
  97. package/dist/components/p-CfayCm9O.js +1 -0
  98. package/dist/components/p-DGjAxoQy.js +1 -0
  99. package/dist/components/p-Exj_2-yI.js +1 -0
  100. package/dist/components/p-XlwGxsqT.js +1 -0
  101. package/dist/components/p-fjMaTJam.js +1 -0
  102. package/dist/components/p-xt4kzz3B.js +1 -0
  103. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  104. package/dist/esm/chatleo-avatar_13.entry.js +2972 -0
  105. package/dist/esm/chatleo-call-adapter-BnCPdbII.js +33 -0
  106. package/dist/esm/chatleo-chat-input.entry.js +65 -0
  107. package/dist/esm/chatleo.js +21 -0
  108. package/dist/esm/index-C-l90Wre.js +53 -0
  109. package/dist/esm/index-DmL518NK.js +1733 -0
  110. package/dist/esm/index.js +1 -0
  111. package/dist/esm/loader.js +11 -0
  112. package/dist/esm/my-component.entry.js +31 -0
  113. package/dist/index.cjs.js +1 -0
  114. package/dist/index.js +1 -0
  115. package/dist/types/__mocks__/stencil-core.d.ts +24 -0
  116. package/dist/types/components/chatleo-avatar/chatleo-avatar.d.ts +27 -0
  117. package/dist/types/components/chatleo-chat/chatleo-chat.d.ts +75 -0
  118. package/dist/types/components/chatleo-chat-header/chatleo-chat-header.d.ts +27 -0
  119. package/dist/types/components/chatleo-chat-input/chatleo-chat-input.d.ts +31 -0
  120. package/dist/types/components/chatleo-chat-message/chatleo-chat-message.d.ts +22 -0
  121. package/dist/types/components/chatleo-component/chatleo-component.d.ts +278 -0
  122. package/dist/types/components/chatleo-new-message-selector/chatleo-new-message-selector.d.ts +68 -0
  123. package/dist/types/components/chatleo-rich-input/chatleo-rich-input.d.ts +216 -0
  124. package/dist/types/components/chatleo-rich-message-renderer/chatleo-rich-message-renderer.d.ts +77 -0
  125. package/dist/types/components/chatleo-room-list/chatleo-room-list.d.ts +52 -0
  126. package/dist/types/components/chatleo-room-tile-component/chatleo-room-tile-component.d.ts +59 -0
  127. package/dist/types/components/chatleo-room-view/chatleo-room-view.d.ts +91 -0
  128. package/dist/types/components/chatleo-tray-component/chatleo-tray-component.d.ts +112 -0
  129. package/dist/types/components/chatleo-user-tile/chatleo-user-tile.d.ts +36 -0
  130. package/dist/types/components/my-component/my-component.d.ts +16 -0
  131. package/dist/types/components.d.ts +1593 -0
  132. package/dist/types/index.d.ts +12 -0
  133. package/dist/types/stencil-public-runtime.d.ts +1879 -0
  134. package/dist/types/utils/call-entry.d.ts +9 -0
  135. package/dist/types/utils/delivery.d.ts +7 -0
  136. package/dist/types/utils/utils.d.ts +24 -0
  137. package/loader/cdn.js +1 -0
  138. package/loader/index.cjs.js +1 -0
  139. package/loader/index.d.ts +24 -0
  140. package/loader/index.es2017.js +1 -0
  141. package/loader/index.js +2 -0
  142. package/package.json +70 -3
  143. package/readme.md +111 -0
  144. package/README.md +0 -3
@@ -0,0 +1,976 @@
1
+ import { h } from "@stencil/core";
2
+ /**
3
+ * ChatleoRichInput
4
+ *
5
+ * A Stencil-based rich text input component that supports:
6
+ * - Free text entry in a contenteditable div
7
+ * - Drag-and-drop and file picker attachments (single or multiple)
8
+ * - Inline, non-editable attachment blocks with thumbnails for images
9
+ *
10
+ * Component produces two payload formats:
11
+ * - Legacy RichInputContent: { text: string, attachments: FileAttachment[] }
12
+ * - StructuredMessageContent: blocks[] + generated html for richer, future-proof messaging
13
+ *
14
+ * Core data flow:
15
+ * - User types or adds files → editor DOM updates
16
+ * - handleInput/handleFiles/drag handlers → emitContentChange/extractContent
17
+ * - Send via Enter key or send button → handleSendMessage
18
+ * - Builds both legacy and structured payloads via extractContent and extractStructuredContent
19
+ * - Emits messageSend (primary)
20
+ */
21
+ export class ChatleoRichInput {
22
+ /**
23
+ * A reference to the root host element of the component, injected by Stencil's decorator.
24
+ */
25
+ hostElement;
26
+ /**
27
+ * If `true`, the editor and all associated buttons will be disabled, preventing user interaction.
28
+ */
29
+ disabled = false;
30
+ /**
31
+ * The placeholder text that appears in the editor when it is empty.
32
+ */
33
+ placeholder = 'Write a message...';
34
+ /**
35
+ * A CSS string that defines the maximum height of the editor area before it starts scrolling.
36
+ */
37
+ maxHeight = '200px';
38
+ /**
39
+ * A comma-separated string of MIME types or file extensions that the file input should accept. This is passed to the `accept` attribute of the hidden file input element.
40
+ */
41
+ acceptFiles = 'image/*,.pdf,.doc,.docx,.txt';
42
+ isDragOver = false;
43
+ /**
44
+ * A state property that is `true` if the editor contains any text or attachments. It is used to enable or disable the send button.
45
+ */
46
+ hasContent = false;
47
+ /** Fires whenever the legacy content snapshot changes (typing, attachments). */
48
+ contentChange;
49
+ /** Primary event emitted on send with structured content blocks and generated HTML. */
50
+ messageSend;
51
+ /** Contenteditable editor element reference. */
52
+ editorRef;
53
+ /** Hidden file input element reference. */
54
+ fileInputRef;
55
+ // --- Host API (used by the app shell for drafts, deep links and shares) ---
56
+ /** Current plain text of the composer. */
57
+ async getText() {
58
+ return this.editorRef?.innerText ?? '';
59
+ }
60
+ /** Replaces the composer content with `text` (used to restore a draft after an update). */
61
+ async setText(text) {
62
+ if (!this.editorRef)
63
+ return;
64
+ this.editorRef.innerText = text ?? '';
65
+ this.placeCaretAtEnd(this.editorRef);
66
+ this.emitContentChange();
67
+ }
68
+ /** Adds files to the composer as attachment blocks (used by the share target). */
69
+ async addFiles(files) {
70
+ if (!files?.length)
71
+ return;
72
+ await this.handleFiles(files);
73
+ }
74
+ /** Focuses the editor and puts the caret at the end. */
75
+ async focusEditor() {
76
+ if (!this.editorRef)
77
+ return;
78
+ this.editorRef.focus();
79
+ this.placeCaretAtEnd(this.editorRef);
80
+ }
81
+ /**
82
+ * Generates a unique attachment id.
83
+ * Combines timestamp and a local counter to avoid collisions.
84
+ */
85
+ generateAttachmentId() {
86
+ return crypto.randomUUID();
87
+ }
88
+ /**
89
+ * Returns true if the given File is an image (based on MIME type).
90
+ */
91
+ isImageFile(file) {
92
+ return file.type.startsWith('image/');
93
+ }
94
+ /**
95
+ * Classifies a file as 'image' | 'document' | 'other' for UI and message blocks.
96
+ */
97
+ // private getFileType(file: File): 'image' | 'document' | 'other' {
98
+ // if (file.type.startsWith('image/')) return 'image';
99
+ // if (file.type.includes('pdf') || file.type.includes('document') || file.type.includes('text')) return 'document';
100
+ // return 'other';
101
+ // }
102
+ /**
103
+ * Generates a small dataURL thumbnail for image files using Canvas.
104
+ * Steps:
105
+ * - Read as DataURL
106
+ * - Load into Image
107
+ * - Draw to canvas constrained to max size
108
+ * - Return JPEG dataURL or undefined if not image
109
+ */
110
+ async generateThumbnail(file) {
111
+ if (!this.isImageFile(file))
112
+ return undefined;
113
+ return new Promise(resolve => {
114
+ const reader = new FileReader();
115
+ reader.onload = e => {
116
+ const img = new Image();
117
+ img.onload = () => {
118
+ const canvas = document.createElement('canvas');
119
+ const ctx = canvas.getContext('2d');
120
+ // Set thumbnail size
121
+ const maxSize = 100;
122
+ let { width, height } = img;
123
+ if (width > height) {
124
+ if (width > maxSize) {
125
+ height = height * (maxSize / width);
126
+ width = maxSize;
127
+ }
128
+ }
129
+ else {
130
+ if (height > maxSize) {
131
+ width = width * (maxSize / height);
132
+ height = maxSize;
133
+ }
134
+ }
135
+ canvas.width = width;
136
+ canvas.height = height;
137
+ ctx?.drawImage(img, 0, 0, width, height);
138
+ resolve(canvas.toDataURL('image/jpeg', 0.8));
139
+ };
140
+ img.src = e.target?.result;
141
+ };
142
+ reader.readAsDataURL(file);
143
+ });
144
+ }
145
+ /**
146
+ * Central file intake handler.
147
+ * - Normalizes FileList into an array
148
+ * - Builds FileAttachment objects and generates image previews
149
+ * - Inserts attachments as a single "attachment-block" at the caret
150
+ * - Emits contentChange after DOM updates
151
+ */
152
+ async handleFiles(files) {
153
+ const fileArray = Array.from(files);
154
+ // Create all attachments first
155
+ const attachments = [];
156
+ for (const file of fileArray) {
157
+ const attachment = {
158
+ mime_type: file.type,
159
+ id: this.generateAttachmentId(),
160
+ file,
161
+ name: file.name,
162
+ size: file.size,
163
+ };
164
+ if (attachment.mime_type.startsWith('image')) {
165
+ attachment.preview = await this.generateThumbnail(file);
166
+ }
167
+ attachments.push(attachment);
168
+ }
169
+ // Insert all attachments as a single block if multiple files were selected
170
+ if (attachments.length > 0) {
171
+ this.insertAttachmentsAtCursor(attachments);
172
+ }
173
+ this.emitContentChange();
174
+ }
175
+ /**
176
+ * Get the current selection scoped to the editor (supports ShadowRoot selection where available).
177
+ * Returns null if the selection is not inside the editor.
178
+ */
179
+ getEditorSelection() {
180
+ if (!this.editorRef)
181
+ return null;
182
+ const sr = this.hostElement.shadowRoot;
183
+ const sel = sr && typeof sr.getSelection === 'function' ? sr.getSelection() : window.getSelection();
184
+ if (!sel || sel.rangeCount === 0)
185
+ return null;
186
+ const anchor = sel.anchorNode;
187
+ return anchor && this.editorRef.contains(anchor) ? sel : null;
188
+ }
189
+ /**
190
+ * Place caret at the end of the editor.
191
+ */
192
+ placeCaretAtEnd(el) {
193
+ const range = document.createRange();
194
+ range.selectNodeContents(el);
195
+ range.collapse(false);
196
+ const sel = this.hostElement.shadowRoot?.getSelection?.() ?? window.getSelection();
197
+ sel?.removeAllRanges();
198
+ sel?.addRange(range);
199
+ }
200
+ /**
201
+ * Inserts a non-editable "attachment-block" element at the current caret.
202
+ * - Creates the block via createAttachmentBlock
203
+ * - Ensures a line break before/after and moves the caret after the block
204
+ * - Falls back to appending at the end when selection is unavailable or outside editor
205
+ */
206
+ insertAttachmentsAtCursor(attachments) {
207
+ if (!this.editorRef)
208
+ return;
209
+ const attachmentBlock = this.createAttachmentBlock(attachments);
210
+ // Ensure editor has focus so selection is within ShadowRoot/editor
211
+ this.editorRef.focus();
212
+ // Use a selection that is guaranteed to be inside the editor
213
+ let selection = this.getEditorSelection();
214
+ if (!selection) {
215
+ // No valid selection inside editor; move caret to end and try again
216
+ this.placeCaretAtEnd(this.editorRef);
217
+ selection = this.getEditorSelection();
218
+ }
219
+ if (selection && selection.rangeCount > 0) {
220
+ const range = selection.getRangeAt(0);
221
+ // If we're in the middle of a text node, break line before inserting the block
222
+ if (range.startContainer.nodeType === Node.TEXT_NODE && range.startOffset > 0) {
223
+ range.setStart(range.startContainer, range.startContainer.textContent?.length || 0);
224
+ range.collapse(true);
225
+ const br = document.createElement('br');
226
+ range.insertNode(br);
227
+ range.setStartAfter(br);
228
+ }
229
+ // Insert the block
230
+ range.insertNode(attachmentBlock);
231
+ // Add a line break after and place caret after it
232
+ const brAfter = document.createElement('br');
233
+ range.setStartAfter(attachmentBlock);
234
+ range.insertNode(brAfter);
235
+ range.setStartAfter(brAfter);
236
+ range.collapse(true);
237
+ selection.removeAllRanges();
238
+ selection.addRange(range);
239
+ return;
240
+ }
241
+ // Fallback: append to end with a trailing line break
242
+ if (this.editorRef.innerHTML.trim() && !this.editorRef.innerHTML.endsWith('<br>')) {
243
+ this.editorRef.appendChild(document.createElement('br'));
244
+ }
245
+ this.editorRef.appendChild(attachmentBlock);
246
+ const br = document.createElement('br');
247
+ this.editorRef.appendChild(br);
248
+ // Position caret after the line break
249
+ this.placeCaretAtEnd(this.editorRef);
250
+ }
251
+ // private insertAttachmentAtCursor(attachment: FileAttachment) {
252
+ // // For backward compatibility, wrap single attachment in array
253
+ // this.insertAttachmentsAtCursor([attachment]);
254
+ // }
255
+ /**
256
+ * Builds the DOM for an attachment block containing one or more attachments.
257
+ * - Stores attachments on the element for later extraction (legacy and new)
258
+ * - Renders thumbnails for images and generic icons for others
259
+ * - Adds per-attachment remove buttons, delegating to removeAttachmentFromBlock
260
+ */
261
+ createAttachmentBlock(attachments) {
262
+ const block = document.createElement('div');
263
+ block.className = 'attachment-block';
264
+ block.contentEditable = 'false';
265
+ // Store attachment data (for backward compatibility, store first ID for single attachments)
266
+ if (attachments.length === 1) {
267
+ block.setAttribute('data-attachment-id', attachments[0].id);
268
+ block._attachmentData = attachments[0]; // Legacy support
269
+ }
270
+ block._attachmentsData = attachments;
271
+ const content = document.createElement('div');
272
+ content.className = 'attachment-content';
273
+ // Create attachment items
274
+ attachments.forEach(attachment => {
275
+ const attachmentItem = document.createElement('div');
276
+ attachmentItem.className = 'attachment-item';
277
+ // Thumbnail or icon
278
+ if (attachment.mime_type.startsWith('image') && attachment.preview) {
279
+ const img = document.createElement('img');
280
+ img.src = attachment.preview;
281
+ img.alt = attachment.name;
282
+ img.className = 'attachment-thumbnail';
283
+ attachmentItem.appendChild(img);
284
+ }
285
+ else {
286
+ const icon = document.createElement('div');
287
+ icon.className = 'attachment-icon';
288
+ icon.innerHTML = `
289
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
290
+ <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
291
+ <polyline points="14,2 14,8 20,8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
292
+ </svg>
293
+ `;
294
+ attachmentItem.appendChild(icon);
295
+ }
296
+ // File info
297
+ const info = document.createElement('div');
298
+ info.className = 'attachment-info';
299
+ const name = document.createElement('div');
300
+ name.className = 'attachment-name';
301
+ name.textContent = attachment.name;
302
+ info.appendChild(name);
303
+ const size = document.createElement('div');
304
+ size.className = 'attachment-size';
305
+ size.textContent = this.formatFileSize(attachment.size);
306
+ info.appendChild(size);
307
+ attachmentItem.appendChild(info);
308
+ // Individual remove button for each attachment
309
+ const removeBtn = document.createElement('button');
310
+ removeBtn.className = 'attachment-remove';
311
+ removeBtn.type = 'button';
312
+ removeBtn.innerHTML = `
313
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
314
+ <path d="M12 4L4 12M4 4l8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
315
+ </svg>
316
+ `;
317
+ removeBtn.onclick = e => {
318
+ e.preventDefault();
319
+ e.stopPropagation();
320
+ this.removeAttachmentFromBlock(block, attachment.id);
321
+ };
322
+ attachmentItem.appendChild(removeBtn);
323
+ content.appendChild(attachmentItem);
324
+ });
325
+ block.appendChild(content);
326
+ return block;
327
+ }
328
+ /**
329
+ * Removes a single attachment from the given block.
330
+ * - If block becomes empty, removes the entire block
331
+ * - Otherwise rebuilds the block's DOM with remaining attachments
332
+ * - Maintains legacy single-attachment metadata for backward compatibility
333
+ * - Emits contentChange after updates
334
+ */
335
+ removeAttachmentFromBlock(block, attachmentId) {
336
+ const attachmentsData = block._attachmentsData;
337
+ if (attachmentsData) {
338
+ const updatedAttachments = attachmentsData.filter(att => att.id !== attachmentId);
339
+ if (updatedAttachments.length === 0) {
340
+ // Remove the entire block if no attachments left
341
+ this.removeAttachmentBlock(block);
342
+ }
343
+ else {
344
+ // Update the block with remaining attachments
345
+ block._attachmentsData = updatedAttachments;
346
+ // Update legacy data for backward compatibility
347
+ if (updatedAttachments.length === 1) {
348
+ block._attachmentData = updatedAttachments[0];
349
+ block.setAttribute('data-attachment-id', updatedAttachments[0].id);
350
+ }
351
+ else {
352
+ delete block._attachmentData;
353
+ block.removeAttribute('data-attachment-id');
354
+ }
355
+ // Recreate the content
356
+ const newBlock = this.createAttachmentBlock(updatedAttachments);
357
+ block.replaceWith(newBlock);
358
+ this.emitContentChange();
359
+ }
360
+ }
361
+ }
362
+ /**
363
+ * Removes the entire attachment block and adjacent trailing <br> if present.
364
+ * Emits contentChange afterward.
365
+ */
366
+ removeAttachmentBlock(block) {
367
+ if (block.parentNode) {
368
+ // Also remove any adjacent line breaks that might be empty
369
+ const nextSibling = block.nextSibling;
370
+ if (nextSibling && nextSibling.nodeName === 'BR') {
371
+ nextSibling.parentNode?.removeChild(nextSibling);
372
+ }
373
+ block.parentNode.removeChild(block);
374
+ this.emitContentChange();
375
+ }
376
+ }
377
+ /**
378
+ * Editor input handler that emits a legacy content snapshot.
379
+ */
380
+ handleInput = () => {
381
+ this.emitContentChange();
382
+ };
383
+ /**
384
+ * Extracts legacy content:
385
+ * - Walks the editor DOM collecting plain text and attachment data
386
+ * - Inserts textual placeholders around attachments to retain context
387
+ * - Returns trimmed text and a flat list of FileAttachment
388
+ */
389
+ extractContent() {
390
+ if (!this.editorRef) {
391
+ return { text: '', attachments: [] };
392
+ }
393
+ let text = '';
394
+ const attachments = [];
395
+ // Walk through all child nodes and extract text and attachments
396
+ if (!document.createTreeWalker) {
397
+ // Fallback for environments where createTreeWalker is not available (e.g., JSDOM)
398
+ const nodes = [];
399
+ const walk = (node) => {
400
+ nodes.push(node);
401
+ node.childNodes.forEach(walk);
402
+ };
403
+ walk(this.editorRef);
404
+ for (const node of nodes) {
405
+ if (node.nodeType === Node.TEXT_NODE) {
406
+ text += node.textContent || '';
407
+ }
408
+ else if (node.nodeType === Node.ELEMENT_NODE) {
409
+ const element = node;
410
+ if (element.classList.contains('attachment-block')) {
411
+ const attachmentsData = element._attachmentsData;
412
+ const attachmentData = element._attachmentData;
413
+ if (attachmentsData) {
414
+ attachments.push(...attachmentsData);
415
+ }
416
+ else if (attachmentData) {
417
+ attachments.push(attachmentData);
418
+ }
419
+ text += '\n[attachment]\n';
420
+ }
421
+ else if (element.tagName === 'BR') {
422
+ text += '\n';
423
+ }
424
+ }
425
+ }
426
+ }
427
+ else {
428
+ const walker = document.createTreeWalker(this.editorRef, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT, {
429
+ acceptNode: node => {
430
+ if (node.nodeType === Node.TEXT_NODE) {
431
+ return NodeFilter.FILTER_ACCEPT;
432
+ }
433
+ if (node.nodeType === Node.ELEMENT_NODE) {
434
+ const element = node;
435
+ if (element.classList.contains('attachment-block')) {
436
+ return NodeFilter.FILTER_ACCEPT;
437
+ }
438
+ if (element.tagName === 'BR') {
439
+ return NodeFilter.FILTER_ACCEPT;
440
+ }
441
+ }
442
+ return NodeFilter.FILTER_SKIP;
443
+ },
444
+ });
445
+ let node;
446
+ while ((node = walker.nextNode())) {
447
+ if (node.nodeType === Node.TEXT_NODE) {
448
+ text += node.textContent || '';
449
+ }
450
+ else if (node.nodeType === Node.ELEMENT_NODE) {
451
+ const element = node;
452
+ if (element.classList.contains('attachment-block')) {
453
+ // Support both new multiple attachments and legacy single attachment
454
+ const attachmentsData = element._attachmentsData;
455
+ const attachmentData = element._attachmentData;
456
+ if (attachmentsData) {
457
+ // New multiple attachments format
458
+ attachments.push(...attachmentsData);
459
+ }
460
+ else if (attachmentData) {
461
+ // Legacy single attachment format
462
+ attachments.push(attachmentData);
463
+ }
464
+ // Add a placeholder in text to maintain positioning context
465
+ text += '\n[attachment]\n';
466
+ }
467
+ else if (element.tagName === 'BR') {
468
+ text += '\n';
469
+ }
470
+ }
471
+ }
472
+ }
473
+ return {
474
+ text: text.trim(),
475
+ attachments,
476
+ };
477
+ }
478
+ /**
479
+ * Generates an HTML representation from structured blocks.
480
+ * - Escapes text content and preserves line breaks
481
+ * - Attachment blocks include data-* metadata for downstream consumers
482
+ */
483
+ generateHtmlContent(blocks) {
484
+ const htmlParts = [];
485
+ for (const block of blocks) {
486
+ if (block.type === 'text') {
487
+ // Convert text content to HTML, preserving line breaks
488
+ const textHtml = block.content.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br>');
489
+ htmlParts.push(`<div data-block-id="${block.id}" data-block-type="text">${textHtml}</div>`);
490
+ }
491
+ else if (block.type === 'attachment') {
492
+ const attachments = block.attachments;
493
+ // Create attachment HTML with data attributes for the block
494
+ const attachmentItems = attachments
495
+ .map(attachment => `
496
+ <div class="attachment-item" data-attachment-id="${attachment.id}" data-attachment-type="${attachment.mime_type}" data-attachment-name="${this.escapeHtml(attachment.name)}" data-attachment-size="${attachment.size}">
497
+ ${attachment.mime_type?.startsWith('image') && attachment.preview
498
+ ? `<img src="${attachment.preview}" alt="${this.escapeHtml(attachment.name)}" class="attachment-thumbnail">`
499
+ : `<div class="attachment-icon">
500
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
501
+ <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
502
+ <polyline points="14,2 14,8 20,8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
503
+ </svg>
504
+ </div>`}
505
+ <div class="attachment-info">
506
+ <div class="attachment-name">${this.escapeHtml(attachment.name)}</div>
507
+ <div class="attachment-size">${this.formatFileSize(attachment.size)}</div>
508
+ </div>
509
+ </div>
510
+ `)
511
+ .join('\n');
512
+ const attachmentHtml = `
513
+ <div class="attachment-block" data-block-id="${block.id}" data-block-type="attachment" data-attachment-count="${attachments.length}">
514
+ <div class="attachment-content">
515
+ ${attachmentItems}
516
+ </div>
517
+ </div>`;
518
+ htmlParts.push(attachmentHtml.trim());
519
+ }
520
+ }
521
+ return htmlParts.join('\n');
522
+ }
523
+ /**
524
+ * Escapes user text for safe embedding into HTML.
525
+ */
526
+ escapeHtml(text) {
527
+ return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
528
+ }
529
+ /**
530
+ * Extracts the structured content model from the editor:
531
+ * - Iterates top-level children to preserve block boundaries
532
+ * - Aggregates contiguous text into TextBlock(s)
533
+ * - Converts each attachment DOM block to an AttachmentBlock
534
+ * - Produces parallel HTML via generateHtmlContent
535
+ * This is the source of the primary messageSend payload.
536
+ */
537
+ extractStructuredContent() {
538
+ if (!this.editorRef) {
539
+ return { blocks: [], version: '1.0', html: '' };
540
+ }
541
+ const blocks = [];
542
+ let blockIdCounter = 0;
543
+ const children = Array.from(this.editorRef.childNodes);
544
+ let currentTextContent = '';
545
+ // Preserve newlines by not trimming the accumulated text
546
+ const flushTextBlock = () => {
547
+ if (currentTextContent.length > 0) {
548
+ const textBlock = {
549
+ id: `text_${++blockIdCounter}`,
550
+ type: 'text',
551
+ content: currentTextContent,
552
+ };
553
+ blocks.push(textBlock);
554
+ currentTextContent = '';
555
+ }
556
+ };
557
+ for (const child of children) {
558
+ if (child.nodeType === Node.TEXT_NODE) {
559
+ const textContent = child.textContent ?? '';
560
+ if (textContent.length > 0) {
561
+ currentTextContent += textContent;
562
+ }
563
+ }
564
+ else if (child.nodeType === Node.ELEMENT_NODE) {
565
+ const element = child;
566
+ if (element.classList.contains('attachment-block')) {
567
+ // Before an attachment, flush any accumulated text (including its newlines)
568
+ flushTextBlock();
569
+ // Support both multiple-attachment and legacy single-attachment formats
570
+ const attachmentsData = element._attachmentsData;
571
+ const attachmentData = element._attachmentData;
572
+ if (attachmentsData) {
573
+ const attachmentBlock = {
574
+ id: `attachment_${++blockIdCounter}`,
575
+ type: 'attachment',
576
+ attachments: attachmentsData,
577
+ };
578
+ blocks.push(attachmentBlock);
579
+ }
580
+ else if (attachmentData) {
581
+ const attachmentBlock = {
582
+ id: `attachment_${++blockIdCounter}`,
583
+ type: 'attachment',
584
+ attachments: [attachmentData],
585
+ };
586
+ blocks.push(attachmentBlock);
587
+ }
588
+ }
589
+ else if (element.tagName === 'BR') {
590
+ // Explicit line break
591
+ currentTextContent += '\n';
592
+ }
593
+ else {
594
+ // Add the element's text (textContent preserves inner <br> as \n)
595
+ const textContent = element.textContent ?? '';
596
+ if (textContent.length > 0) {
597
+ currentTextContent += textContent;
598
+ }
599
+ // If the element is block-level, ensure a newline boundary after it
600
+ if (this.isBlockElement(element) && !currentTextContent.endsWith('\n')) {
601
+ currentTextContent += '\n';
602
+ }
603
+ }
604
+ }
605
+ }
606
+ // Flush any remaining text (keep trailing newlines)
607
+ flushTextBlock();
608
+ const html = this.generateHtmlContent(blocks);
609
+ return {
610
+ blocks,
611
+ version: '1.0',
612
+ html,
613
+ };
614
+ }
615
+ /**
616
+ * Returns true if the element is a block-level element where a visual line break is implied.
617
+ * Used by extractStructuredContent to preserve newlines across block boundaries.
618
+ */
619
+ isBlockElement(el) {
620
+ const blockTags = new Set(['DIV', 'P', 'PRE', 'LI', 'UL', 'OL', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'BLOCKQUOTE']);
621
+ return blockTags.has(el.tagName);
622
+ }
623
+ /**
624
+ * Keyboard handler:
625
+ * - Enter sends the message
626
+ * - Shift+Enter inserts a newline (default behavior)
627
+ */
628
+ handleKeyDown = (e) => {
629
+ if (e.key === 'Enter' && !e.shiftKey) {
630
+ e.preventDefault();
631
+ this.handleSendMessage();
632
+ }
633
+ };
634
+ /**
635
+ * Opens the hidden file input to pick files.
636
+ */
637
+ handleFileButtonClick = () => {
638
+ this.fileInputRef?.click();
639
+ };
640
+ /**
641
+ * Forwards files selected from the file input to handleFiles and resets the input.
642
+ */
643
+ handleFileInputChange = (e) => {
644
+ const target = e.target;
645
+ if (target.files && target.files.length > 0) {
646
+ this.handleFiles(target.files);
647
+ target.value = ''; // Reset input
648
+ }
649
+ };
650
+ /**
651
+ * Drag handlers to improve UX:
652
+ * - handleDragOver/handleDragLeave toggle a visual overlay
653
+ * - handleDrop moves the caret to the drop location and forwards files
654
+ */
655
+ handleDragOver = (e) => {
656
+ e.preventDefault();
657
+ e.stopPropagation();
658
+ this.isDragOver = true;
659
+ };
660
+ handleDragLeave = (e) => {
661
+ e.preventDefault();
662
+ e.stopPropagation();
663
+ this.isDragOver = false;
664
+ };
665
+ /**
666
+ * Accepts dropped files:
667
+ * - Places caret at the drop point within the editor when possible
668
+ * - Delegates to handleFiles for processing and insertion
669
+ */
670
+ handleDrop = async (e) => {
671
+ e.preventDefault();
672
+ e.stopPropagation();
673
+ this.isDragOver = false;
674
+ const files = e.dataTransfer?.files;
675
+ if (files && files.length > 0) {
676
+ // Set cursor position to drop location if possible
677
+ const range = document.caretRangeFromPoint(e.clientX, e.clientY);
678
+ if (range && this.editorRef?.contains(range.startContainer)) {
679
+ const selection = window.getSelection();
680
+ selection?.removeAllRanges();
681
+ selection?.addRange(range);
682
+ }
683
+ await this.handleFiles(files);
684
+ }
685
+ };
686
+ /**
687
+ * Sends the current message:
688
+ * - Builds both legacy and structured payloads
689
+ * - Emits messageSend (structured)
690
+ * - Clears the editor if there was content
691
+ */
692
+ handleSendMessage = () => {
693
+ const content = this.extractContent();
694
+ const structuredContent = this.extractStructuredContent();
695
+ console.debug(`handleSendMessage`, structuredContent.blocks);
696
+ if (content.text.trim() || content.attachments.length > 0) {
697
+ // Emit the new structured format as the primary event
698
+ this.messageSend.emit(structuredContent);
699
+ // Clear content after sending
700
+ if (this.editorRef) {
701
+ this.editorRef.innerHTML = '';
702
+ }
703
+ // Update state to reflect cleared content
704
+ this.emitContentChange();
705
+ }
706
+ };
707
+ /**
708
+ * Emits a contentChange event with the current legacy content snapshot.
709
+ * Also updates hasContent state to trigger re-render.
710
+ */
711
+ emitContentChange = () => {
712
+ const content = this.extractContent();
713
+ const has = !!(content.text.trim() || content.attachments.length > 0);
714
+ if (this.hasContent !== has)
715
+ this.hasContent = has;
716
+ this.contentChange.emit(content);
717
+ };
718
+ /**
719
+ * Formats a byte size into a human-readable string (Bytes, KB, MB, GB).
720
+ */
721
+ formatFileSize = (bytes) => {
722
+ if (bytes === 0)
723
+ return '0 Bytes';
724
+ const k = 1024;
725
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
726
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
727
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
728
+ };
729
+ /**
730
+ * Renders the component:
731
+ * - Contenteditable editor with placeholder
732
+ * - File and send action buttons
733
+ * - Hidden file input
734
+ * - Drag-and-drop overlay
735
+ * The send button is disabled when there is no content or when disabled.
736
+ */
737
+ render() {
738
+ // Use reactive state so typing/attachments trigger re-render
739
+ const hasContent = this.hasContent;
740
+ return (h("div", { key: '2a3b14309017d69790c17db7591a28f82f49cee4', class: `rich-input-container ${this.isDragOver ? 'drag-over' : ''}`, onDragOver: this.handleDragOver, onDragLeave: this.handleDragLeave, onDrop: this.handleDrop }, h("div", { key: '4a2310a460ed29c6d47dd1683f070ebbd054b73a', class: "editor-area" }, h("div", { key: '922433e6227fdd46fa71fdc5b05f1c508fcab423', class: "editor-wrapper" }, h("div", { key: '6fd7691dab9e056058a0109dfe708e6bd3236c4b', ref: el => (this.editorRef = el), class: "rich-editor", contentEditable: !this.disabled, onInput: this.handleInput, onKeyDown: this.handleKeyDown, "data-placeholder": this.placeholder, style: { maxHeight: this.maxHeight } }), h("div", { key: '7ef1ab99474753beafcbf08e85d55e1037b887ff', class: "input-actions" }, h("button", { key: '622970886800a5f602a079598d283eea9a1f0689', class: "action-button file-button", onClick: this.handleFileButtonClick, disabled: this.disabled, type: "button" }, h("svg", { key: '722d7fb7a68b08888039e36f58d16d39472ad229', xmlns: "http://www.w3.org/2000/svg", width: "17", height: "16", viewBox: "0 0 17 16", fill: "none" }, h("path", { key: 'e06306ea498415db01f587e218637594b90a8983', d: "M11.9286 3.42858L11.9286 10.5714C11.9286 12.6286 10.2714 14.2857 8.21429 14.2857C6.15714 14.2857 4.5 12.6286 4.5 10.5714L4.5 4.28572C4.5 2.85715 5.64286 1.71429 7.07143 1.71429C8.5 1.71429 9.64286 2.85715 9.64286 4.28572L9.64286 10C9.64286 10.8 9.01429 11.4286 8.21429 11.4286C7.41429 11.4286 6.78571 10.8 6.78571 10L6.78571 5.14287", stroke: "#4A86E8", "stroke-width": "1.5", "stroke-miterlimit": "10", "stroke-linecap": "square" }))), h("button", { key: '717f2e6f57f4b8316ffa58da639f695f4e55ca6f', class: "action-button file-button", onClick: this.handleFileButtonClick, disabled: this.disabled, type: "button" }, h("svg", { key: '08a5a232a719d8e4e18053d469e868aeeba1972b', xmlns: "http://www.w3.org/2000/svg", width: "33", height: "32", viewBox: "0 0 33 32", fill: "none" }, h("path", { key: 'c642251b6186dde4ab105f7655c212f510734693', d: "M10.5 18.5312L14.3226 14.7683C14.6047 14.4907 15.062 14.4907 15.344 14.7683L18.4444 17.8203M18.4444 17.8203L17.3611 18.8867M18.4444 17.8203L19.7393 16.5457C20.0214 16.268 20.4786 16.268 20.7607 16.5457L23.5 19.2422M11.9444 21.375H22.0556C22.8533 21.375 23.5 20.7384 23.5 19.9531V11.4219C23.5 10.6366 22.8533 10 22.0556 10H11.9444C11.1467 10 10.5 10.6366 10.5 11.4219V19.9531C10.5 20.7384 11.1467 21.375 11.9444 21.375ZM21.6944 13.1992C21.6944 13.9845 21.0477 14.6211 20.25 14.6211C19.4523 14.6211 18.8056 13.9845 18.8056 13.1992C18.8056 12.4139 19.4523 11.7773 20.25 11.7773C21.0477 11.7773 21.6944 12.4139 21.6944 13.1992Z", stroke: "#4A86E8", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }))), h("button", { key: 'caa33c6d18525872a4ee2d672bee04a549779499', class: "action-button send-button", onClick: this.handleSendMessage, disabled: this.disabled || !hasContent, type: "button" }, h("svg", { key: 'c111af09449b62afeb754eb691abdeee59c092ce', xmlns: "http://www.w3.org/2000/svg", width: "17", height: "16", viewBox: "0 0 17 16", fill: "none" }, h("path", { key: 'c7a9328a8abe02f7aa16dbae45574639bc94eb37', d: "M14.214 2.28564L5.64258 9.14279L5.64258 13.1428L7.69972 10.6856", stroke: "#4A86E8", "stroke-width": "1.5", "stroke-miterlimit": "10" }), h("path", { key: '0e141532e3694d564b8eab7240fd80a2ce172a7c', d: "M2.78613 6.85707L14.2147 2.28564L11.929 13.7142L2.78613 6.85707Z", stroke: "#4A86E8", "stroke-width": "1.5", "stroke-miterlimit": "10", "stroke-linecap": "square" })))))), h("input", { key: 'ed2eb79d5e731a3c324943439f5fcc8cee484e66', ref: el => (this.fileInputRef = el), type: "file", accept: this.acceptFiles, multiple: true, onChange: this.handleFileInputChange, style: { display: 'none' } }), this.isDragOver && (h("div", { key: '7d1deb8bc1c5cceac823ea6aa08de5c81e412e3d', class: "drag-overlay" }, h("div", { key: 'c27aff7a27b17eb06c4b79f25901e2db7c11be69', class: "drag-content" }, h("svg", { key: '13c7243782c1fb604113ec8e09a53cd44aabb1e4', xmlns: "http://www.w3.org/2000/svg", width: "48", height: "48", viewBox: "0 0 48 48", fill: "none" }, h("path", { key: '0ac333bcd102668edcf034e559a75cbd64e7bdd8', d: "M38 20v16a4 4 0 0 1-4 4H14a4 4 0 0 1-4-4V20M32 10L24 2l-8 8M24 2v28", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })), h("p", { key: '4addb3c7733503a556958fa9b46b2c520cc3bf5d' }, "Dateien hier ziehen"))))));
741
+ }
742
+ static get is() { return "chatleo-rich-input"; }
743
+ static get encapsulation() { return "shadow"; }
744
+ static get originalStyleUrls() {
745
+ return {
746
+ "$": ["chatleo-rich-input.css"]
747
+ };
748
+ }
749
+ static get styleUrls() {
750
+ return {
751
+ "$": ["chatleo-rich-input.css"]
752
+ };
753
+ }
754
+ static get properties() {
755
+ return {
756
+ "disabled": {
757
+ "type": "boolean",
758
+ "mutable": false,
759
+ "complexType": {
760
+ "original": "boolean",
761
+ "resolved": "boolean",
762
+ "references": {}
763
+ },
764
+ "required": false,
765
+ "optional": false,
766
+ "docs": {
767
+ "tags": [],
768
+ "text": "If `true`, the editor and all associated buttons will be disabled, preventing user interaction."
769
+ },
770
+ "getter": false,
771
+ "setter": false,
772
+ "reflect": false,
773
+ "attribute": "disabled",
774
+ "defaultValue": "false"
775
+ },
776
+ "placeholder": {
777
+ "type": "string",
778
+ "mutable": false,
779
+ "complexType": {
780
+ "original": "string",
781
+ "resolved": "string",
782
+ "references": {}
783
+ },
784
+ "required": false,
785
+ "optional": false,
786
+ "docs": {
787
+ "tags": [],
788
+ "text": "The placeholder text that appears in the editor when it is empty."
789
+ },
790
+ "getter": false,
791
+ "setter": false,
792
+ "reflect": false,
793
+ "attribute": "placeholder",
794
+ "defaultValue": "'Write a message...'"
795
+ },
796
+ "maxHeight": {
797
+ "type": "string",
798
+ "mutable": false,
799
+ "complexType": {
800
+ "original": "string",
801
+ "resolved": "string",
802
+ "references": {}
803
+ },
804
+ "required": false,
805
+ "optional": false,
806
+ "docs": {
807
+ "tags": [],
808
+ "text": "A CSS string that defines the maximum height of the editor area before it starts scrolling."
809
+ },
810
+ "getter": false,
811
+ "setter": false,
812
+ "reflect": false,
813
+ "attribute": "max-height",
814
+ "defaultValue": "'200px'"
815
+ },
816
+ "acceptFiles": {
817
+ "type": "string",
818
+ "mutable": false,
819
+ "complexType": {
820
+ "original": "string",
821
+ "resolved": "string",
822
+ "references": {}
823
+ },
824
+ "required": false,
825
+ "optional": false,
826
+ "docs": {
827
+ "tags": [],
828
+ "text": "A comma-separated string of MIME types or file extensions that the file input should accept. This is passed to the `accept` attribute of the hidden file input element."
829
+ },
830
+ "getter": false,
831
+ "setter": false,
832
+ "reflect": false,
833
+ "attribute": "accept-files",
834
+ "defaultValue": "'image/*,.pdf,.doc,.docx,.txt'"
835
+ }
836
+ };
837
+ }
838
+ static get states() {
839
+ return {
840
+ "isDragOver": {},
841
+ "hasContent": {}
842
+ };
843
+ }
844
+ static get events() {
845
+ return [{
846
+ "method": "contentChange",
847
+ "name": "contentChange",
848
+ "bubbles": true,
849
+ "cancelable": true,
850
+ "composed": true,
851
+ "docs": {
852
+ "tags": [],
853
+ "text": "Fires whenever the legacy content snapshot changes (typing, attachments)."
854
+ },
855
+ "complexType": {
856
+ "original": "RichInputContent",
857
+ "resolved": "RichInputContent",
858
+ "references": {
859
+ "RichInputContent": {
860
+ "location": "import",
861
+ "path": "@chat-leo/chatleolib",
862
+ "id": "../chatleolib/dist/index.d.ts::RichInputContent",
863
+ "referenceLocation": "RichInputContent"
864
+ }
865
+ }
866
+ }
867
+ }, {
868
+ "method": "messageSend",
869
+ "name": "messageSend",
870
+ "bubbles": true,
871
+ "cancelable": true,
872
+ "composed": true,
873
+ "docs": {
874
+ "tags": [],
875
+ "text": "Primary event emitted on send with structured content blocks and generated HTML."
876
+ },
877
+ "complexType": {
878
+ "original": "StructuredMessageContent",
879
+ "resolved": "StructuredMessageContent",
880
+ "references": {
881
+ "StructuredMessageContent": {
882
+ "location": "import",
883
+ "path": "@chat-leo/chatleolib",
884
+ "id": "../chatleolib/dist/index.d.ts::StructuredMessageContent",
885
+ "referenceLocation": "StructuredMessageContent"
886
+ }
887
+ }
888
+ }
889
+ }];
890
+ }
891
+ static get methods() {
892
+ return {
893
+ "getText": {
894
+ "complexType": {
895
+ "signature": "() => Promise<string>",
896
+ "parameters": [],
897
+ "references": {
898
+ "Promise": {
899
+ "location": "global",
900
+ "id": "global::Promise"
901
+ }
902
+ },
903
+ "return": "Promise<string>"
904
+ },
905
+ "docs": {
906
+ "text": "Current plain text of the composer.",
907
+ "tags": []
908
+ }
909
+ },
910
+ "setText": {
911
+ "complexType": {
912
+ "signature": "(text: string) => Promise<void>",
913
+ "parameters": [{
914
+ "name": "text",
915
+ "type": "string",
916
+ "docs": ""
917
+ }],
918
+ "references": {
919
+ "Promise": {
920
+ "location": "global",
921
+ "id": "global::Promise"
922
+ }
923
+ },
924
+ "return": "Promise<void>"
925
+ },
926
+ "docs": {
927
+ "text": "Replaces the composer content with `text` (used to restore a draft after an update).",
928
+ "tags": []
929
+ }
930
+ },
931
+ "addFiles": {
932
+ "complexType": {
933
+ "signature": "(files: File[]) => Promise<void>",
934
+ "parameters": [{
935
+ "name": "files",
936
+ "type": "File[]",
937
+ "docs": ""
938
+ }],
939
+ "references": {
940
+ "Promise": {
941
+ "location": "global",
942
+ "id": "global::Promise"
943
+ },
944
+ "File": {
945
+ "location": "global",
946
+ "id": "global::File"
947
+ }
948
+ },
949
+ "return": "Promise<void>"
950
+ },
951
+ "docs": {
952
+ "text": "Adds files to the composer as attachment blocks (used by the share target).",
953
+ "tags": []
954
+ }
955
+ },
956
+ "focusEditor": {
957
+ "complexType": {
958
+ "signature": "() => Promise<void>",
959
+ "parameters": [],
960
+ "references": {
961
+ "Promise": {
962
+ "location": "global",
963
+ "id": "global::Promise"
964
+ }
965
+ },
966
+ "return": "Promise<void>"
967
+ },
968
+ "docs": {
969
+ "text": "Focuses the editor and puts the caret at the end.",
970
+ "tags": []
971
+ }
972
+ }
973
+ };
974
+ }
975
+ static get elementRef() { return "hostElement"; }
976
+ }