@chai-ui/vue 0.8.0 → 0.9.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.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { inject, computed, defineComponent, provide, renderSlot, watch, onScopeDispose, h, ref, openBlock, createElementBlock, createElementVNode, normalizeClass, createBlock, unref, Fragment, renderList, resolveDynamicComponent, createTextVNode, toDisplayString, createCommentVNode, normalizeStyle, createVNode, useId, nextTick, mergeProps, onMounted, onUnmounted, withModifiers, withCtx, withDirectives, vModelText, reactive, toValue, shallowRef } from "vue";
2
- import { reasoningEngineFor, createReasoning, regionColor, MAX_ANIMATE_ENHANCE_LENGTH, enhanceRevealDurationMs, composerView, composerAttachMenuItems, composerAttachmentsFromFiles, regionBoxStyle, REGION_CORNERS, DEFAULT_MAX_REGIONS, freeRegionNumber, EDIT_ZOOM_STEPS, regionPopoverPosition, editCardWidth, newRegion, panForZoom, clampPan, fitBox, resizeBox, regionBoxForKey, panForKey, downloadMedia, downloadFilename, shareMedia, resultModelLabel, formatTokens, formatCost, formatDuration, formatAspectRatio, SUGGESTED_ANALYSIS_MODELS, DEFAULT_MAX_ATTACHMENTS_BY_KIND, isMediaAnalyzerAtCap, mediaAnalyzerModelSections, PROMPT_LENGTH_HINT, readMediaFiles, nextMediaAnalyzerAttachments, replacedNote, createComposerStore, pickReasoning, createMediaAnalyzerStore } from "@chai-ui/core";
3
- import { DEFAULT_MAX_ATTACHMENTS_BY_KIND as DEFAULT_MAX_ATTACHMENTS_BY_KIND2, DEFAULT_MAX_REGIONS as DEFAULT_MAX_REGIONS2, DEFAULT_MEDIA_ANALYSIS_PROMPT_LENGTH, DEFAULT_MODEL_ID, DEFAULT_REASONING_MODEL, DEFAULT_REASONING_MODEL_BY_KIND, EDIT_IMAGE_USE_CASE, GenerationError, MEDIA_ANALYSIS_PROMPTS, MEDIA_ANALYSIS_PROMPT_LENGTHS, PRECISE_EDIT_MODELS, ROUTING_MODEL_ID, SUGGESTED_ANALYSIS_MODELS as SUGGESTED_ANALYSIS_MODELS2, SUGGESTED_EDIT_MODELS, SUGGESTED_IMAGE_MODELS, SUGGESTED_IMAGE_TO_VIDEO_MODELS, SUGGESTED_TEXT_TO_VIDEO_MODELS, TEXT_USE_CASE, buildRegionEditPrompt, checkSuggestedModels, createFalEngine, createMockEngine, createOpenRouterEngine, isMediaAnalyzerAtCap as isMediaAnalyzerAtCap2, mockEngine, nextMediaAnalyzerAttachments as nextMediaAnalyzerAttachments2, reasoningModelFor, suggestedModels } from "@chai-ui/core";
1
+ import { inject, computed, defineComponent, provide, renderSlot, watch, onScopeDispose, h, ref, openBlock, createElementBlock, createElementVNode, normalizeClass, createBlock, unref, Fragment, renderList, resolveDynamicComponent, createTextVNode, toDisplayString, createCommentVNode, normalizeStyle, createVNode, useId, nextTick, shallowRef, mergeProps, onMounted, onUnmounted, withModifiers, withCtx, withDirectives, vModelText, reactive, toValue } from "vue";
2
+ import { reasoningEngineFor, createReasoning, regionColor, MAX_ANIMATE_ENHANCE_LENGTH, enhanceRevealDurationMs, VOICE_LEVEL_COUNT, formatVoiceElapsed, composerView, composerAttachMenuItems, createVoiceInput, composerAttachmentsFromFiles, regionBoxStyle, REGION_CORNERS, DEFAULT_MAX_REGIONS, freeRegionNumber, EDIT_ZOOM_STEPS, regionPopoverPosition, editCardWidth, newRegion, panForZoom, clampPan, fitBox, resizeBox, regionBoxForKey, panForKey, downloadMedia, downloadFilename, shareMedia, resultModelLabel, formatTokens, formatCost, formatDuration, formatAspectRatio, SUGGESTED_ANALYSIS_MODELS, DEFAULT_MAX_ATTACHMENTS_BY_KIND, isMediaAnalyzerAtCap, mediaAnalyzerModelSections, PROMPT_LENGTH_HINT, readMediaFiles, nextMediaAnalyzerAttachments, replacedNote, createComposerStore, pickReasoning, createMediaAnalyzerStore } from "@chai-ui/core";
3
+ import { DEFAULT_MAX_ATTACHMENTS_BY_KIND as DEFAULT_MAX_ATTACHMENTS_BY_KIND2, DEFAULT_MAX_REGIONS as DEFAULT_MAX_REGIONS2, DEFAULT_MEDIA_ANALYSIS_PROMPT_LENGTH, DEFAULT_MODEL_ID, DEFAULT_REASONING_MODEL, DEFAULT_REASONING_MODEL_BY_KIND, EDIT_IMAGE_USE_CASE, GenerationError, MEDIA_ANALYSIS_PROMPTS, MEDIA_ANALYSIS_PROMPT_LENGTHS, PRECISE_EDIT_MODELS, ROUTING_MODEL_ID, SUGGESTED_ANALYSIS_MODELS as SUGGESTED_ANALYSIS_MODELS2, SUGGESTED_EDIT_MODELS, SUGGESTED_IMAGE_MODELS, SUGGESTED_IMAGE_TO_VIDEO_MODELS, SUGGESTED_TEXT_TO_VIDEO_MODELS, TEXT_USE_CASE, buildRegionEditPrompt, checkSuggestedModels, createFalEngine, createFalTranscriber, createMockEngine, createOpenRouterEngine, isMediaAnalyzerAtCap as isMediaAnalyzerAtCap2, mockEngine, nextMediaAnalyzerAttachments as nextMediaAnalyzerAttachments2, reasoningModelFor, suggestedModels } from "@chai-ui/core";
4
4
  import "@material/web/fab/fab.js";
5
5
  import "@material/web/checkbox/checkbox.js";
6
6
  import "@material/web/textfield/outlined-text-field.js";
@@ -10,7 +10,7 @@ function useReasoning() {
10
10
  const provided = inject(reasoningKey, null);
11
11
  return computed(() => provided?.value);
12
12
  }
13
- const _sfc_main$i = /* @__PURE__ */ defineComponent({
13
+ const _sfc_main$k = /* @__PURE__ */ defineComponent({
14
14
  __name: "ChaiProvider",
15
15
  props: {
16
16
  reasoningModel: {},
@@ -64,6 +64,7 @@ const VisibilityIcon = icon("0 -960 960 960", [{ "d": "M600.5-379.5Q650-429 650-
64
64
  const VisibilityOffIcon = icon("0 -960 960 960", [{ "d": "m629-419-44-44q26-71-27-118t-115-24l-44-44q17-11 38-16t43-5q71 0 120.5 49.5T650-500q0 22-5.5 43.5T629-419Zm129 129-40-40q49-36 85.5-80.5T857-500q-50-111-150-175.5T490-740q-42 0-86 8t-69 19l-46-47q35-16 89.5-28T485-800q143 0 261.5 81.5T920-500q-26 64-67 117t-95 93Zm58 226L648-229q-35 14-79 21.5t-89 7.5q-146 0-265-81.5T40-500q20-52 55.5-101.5T182-696L56-822l42-43 757 757-39 44ZM223-654q-37 27-71.5 71T102-500q51 111 153.5 175.5T488-260q33 0 65-4t48-12l-64-64q-11 5-27 7.5t-30 2.5q-70 0-120-49t-50-121q0-15 2.5-30t7.5-27l-97-97Zm305 142Zm-116 58Z", "fill": "currentColor" }]);
65
65
  const CheckSymbolIcon = icon("0 -960 960 960", [{ "d": "M378-246 154-470l43-43 181 181 384-384 43 43-427 427Z", "fill": "currentColor" }]);
66
66
  const CloseSymbolIcon = icon("0 -960 960 960", [{ "d": "m249-207-42-42 231-231-231-231 42-42 231 231 231-231 42 42-231 231 231 231-42 42-231-231-231 231Z", "fill": "currentColor" }]);
67
+ const MicIcon = icon("0 -960 960 960", [{ "d": "M408-453.92q-29-30.91-29-75.08v-251q0-41.67 29.44-70.83Q437.88-880 479.94-880t71.56 29.17Q581-821.67 581-780v251q0 44.17-29 75.08Q523-423 480-423t-72-30.92ZM480-651Zm-30 531v-136q-106-11-178-89t-72-184h60q0 91 64.29 153t155.5 62q91.21 0 155.71-62Q700-438 700-529h60q0 106-72 184t-178 89v136h-60Zm59.5-376.5Q521-510 521-529v-251q0-17-11.79-28.5T480-820q-17.42 0-29.21 11.5T439-780v251q0 19 11.5 32.5T480-483q18 0 29.5-13.5Z", "fill": "currentColor" }]);
67
68
  const StopIcon = icon("0 -960 960 960", [{ "d": "M240-240v-480h480v480H240Z", "fill": "currentColor" }]);
68
69
  const ThumbUpIcon = icon("0 0 18 18", [{ "d": "M5.25039 15.7502V6.00019L10.5004 0.750193L11.8879 2.13769L10.9129 6.00019H17.2504V9.30019L14.5129 15.7502H5.25039ZM6.75039 14.2502H13.5004L15.7504 9.00019V7.50019H9.00039L10.0129 3.37519L6.75039 6.63769V14.2502ZM1.50039 15.7502V6.00019H5.25039V7.50019H3.00039V14.2502H5.25039V15.7502H1.50039Z", "fill": "currentColor" }], true);
69
70
  const ThumbDownIcon = icon("0 0 18 18", [{ "d": "M2.24961 12C1.84961 12 1.49961 11.85 1.19961 11.55C0.899615 11.25 0.749615 10.9 0.749615 10.5V9C0.749615 8.9125 0.762115 8.81875 0.787115 8.71875C0.812115 8.61875 0.837115 8.525 0.862115 8.4375L3.11211 3.15C3.22461 2.9 3.41211 2.6875 3.67461 2.5125C3.93711 2.3375 4.21211 2.25 4.49961 2.25H12.7496V12L8.24961 16.4625C8.06211 16.65 7.84024 16.7594 7.58399 16.7906C7.32774 16.8219 7.08086 16.775 6.84336 16.65C6.60586 16.525 6.43086 16.35 6.31836 16.125C6.20586 15.9 6.18086 15.6688 6.24336 15.4313L7.08711 12H2.24961ZM11.2496 11.3625V3.75H4.49961L2.24961 9V10.5H8.99961L7.98711 14.625L11.2496 11.3625ZM14.9996 2.25C15.4121 2.25 15.7652 2.39688 16.059 2.69063C16.3527 2.98438 16.4996 3.3375 16.4996 3.75V10.5C16.4996 10.9125 16.3527 11.2656 16.059 11.5594C15.7652 11.8531 15.4121 12 14.9996 12H12.7496V10.5H14.9996V3.75H12.7496V2.25H14.9996Z", "fill": "currentColor" }], true);
@@ -90,21 +91,21 @@ const GlobeIcon = icon("0 -960 960 960", [{ "d": "M480.27-80q-82.74 0-155.5-31.5
90
91
  const VideocamIcon = icon("0 -960 960 960", [{ "d": "M140-160q-24 0-42-18t-18-42v-520q0-24 18-42t42-18h520q24 0 42 18t18 42v215l160-160v410L720-435v215q0 24-18 42t-42 18H140Zm0-60h520v-520H140v520Zm0 0v-520 520Z", "fill": "currentColor" }]);
91
92
  const ContentCutIcon = icon("0 -960 960 960", [{ "d": "M782-114 481-415 364-298q11 17 13.5 33t2.5 35q0 64-43 107T230-80q-64 0-107-43T80-230q0-64 43-107t107-43q18 0 35.5 5t36.5 15l116-116-118-118q-17 8-34.5 11t-35.5 3q-64 0-107-43T80-730q0-64 43-107t107-43q64 0 107 43t43 107q0 19-2.5 36T367-662l514 514v34h-99ZM599-527l-66-66 249-249h99v33L599-527ZM294-666q26-26 26-64t-26-64q-26-26-64-26t-64 26q-26 26-26 64t26 64q26 26 64 26t64-26Zm202.5 203.5Q502-468 502-476t-5.5-13.5Q491-495 483-495t-13.5 5.5Q464-484 464-476t5.5 13.5Q475-457 483-457t13.5-5.5ZM294-166q26-26 26-64t-26-64q-26-26-64-26t-64 26q-26 26-26 64t26 64q26 26 64 26t64-26Z", "fill": "currentColor" }]);
92
93
  const MusicNoteIcon = icon("0 -960 960 960", [{ "d": "M286.5-163.5Q243-207 243-270t43.5-106.5Q330-420 393-420q28 0 50.5 8t39.5 22v-450h234v135H543v435q0 63-43.5 106.5T393-120q-63 0-106.5-43.5Z", "fill": "currentColor" }]);
93
- const _hoisted_1$h = ["disabled", "aria-expanded", "aria-label"];
94
- const _hoisted_2$c = {
94
+ const _hoisted_1$j = ["disabled", "aria-expanded", "aria-label"];
95
+ const _hoisted_2$e = {
95
96
  key: 0,
96
97
  class: "chai-composer__attach-menu",
97
98
  role: "menu"
98
99
  };
99
- const _hoisted_3$a = ["onClick"];
100
- const _hoisted_4$8 = { class: "chai-composer__attach-menu-icon" };
100
+ const _hoisted_3$c = ["onClick"];
101
+ const _hoisted_4$9 = { class: "chai-composer__attach-menu-icon" };
101
102
  const _hoisted_5$7 = {
102
103
  key: 0,
103
104
  class: "chai-composer__attach-menu-divider",
104
105
  role: "separator"
105
106
  };
106
107
  const _hoisted_6$7 = ["accept", "multiple", "disabled"];
107
- const _sfc_main$h = /* @__PURE__ */ defineComponent({
108
+ const _sfc_main$j = /* @__PURE__ */ defineComponent({
108
109
  __name: "AttachMenu",
109
110
  props: {
110
111
  items: {},
@@ -145,8 +146,8 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
145
146
  onClick: _cache[0] || (_cache[0] = ($event) => open.value = !open.value)
146
147
  }, [
147
148
  open.value ? (openBlock(), createBlock(unref(CloseSymbolIcon), { key: 0 })) : (openBlock(), createBlock(unref(PlusIcon), { key: 1 }))
148
- ], 10, _hoisted_1$h),
149
- open.value ? (openBlock(), createElementBlock("ul", _hoisted_2$c, [
149
+ ], 10, _hoisted_1$j),
150
+ open.value ? (openBlock(), createElementBlock("ul", _hoisted_2$e, [
150
151
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, i) => {
151
152
  return openBlock(), createElementBlock("li", {
152
153
  key: item.action,
@@ -158,11 +159,11 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
158
159
  class: "chai-composer__attach-menu-item",
159
160
  onClick: ($event) => pick(item.action)
160
161
  }, [
161
- createElementVNode("span", _hoisted_4$8, [
162
+ createElementVNode("span", _hoisted_4$9, [
162
163
  (openBlock(), createBlock(resolveDynamicComponent(ICONS[item.action])))
163
164
  ]),
164
165
  createTextVNode(toDisplayString(item.label), 1)
165
- ], 8, _hoisted_3$a),
166
+ ], 8, _hoisted_3$c),
166
167
  item.divider && i < __props.items.length - 1 ? (openBlock(), createElementBlock("hr", _hoisted_5$7)) : createCommentVNode("", true)
167
168
  ]);
168
169
  }), 128))
@@ -181,13 +182,13 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
181
182
  };
182
183
  }
183
184
  });
184
- const _hoisted_1$g = {
185
+ const _hoisted_1$i = {
185
186
  key: 0,
186
187
  class: "chai-composer__region-badge",
187
188
  "aria-hidden": "true"
188
189
  };
189
- const _hoisted_2$b = ["disabled", "aria-label"];
190
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
190
+ const _hoisted_2$d = ["disabled", "aria-label"];
191
+ const _sfc_main$i = /* @__PURE__ */ defineComponent({
191
192
  __name: "Chip",
192
193
  props: {
193
194
  label: {},
@@ -203,7 +204,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
203
204
  class: normalizeClass(["chai-composer__chip", { "chai-composer__chip--region": __props.regionNumber != null }]),
204
205
  style: normalizeStyle(__props.regionNumber != null ? { "--chai-region-color": unref(regionColor)(__props.regionNumber) } : void 0)
205
206
  }, [
206
- __props.regionNumber != null ? (openBlock(), createElementBlock("span", _hoisted_1$g, toDisplayString(__props.regionNumber), 1)) : createCommentVNode("", true),
207
+ __props.regionNumber != null ? (openBlock(), createElementBlock("span", _hoisted_1$i, toDisplayString(__props.regionNumber), 1)) : createCommentVNode("", true),
207
208
  createTextVNode(toDisplayString(__props.label), 1),
208
209
  __props.removable ? (openBlock(), createElementBlock("button", {
209
210
  key: 1,
@@ -214,18 +215,18 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
214
215
  onClick: _cache[0] || (_cache[0] = ($event) => emit("remove"))
215
216
  }, [
216
217
  createVNode(unref(CloseSymbolIcon))
217
- ], 8, _hoisted_2$b)) : createCommentVNode("", true)
218
+ ], 8, _hoisted_2$d)) : createCommentVNode("", true)
218
219
  ], 6);
219
220
  };
220
221
  }
221
222
  });
222
- const _hoisted_1$f = {
223
+ const _hoisted_1$h = {
223
224
  key: 0,
224
225
  class: "chai-composer__world-field"
225
226
  };
226
- const _hoisted_2$a = { class: "chai-composer__world-field-head" };
227
- const _hoisted_3$9 = ["for"];
228
- const _hoisted_4$7 = ["disabled", "aria-label", "title"];
227
+ const _hoisted_2$c = { class: "chai-composer__world-field-head" };
228
+ const _hoisted_3$b = ["for"];
229
+ const _hoisted_4$8 = ["disabled", "aria-label", "title"];
229
230
  const _hoisted_5$6 = { class: "chai-composer__field chai-composer__field--boxed" };
230
231
  const _hoisted_6$6 = ["id", "value", "placeholder", "aria-describedby", "disabled"];
231
232
  const _hoisted_7$6 = {
@@ -245,9 +246,9 @@ const _hoisted_12$5 = {
245
246
  class: "chai-composer__reveal chai-composer__type",
246
247
  "aria-hidden": "true"
247
248
  };
248
- const _hoisted_13$4 = { class: "chai-composer__reveal-text" };
249
- const _hoisted_14$4 = ["disabled", "aria-label", "title"];
250
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
249
+ const _hoisted_13$5 = { class: "chai-composer__reveal-text" };
250
+ const _hoisted_14$5 = ["disabled", "aria-label", "title"];
251
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
251
252
  __name: "PromptField",
252
253
  props: {
253
254
  value: {},
@@ -319,15 +320,15 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
319
320
  props.onEnhance?.(props.value);
320
321
  }
321
322
  return (_ctx, _cache) => {
322
- return __props.heading ? (openBlock(), createElementBlock("div", _hoisted_1$f, [
323
- createElementVNode("div", _hoisted_2$a, [
323
+ return __props.heading ? (openBlock(), createElementBlock("div", _hoisted_1$h, [
324
+ createElementVNode("div", _hoisted_2$c, [
324
325
  createElementVNode("label", {
325
326
  for: unref(id),
326
327
  class: "chai-composer__world-field-label"
327
328
  }, [
328
329
  createElementVNode("strong", null, toDisplayString(__props.heading), 1),
329
330
  createTextVNode(" " + toDisplayString(__props.note), 1)
330
- ], 8, _hoisted_3$9),
331
+ ], 8, _hoisted_3$b),
331
332
  __props.onEnhance ? (openBlock(), createElementBlock("button", {
332
333
  key: 0,
333
334
  type: "button",
@@ -338,7 +339,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
338
339
  onClick: onOptimizeClick
339
340
  }, [
340
341
  isEnhanced.value ? (openBlock(), createBlock(unref(UndoIcon), { key: 0 })) : (openBlock(), createBlock(unref(OptimizeIcon), { key: 1 }))
341
- ], 10, _hoisted_4$7)) : createCommentVNode("", true)
342
+ ], 10, _hoisted_4$8)) : createCommentVNode("", true)
342
343
  ]),
343
344
  createElementVNode("div", _hoisted_5$6, [
344
345
  createElementVNode("textarea", {
@@ -376,7 +377,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
376
377
  onInput: _cache[1] || (_cache[1] = ($event) => emit("change", $event.target.value))
377
378
  }, null, 42, _hoisted_11$5),
378
379
  animating.value ? (openBlock(), createElementBlock("div", _hoisted_12$5, [
379
- createElementVNode("span", _hoisted_13$4, toDisplayString(animatingText.value.slice(0, revealedLength.value)), 1)
380
+ createElementVNode("span", _hoisted_13$5, toDisplayString(animatingText.value.slice(0, revealedLength.value)), 1)
380
381
  ])) : createCommentVNode("", true),
381
382
  __props.onEnhance ? (openBlock(), createElementBlock("button", {
382
383
  key: 1,
@@ -388,11 +389,98 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
388
389
  onClick: onOptimizeClick
389
390
  }, [
390
391
  isEnhanced.value ? (openBlock(), createBlock(unref(UndoIcon), { key: 0 })) : (openBlock(), createBlock(unref(OptimizeIcon), { key: 1 }))
391
- ], 10, _hoisted_14$4)) : createCommentVNode("", true)
392
+ ], 10, _hoisted_14$5)) : createCommentVNode("", true)
392
393
  ]));
393
394
  };
394
395
  }
395
396
  });
397
+ const _hoisted_1$g = ["data-status"];
398
+ const _hoisted_2$b = ["disabled", "aria-label", "title"];
399
+ const _hoisted_3$a = {
400
+ key: 0,
401
+ class: "chai-composer__voice-spinner",
402
+ "aria-hidden": "true"
403
+ };
404
+ const _hoisted_4$7 = {
405
+ class: "chai-visually-hidden",
406
+ role: "status"
407
+ };
408
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
409
+ __name: "VoiceButton",
410
+ props: {
411
+ voice: {},
412
+ state: {},
413
+ disabled: { type: Boolean }
414
+ },
415
+ setup(__props) {
416
+ const props = __props;
417
+ const label = computed(
418
+ () => props.state.status === "recording" ? "Stop recording and transcribe" : props.state.status === "transcribing" ? "Cancel transcription" : "Start voice input"
419
+ );
420
+ function onClick() {
421
+ const { status } = props.state;
422
+ if (status === "recording") props.voice.stop();
423
+ else if (status === "transcribing") props.voice.cancel();
424
+ else {
425
+ props.voice.dismiss();
426
+ void props.voice.start();
427
+ }
428
+ }
429
+ function onKeydown(e) {
430
+ if (e.key === "Escape" && props.state.status === "recording") props.voice.cancel();
431
+ }
432
+ return (_ctx, _cache) => {
433
+ return openBlock(), createElementBlock("div", {
434
+ class: "chai-composer__voice",
435
+ "data-status": __props.state.status
436
+ }, [
437
+ createElementVNode("button", {
438
+ type: "button",
439
+ class: "chai-composer__voice-button",
440
+ disabled: __props.disabled,
441
+ "aria-label": label.value,
442
+ title: label.value,
443
+ onClick,
444
+ onKeydown
445
+ }, [
446
+ __props.state.status === "transcribing" ? (openBlock(), createElementBlock("span", _hoisted_3$a)) : __props.state.status === "recording" ? (openBlock(), createBlock(unref(StopIcon), { key: 1 })) : (openBlock(), createBlock(unref(MicIcon), { key: 2 }))
447
+ ], 40, _hoisted_2$b),
448
+ createElementVNode("span", _hoisted_4$7, toDisplayString(__props.state.status === "recording" ? "Recording" : __props.state.status === "transcribing" ? "Transcribing" : ""), 1)
449
+ ], 8, _hoisted_1$g);
450
+ };
451
+ }
452
+ });
453
+ const _hoisted_1$f = {
454
+ class: "chai-composer__waveform",
455
+ "aria-hidden": "true"
456
+ };
457
+ const _hoisted_2$a = { class: "chai-composer__waveform-bars" };
458
+ const _hoisted_3$9 = { class: "chai-composer__waveform-time" };
459
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
460
+ __name: "VoiceWaveform",
461
+ props: {
462
+ levels: {},
463
+ elapsedMs: {}
464
+ },
465
+ setup(__props) {
466
+ const props = __props;
467
+ const bars = computed(() => [...Array(Math.max(0, VOICE_LEVEL_COUNT - props.levels.length)).fill(0), ...props.levels]);
468
+ return (_ctx, _cache) => {
469
+ return openBlock(), createElementBlock("div", _hoisted_1$f, [
470
+ createElementVNode("div", _hoisted_2$a, [
471
+ (openBlock(true), createElementBlock(Fragment, null, renderList(bars.value, (level, i) => {
472
+ return openBlock(), createElementBlock("span", {
473
+ key: i,
474
+ class: "chai-composer__waveform-bar",
475
+ style: normalizeStyle({ height: `${Math.max(20, level * 100)}%` })
476
+ }, null, 4);
477
+ }), 128))
478
+ ]),
479
+ createElementVNode("span", _hoisted_3$9, toDisplayString(unref(formatVoiceElapsed)(__props.elapsedMs)), 1)
480
+ ]);
481
+ };
482
+ }
483
+ });
396
484
  const _hoisted_1$e = ["aria-label", ".selected", ".disabled"];
397
485
  const _sfc_main$e = /* @__PURE__ */ defineComponent({
398
486
  __name: "Toggle",
@@ -434,8 +522,8 @@ const _hoisted_10$5 = {
434
522
  };
435
523
  const _hoisted_11$4 = ["aria-label"];
436
524
  const _hoisted_12$4 = ["aria-pressed", "disabled", "onClick"];
437
- const _hoisted_13$3 = [".checked", ".disabled"];
438
- const _hoisted_14$3 = { class: "chai-search-menu__option-label" };
525
+ const _hoisted_13$4 = [".checked", ".disabled"];
526
+ const _hoisted_14$4 = { class: "chai-search-menu__option-label" };
439
527
  const _hoisted_15$3 = {
440
528
  key: 1,
441
529
  class: "chai-search-menu__divider",
@@ -634,8 +722,8 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
634
722
  ".disabled": __props.toggleHeader?.value ?? false,
635
723
  tabindex: "-1",
636
724
  "aria-hidden": "true"
637
- }, null, 40, _hoisted_13$3)) : createCommentVNode("", true),
638
- createElementVNode("span", _hoisted_14$3, toDisplayString(o.rowLabel ?? o.label), 1),
725
+ }, null, 40, _hoisted_13$4)) : createCommentVNode("", true),
726
+ createElementVNode("span", _hoisted_14$4, toDisplayString(o.rowLabel ?? o.label), 1),
639
727
  !__props.multiple && isSelected(o.id) ? (openBlock(), createBlock(unref(CheckIcon), { key: 1 })) : createCommentVNode("", true)
640
728
  ], 10, _hoisted_12$4)
641
729
  ]);
@@ -668,18 +756,24 @@ const _hoisted_6$4 = {
668
756
  "aria-label": "Edit regions"
669
757
  };
670
758
  const _hoisted_7$4 = {
671
- key: 2,
759
+ key: 3,
672
760
  class: "chai-composer__world-fields"
673
761
  };
674
762
  const _hoisted_8$4 = {
675
- key: 4,
763
+ key: 5,
676
764
  class: "chai-composer__error",
677
765
  role: "alert"
678
766
  };
679
- const _hoisted_9$4 = { class: "chai-composer__controls" };
680
- const _hoisted_10$4 = { class: "chai-composer__controls-start" };
681
- const _hoisted_11$3 = ["data-ready", "data-error", "data-stop", "aria-label", "aria-disabled"];
682
- const _hoisted_12$3 = { slot: "icon" };
767
+ const _hoisted_9$4 = {
768
+ key: 6,
769
+ class: "chai-composer__error",
770
+ role: "alert"
771
+ };
772
+ const _hoisted_10$4 = { class: "chai-composer__controls" };
773
+ const _hoisted_11$3 = { class: "chai-composer__controls-start" };
774
+ const _hoisted_12$3 = { class: "chai-composer__controls-end" };
775
+ const _hoisted_13$3 = ["data-ready", "data-error", "data-stop", "aria-label", "aria-disabled"];
776
+ const _hoisted_14$3 = { slot: "icon" };
683
777
  const _sfc_main$c = /* @__PURE__ */ defineComponent({
684
778
  __name: "Composer",
685
779
  props: {
@@ -721,6 +815,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
721
815
  attachMenuActions: {},
722
816
  regions: { default: () => [] },
723
817
  "onUpdate:regions": {},
818
+ voiceInput: {},
724
819
  disabled: { type: Boolean }
725
820
  },
726
821
  emits: ["update:modelValue", "submit", "unsupportedFile"],
@@ -765,7 +860,20 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
765
860
  const enhancingField = ref("prompt");
766
861
  const enhanceField = (field) => props.onEnhance && ((current) => {
767
862
  enhancingField.value = field;
768
- props.onEnhance?.(current, field);
863
+ props.onEnhance?.(current, field, view.value.enhanceMode);
864
+ });
865
+ const voice = createVoiceInput(
866
+ () => props.voiceInput ?? { transcribe: async () => "" },
867
+ (text) => {
868
+ const current = props.modelValue;
869
+ emit("update:modelValue", current.trim() ? `${current.trimEnd()} ${text}` : text);
870
+ }
871
+ );
872
+ const voiceState = shallowRef(voice.getState());
873
+ const stopVoice = voice.subscribe(() => voiceState.value = voice.getState());
874
+ onScopeDispose(() => {
875
+ stopVoice();
876
+ voice.dispose();
769
877
  });
770
878
  async function onFiles(files) {
771
879
  const onAttachments = props["onUpdate:attachments"];
@@ -815,7 +923,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
815
923
  return openBlock(), createElementBlock("li", {
816
924
  key: r.id
817
925
  }, [
818
- createVNode(_sfc_main$g, {
926
+ createVNode(_sfc_main$i, {
819
927
  label: `Region ${r.number}`,
820
928
  "region-number": r.number,
821
929
  removable: Boolean(props["onUpdate:regions"]),
@@ -825,8 +933,12 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
825
933
  ]);
826
934
  }), 128))
827
935
  ])) : createCommentVNode("", true),
828
- view.value.world ? (openBlock(), createElementBlock("div", _hoisted_7$4, [
829
- createVNode(_sfc_main$f, {
936
+ __props.voiceInput && voiceState.value.status === "recording" ? (openBlock(), createBlock(_sfc_main$f, {
937
+ key: 2,
938
+ levels: voiceState.value.levels,
939
+ "elapsed-ms": voiceState.value.elapsedMs
940
+ }, null, 8, ["levels", "elapsed-ms"])) : view.value.world ? (openBlock(), createElementBlock("div", _hoisted_7$4, [
941
+ createVNode(_sfc_main$h, {
830
942
  value: __props.modelValue,
831
943
  placeholder: view.value.placeholder,
832
944
  heading: "Environment",
@@ -837,7 +949,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
837
949
  disabled: __props.disabled,
838
950
  onChange: _cache[0] || (_cache[0] = ($event) => emit("update:modelValue", $event))
839
951
  }, null, 8, ["value", "placeholder", "hint", "on-enhance", "enhancing", "disabled"]),
840
- props["onUpdate:character"] ? (openBlock(), createBlock(_sfc_main$f, {
952
+ props["onUpdate:character"] ? (openBlock(), createBlock(_sfc_main$h, {
841
953
  key: 0,
842
954
  value: __props.character,
843
955
  placeholder: view.value.characterPlaceholder,
@@ -848,8 +960,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
848
960
  disabled: __props.disabled,
849
961
  onChange: _cache[1] || (_cache[1] = ($event) => props["onUpdate:character"]?.($event))
850
962
  }, null, 8, ["value", "placeholder", "on-enhance", "enhancing", "disabled"])) : createCommentVNode("", true)
851
- ])) : (openBlock(), createBlock(_sfc_main$f, {
852
- key: 3,
963
+ ])) : (openBlock(), createBlock(_sfc_main$h, {
964
+ key: 4,
853
965
  value: __props.modelValue,
854
966
  placeholder: view.value.placeholder,
855
967
  label: __props.promptLabel,
@@ -862,9 +974,13 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
862
974
  createVNode(unref(ErrorIcon)),
863
975
  createTextVNode(toDisplayString(__props.submitError), 1)
864
976
  ])) : createCommentVNode("", true),
865
- createElementVNode("div", _hoisted_9$4, [
866
- createElementVNode("div", _hoisted_10$4, [
867
- menuItems.value.length > 0 ? (openBlock(), createBlock(_sfc_main$h, {
977
+ __props.voiceInput && voiceState.value.status === "error" ? (openBlock(), createElementBlock("p", _hoisted_9$4, [
978
+ createVNode(unref(ErrorIcon)),
979
+ createTextVNode(toDisplayString(voiceState.value.error), 1)
980
+ ])) : createCommentVNode("", true),
981
+ createElementVNode("div", _hoisted_10$4, [
982
+ createElementVNode("div", _hoisted_11$3, [
983
+ menuItems.value.length > 0 ? (openBlock(), createBlock(_sfc_main$j, {
868
984
  key: 0,
869
985
  items: menuItems.value,
870
986
  "images-only": view.value.editing,
@@ -873,7 +989,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
873
989
  onFiles
874
990
  }, null, 8, ["items", "images-only", "disabled"])) : createCommentVNode("", true),
875
991
  (openBlock(true), createElementBlock(Fragment, null, renderList(view.value.pickedUseCases, (u) => {
876
- return openBlock(), createBlock(_sfc_main$g, {
992
+ return openBlock(), createBlock(_sfc_main$i, {
877
993
  key: u.kind,
878
994
  label: u.label,
879
995
  removable: Boolean(__props.multiSelectUseCases ? props["onUpdate:useCases"] : __props.onClearUseCase),
@@ -916,22 +1032,31 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
916
1032
  onSelect: _cache[6] || (_cache[6] = ($event) => props["onUpdate:frameRate"]?.(Number($event.id)))
917
1033
  }, null, 8, ["options", "value", "trigger-label", "disabled"])) : createCommentVNode("", true)
918
1034
  ]),
919
- createElementVNode("md-fab", {
920
- class: "chai-composer__submit",
921
- size: "small",
922
- variant: "secondary",
923
- label: "",
924
- "data-ready": view.value.showStop || !view.value.isSubmitDisabled || void 0,
925
- "data-error": Boolean(__props.submitError) || void 0,
926
- "data-stop": view.value.showStop || void 0,
927
- "aria-label": view.value.showStop ? "Stop" : __props.submitError ? "Retry" : "Submit",
928
- "aria-disabled": view.value.showStop ? "false" : __props.submitting || view.value.isSubmitDisabled ? "true" : "false",
929
- onClick: onSubmitClick
930
- }, [
931
- createElementVNode("span", _hoisted_12$3, [
932
- view.value.showStop ? (openBlock(), createBlock(unref(StopIcon), { key: 0 })) : __props.submitError ? (openBlock(), createBlock(unref(RetryIcon), { key: 1 })) : (openBlock(), createBlock(unref(ArrowForwardIcon), { key: 2 }))
933
- ])
934
- ], 8, _hoisted_11$3)
1035
+ createElementVNode("div", _hoisted_12$3, [
1036
+ __props.voiceInput ? (openBlock(), createBlock(_sfc_main$g, {
1037
+ key: 0,
1038
+ voice: unref(voice),
1039
+ state: voiceState.value,
1040
+ disabled: __props.disabled
1041
+ }, null, 8, ["voice", "state", "disabled"])) : createCommentVNode("", true),
1042
+ !(__props.voiceInput && (voiceState.value.status === "recording" || voiceState.value.status === "transcribing")) ? (openBlock(), createElementBlock("md-fab", {
1043
+ key: 1,
1044
+ class: "chai-composer__submit",
1045
+ size: "small",
1046
+ variant: "secondary",
1047
+ label: "",
1048
+ "data-ready": view.value.showStop || !view.value.isSubmitDisabled || void 0,
1049
+ "data-error": Boolean(__props.submitError) || void 0,
1050
+ "data-stop": view.value.showStop || void 0,
1051
+ "aria-label": view.value.showStop ? "Stop" : __props.submitError ? "Retry" : "Submit",
1052
+ "aria-disabled": view.value.showStop ? "false" : __props.submitting || view.value.isSubmitDisabled ? "true" : "false",
1053
+ onClick: onSubmitClick
1054
+ }, [
1055
+ createElementVNode("span", _hoisted_14$3, [
1056
+ view.value.showStop ? (openBlock(), createBlock(unref(StopIcon), { key: 0 })) : __props.submitError ? (openBlock(), createBlock(unref(RetryIcon), { key: 1 })) : (openBlock(), createBlock(unref(ArrowForwardIcon), { key: 2 }))
1057
+ ])
1058
+ ], 8, _hoisted_13$3)) : createCommentVNode("", true)
1059
+ ])
935
1060
  ])
936
1061
  ]);
937
1062
  };
@@ -2623,7 +2748,7 @@ function useMediaAnalyzer(options = {}) {
2623
2748
  };
2624
2749
  }
2625
2750
  export {
2626
- _sfc_main$i as ChaiProvider,
2751
+ _sfc_main$k as ChaiProvider,
2627
2752
  _sfc_main$c as Composer,
2628
2753
  DEFAULT_MAX_ATTACHMENTS_BY_KIND2 as DEFAULT_MAX_ATTACHMENTS_BY_KIND,
2629
2754
  DEFAULT_MAX_REGIONS2 as DEFAULT_MAX_REGIONS,
@@ -2652,6 +2777,7 @@ export {
2652
2777
  buildRegionEditPrompt,
2653
2778
  checkSuggestedModels,
2654
2779
  createFalEngine,
2780
+ createFalTranscriber,
2655
2781
  createMockEngine,
2656
2782
  createOpenRouterEngine,
2657
2783
  isMediaAnalyzerAtCap2 as isMediaAnalyzerAtCap,