@8wave/ai-elements 0.98.0-beta.5 → 0.99.0-beta.1

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 (76) hide show
  1. package/README.md +24 -5
  2. package/dist/_chunks/{PkToolShowForm-BNV4Ja6g.js → PkToolShowForm-dFuoqTPs.js} +84 -80
  3. package/dist/_chunks/PkToolShowForm-dFuoqTPs.js.map +1 -0
  4. package/dist/ai-elements.es.js +3153 -2982
  5. package/dist/ai-elements.es.js.map +1 -1
  6. package/dist-vue/PkChatbot.js +1 -1
  7. package/dist-vue/PkChatbotMessages.js +1 -1
  8. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  9. package/dist-vue/PkChatbotSteps.js +1 -1
  10. package/dist-vue/PkChatbotViewChat.js +1 -1
  11. package/dist-vue/PkChatbotViewConversations.js +1 -1
  12. package/dist-vue/PkChatbotViewFiles.js +1 -1
  13. package/dist-vue/PkChatbotViewProfile.js +1 -1
  14. package/dist-vue/_chunks/{PkChatbot-DHkhT0Jf.js → PkChatbot-BlG1WlAO.js} +7 -7
  15. package/dist-vue/_chunks/{PkChatbot-DHkhT0Jf.js.map → PkChatbot-BlG1WlAO.js.map} +1 -1
  16. package/dist-vue/_chunks/PkChatbotMessages-BrufA7o1.js +752 -0
  17. package/dist-vue/_chunks/PkChatbotMessages-BrufA7o1.js.map +1 -0
  18. package/dist-vue/_chunks/{PkChatbotStepToolDetail-ldThv0t5.js → PkChatbotStepToolDetail-BVI72gyx.js} +2 -2
  19. package/dist-vue/_chunks/{PkChatbotStepToolDetail-ldThv0t5.js.map → PkChatbotStepToolDetail-BVI72gyx.js.map} +1 -1
  20. package/dist-vue/_chunks/PkChatbotSteps-Dv9NkYER.js +172 -0
  21. package/dist-vue/_chunks/{PkChatbotSteps-BpqdFhsG.js.map → PkChatbotSteps-Dv9NkYER.js.map} +1 -1
  22. package/dist-vue/_chunks/{PkChatbotViewChat-C08TsXiL.js → PkChatbotViewChat-CAqvbbfN.js} +66 -66
  23. package/dist-vue/_chunks/PkChatbotViewChat-CAqvbbfN.js.map +1 -0
  24. package/dist-vue/_chunks/{PkChatbotViewConversations-BQZi5kSC.js → PkChatbotViewConversations-Cq41H-tc.js} +2 -2
  25. package/dist-vue/_chunks/{PkChatbotViewConversations-BQZi5kSC.js.map → PkChatbotViewConversations-Cq41H-tc.js.map} +1 -1
  26. package/dist-vue/_chunks/{PkChatbotViewFiles-TLKE_tRw.js → PkChatbotViewFiles-DNuzmBJc.js} +2 -2
  27. package/dist-vue/_chunks/{PkChatbotViewFiles-TLKE_tRw.js.map → PkChatbotViewFiles-DNuzmBJc.js.map} +1 -1
  28. package/dist-vue/_chunks/{PkChatbotViewProfile-B6ANZY96.js → PkChatbotViewProfile-C0BXIY2N.js} +2 -2
  29. package/dist-vue/_chunks/{PkChatbotViewProfile-B6ANZY96.js.map → PkChatbotViewProfile-C0BXIY2N.js.map} +1 -1
  30. package/dist-vue/_chunks/{PkToolShowForm-C-mWyeka.js → PkToolShowForm-CQuX08lk.js} +62 -58
  31. package/dist-vue/_chunks/PkToolShowForm-CQuX08lk.js.map +1 -0
  32. package/dist-vue/_chunks/{createChatbotApiClient-BOBdBxmf.js → createChatbotApiClient-BMZltBLh.js} +367 -363
  33. package/dist-vue/_chunks/createChatbotApiClient-BMZltBLh.js.map +1 -0
  34. package/dist-vue/_chunks/{useChatbotStore-BJ-EDmND.js → useChatbotStore-DZiorgLW.js} +113 -103
  35. package/dist-vue/_chunks/{useChatbotStore-BJ-EDmND.js.map → useChatbotStore-DZiorgLW.js.map} +1 -1
  36. package/dist-vue/_chunks/{utils-BMa8jwJS.js → utils-Cru8TJxe.js} +48 -30
  37. package/dist-vue/_chunks/utils-Cru8TJxe.js.map +1 -0
  38. package/dist-vue/api.js +1 -1
  39. package/dist-vue/composables.js +3 -3
  40. package/dist-vue/index.js +4351 -4041
  41. package/dist-vue/index.js.map +1 -1
  42. package/dist-vue/locales.js +16 -0
  43. package/dist-vue/packages/components/src/PkCheckboxField.d.ts +45 -0
  44. package/dist-vue/packages/components/src/PkEditorRepeater.d.ts +2 -2
  45. package/dist-vue/packages/components/src/PkPwaInstallPrompt.d.ts +4 -0
  46. package/dist-vue/packages/components/src/PkPwaOfflineNotice.d.ts +4 -0
  47. package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +11 -2
  48. package/dist-vue/packages/components/src/chat/PkChatbotMessages.d.ts +24 -2
  49. package/dist-vue/packages/components/src/chat/PkToolApprovalBadge.d.ts +4 -0
  50. package/dist-vue/packages/components/src/chat/PkToolApprovalCard.d.ts +35 -0
  51. package/dist-vue/packages/components/src/chat/PkToolApprovalPreviewMessage.d.ts +11 -0
  52. package/dist-vue/packages/components/src/chat/index.d.ts +2 -1
  53. package/dist-vue/packages/components/src/chat/toolApprovalPreviews.d.ts +12 -0
  54. package/dist-vue/packages/components/src/chat/toolComponentMap.d.ts +5 -3
  55. package/dist-vue/packages/components/src/chat/useChatScroll.d.ts +6 -0
  56. package/dist-vue/packages/components/src/chat/utils.d.ts +13 -0
  57. package/dist-vue/packages/components/src/index.d.ts +4 -1
  58. package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +34 -1
  59. package/dist-vue/packages/models/src/schema/Agent.d.ts +48 -0
  60. package/dist-vue/packages/models/src/schema/ReasoningChat.d.ts +6 -0
  61. package/dist-vue/packages/models/src/schema/SubAgent.d.ts +6 -0
  62. package/dist-vue/style.css +1 -1
  63. package/package.json +1 -1
  64. package/dist/_chunks/PkToolRequestConfirm-FQ9nDFXy.js +0 -48
  65. package/dist/_chunks/PkToolRequestConfirm-FQ9nDFXy.js.map +0 -1
  66. package/dist/_chunks/PkToolShowForm-BNV4Ja6g.js.map +0 -1
  67. package/dist-vue/_chunks/PkChatbotMessages-B4qfTNOJ.js +0 -630
  68. package/dist-vue/_chunks/PkChatbotMessages-B4qfTNOJ.js.map +0 -1
  69. package/dist-vue/_chunks/PkChatbotSteps-BpqdFhsG.js +0 -172
  70. package/dist-vue/_chunks/PkChatbotViewChat-C08TsXiL.js.map +0 -1
  71. package/dist-vue/_chunks/PkToolRequestConfirm-CQNa3seA.js +0 -48
  72. package/dist-vue/_chunks/PkToolRequestConfirm-CQNa3seA.js.map +0 -1
  73. package/dist-vue/_chunks/PkToolShowForm-C-mWyeka.js.map +0 -1
  74. package/dist-vue/_chunks/createChatbotApiClient-BOBdBxmf.js.map +0 -1
  75. package/dist-vue/_chunks/utils-BMa8jwJS.js.map +0 -1
  76. package/dist-vue/packages/components/src/chat/PkToolRequestConfirm.d.ts +0 -11
@@ -1 +0,0 @@
1
- {"version":3,"file":"PkChatbotMessages-B4qfTNOJ.js","names":["$emit"],"sources":["../../../../packages/components/src/chat/toolComponentMap.ts","../../../../packages/components/src/chat/useChatScroll.ts","../../../../packages/components/src/chat/PkChatbotMessages.vue","../../../../packages/components/src/chat/PkChatbotMessages.vue"],"sourcesContent":["import { defineAsyncComponent } from 'vue'\n\n/**\n * Maps tool `part.type` to the corresponding component for auto-rendering.\n * Only includes simple tools that accept only a `:part` prop.\n * Interactive tools (requestConfirm, showContactForm, showSuggestedReply,\n * showSources, showMultipleChoice) must be wired explicitly in the parent\n * with their required callbacks/events.\n */\nexport const toolComponentMap: Record<\n string,\n ReturnType<typeof defineAsyncComponent>\n> = {\n requestConfirm: defineAsyncComponent(\n () => import('./PkToolRequestConfirm.vue'),\n ),\n requestOAuthConnection: defineAsyncComponent(\n () => import('./PkToolRequestOAuthConnection.vue'),\n ),\n showArtifact: defineAsyncComponent(\n () => import('./PkToolShowArtifact.vue'),\n ),\n showCalendarEvent: defineAsyncComponent(\n () => import('./PkToolShowCalendarEvent.vue'),\n ),\n showComparison: defineAsyncComponent(\n () => import('./PkToolShowComparison.vue'),\n ),\n showContactForm: defineAsyncComponent(\n () => import('./PkToolShowContactForm.vue'),\n ),\n showDiagram: defineAsyncComponent(() => import('./PkToolShowDiagram.vue')),\n showEmail: defineAsyncComponent(() => import('./PkToolShowEmail.vue')),\n showImageGallery: defineAsyncComponent(\n () => import('./PkToolShowImageGallery.vue'),\n ),\n showLocation: defineAsyncComponent(\n () => import('./PkToolShowLocation.vue'),\n ),\n showMessage: defineAsyncComponent(() => import('./PkToolShowMessage.vue')),\n showForm: defineAsyncComponent(() => import('./PkToolShowForm.vue')),\n showMultipleChoice: defineAsyncComponent(\n () => import('./PkToolShowForm.vue'),\n ),\n showProductList: defineAsyncComponent(\n () => import('./PkToolShowProductList.vue'),\n ),\n showQrCode: defineAsyncComponent(() => import('./PkToolShowQrCode.vue')),\n showSources: defineAsyncComponent(() => import('./PkToolShowSources.vue')),\n showSuggestedReply: defineAsyncComponent(\n () => import('./PkToolShowSuggestedReply.vue'),\n ),\n showVideo: defineAsyncComponent(() => import('./PkToolShowVideo.vue')),\n showWeather: defineAsyncComponent(() => import('./PkToolShowWeather.vue')),\n showWebPages: defineAsyncComponent(\n () => import('./PkToolShowWebPages.vue'),\n ),\n}\n","import type { Ref, ShallowRef } from 'vue'\nimport { ref, watch, onMounted, onBeforeUnmount, nextTick } from 'vue'\n\nconst NEAR_BOTTOM_THRESHOLD = 30\nconst SMOOTH_SCROLL_DURATION = 500\n\ninterface UseChatScrollOptions {\n scrollEl:\n | Readonly<ShallowRef<HTMLDivElement | null>>\n | Ref<HTMLDivElement | undefined>\n status: () => string | undefined\n messagesLength: () => number | undefined\n lastMessageRole: () => string | undefined\n /**\n * Element whose height tracks the content height, watched for late\n * growth (lazy tool outputs). Defaults to the scroll element's first\n * child.\n */\n contentEl?: () => HTMLElement | null\n onScrollUp?: () => void\n onScrollDown?: () => void\n}\n\nexport function useChatScroll(options: UseChatScrollOptions) {\n const {\n scrollEl,\n status,\n messagesLength,\n lastMessageRole,\n contentEl,\n onScrollUp,\n onScrollDown,\n } = options\n\n const userScrolledUp = ref(false)\n const isAtBottom = ref(true)\n let isAutoScrolling = false\n let mutationObserver: MutationObserver | null = null\n let resizeObserver: ResizeObserver | null = null\n let initMutationObserver: MutationObserver | null = null\n let contentResizeObserver: ResizeObserver | null = null\n let lastScrollTop = 0\n\n // --- Core scroll ---\n\n const scrollToBottom = (behavior: ScrollBehavior = 'smooth') => {\n if (!scrollEl.value || userScrolledUp.value) {\n return\n }\n isAutoScrolling = true\n scrollEl.value.scrollTo({\n top: scrollEl.value.scrollHeight,\n behavior,\n })\n const unlockDelay = behavior === 'instant' ? 0 : SMOOTH_SCROLL_DURATION\n setTimeout(() => {\n isAutoScrolling = false\n }, unlockDelay)\n }\n\n // --- User scroll detection ---\n // Intent to scroll away comes from input events (wheel/touch): unlike\n // scroll deltas they are never produced by programmatic scrolls, layout\n // shifts or elastic overscroll bounces, so the auto-scroll never fights\n // the user nor disables itself spuriously.\n\n const onWheel = (event: WheelEvent) => {\n if (event.deltaY < 0) {\n userScrolledUp.value = true\n }\n }\n\n let lastTouchY = 0\n const onTouchStart = (event: TouchEvent) => {\n lastTouchY = event.touches[0]?.clientY ?? 0\n }\n const onTouchMove = (event: TouchEvent) => {\n const y = event.touches[0]?.clientY ?? 0\n // Finger moving down drags the content up\n if (y > lastTouchY) {\n userScrolledUp.value = true\n }\n lastTouchY = y\n }\n\n const handleScroll = () => {\n if (!scrollEl.value) {\n return\n }\n const {\n scrollTop: currentScrollTop,\n scrollHeight,\n clientHeight,\n } = scrollEl.value\n isAtBottom.value =\n scrollHeight - clientHeight - currentScrollTop <\n NEAR_BOTTOM_THRESHOLD\n if (isAutoScrolling) {\n lastScrollTop = currentScrollTop\n return\n }\n\n if (currentScrollTop < lastScrollTop) {\n onScrollUp?.()\n }\n\n if (currentScrollTop > lastScrollTop) {\n // Back at the bottom: re-enable auto-scroll\n if (isAtBottom.value) {\n userScrolledUp.value = false\n }\n onScrollDown?.()\n }\n\n lastScrollTop = currentScrollTop\n }\n\n // --- Streaming auto-follow ---\n // Tracks the growing content towards the bottom, never above the\n // current position. While the answer fits the space reserved by the\n // last-message spacer in PkChatbotMessages the content bottom does not\n // move, so the freshly sent user message stays anchored at the top;\n // once the answer overflows, the follow keeps the tail in view until\n // the user scrolls away (wheel/touch sets `userScrolledUp`).\n const autoFollow = () => {\n if (isAutoScrolling || userScrolledUp.value || !scrollEl.value) {\n return\n }\n const el = scrollEl.value\n const bottom = el.scrollHeight - el.clientHeight\n if (bottom <= el.scrollTop) {\n return\n }\n isAtBottom.value = true\n isAutoScrolling = true\n el.scrollTop = bottom\n requestAnimationFrame(() => {\n isAutoScrolling = false\n })\n }\n\n const startMutationScroll = () => {\n if (mutationObserver || !scrollEl.value) {\n return\n }\n mutationObserver = new MutationObserver(autoFollow)\n mutationObserver.observe(scrollEl.value, {\n childList: true,\n subtree: true,\n characterData: true,\n })\n }\n\n const stopMutationScroll = () => {\n mutationObserver?.disconnect()\n mutationObserver = null\n }\n\n // --- Status watcher ---\n\n watch(status, (newStatus, oldStatus) => {\n if (newStatus === 'streaming' || newStatus === 'submitted') {\n startMutationScroll()\n return\n }\n if (newStatus === 'ready' && oldStatus === 'streaming') {\n // Keep observer active to catch footer buttons rendering\n return\n }\n stopMutationScroll()\n })\n\n // --- New message watcher ---\n\n watch(messagesLength, async () => {\n if (!messagesLength()) {\n return\n }\n if (lastMessageRole() === 'assistant') {\n return\n }\n // A user send ends the initial-load phase: on a chat whose content\n // first overflows while the answer streams in, the initial observers\n // would otherwise slam the scroll to the bottom past the anchor\n cleanupInitialObservers()\n userScrolledUp.value = false\n isAutoScrolling = true\n await nextTick()\n scrollToBottom()\n })\n\n // --- Initial scroll ---\n\n let initialScrollTimer: ReturnType<typeof setTimeout> | null = null\n const INITIAL_SCROLL_SETTLE_MS = 300\n\n const tryInitialScroll = () => {\n if (!scrollEl.value) {\n return\n }\n if (scrollEl.value.scrollHeight <= scrollEl.value.clientHeight) {\n return\n }\n scrollEl.value.scrollTop = scrollEl.value.scrollHeight\n\n // Reset the settle timer on each mutation — disconnect only after stability\n if (initialScrollTimer) {\n clearTimeout(initialScrollTimer)\n }\n initialScrollTimer = setTimeout(\n cleanupInitialObservers,\n INITIAL_SCROLL_SETTLE_MS,\n )\n }\n\n const cleanupInitialObservers = () => {\n resizeObserver?.disconnect()\n resizeObserver = null\n initMutationObserver?.disconnect()\n initMutationObserver = null\n if (initialScrollTimer) {\n clearTimeout(initialScrollTimer)\n initialScrollTimer = null\n }\n }\n\n onMounted(() => {\n if (!scrollEl.value) {\n return\n }\n scrollEl.value.addEventListener('wheel', onWheel, { passive: true })\n scrollEl.value.addEventListener('touchstart', onTouchStart, {\n passive: true,\n })\n scrollEl.value.addEventListener('touchmove', onTouchMove, {\n passive: true,\n })\n\n // Mounted mid-send (e.g. fullscreen first message: the messages view\n // replaces the empty state after the message is already in) is not a\n // history load: skip the initial bottom-jump and follow the stream\n // from the anchored position instead.\n const isSendInFlight =\n status() === 'submitted' || status() === 'streaming'\n if (isSendInFlight) {\n startMutationScroll()\n } else {\n resizeObserver = new ResizeObserver(tryInitialScroll)\n resizeObserver.observe(scrollEl.value)\n\n initMutationObserver = new MutationObserver(tryInitialScroll)\n initMutationObserver.observe(scrollEl.value, {\n childList: true,\n subtree: true,\n })\n }\n\n // Late content growth: tool outputs render lazily (async chunks,\n // dynamic imports: diagrams, images...) and can change the content\n // height long after the initial scroll settled. The wrapper height\n // tracks the content height (the scroll element itself never\n // resizes with it).\n const wrapper = contentEl?.() ?? scrollEl.value.firstElementChild\n if (wrapper) {\n contentResizeObserver = new ResizeObserver(autoFollow)\n contentResizeObserver.observe(wrapper)\n }\n\n if (!isSendInFlight) {\n tryInitialScroll()\n }\n })\n\n onBeforeUnmount(() => {\n scrollEl.value?.removeEventListener('wheel', onWheel)\n scrollEl.value?.removeEventListener('touchstart', onTouchStart)\n scrollEl.value?.removeEventListener('touchmove', onTouchMove)\n contentResizeObserver?.disconnect()\n contentResizeObserver = null\n stopMutationScroll()\n cleanupInitialObservers()\n })\n\n return {\n handleScroll,\n scrollToBottom,\n userScrolledUp,\n isAtBottom,\n }\n}\n","<script lang=\"ts\" setup>\n import type {\n ChatMessageActions,\n MessageFeedback,\n RevisedAnswer,\n UIChatMessage,\n } from 'models'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n import PkChatbotError from './PkChatbotError.vue'\n import PkChatbotFeedbackForm from './PkChatbotFeedbackForm.vue'\n import PkChatbotMessageFeedback from './PkChatbotMessageFeedback.vue'\n import PkChatbotFilePreview from './PkChatbotFilePreview.vue'\n import PkRelativeTime from '../PkRelativeTime.vue'\n import { useI18n } from 'vue-i18n'\n import {\n useTemplateRef,\n ref,\n watch,\n computed,\n nextTick,\n useSlots,\n } from 'vue'\n import { toolComponentMap } from './toolComponentMap'\n import PkChatbotSteps from './PkChatbotSteps.vue'\n import {\n resolveContrastColor,\n getPartState,\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n isStreamingPart,\n getPartIcon,\n getToolPartLabel,\n mergeConsecutiveTextParts,\n formatDuration,\n } from './utils'\n import { getFilePartMedia, getToolPartName, toKebabCase } from 'utils'\n import PkStreamingMarkdownAutoscroll from './PkStreamingMarkdownAutoscroll.vue'\n import PkChatbotOutlineRail from './PkChatbotOutlineRail.vue'\n import { useChatScroll } from './useChatScroll'\n\n const props = defineProps<{\n status?: 'submitted' | 'streaming' | 'ready' | 'error'\n messages?: UIChatMessage[]\n error?: Error\n actions?: ChatMessageActions[]\n mainColor?: string\n textColor?: 'auto' | 'white' | 'black'\n revisedAnswers?: RevisedAnswer[]\n messageFeedbacks?: MessageFeedback[]\n /**\n * Render the vote/feedback action buttons as read-only state indicators\n * (e.g. admin chat-logs view): icons reflect the user's feedback but the\n * buttons are not interactive.\n */\n readonlyFeedback?: boolean\n disableHeightAdjustment?: boolean\n showMessageDateTime?: boolean\n showMessageTokensCount?: boolean\n showAllMessageParts?: boolean\n showExtendedSteps?: boolean\n isDark?: boolean\n /** Show a floating \"back to bottom\" button when the user scrolls up (fullscreen layout) */\n showScrollToBottom?: boolean\n // TODO: move feedback in a separate component to avoid passing these props\n feedbackMessageId?: string\n feedbackLoading?: boolean\n feedbackSubmitted?: boolean\n feedbackError?: string\n }>()\n\n const emit = defineEmits<{\n (e: 'show-info', message: UIChatMessage): void\n (e: 'regenerate'): void\n (e: 'revise', message: UIChatMessage): void\n (e: 'upvote', message: UIChatMessage): void\n (e: 'downvote', message: UIChatMessage): void\n (e: 'feedback', message: UIChatMessage): void\n (e: 'feedback-submit', comment: string): void\n (e: 'feedback-close'): void\n (e: 'scroll-up'): void\n (e: 'scroll-down'): void\n (e: 'auto-retry'): void\n (e: 'reset-chat'): void\n }>()\n\n const {\n t: $t,\n d: $d,\n n: $n,\n } = useI18n({\n useScope: 'global',\n })\n\n const slots = useSlots()\n\n const scrollEl = useTemplateRef<HTMLDivElement>('scrollEl')\n const wrapperEl = useTemplateRef<HTMLDivElement>('wrapperEl')\n const contrastColor = computed(() =>\n resolveContrastColor(props.textColor, props.mainColor),\n )\n\n // --- Scroll ---\n\n const messagesElRefs = useTemplateRef<HTMLDivElement[]>('messagesEl')\n\n const { handleScroll, scrollToBottom, userScrolledUp, isAtBottom } =\n useChatScroll({\n scrollEl,\n status: () => props.status,\n messagesLength: () => props.messages?.length,\n lastMessageRole: () =>\n props.messages?.[props.messages.length - 1]?.role,\n contentEl: () => wrapperEl.value,\n onScrollUp: () => emit('scroll-up'),\n onScrollDown: () => emit('scroll-down'),\n })\n\n const onScrollToBottomClick = () => {\n // scrollToBottom() is a no-op while userScrolledUp is set\n userScrolledUp.value = false\n scrollToBottom()\n }\n\n // --- Conversation outline (fullscreen, desktop) ---\n\n const outlineItems = computed(() =>\n (props.messages ?? [])\n .filter((message) => message.role === 'user')\n .map((message) => ({\n id: message.id,\n preview:\n message.parts.find(isTextPart)?.text.trim().slice(0, 120) ||\n '…',\n })),\n )\n const activeOutlineId = ref<string>()\n\n // The rail entries map 1:1 onto the rendered user messages\n const getUserMessageEls = () =>\n scrollEl.value?.querySelectorAll('.pk-chatbot-message--user') ?? []\n\n // Scroll-spy: active is the last user message above the middle of the\n // viewport (the exchange currently being read)\n const updateActiveOutline = () => {\n const scroller = scrollEl.value\n if (!scroller || !props.showScrollToBottom) {\n return\n }\n const line =\n scroller.getBoundingClientRect().top + scroller.clientHeight / 2\n let active = outlineItems.value[0]?.id\n getUserMessageEls().forEach((el, index) => {\n if (el.getBoundingClientRect().top <= line) {\n active = outlineItems.value[index]?.id\n }\n })\n activeOutlineId.value = active\n }\n\n watch(outlineItems, async () => {\n await nextTick()\n updateActiveOutline()\n })\n\n const onScroll = () => {\n handleScroll()\n updateActiveOutline()\n }\n\n const scrollToUserMessage = (id: string) => {\n const scroller = scrollEl.value\n const index = outlineItems.value.findIndex((item) => item.id === id)\n const messageEl = getUserMessageEls()[index]\n if (!scroller || !messageEl) {\n return\n }\n // Intentional jump away from the live tail: the wheel/touch intent\n // detection cannot see programmatic scrolls, pause the auto-follow\n // explicitly (reaching the bottom again re-enables it)\n userScrolledUp.value = true\n // Same resting line as a freshly sent message: top of the content area\n scroller.scrollTo({\n top:\n scroller.scrollTop +\n messageEl.getBoundingClientRect().top -\n scroller.getBoundingClientRect().top -\n Number.parseFloat(getComputedStyle(scroller).paddingTop),\n behavior: 'smooth',\n })\n }\n\n // --- Height adjustment ---\n\n const height = ref<number>(0)\n\n // Recalculate when a message is added or the conversation changes (the\n // store recreates `messages` on every streamed token, so watching the\n // array reference would re-run this on each character). The height only\n // depends on the last user message height, which is stable while\n // streaming.\n watch(\n () => [\n props.messages?.length,\n props.messages?.[props.messages.length - 1]?.id,\n ],\n async () => {\n const messages = props.messages\n if (!messages?.length || props.disableHeightAdjustment) {\n return\n }\n // The spacer only serves the in-flight exchange, letting the\n // fresh user message anchor at the top while the answer streams.\n // On plain loads (e.g. opening an old conversation) it would\n // just leave a large void after the last message.\n const isExchangeInFlight =\n messages[messages.length - 1].role === 'user' ||\n props.status === 'submitted' ||\n props.status === 'streaming'\n if (!isExchangeInFlight) {\n return\n }\n await nextTick()\n if (!scrollEl.value) {\n return\n }\n // Spacer sized so the freshly sent user message rests at the top\n // of the content area once scrolled to bottom: subtract both\n // paddings (clientHeight includes them) so any extra top\n // clearance (e.g. the fullscreen overlay header) is respected,\n // and the wrapper row gap separating the message from the spacer\n const { paddingTop, paddingBottom } = getComputedStyle(\n scrollEl.value,\n )\n const scrollElHeight =\n scrollEl.value.clientHeight -\n Number.parseFloat(paddingTop) -\n Number.parseFloat(paddingBottom)\n const wrapperGap = wrapperEl.value\n ? Number.parseFloat(getComputedStyle(wrapperEl.value).rowGap) ||\n 0\n : 0\n const lastUserMessageIndex = messages\n .map((message) => message.role)\n .lastIndexOf('user')\n const lastUserMessageHeight =\n messagesElRefs.value?.[lastUserMessageIndex]?.clientHeight ?? 0\n const newHeight =\n scrollElHeight - lastUserMessageHeight - wrapperGap\n if (newHeight > 0) {\n height.value = newHeight\n }\n },\n )\n\n // Release the spacer once the exchange is over: it would otherwise\n // leave a large empty area after the last message. The min-height\n // transition settles the layout smoothly (the browser clamps the\n // scroll progressively when the viewport sat inside the removed area).\n watch(\n () => props.status,\n (status) => {\n if (status === 'ready' || status === 'error') {\n height.value = 0\n }\n },\n )\n\n const isRevised = (messageId: string) => {\n return props.revisedAnswers?.some((r) => r.messageId === messageId)\n }\n\n const getMessageFeedback = (messageId: string) =>\n props.messageFeedbacks?.find((f) => f.messageId === messageId)\n\n // Interactive vote/feedback buttons. In read-only mode (admin chat-logs)\n // the vote is shown on the message itself (coloured bubble border + an\n // \"active\" thumb in the footer) and the comment, if any, below it.\n const isFeedbackButtonVisible = (\n kind: 'upvote' | 'downvote' | 'feedback',\n index: number,\n ) => !props.readonlyFeedback && isActionButtonVisible(kind, index)\n\n // Read-only feedback for a message (drives the reaction chip anchored to\n // the bubble). undefined when not in read-only mode.\n const readonlyFeedbackOf = (messageId: string) =>\n props.readonlyFeedback ? getMessageFeedback(messageId) : undefined\n const feedbackVote = (messageId: string) =>\n readonlyFeedbackOf(messageId)?.vote\n // The real reaction glyph, shown ONLY for unmapped reactions (no vote):\n // 👍/❤️/👎 keep the classic thumb icon, while e.g. WhatsApp \"😍\" shows the\n // actual emoji. Platforms that send a type word (Teams \"like\") have a vote\n // and therefore use the icon too.\n const feedbackEmoji = (messageId: string) => {\n const feedback = readonlyFeedbackOf(messageId)\n if (feedback?.vote) {\n return undefined\n }\n const raw = feedback?.metadata?.reactionEmoji\n return typeof raw === 'string' && /\\p{Extended_Pictographic}/u.test(raw)\n ? raw\n : undefined\n }\n const hasReaction = (messageId: string) =>\n Boolean(feedbackVote(messageId) || feedbackEmoji(messageId))\n const reactionToneClass = (messageId: string) => {\n // A real emoji carries its own colour → neutral pill. Only the\n // thumb-icon fallback uses the sentiment colour.\n if (feedbackEmoji(messageId)) {\n return 'pk-chatbot-message__reaction--neutral'\n }\n const vote = feedbackVote(messageId)\n if (vote === 'upvote') {\n return 'pk-chatbot-message__reaction--positive'\n }\n if (vote === 'downvote') {\n return 'pk-chatbot-message__reaction--negative'\n }\n return 'pk-chatbot-message__reaction--neutral'\n }\n const reactionTitle = (messageId: string) => {\n const vote = feedbackVote(messageId)\n if (vote === 'upvote') {\n return $t('hint.userFeedbackPositive')\n }\n if (vote === 'downvote') {\n return $t('hint.userFeedbackNegative')\n }\n return $t('hint.userFeedbackReaction')\n }\n\n // Index of the last text part: the reaction chip anchors to that bubble so\n // it renders once even when the message has several text parts.\n const lastTextPartIndex = (message: UIChatMessage) => {\n const parts = getMergedParts(message)\n for (let index = parts.length - 1; index >= 0; index -= 1) {\n if (isTextPart(parts[index])) {\n return index\n }\n }\n return -1\n }\n\n const activeMessage = computed(() => {\n return props.messages?.[props.messages.length - 1]\n })\n const activeMessageLastPart = computed(() => {\n const active = activeMessage.value\n if (!active) {\n return null\n }\n return active.parts[active.parts.length - 1]\n })\n\n const mergedPartsMap = computed(() => {\n const map = new Map<string, UIChatMessage['parts']>()\n for (const message of props.messages ?? []) {\n if (message.role === 'assistant') {\n map.set(message.id, mergeConsecutiveTextParts(message.parts))\n }\n }\n return map\n })\n const getMergedParts = (message: UIChatMessage) => {\n return mergedPartsMap.value.get(message.id) ?? message.parts\n }\n const isLoading = computed(() => {\n return props.status === 'submitted' || props.status === 'streaming'\n })\n const isError = computed(() => props.status === 'error')\n\n const activeMessageLastPartLabel = computed(() => {\n const part = activeMessageLastPart.value\n return getToolPartLabel($t, part)\n })\n const activeMessageLastPartIcon = computed(() => {\n const part = activeMessageLastPart.value\n return getPartIcon(part)\n })\n\n const getMessageIndexById = (messageId: string) => {\n return props.messages?.findIndex((m) => m.id === messageId)\n }\n const isLastMessage = (index?: number) => {\n if (index === undefined || !props.messages) {\n return false\n }\n return index === props.messages.length - 1\n }\n const isMessageRegenerateButtonVisible = (index: number) => {\n return (\n isLastMessage(index) &&\n props.status === 'ready' &&\n !!props.actions?.includes('regenerate')\n )\n }\n // On the last message the actions appear only once the answer is ready;\n // on previous messages they are always available.\n const isActionButtonVisible = (\n action: ChatMessageActions,\n index: number,\n ) => {\n return (\n (!isLastMessage(index) || props.status === 'ready') &&\n !!props.actions?.includes(action)\n )\n }\n const isLastTextPart = (message: UIChatMessage) => {\n const lastPart = message.parts[message.parts.length - 1]\n return isTextPart(lastPart)\n }\n const messageHasSteps = (message: UIChatMessage) =>\n message.parts.some((part) => isReasoningPart(part) || isToolPart(part))\n // The extended steps timeline replaces the compact activity indicator as\n // soon as the message has at least one step to show.\n const showStepsTimeline = (message: UIChatMessage) =>\n Boolean(props.showExtendedSteps) &&\n isAssistant(message) &&\n messageHasSteps(message)\n const isAssistant = (message: UIChatMessage) => message.role === 'assistant'\n const isUser = (message: UIChatMessage) => message.role === 'user'\n const getPreviousAssistantMessage = (index: number) => {\n return props.messages\n ?.slice(0, index)\n .reverse()\n .find((message) => isAssistant(message))\n }\n const getNextAssistantMessage = (index: number) => {\n return props.messages\n ?.slice(index + 1)\n .find((message) => isAssistant(message))\n }\n // Returns the date to show in the day divider before the message at\n // `index`, or undefined when the surrounding assistant messages belong\n // to the same (local) day.\n const getDividerDate = (index: number) => {\n const previousCreatedAt =\n getPreviousAssistantMessage(index)?.metadata?.createdAt\n const nextCreatedAt =\n getNextAssistantMessage(index)?.metadata?.createdAt\n if (!previousCreatedAt || !nextCreatedAt) {\n return undefined\n }\n const previousDate = new Date(previousCreatedAt)\n const nextDate = new Date(nextCreatedAt)\n return previousDate.toDateString() !== nextDate.toDateString()\n ? nextDate\n : undefined\n }\n const showMessageFooter = (message: UIChatMessage, index: number) => {\n if (index === 0 || message.role !== 'assistant') {\n return false\n }\n return Boolean(\n props.actions?.length ||\n (props.showMessageDateTime &&\n message.metadata?.createdAt !== undefined) ||\n message.metadata?.completedAt !== undefined ||\n (props.showMessageTokensCount &&\n message.metadata?.totalTokens !== undefined),\n )\n }\n // Hover-only metadata (time + duration), shown when the fixed variant\n // (showMessageDateTime) is off.\n const formatMessageTime = (createdAt: number) => {\n const date = new Date(createdAt)\n const isToday = date.toDateString() === new Date().toDateString()\n return $d(date, isToday ? 'time' : 'date-time')\n }\n const getMessageDuration = (message: UIChatMessage) => {\n const { createdAt, completedAt } = message.metadata ?? {}\n if (!createdAt || !completedAt) {\n return undefined\n }\n return formatDuration($n, completedAt - createdAt)\n }\n // feedback message auto scroll\n const feedbackMessageEl =\n useTemplateRef<InstanceType<typeof PkChatbotFeedbackForm>[]>(\n 'feedbackMessageEl',\n )\n watch(\n () => props.feedbackMessageId,\n async () => {\n await nextTick()\n if (!props.feedbackMessageId) {\n return\n }\n const el = feedbackMessageEl.value?.[0]?.$el\n if (!el) {\n return\n }\n if (isLastMessage(getMessageIndexById(props.feedbackMessageId))) {\n scrollToBottom()\n return\n }\n el.scrollIntoView({ behavior: 'smooth', block: 'center' })\n },\n )\n</script>\n\n<template>\n <div\n ref=\"scrollEl\"\n class=\"pk-chatbot-messages\"\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions text\"\n :aria-busy=\"isLoading\"\n :style=\"{\n '--chatbot-main-color': mainColor,\n '--chatbot-contrast-color': contrastColor,\n }\"\n @scroll=\"onScroll\">\n <!-- First in flow (content top): its absolutely-positioned children\n must never inflate the scrollable overflow past the real content -->\n <div\n v-if=\"showScrollToBottom && outlineItems.length > 1\"\n class=\"pk-chatbot-messages__outline\">\n <PkChatbotOutlineRail\n :items=\"outlineItems\"\n :active-id=\"activeOutlineId\"\n @select=\"scrollToUserMessage\" />\n </div>\n <div ref=\"wrapperEl\" class=\"pk-chatbot-messages__wrapper\">\n <template v-for=\"(message, index) in messages\" :key=\"message.id\">\n <div\n v-if=\"isUser(message) && getDividerDate(index)\"\n class=\"pk-chatbot-divider\">\n <span class=\"pk-chatbot-divider__label\">\n {{ $d(getDividerDate(index)!, 'short') }}\n </span>\n </div>\n <div\n v-if=\"\n message.parts.length ||\n (isLastMessage(index) &&\n isLoading &&\n isAssistant(message))\n \"\n ref=\"messagesEl\"\n class=\"pk-chatbot-message\"\n :class=\"[\n `pk-chatbot-message--${message.role}`,\n {\n 'pk-chatbot-message--loading':\n isLoading &&\n isLastMessage(index) &&\n isAssistant(message),\n },\n ]\"\n :style=\"{\n minHeight:\n isLastMessage(index) &&\n isAssistant(message) &&\n !isError\n ? `${height}px`\n : undefined,\n }\">\n <transition appear name=\"pk-chatbot-part\">\n <PkChatbotSteps\n v-if=\"showStepsTimeline(message)\"\n :message\n :is-streaming=\"isLoading && isLastMessage(index)\"\n :is-dark />\n </transition>\n <template\n v-for=\"(part, partIndex) in getMergedParts(message)\"\n :key=\"partIndex\">\n <transition\n v-if=\"isTextPart(part) && part.text.trim()\"\n appear\n name=\"pk-chatbot-part\">\n <div class=\"pk-chatbot-message__text\">\n <slot\n v-bind=\"{\n message,\n part,\n index,\n isLoading,\n }\"\n name=\"text\">\n <PkStreamingMarkdown\n v-if=\"isAssistant(message)\"\n class=\"wysiwyg\"\n :markdown=\"part.text\"\n :is-dark\n :loading=\"\n isLastMessage(index) &&\n status === 'streaming'\n \" />\n <template v-else>\n {{ part.text }}\n </template>\n </slot>\n <!-- Read-only reaction chip overlapping the\n bubble corner, like a messaging app. Hidden\n when a comment is shown: the callout below\n then carries the reaction glyph instead. -->\n <span\n v-if=\"\n hasReaction(message.id) &&\n !getMessageFeedback(message.id)\n ?.comment &&\n partIndex === lastTextPartIndex(message)\n \"\n class=\"pk-chatbot-message__reaction\"\n :class=\"reactionToneClass(message.id)\"\n :title=\"reactionTitle(message.id)\">\n <span\n v-if=\"feedbackEmoji(message.id)\"\n class=\"pk-chatbot-message__reaction-emoji\">\n {{ feedbackEmoji(message.id) }}\n </span>\n <VvIcon\n v-else\n :name=\"\n feedbackVote(message.id) ===\n 'downvote'\n ? 'ri:thumb-down-fill'\n : 'ri:thumb-up-fill'\n \" />\n </span>\n </div>\n </transition>\n <transition\n v-else-if=\"isFilePart(part)\"\n appear\n name=\"pk-chatbot-part\">\n <PkChatbotFilePreview\n :media-type=\"part.mediaType\"\n :url=\"part.url\"\n :filename=\"part.filename\"\n :size=\"getFilePartMedia(part)?.bytesCount\" />\n </transition>\n <transition\n v-else-if=\"\n isToolPart(part) &&\n !isStreamingPart(part) &&\n (toolComponentMap[getToolPartName(part)] ||\n slots[part.type] ||\n showAllMessageParts)\n \"\n appear\n name=\"pk-chatbot-part\">\n <component\n :is=\"toolComponentMap[getToolPartName(part)]\"\n v-if=\"\n !slots[part.type] &&\n toolComponentMap[getToolPartName(part)]\n \"\n :key=\"`component-${partIndex}-${getPartState(part)}`\"\n :part />\n <slot\n v-else\n :name=\"part.type\"\n v-bind=\"{\n message,\n part,\n index,\n isLoading,\n }\">\n <div\n v-if=\"showAllMessageParts\"\n class=\"pk-chatbot-message__loading-info\">\n <div class=\"flex gap-8 items-center\">\n <VvIcon\n v-if=\"getPartIcon(part)\"\n :name=\"getPartIcon(part)!\"\n class=\"shrink-0\" />\n <code class=\"font-mono rounded text-12\">\n {{ toKebabCase(part.type) }}\n </code>\n </div>\n </div>\n </slot>\n </transition>\n <!-- Read-only comment: anchored right after the message\n text (same bubble as the reaction chip) so the\n feedback stays attached to the message body. -->\n <transition mode=\"out-in\">\n <PkChatbotMessageFeedback\n v-if=\"\n partIndex === lastTextPartIndex(message) &&\n readonlyFeedback &&\n getMessageFeedback(message.id)?.comment\n \"\n :feedback=\"getMessageFeedback(message.id)!\" />\n </transition>\n </template>\n <transition name=\"fade-in\" mode=\"out-in\">\n <div\n v-if=\"\n isLoading &&\n isLastMessage(index) &&\n !isLastTextPart(message) &&\n isAssistant(message) &&\n !showStepsTimeline(message)\n \"\n :key=\"`loading-info-${message.id}`\"\n class=\"pk-chatbot-message__loading-info\">\n <div class=\"flex gap-8 items-center\">\n <VvIcon\n name=\"line-md:loading-loop\"\n class=\"shrink-0\" />\n <transition mode=\"out-in\">\n <VvIcon\n v-if=\"activeMessageLastPartIcon\"\n :key=\"activeMessageLastPartIcon\"\n class=\"shrink-0\"\n :name=\"activeMessageLastPartIcon\" />\n </transition>\n <transition mode=\"out-in\">\n <span\n v-if=\"activeMessageLastPartLabel\"\n :key=\"activeMessageLastPartLabel\"\n class=\"text-12\">\n {{ activeMessageLastPartLabel }}\n </span>\n </transition>\n </div>\n <transition name=\"fade-in\" mode=\"out-in\">\n <PkStreamingMarkdownAutoscroll\n v-if=\"\n activeMessageLastPart &&\n 'text' in activeMessageLastPart &&\n activeMessageLastPart.text.trim()\n \"\n :markdown=\"activeMessageLastPart.text\"\n :is-dark\n inner-class=\"wysiwyg\"\n class=\"border border-surface-4 rounded p-4 mt-8 bg-surface-1 max-h-64 text-12 w-full\" />\n </transition>\n </div>\n </transition>\n <transition mode=\"out-in\">\n <div\n v-if=\"showMessageFooter(message, index)\"\n class=\"pk-chatbot-message__footer\">\n <VvButtonGroup\n modifiers=\"compact\"\n class=\"mr-auto shrink-0\">\n <transition mode=\"out-in\">\n <VvButton\n v-if=\"\n isMessageRegenerateButtonVisible(\n index,\n )\n \"\n icon=\"ri:reset-right-line\"\n modifiers=\"action-quiet-small\"\n :title=\"$t('action.regenerate')\"\n :aria-label=\"$t('action.regenerate')\"\n @click.stop=\"$emit('regenerate')\" />\n </transition>\n <transition mode=\"out-in\">\n <VvButton\n v-if=\"\n isActionButtonVisible(\n 'show-info',\n index,\n )\n \"\n icon=\"ri:information-line\"\n :title=\"$t('action.getMoreInfo')\"\n :aria-label=\"$t('action.getMoreInfo')\"\n modifiers=\"action-quiet-small\"\n @click.stop=\"\n $emit('show-info', message)\n \" />\n </transition>\n <transition mode=\"out-in\">\n <VvButton\n v-if=\"\n isActionButtonVisible(\n 'revise',\n index,\n )\n \"\n :icon=\"\n isRevised(message.id)\n ? 'ri:file-edit-fill'\n : 'ri:file-edit-line'\n \"\n :title=\"\n isRevised(message.id)\n ? $t('action.editRevise')\n : $t('action.createRevise')\n \"\n :aria-label=\"\n isRevised(message.id)\n ? $t('action.editRevise')\n : $t('action.createRevise')\n \"\n modifiers=\"action-quiet-small\"\n :class=\"{\n 'text-brand': isRevised(message.id),\n }\"\n @click.stop=\"\n $emit('revise', message)\n \" />\n </transition>\n <transition mode=\"out-in\">\n <VvButton\n v-if=\"\n isFeedbackButtonVisible(\n 'upvote',\n index,\n )\n \"\n :icon=\"\n getMessageFeedback(message.id)\n ?.vote === 'upvote'\n ? 'ri:thumb-up-fill'\n : 'ri:thumb-up-line'\n \"\n :title=\"$t('action.upvote')\"\n :aria-label=\"$t('action.upvote')\"\n modifiers=\"action-quiet-small\"\n @click.stop=\"\n $emit('upvote', message)\n \" />\n </transition>\n <transition mode=\"out-in\">\n <VvButton\n v-if=\"\n isFeedbackButtonVisible(\n 'downvote',\n index,\n )\n \"\n :icon=\"\n getMessageFeedback(message.id)\n ?.vote === 'downvote'\n ? 'ri:thumb-down-fill'\n : 'ri:thumb-down-line'\n \"\n :title=\"$t('action.downvote')\"\n :aria-label=\"$t('action.downvote')\"\n modifiers=\"action-quiet-small\"\n @click.stop=\"\n $emit('downvote', message)\n \" />\n </transition>\n <transition mode=\"out-in\">\n <VvButton\n v-if=\"\n isFeedbackButtonVisible(\n 'feedback',\n index,\n )\n \"\n :icon=\"\n getMessageFeedback(message.id)\n ?.comment\n ? 'ri:feedback-fill'\n : 'ri:feedback-line'\n \"\n :title=\"$t('action.feedback')\"\n :aria-label=\"$t('action.feedback')\"\n modifiers=\"action-quiet-small\"\n @click.stop=\"\n $emit('feedback', message)\n \" />\n </transition>\n </VvButtonGroup>\n <div\n v-if=\"\n !showMessageDateTime &&\n message.metadata?.createdAt &&\n message.metadata?.completedAt\n \"\n class=\"pk-chatbot-message__hover-meta\">\n <time\n :datetime=\"\n new Date(\n message.metadata.createdAt,\n ).toISOString()\n \"\n :title=\"\n $d(\n new Date(\n message.metadata.createdAt,\n ),\n 'date-time',\n )\n \"\n class=\"flex items-center gap-4 min-w-0\">\n <VvIcon\n name=\"ri:time-line\"\n class=\"shrink-0\" />\n <span class=\"truncate\">{{\n formatMessageTime(\n message.metadata.createdAt,\n )\n }}</span>\n </time>\n <span\n v-if=\"getMessageDuration(message)\"\n class=\"flex items-center gap-4 min-w-0\">\n <VvIcon\n name=\"ri:hourglass-line\"\n class=\"shrink-0\" />\n <span class=\"truncate\">{{\n getMessageDuration(message)\n }}</span>\n </span>\n </div>\n <span\n v-if=\"\n showMessageTokensCount &&\n message.metadata?.totalTokens\n \"\n class=\"flex items-center gap-4 text-12 text-word-3\">\n <VvIcon\n name=\"ri:ai-generate-2-line\"\n class=\"shrink-0\" />\n <span class=\"truncate\"\n >{{\n $n(\n message.metadata.totalTokens,\n 'integer',\n )\n }}\n {{ $t('label.tokens') }}\n </span>\n </span>\n <time\n v-if=\"\n showMessageDateTime &&\n message.metadata?.createdAt\n \"\n :datetime=\"\n new Date(\n message.metadata?.createdAt,\n ).toISOString()\n \"\n class=\"flex items-center gap-4 text-12 text-word-3\">\n <VvIcon name=\"ri:time-line\" class=\"shrink-0\" />\n <span class=\"truncate\">{{\n $d(\n new Date(message.metadata?.createdAt),\n 'date-time',\n )\n }}</span>\n </time>\n <div\n v-if=\"\n showMessageDateTime &&\n message?.metadata?.completedAt &&\n message?.metadata?.createdAt\n \"\n class=\"flex items-center gap-4 text-12 text-word-3\">\n <VvIcon\n name=\"ri:hourglass-line\"\n class=\"shrink-0\" />\n <PkRelativeTime\n class=\"truncate\"\n :date=\"message.metadata?.createdAt\"\n :end-date=\"message.metadata?.completedAt\" />\n </div>\n </div>\n </transition>\n <transition mode=\"out-in\">\n <PkChatbotFeedbackForm\n v-if=\"message.id === feedbackMessageId\"\n ref=\"feedbackMessageEl\"\n :loading=\"feedbackLoading\"\n :submitted=\"feedbackSubmitted\"\n :error=\"feedbackError\"\n @submit=\"$emit('feedback-submit', $event)\"\n @close=\"$emit('feedback-close')\" />\n </transition>\n </div>\n </template>\n <transition appear name=\"pk-chatbot-part\">\n <PkChatbotError\n v-if=\"isError\"\n :error\n @retry=\"$emit('auto-retry')\"\n @reset=\"$emit('reset-chat')\" />\n </transition>\n <div\n v-if=\"activeMessage?.role === 'user' || isError\"\n class=\"pk-chatbot-messages__spacer\"\n :style=\"{ minHeight: `${height}px` }\"></div>\n </div>\n <Transition name=\"pk-chatbot-messages-fab\">\n <button\n v-if=\"showScrollToBottom && (userScrolledUp || !isAtBottom)\"\n type=\"button\"\n class=\"pk-chatbot-messages__scroll-to-bottom\"\n :title=\"$t('action.scrollToBottom')\"\n :aria-label=\"$t('action.scrollToBottom')\"\n @click=\"onScrollToBottomClick\">\n <VvIcon name=\"ri:arrow-down-line\" />\n </button>\n </Transition>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chatbot-messages {\n overflow-y: auto;\n flex: 1;\n min-width: 0;\n font-size: var(--text-14);\n\n scrollbar-width: thin;\n scrollbar-color: var(--color-word-5) var(--color-surface-1);\n\n &__wrapper {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-16);\n min-width: 0;\n }\n\n // Conversation outline rail: sticky shell pinned to the vertical\n // middle of the scroll area, at the right edge. Zero-sized and\n // first in flow so neither it nor its absolutely-positioned pieces\n // inflate scrollHeight (desktop only, like ChatGPT)\n &__outline {\n display: none;\n position: sticky;\n top: 50%;\n z-index: 2;\n flex: none;\n align-self: flex-end;\n height: 0;\n\n @include media-breakpoint-up('md', $breakpoints) {\n display: block;\n }\n\n .pk-chatbot-outline {\n position: absolute;\n top: 0;\n right: 0;\n transform: translateY(-50%);\n }\n }\n\n // Placeholder while the answer has not started yet: settles like\n // the message spacer when released\n &__spacer {\n transition: min-height 300ms var(--ease-out);\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n }\n\n // Floating \"back to bottom\" button, sticky inside the scroll area\n &__scroll-to-bottom {\n position: sticky;\n bottom: var(--spacing-8);\n z-index: 2;\n display: flex;\n align-items: center;\n justify-content: center;\n // The scroll container is a flex column: without this the\n // overflowing content shrinks the button, ignoring its height\n flex: none;\n width: var(--spacing-36);\n height: var(--spacing-36);\n // Net-zero layout contribution: mounting/unmounting the button\n // must not change scrollHeight, or reaching the bottom (which\n // hides it) would clamp scrollTop and cause a visible jump\n margin-block-start: calc(-1 * var(--spacing-36));\n margin-inline: auto;\n border: 1px solid var(--color-surface-3);\n border-radius: var(--rounded-full);\n background-color: var(--color-surface-1);\n box-shadow: var(--shadow-md);\n color: var(--color-word-1);\n cursor: pointer;\n transition: var(--transition-colors);\n\n &:hover {\n background-color: var(--color-surface-2);\n }\n }\n }\n\n .pk-chatbot-messages-fab-enter-active,\n .pk-chatbot-messages-fab-leave-active {\n transition: opacity 150ms var(--ease-out);\n }\n\n .pk-chatbot-messages-fab-enter-from,\n .pk-chatbot-messages-fab-leave-to {\n opacity: 0;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .pk-chatbot-messages-fab-enter-active,\n .pk-chatbot-messages-fab-leave-active {\n transition: none;\n }\n }\n\n .pk-chatbot-divider {\n position: relative;\n border-bottom: 1px solid var(--color-surface-3);\n\n &__label {\n position: absolute;\n padding-inline: var(--spacing-8);\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background-color: var(--color-surface);\n color: var(--color-word-4);\n font-size: var(--text-12);\n }\n }\n\n .pk-chatbot-message {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-sm);\n min-width: 0;\n align-items: flex-start;\n overflow: hidden;\n max-width: 100%;\n // The anchor spacer (inline min-height on the last assistant\n // message) settles smoothly when released at the end of the stream\n transition: min-height 300ms var(--ease-out);\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n &__text {\n position: relative;\n color: var(--color-word-2);\n background-color: var(--color-surface);\n line-height: var(--leading-normal);\n border-width: var(--spacing-px);\n border-style: solid;\n border-color: var(--color-surface-3);\n padding: var(--spacing-sm);\n border-radius: var(--rounded-xl) var(--rounded-xl) var(--rounded-xl)\n 0;\n max-width: 100%;\n text-overflow: ellipsis;\n overflow: hidden;\n }\n\n // Read-only feedback: a circular vote chip that overlaps the bubble's\n // bottom-right corner (messaging-app style). White ring lifts it off\n // the bubble; solid accent makes the rating unmistakable.\n &__reaction {\n position: absolute;\n right: var(--spacing-8);\n bottom: 0;\n transform: translateY(50%);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--spacing-24);\n height: var(--spacing-24);\n border-radius: var(--rounded-full, 9999px);\n color: var(--color-white, #fff);\n font-size: var(--text-12);\n box-shadow: var(--shadow-md);\n\n &--positive {\n background-color: var(--color-success);\n }\n\n &--negative {\n background-color: var(--color-danger);\n }\n\n // Real emoji (e.g. WhatsApp): the glyph carries its own colour, so\n // the chip stays a neutral surface pill.\n &--neutral {\n background-color: var(--color-surface-1);\n }\n }\n\n &__reaction-emoji {\n // Smaller than the chip so the glyph doesn't touch the ring.\n font-size: var(--text-12);\n line-height: 1;\n }\n\n &__loading-info {\n line-height: var(--leading-normal);\n border-width: var(--spacing-px);\n border-style: solid;\n border-color: var(--color-surface-3);\n padding: var(--spacing-sm);\n border-radius: var(--rounded-xl) var(--rounded-xl) var(--rounded-xl)\n 0;\n font-size: var(--text-12);\n color: var(--color-word-3);\n }\n\n &__footer {\n width: 100%;\n display: flex;\n gap: var(--spacing-8);\n align-items: center;\n }\n\n &__hover-meta {\n display: flex;\n min-width: 0;\n align-items: center;\n gap: var(--spacing-8);\n font-size: var(--text-12);\n color: var(--color-word-3);\n white-space: nowrap;\n font-variant-numeric: tabular-nums;\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n\n &:hover &__hover-meta,\n &:focus-within &__hover-meta {\n opacity: 1;\n }\n\n // Hover doesn't exist on touch devices: keep the metadata visible\n @media (hover: none) {\n &__hover-meta {\n opacity: 1;\n }\n }\n\n &--user {\n align-items: flex-end;\n\n .pk-chatbot-message__text {\n background-color: var(\n --chatbot-main-color,\n var(--color-surface-1)\n );\n border-color: var(--chatbot-main-color, var(--color-surface-4));\n color: var(--chatbot-contrast-color, var(--color-word-1));\n border-radius: var(--rounded-xl) var(--rounded-xl) 0\n var(--rounded-xl);\n }\n }\n\n &--assistant {\n width: 100%;\n gap: var(--spacing-16);\n\n .pk-chatbot-message__text {\n width: 100%;\n }\n }\n\n &--system {\n align-items: flex-end;\n\n .pk-chatbot-message__text {\n display: flex;\n gap: var(--spacing-8);\n font-size: var(--text-12);\n padding: var(--spacing-8) var(--spacing-sm);\n align-items: center;\n border-color: var(--chatbot-main-color, var(--color-surface-4));\n color: var(--chatbot-main-color, var(--color-word-1));\n border-radius: var(--rounded-xl) var(--rounded-xl) 0\n var(--rounded-xl);\n }\n }\n }\n\n .pk-chatbot-part-enter-active {\n transition:\n opacity 0.25s ease,\n transform 0.25s ease;\n }\n\n .pk-chatbot-part-enter-from {\n opacity: 0;\n transform: translateY(8px);\n }\n\n @media (prefers-reduced-motion: reduce) {\n .pk-chatbot-part-enter-active {\n transition: none;\n }\n\n .pk-chatbot-part-enter-from {\n transform: none;\n }\n }\n</style>\n","<script lang=\"ts\" setup>\n import type {\n ChatMessageActions,\n MessageFeedback,\n RevisedAnswer,\n UIChatMessage,\n } from 'models'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n import PkChatbotError from './PkChatbotError.vue'\n import PkChatbotFeedbackForm from './PkChatbotFeedbackForm.vue'\n import PkChatbotMessageFeedback from './PkChatbotMessageFeedback.vue'\n import PkChatbotFilePreview from './PkChatbotFilePreview.vue'\n import PkRelativeTime from '../PkRelativeTime.vue'\n import { useI18n } from 'vue-i18n'\n import {\n useTemplateRef,\n ref,\n watch,\n computed,\n nextTick,\n useSlots,\n } from 'vue'\n import { toolComponentMap } from './toolComponentMap'\n import PkChatbotSteps from './PkChatbotSteps.vue'\n import {\n resolveContrastColor,\n getPartState,\n isTextPart,\n isFilePart,\n isToolPart,\n isReasoningPart,\n isStreamingPart,\n getPartIcon,\n getToolPartLabel,\n mergeConsecutiveTextParts,\n formatDuration,\n } from './utils'\n import { getFilePartMedia, getToolPartName, toKebabCase } from 'utils'\n import PkStreamingMarkdownAutoscroll from './PkStreamingMarkdownAutoscroll.vue'\n import PkChatbotOutlineRail from './PkChatbotOutlineRail.vue'\n import { useChatScroll } from './useChatScroll'\n\n const props = defineProps<{\n status?: 'submitted' | 'streaming' | 'ready' | 'error'\n messages?: UIChatMessage[]\n error?: Error\n actions?: ChatMessageActions[]\n mainColor?: string\n textColor?: 'auto' | 'white' | 'black'\n revisedAnswers?: RevisedAnswer[]\n messageFeedbacks?: MessageFeedback[]\n /**\n * Render the vote/feedback action buttons as read-only state indicators\n * (e.g. admin chat-logs view): icons reflect the user's feedback but the\n * buttons are not interactive.\n */\n readonlyFeedback?: boolean\n disableHeightAdjustment?: boolean\n showMessageDateTime?: boolean\n showMessageTokensCount?: boolean\n showAllMessageParts?: boolean\n showExtendedSteps?: boolean\n isDark?: boolean\n /** Show a floating \"back to bottom\" button when the user scrolls up (fullscreen layout) */\n showScrollToBottom?: boolean\n // TODO: move feedback in a separate component to avoid passing these props\n feedbackMessageId?: string\n feedbackLoading?: boolean\n feedbackSubmitted?: boolean\n feedbackError?: string\n }>()\n\n const emit = defineEmits<{\n (e: 'show-info', message: UIChatMessage): void\n (e: 'regenerate'): void\n (e: 'revise', message: UIChatMessage): void\n (e: 'upvote', message: UIChatMessage): void\n (e: 'downvote', message: UIChatMessage): void\n (e: 'feedback', message: UIChatMessage): void\n (e: 'feedback-submit', comment: string): void\n (e: 'feedback-close'): void\n (e: 'scroll-up'): void\n (e: 'scroll-down'): void\n (e: 'auto-retry'): void\n (e: 'reset-chat'): void\n }>()\n\n const {\n t: $t,\n d: $d,\n n: $n,\n } = useI18n({\n useScope: 'global',\n })\n\n const slots = useSlots()\n\n const scrollEl = useTemplateRef<HTMLDivElement>('scrollEl')\n const wrapperEl = useTemplateRef<HTMLDivElement>('wrapperEl')\n const contrastColor = computed(() =>\n resolveContrastColor(props.textColor, props.mainColor),\n )\n\n // --- Scroll ---\n\n const messagesElRefs = useTemplateRef<HTMLDivElement[]>('messagesEl')\n\n const { handleScroll, scrollToBottom, userScrolledUp, isAtBottom } =\n useChatScroll({\n scrollEl,\n status: () => props.status,\n messagesLength: () => props.messages?.length,\n lastMessageRole: () =>\n props.messages?.[props.messages.length - 1]?.role,\n contentEl: () => wrapperEl.value,\n onScrollUp: () => emit('scroll-up'),\n onScrollDown: () => emit('scroll-down'),\n })\n\n const onScrollToBottomClick = () => {\n // scrollToBottom() is a no-op while userScrolledUp is set\n userScrolledUp.value = false\n scrollToBottom()\n }\n\n // --- Conversation outline (fullscreen, desktop) ---\n\n const outlineItems = computed(() =>\n (props.messages ?? [])\n .filter((message) => message.role === 'user')\n .map((message) => ({\n id: message.id,\n preview:\n message.parts.find(isTextPart)?.text.trim().slice(0, 120) ||\n '…',\n })),\n )\n const activeOutlineId = ref<string>()\n\n // The rail entries map 1:1 onto the rendered user messages\n const getUserMessageEls = () =>\n scrollEl.value?.querySelectorAll('.pk-chatbot-message--user') ?? []\n\n // Scroll-spy: active is the last user message above the middle of the\n // viewport (the exchange currently being read)\n const updateActiveOutline = () => {\n const scroller = scrollEl.value\n if (!scroller || !props.showScrollToBottom) {\n return\n }\n const line =\n scroller.getBoundingClientRect().top + scroller.clientHeight / 2\n let active = outlineItems.value[0]?.id\n getUserMessageEls().forEach((el, index) => {\n if (el.getBoundingClientRect().top <= line) {\n active = outlineItems.value[index]?.id\n }\n })\n activeOutlineId.value = active\n }\n\n watch(outlineItems, async () => {\n await nextTick()\n updateActiveOutline()\n })\n\n const onScroll = () => {\n handleScroll()\n updateActiveOutline()\n }\n\n const scrollToUserMessage = (id: string) => {\n const scroller = scrollEl.value\n const index = outlineItems.value.findIndex((item) => item.id === id)\n const messageEl = getUserMessageEls()[index]\n if (!scroller || !messageEl) {\n return\n }\n // Intentional jump away from the live tail: the wheel/touch intent\n // detection cannot see programmatic scrolls, pause the auto-follow\n // explicitly (reaching the bottom again re-enables it)\n userScrolledUp.value = true\n // Same resting line as a freshly sent message: top of the content area\n scroller.scrollTo({\n top:\n scroller.scrollTop +\n messageEl.getBoundingClientRect().top -\n scroller.getBoundingClientRect().top -\n Number.parseFloat(getComputedStyle(scroller).paddingTop),\n behavior: 'smooth',\n })\n }\n\n // --- Height adjustment ---\n\n const height = ref<number>(0)\n\n // Recalculate when a message is added or the conversation changes (the\n // store recreates `messages` on every streamed token, so watching the\n // array reference would re-run this on each character). The height only\n // depends on the last user message height, which is stable while\n // streaming.\n watch(\n () => [\n props.messages?.length,\n props.messages?.[props.messages.length - 1]?.id,\n ],\n async () => {\n const messages = props.messages\n if (!messages?.length || props.disableHeightAdjustment) {\n return\n }\n // The spacer only serves the in-flight exchange, letting the\n // fresh user message anchor at the top while the answer streams.\n // On plain loads (e.g. opening an old conversation) it would\n // just leave a large void after the last message.\n const isExchangeInFlight =\n messages[messages.length - 1].role === 'user' ||\n props.status === 'submitted' ||\n props.status === 'streaming'\n if (!isExchangeInFlight) {\n return\n }\n await nextTick()\n if (!scrollEl.value) {\n return\n }\n // Spacer sized so the freshly sent user message rests at the top\n // of the content area once scrolled to bottom: subtract both\n // paddings (clientHeight includes them) so any extra top\n // clearance (e.g. the fullscreen overlay header) is respected,\n // and the wrapper row gap separating the message from the spacer\n const { paddingTop, paddingBottom } = getComputedStyle(\n scrollEl.value,\n )\n const scrollElHeight =\n scrollEl.value.clientHeight -\n Number.parseFloat(paddingTop) -\n Number.parseFloat(paddingBottom)\n const wrapperGap = wrapperEl.value\n ? Number.parseFloat(getComputedStyle(wrapperEl.value).rowGap) ||\n 0\n : 0\n const lastUserMessageIndex = messages\n .map((message) => message.role)\n .lastIndexOf('user')\n const lastUserMessageHeight =\n messagesElRefs.value?.[lastUserMessageIndex]?.clientHeight ?? 0\n const newHeight =\n scrollElHeight - lastUserMessageHeight - wrapperGap\n if (newHeight > 0) {\n height.value = newHeight\n }\n },\n )\n\n // Release the spacer once the exchange is over: it would otherwise\n // leave a large empty area after the last message. The min-height\n // transition settles the layout smoothly (the browser clamps the\n // scroll progressively when the viewport sat inside the removed area).\n watch(\n () => props.status,\n (status) => {\n if (status === 'ready' || status === 'error') {\n height.value = 0\n }\n },\n )\n\n const isRevised = (messageId: string) => {\n return props.revisedAnswers?.some((r) => r.messageId === messageId)\n }\n\n const getMessageFeedback = (messageId: string) =>\n props.messageFeedbacks?.find((f) => f.messageId === messageId)\n\n // Interactive vote/feedback buttons. In read-only mode (admin chat-logs)\n // the vote is shown on the message itself (coloured bubble border + an\n // \"active\" thumb in the footer) and the comment, if any, below it.\n const isFeedbackButtonVisible = (\n kind: 'upvote' | 'downvote' | 'feedback',\n index: number,\n ) => !props.readonlyFeedback && isActionButtonVisible(kind, index)\n\n // Read-only feedback for a message (drives the reaction chip anchored to\n // the bubble). undefined when not in read-only mode.\n const readonlyFeedbackOf = (messageId: string) =>\n props.readonlyFeedback ? getMessageFeedback(messageId) : undefined\n const feedbackVote = (messageId: string) =>\n readonlyFeedbackOf(messageId)?.vote\n // The real reaction glyph, shown ONLY for unmapped reactions (no vote):\n // 👍/❤️/👎 keep the classic thumb icon, while e.g. WhatsApp \"😍\" shows the\n // actual emoji. Platforms that send a type word (Teams \"like\") have a vote\n // and therefore use the icon too.\n const feedbackEmoji = (messageId: string) => {\n const feedback = readonlyFeedbackOf(messageId)\n if (feedback?.vote) {\n return undefined\n }\n const raw = feedback?.metadata?.reactionEmoji\n return typeof raw === 'string' && /\\p{Extended_Pictographic}/u.test(raw)\n ? raw\n : undefined\n }\n const hasReaction = (messageId: string) =>\n Boolean(feedbackVote(messageId) || feedbackEmoji(messageId))\n const reactionToneClass = (messageId: string) => {\n // A real emoji carries its own colour → neutral pill. Only the\n // thumb-icon fallback uses the sentiment colour.\n if (feedbackEmoji(messageId)) {\n return 'pk-chatbot-message__reaction--neutral'\n }\n const vote = feedbackVote(messageId)\n if (vote === 'upvote') {\n return 'pk-chatbot-message__reaction--positive'\n }\n if (vote === 'downvote') {\n return 'pk-chatbot-message__reaction--negative'\n }\n return 'pk-chatbot-message__reaction--neutral'\n }\n const reactionTitle = (messageId: string) => {\n const vote = feedbackVote(messageId)\n if (vote === 'upvote') {\n return $t('hint.userFeedbackPositive')\n }\n if (vote === 'downvote') {\n return $t('hint.userFeedbackNegative')\n }\n return $t('hint.userFeedbackReaction')\n }\n\n // Index of the last text part: the reaction chip anchors to that bubble so\n // it renders once even when the message has several text parts.\n const lastTextPartIndex = (message: UIChatMessage) => {\n const parts = getMergedParts(message)\n for (let index = parts.length - 1; index >= 0; index -= 1) {\n if (isTextPart(parts[index])) {\n return index\n }\n }\n return -1\n }\n\n const activeMessage = computed(() => {\n return props.messages?.[props.messages.length - 1]\n })\n const activeMessageLastPart = computed(() => {\n const active = activeMessage.value\n if (!active) {\n return null\n }\n return active.parts[active.parts.length - 1]\n })\n\n const mergedPartsMap = computed(() => {\n const map = new Map<string, UIChatMessage['parts']>()\n for (const message of props.messages ?? []) {\n if (message.role === 'assistant') {\n map.set(message.id, mergeConsecutiveTextParts(message.parts))\n }\n }\n return map\n })\n const getMergedParts = (message: UIChatMessage) => {\n return mergedPartsMap.value.get(message.id) ?? message.parts\n }\n const isLoading = computed(() => {\n return props.status === 'submitted' || props.status === 'streaming'\n })\n const isError = computed(() => props.status === 'error')\n\n const activeMessageLastPartLabel = computed(() => {\n const part = activeMessageLastPart.value\n return getToolPartLabel($t, part)\n })\n const activeMessageLastPartIcon = computed(() => {\n const part = activeMessageLastPart.value\n return getPartIcon(part)\n })\n\n const getMessageIndexById = (messageId: string) => {\n return props.messages?.findIndex((m) => m.id === messageId)\n }\n const isLastMessage = (index?: number) => {\n if (index === undefined || !props.messages) {\n return false\n }\n return index === props.messages.length - 1\n }\n const isMessageRegenerateButtonVisible = (index: number) => {\n return (\n isLastMessage(index) &&\n props.status === 'ready' &&\n !!props.actions?.includes('regenerate')\n )\n }\n // On the last message the actions appear only once the answer is ready;\n // on previous messages they are always available.\n const isActionButtonVisible = (\n action: ChatMessageActions,\n index: number,\n ) => {\n return (\n (!isLastMessage(index) || props.status === 'ready') &&\n !!props.actions?.includes(action)\n )\n }\n const isLastTextPart = (message: UIChatMessage) => {\n const lastPart = message.parts[message.parts.length - 1]\n return isTextPart(lastPart)\n }\n const messageHasSteps = (message: UIChatMessage) =>\n message.parts.some((part) => isReasoningPart(part) || isToolPart(part))\n // The extended steps timeline replaces the compact activity indicator as\n // soon as the message has at least one step to show.\n const showStepsTimeline = (message: UIChatMessage) =>\n Boolean(props.showExtendedSteps) &&\n isAssistant(message) &&\n messageHasSteps(message)\n const isAssistant = (message: UIChatMessage) => message.role === 'assistant'\n const isUser = (message: UIChatMessage) => message.role === 'user'\n const getPreviousAssistantMessage = (index: number) => {\n return props.messages\n ?.slice(0, index)\n .reverse()\n .find((message) => isAssistant(message))\n }\n const getNextAssistantMessage = (index: number) => {\n return props.messages\n ?.slice(index + 1)\n .find((message) => isAssistant(message))\n }\n // Returns the date to show in the day divider before the message at\n // `index`, or undefined when the surrounding assistant messages belong\n // to the same (local) day.\n const getDividerDate = (index: number) => {\n const previousCreatedAt =\n getPreviousAssistantMessage(index)?.metadata?.createdAt\n const nextCreatedAt =\n getNextAssistantMessage(index)?.metadata?.createdAt\n if (!previousCreatedAt || !nextCreatedAt) {\n return undefined\n }\n const previousDate = new Date(previousCreatedAt)\n const nextDate = new Date(nextCreatedAt)\n return previousDate.toDateString() !== nextDate.toDateString()\n ? nextDate\n : undefined\n }\n const showMessageFooter = (message: UIChatMessage, index: number) => {\n if (index === 0 || message.role !== 'assistant') {\n return false\n }\n return Boolean(\n props.actions?.length ||\n (props.showMessageDateTime &&\n message.metadata?.createdAt !== undefined) ||\n message.metadata?.completedAt !== undefined ||\n (props.showMessageTokensCount &&\n message.metadata?.totalTokens !== undefined),\n )\n }\n // Hover-only metadata (time + duration), shown when the fixed variant\n // (showMessageDateTime) is off.\n const formatMessageTime = (createdAt: number) => {\n const date = new Date(createdAt)\n const isToday = date.toDateString() === new Date().toDateString()\n return $d(date, isToday ? 'time' : 'date-time')\n }\n const getMessageDuration = (message: UIChatMessage) => {\n const { createdAt, completedAt } = message.metadata ?? {}\n if (!createdAt || !completedAt) {\n return undefined\n }\n return formatDuration($n, completedAt - createdAt)\n }\n // feedback message auto scroll\n const feedbackMessageEl =\n useTemplateRef<InstanceType<typeof PkChatbotFeedbackForm>[]>(\n 'feedbackMessageEl',\n )\n watch(\n () => props.feedbackMessageId,\n async () => {\n await nextTick()\n if (!props.feedbackMessageId) {\n return\n }\n const el = feedbackMessageEl.value?.[0]?.$el\n if (!el) {\n return\n }\n if (isLastMessage(getMessageIndexById(props.feedbackMessageId))) {\n scrollToBottom()\n return\n }\n el.scrollIntoView({ behavior: 'smooth', block: 'center' })\n },\n )\n</script>\n\n<template>\n <div\n ref=\"scrollEl\"\n class=\"pk-chatbot-messages\"\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions text\"\n :aria-busy=\"isLoading\"\n :style=\"{\n '--chatbot-main-color': mainColor,\n '--chatbot-contrast-color': contrastColor,\n }\"\n @scroll=\"onScroll\">\n <!-- First in flow (content top): its absolutely-positioned children\n must never inflate the scrollable overflow past the real content -->\n <div\n v-if=\"showScrollToBottom && outlineItems.length > 1\"\n class=\"pk-chatbot-messages__outline\">\n <PkChatbotOutlineRail\n :items=\"outlineItems\"\n :active-id=\"activeOutlineId\"\n @select=\"scrollToUserMessage\" />\n </div>\n <div ref=\"wrapperEl\" class=\"pk-chatbot-messages__wrapper\">\n <template v-for=\"(message, index) in messages\" :key=\"message.id\">\n <div\n v-if=\"isUser(message) && getDividerDate(index)\"\n class=\"pk-chatbot-divider\">\n <span class=\"pk-chatbot-divider__label\">\n {{ $d(getDividerDate(index)!, 'short') }}\n </span>\n </div>\n <div\n v-if=\"\n message.parts.length ||\n (isLastMessage(index) &&\n isLoading &&\n isAssistant(message))\n \"\n ref=\"messagesEl\"\n class=\"pk-chatbot-message\"\n :class=\"[\n `pk-chatbot-message--${message.role}`,\n {\n 'pk-chatbot-message--loading':\n isLoading &&\n isLastMessage(index) &&\n isAssistant(message),\n },\n ]\"\n :style=\"{\n minHeight:\n isLastMessage(index) &&\n isAssistant(message) &&\n !isError\n ? `${height}px`\n : undefined,\n }\">\n <transition appear name=\"pk-chatbot-part\">\n <PkChatbotSteps\n v-if=\"showStepsTimeline(message)\"\n :message\n :is-streaming=\"isLoading && isLastMessage(index)\"\n :is-dark />\n </transition>\n <template\n v-for=\"(part, partIndex) in getMergedParts(message)\"\n :key=\"partIndex\">\n <transition\n v-if=\"isTextPart(part) && part.text.trim()\"\n appear\n name=\"pk-chatbot-part\">\n <div class=\"pk-chatbot-message__text\">\n <slot\n v-bind=\"{\n message,\n part,\n index,\n isLoading,\n }\"\n name=\"text\">\n <PkStreamingMarkdown\n v-if=\"isAssistant(message)\"\n class=\"wysiwyg\"\n :markdown=\"part.text\"\n :is-dark\n :loading=\"\n isLastMessage(index) &&\n status === 'streaming'\n \" />\n <template v-else>\n {{ part.text }}\n </template>\n </slot>\n <!-- Read-only reaction chip overlapping the\n bubble corner, like a messaging app. Hidden\n when a comment is shown: the callout below\n then carries the reaction glyph instead. -->\n <span\n v-if=\"\n hasReaction(message.id) &&\n !getMessageFeedback(message.id)\n ?.comment &&\n partIndex === lastTextPartIndex(message)\n \"\n class=\"pk-chatbot-message__reaction\"\n :class=\"reactionToneClass(message.id)\"\n :title=\"reactionTitle(message.id)\">\n <span\n v-if=\"feedbackEmoji(message.id)\"\n class=\"pk-chatbot-message__reaction-emoji\">\n {{ feedbackEmoji(message.id) }}\n </span>\n <VvIcon\n v-else\n :name=\"\n feedbackVote(message.id) ===\n 'downvote'\n ? 'ri:thumb-down-fill'\n : 'ri:thumb-up-fill'\n \" />\n </span>\n </div>\n </transition>\n <transition\n v-else-if=\"isFilePart(part)\"\n appear\n name=\"pk-chatbot-part\">\n <PkChatbotFilePreview\n :media-type=\"part.mediaType\"\n :url=\"part.url\"\n :filename=\"part.filename\"\n :size=\"getFilePartMedia(part)?.bytesCount\" />\n </transition>\n <transition\n v-else-if=\"\n isToolPart(part) &&\n !isStreamingPart(part) &&\n (toolComponentMap[getToolPartName(part)] ||\n slots[part.type] ||\n showAllMessageParts)\n \"\n appear\n name=\"pk-chatbot-part\">\n <component\n :is=\"toolComponentMap[getToolPartName(part)]\"\n v-if=\"\n !slots[part.type] &&\n toolComponentMap[getToolPartName(part)]\n \"\n :key=\"`component-${partIndex}-${getPartState(part)}`\"\n :part />\n <slot\n v-else\n :name=\"part.type\"\n v-bind=\"{\n message,\n part,\n index,\n isLoading,\n }\">\n <div\n v-if=\"showAllMessageParts\"\n class=\"pk-chatbot-message__loading-info\">\n <div class=\"flex gap-8 items-center\">\n <VvIcon\n v-if=\"getPartIcon(part)\"\n :name=\"getPartIcon(part)!\"\n class=\"shrink-0\" />\n <code class=\"font-mono rounded text-12\">\n {{ toKebabCase(part.type) }}\n </code>\n </div>\n </div>\n </slot>\n </transition>\n <!-- Read-only comment: anchored right after the message\n text (same bubble as the reaction chip) so the\n feedback stays attached to the message body. -->\n <transition mode=\"out-in\">\n <PkChatbotMessageFeedback\n v-if=\"\n partIndex === lastTextPartIndex(message) &&\n readonlyFeedback &&\n getMessageFeedback(message.id)?.comment\n \"\n :feedback=\"getMessageFeedback(message.id)!\" />\n </transition>\n </template>\n <transition name=\"fade-in\" mode=\"out-in\">\n <div\n v-if=\"\n isLoading &&\n isLastMessage(index) &&\n !isLastTextPart(message) &&\n isAssistant(message) &&\n !showStepsTimeline(message)\n \"\n :key=\"`loading-info-${message.id}`\"\n class=\"pk-chatbot-message__loading-info\">\n <div class=\"flex gap-8 items-center\">\n <VvIcon\n name=\"line-md:loading-loop\"\n class=\"shrink-0\" />\n <transition mode=\"out-in\">\n <VvIcon\n v-if=\"activeMessageLastPartIcon\"\n :key=\"activeMessageLastPartIcon\"\n class=\"shrink-0\"\n :name=\"activeMessageLastPartIcon\" />\n </transition>\n <transition mode=\"out-in\">\n <span\n v-if=\"activeMessageLastPartLabel\"\n :key=\"activeMessageLastPartLabel\"\n class=\"text-12\">\n {{ activeMessageLastPartLabel }}\n </span>\n </transition>\n </div>\n <transition name=\"fade-in\" mode=\"out-in\">\n <PkStreamingMarkdownAutoscroll\n v-if=\"\n activeMessageLastPart &&\n 'text' in activeMessageLastPart &&\n activeMessageLastPart.text.trim()\n \"\n :markdown=\"activeMessageLastPart.text\"\n :is-dark\n inner-class=\"wysiwyg\"\n class=\"border border-surface-4 rounded p-4 mt-8 bg-surface-1 max-h-64 text-12 w-full\" />\n </transition>\n </div>\n </transition>\n <transition mode=\"out-in\">\n <div\n v-if=\"showMessageFooter(message, index)\"\n class=\"pk-chatbot-message__footer\">\n <VvButtonGroup\n modifiers=\"compact\"\n class=\"mr-auto shrink-0\">\n <transition mode=\"out-in\">\n <VvButton\n v-if=\"\n isMessageRegenerateButtonVisible(\n index,\n )\n \"\n icon=\"ri:reset-right-line\"\n modifiers=\"action-quiet-small\"\n :title=\"$t('action.regenerate')\"\n :aria-label=\"$t('action.regenerate')\"\n @click.stop=\"$emit('regenerate')\" />\n </transition>\n <transition mode=\"out-in\">\n <VvButton\n v-if=\"\n isActionButtonVisible(\n 'show-info',\n index,\n )\n \"\n icon=\"ri:information-line\"\n :title=\"$t('action.getMoreInfo')\"\n :aria-label=\"$t('action.getMoreInfo')\"\n modifiers=\"action-quiet-small\"\n @click.stop=\"\n $emit('show-info', message)\n \" />\n </transition>\n <transition mode=\"out-in\">\n <VvButton\n v-if=\"\n isActionButtonVisible(\n 'revise',\n index,\n )\n \"\n :icon=\"\n isRevised(message.id)\n ? 'ri:file-edit-fill'\n : 'ri:file-edit-line'\n \"\n :title=\"\n isRevised(message.id)\n ? $t('action.editRevise')\n : $t('action.createRevise')\n \"\n :aria-label=\"\n isRevised(message.id)\n ? $t('action.editRevise')\n : $t('action.createRevise')\n \"\n modifiers=\"action-quiet-small\"\n :class=\"{\n 'text-brand': isRevised(message.id),\n }\"\n @click.stop=\"\n $emit('revise', message)\n \" />\n </transition>\n <transition mode=\"out-in\">\n <VvButton\n v-if=\"\n isFeedbackButtonVisible(\n 'upvote',\n index,\n )\n \"\n :icon=\"\n getMessageFeedback(message.id)\n ?.vote === 'upvote'\n ? 'ri:thumb-up-fill'\n : 'ri:thumb-up-line'\n \"\n :title=\"$t('action.upvote')\"\n :aria-label=\"$t('action.upvote')\"\n modifiers=\"action-quiet-small\"\n @click.stop=\"\n $emit('upvote', message)\n \" />\n </transition>\n <transition mode=\"out-in\">\n <VvButton\n v-if=\"\n isFeedbackButtonVisible(\n 'downvote',\n index,\n )\n \"\n :icon=\"\n getMessageFeedback(message.id)\n ?.vote === 'downvote'\n ? 'ri:thumb-down-fill'\n : 'ri:thumb-down-line'\n \"\n :title=\"$t('action.downvote')\"\n :aria-label=\"$t('action.downvote')\"\n modifiers=\"action-quiet-small\"\n @click.stop=\"\n $emit('downvote', message)\n \" />\n </transition>\n <transition mode=\"out-in\">\n <VvButton\n v-if=\"\n isFeedbackButtonVisible(\n 'feedback',\n index,\n )\n \"\n :icon=\"\n getMessageFeedback(message.id)\n ?.comment\n ? 'ri:feedback-fill'\n : 'ri:feedback-line'\n \"\n :title=\"$t('action.feedback')\"\n :aria-label=\"$t('action.feedback')\"\n modifiers=\"action-quiet-small\"\n @click.stop=\"\n $emit('feedback', message)\n \" />\n </transition>\n </VvButtonGroup>\n <div\n v-if=\"\n !showMessageDateTime &&\n message.metadata?.createdAt &&\n message.metadata?.completedAt\n \"\n class=\"pk-chatbot-message__hover-meta\">\n <time\n :datetime=\"\n new Date(\n message.metadata.createdAt,\n ).toISOString()\n \"\n :title=\"\n $d(\n new Date(\n message.metadata.createdAt,\n ),\n 'date-time',\n )\n \"\n class=\"flex items-center gap-4 min-w-0\">\n <VvIcon\n name=\"ri:time-line\"\n class=\"shrink-0\" />\n <span class=\"truncate\">{{\n formatMessageTime(\n message.metadata.createdAt,\n )\n }}</span>\n </time>\n <span\n v-if=\"getMessageDuration(message)\"\n class=\"flex items-center gap-4 min-w-0\">\n <VvIcon\n name=\"ri:hourglass-line\"\n class=\"shrink-0\" />\n <span class=\"truncate\">{{\n getMessageDuration(message)\n }}</span>\n </span>\n </div>\n <span\n v-if=\"\n showMessageTokensCount &&\n message.metadata?.totalTokens\n \"\n class=\"flex items-center gap-4 text-12 text-word-3\">\n <VvIcon\n name=\"ri:ai-generate-2-line\"\n class=\"shrink-0\" />\n <span class=\"truncate\"\n >{{\n $n(\n message.metadata.totalTokens,\n 'integer',\n )\n }}\n {{ $t('label.tokens') }}\n </span>\n </span>\n <time\n v-if=\"\n showMessageDateTime &&\n message.metadata?.createdAt\n \"\n :datetime=\"\n new Date(\n message.metadata?.createdAt,\n ).toISOString()\n \"\n class=\"flex items-center gap-4 text-12 text-word-3\">\n <VvIcon name=\"ri:time-line\" class=\"shrink-0\" />\n <span class=\"truncate\">{{\n $d(\n new Date(message.metadata?.createdAt),\n 'date-time',\n )\n }}</span>\n </time>\n <div\n v-if=\"\n showMessageDateTime &&\n message?.metadata?.completedAt &&\n message?.metadata?.createdAt\n \"\n class=\"flex items-center gap-4 text-12 text-word-3\">\n <VvIcon\n name=\"ri:hourglass-line\"\n class=\"shrink-0\" />\n <PkRelativeTime\n class=\"truncate\"\n :date=\"message.metadata?.createdAt\"\n :end-date=\"message.metadata?.completedAt\" />\n </div>\n </div>\n </transition>\n <transition mode=\"out-in\">\n <PkChatbotFeedbackForm\n v-if=\"message.id === feedbackMessageId\"\n ref=\"feedbackMessageEl\"\n :loading=\"feedbackLoading\"\n :submitted=\"feedbackSubmitted\"\n :error=\"feedbackError\"\n @submit=\"$emit('feedback-submit', $event)\"\n @close=\"$emit('feedback-close')\" />\n </transition>\n </div>\n </template>\n <transition appear name=\"pk-chatbot-part\">\n <PkChatbotError\n v-if=\"isError\"\n :error\n @retry=\"$emit('auto-retry')\"\n @reset=\"$emit('reset-chat')\" />\n </transition>\n <div\n v-if=\"activeMessage?.role === 'user' || isError\"\n class=\"pk-chatbot-messages__spacer\"\n :style=\"{ minHeight: `${height}px` }\"></div>\n </div>\n <Transition name=\"pk-chatbot-messages-fab\">\n <button\n v-if=\"showScrollToBottom && (userScrolledUp || !isAtBottom)\"\n type=\"button\"\n class=\"pk-chatbot-messages__scroll-to-bottom\"\n :title=\"$t('action.scrollToBottom')\"\n :aria-label=\"$t('action.scrollToBottom')\"\n @click=\"onScrollToBottomClick\">\n <VvIcon name=\"ri:arrow-down-line\" />\n </button>\n </Transition>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-chatbot-messages {\n overflow-y: auto;\n flex: 1;\n min-width: 0;\n font-size: var(--text-14);\n\n scrollbar-width: thin;\n scrollbar-color: var(--color-word-5) var(--color-surface-1);\n\n &__wrapper {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-16);\n min-width: 0;\n }\n\n // Conversation outline rail: sticky shell pinned to the vertical\n // middle of the scroll area, at the right edge. Zero-sized and\n // first in flow so neither it nor its absolutely-positioned pieces\n // inflate scrollHeight (desktop only, like ChatGPT)\n &__outline {\n display: none;\n position: sticky;\n top: 50%;\n z-index: 2;\n flex: none;\n align-self: flex-end;\n height: 0;\n\n @include media-breakpoint-up('md', $breakpoints) {\n display: block;\n }\n\n .pk-chatbot-outline {\n position: absolute;\n top: 0;\n right: 0;\n transform: translateY(-50%);\n }\n }\n\n // Placeholder while the answer has not started yet: settles like\n // the message spacer when released\n &__spacer {\n transition: min-height 300ms var(--ease-out);\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n }\n\n // Floating \"back to bottom\" button, sticky inside the scroll area\n &__scroll-to-bottom {\n position: sticky;\n bottom: var(--spacing-8);\n z-index: 2;\n display: flex;\n align-items: center;\n justify-content: center;\n // The scroll container is a flex column: without this the\n // overflowing content shrinks the button, ignoring its height\n flex: none;\n width: var(--spacing-36);\n height: var(--spacing-36);\n // Net-zero layout contribution: mounting/unmounting the button\n // must not change scrollHeight, or reaching the bottom (which\n // hides it) would clamp scrollTop and cause a visible jump\n margin-block-start: calc(-1 * var(--spacing-36));\n margin-inline: auto;\n border: 1px solid var(--color-surface-3);\n border-radius: var(--rounded-full);\n background-color: var(--color-surface-1);\n box-shadow: var(--shadow-md);\n color: var(--color-word-1);\n cursor: pointer;\n transition: var(--transition-colors);\n\n &:hover {\n background-color: var(--color-surface-2);\n }\n }\n }\n\n .pk-chatbot-messages-fab-enter-active,\n .pk-chatbot-messages-fab-leave-active {\n transition: opacity 150ms var(--ease-out);\n }\n\n .pk-chatbot-messages-fab-enter-from,\n .pk-chatbot-messages-fab-leave-to {\n opacity: 0;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .pk-chatbot-messages-fab-enter-active,\n .pk-chatbot-messages-fab-leave-active {\n transition: none;\n }\n }\n\n .pk-chatbot-divider {\n position: relative;\n border-bottom: 1px solid var(--color-surface-3);\n\n &__label {\n position: absolute;\n padding-inline: var(--spacing-8);\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background-color: var(--color-surface);\n color: var(--color-word-4);\n font-size: var(--text-12);\n }\n }\n\n .pk-chatbot-message {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-sm);\n min-width: 0;\n align-items: flex-start;\n overflow: hidden;\n max-width: 100%;\n // The anchor spacer (inline min-height on the last assistant\n // message) settles smoothly when released at the end of the stream\n transition: min-height 300ms var(--ease-out);\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n &__text {\n position: relative;\n color: var(--color-word-2);\n background-color: var(--color-surface);\n line-height: var(--leading-normal);\n border-width: var(--spacing-px);\n border-style: solid;\n border-color: var(--color-surface-3);\n padding: var(--spacing-sm);\n border-radius: var(--rounded-xl) var(--rounded-xl) var(--rounded-xl)\n 0;\n max-width: 100%;\n text-overflow: ellipsis;\n overflow: hidden;\n }\n\n // Read-only feedback: a circular vote chip that overlaps the bubble's\n // bottom-right corner (messaging-app style). White ring lifts it off\n // the bubble; solid accent makes the rating unmistakable.\n &__reaction {\n position: absolute;\n right: var(--spacing-8);\n bottom: 0;\n transform: translateY(50%);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--spacing-24);\n height: var(--spacing-24);\n border-radius: var(--rounded-full, 9999px);\n color: var(--color-white, #fff);\n font-size: var(--text-12);\n box-shadow: var(--shadow-md);\n\n &--positive {\n background-color: var(--color-success);\n }\n\n &--negative {\n background-color: var(--color-danger);\n }\n\n // Real emoji (e.g. WhatsApp): the glyph carries its own colour, so\n // the chip stays a neutral surface pill.\n &--neutral {\n background-color: var(--color-surface-1);\n }\n }\n\n &__reaction-emoji {\n // Smaller than the chip so the glyph doesn't touch the ring.\n font-size: var(--text-12);\n line-height: 1;\n }\n\n &__loading-info {\n line-height: var(--leading-normal);\n border-width: var(--spacing-px);\n border-style: solid;\n border-color: var(--color-surface-3);\n padding: var(--spacing-sm);\n border-radius: var(--rounded-xl) var(--rounded-xl) var(--rounded-xl)\n 0;\n font-size: var(--text-12);\n color: var(--color-word-3);\n }\n\n &__footer {\n width: 100%;\n display: flex;\n gap: var(--spacing-8);\n align-items: center;\n }\n\n &__hover-meta {\n display: flex;\n min-width: 0;\n align-items: center;\n gap: var(--spacing-8);\n font-size: var(--text-12);\n color: var(--color-word-3);\n white-space: nowrap;\n font-variant-numeric: tabular-nums;\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n\n &:hover &__hover-meta,\n &:focus-within &__hover-meta {\n opacity: 1;\n }\n\n // Hover doesn't exist on touch devices: keep the metadata visible\n @media (hover: none) {\n &__hover-meta {\n opacity: 1;\n }\n }\n\n &--user {\n align-items: flex-end;\n\n .pk-chatbot-message__text {\n background-color: var(\n --chatbot-main-color,\n var(--color-surface-1)\n );\n border-color: var(--chatbot-main-color, var(--color-surface-4));\n color: var(--chatbot-contrast-color, var(--color-word-1));\n border-radius: var(--rounded-xl) var(--rounded-xl) 0\n var(--rounded-xl);\n }\n }\n\n &--assistant {\n width: 100%;\n gap: var(--spacing-16);\n\n .pk-chatbot-message__text {\n width: 100%;\n }\n }\n\n &--system {\n align-items: flex-end;\n\n .pk-chatbot-message__text {\n display: flex;\n gap: var(--spacing-8);\n font-size: var(--text-12);\n padding: var(--spacing-8) var(--spacing-sm);\n align-items: center;\n border-color: var(--chatbot-main-color, var(--color-surface-4));\n color: var(--chatbot-main-color, var(--color-word-1));\n border-radius: var(--rounded-xl) var(--rounded-xl) 0\n var(--rounded-xl);\n }\n }\n }\n\n .pk-chatbot-part-enter-active {\n transition:\n opacity 0.25s ease,\n transform 0.25s ease;\n }\n\n .pk-chatbot-part-enter-from {\n opacity: 0;\n transform: translateY(8px);\n }\n\n @media (prefers-reduced-motion: reduce) {\n .pk-chatbot-part-enter-active {\n transition: none;\n }\n\n .pk-chatbot-part-enter-from {\n transform: none;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;AASA,IAAa,KAGT;CACA,gBAAgB,QACN,OAAO,qCACjB;CACA,wBAAwB,QACd,OAAO,6CACjB;CACA,cAAc,QACJ,OAAO,mCACjB,CAAA,MAAA,MAAA,EAAA,CAAA,CAAA;CACA,mBAAmB,QACT,OAAO,wCACjB,CAAA,MAAA,MAAA,EAAA,CAAA,CAAA;CACA,gBAAgB,QACN,OAAO,qCACjB,CAAA,MAAA,MAAA,EAAA,CAAA,CAAA;CACA,iBAAiB,QACP,OAAO,sCACjB,CAAA,MAAA,MAAA,EAAA,CAAA,CAAA;CACA,aAAa,QAA2B,OAAO,kCAA0B;CACzE,WAAW,QAA2B,OAAO,gCAAwB,CAAA,MAAA,MAAA,EAAA,CAAA,CAAA;CACrE,kBAAkB,QACR,OAAO,uCACjB,CAAA,MAAA,MAAA,EAAA,CAAA,CAAA;CACA,cAAc,QACJ,OAAO,mCACjB,CAAA,MAAA,MAAA,EAAA,CAAA,CAAA;CACA,aAAa,QAA2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AK,gBAAA;;;;;;;;;KAI7B,EAMa,GAAA;MAND,QAAA;MAAO,MAAK;;uBAKe,CAHzB,GAAA,SAAA,EAAA,GADV,EAImC,GAAA;;OAF9B,OAAA,EAAA;OACA,SAAK,AAAA,EAAA,QAAA,MAAEA,EAAAA,MAAK,YAAA;OACZ,SAAK,AAAA,EAAA,QAAA,MAAEA,EAAAA,MAAK,YAAA;;;;KAGX,GAAA,OAAe,SAAI,UAAe,GAAA,SAAA,EAAA,GAD5C,EAGgD,OAAA;;MAD5C,OAAM;MACL,OAAK,GAAA,EAAA,WAAA,GAAkB,EAAA,MAAM,IAAA,CAAA;;;IAEtC,EAUa,GAAA,EAVD,MAAK,0BAAyB,GAAA;sBAS7B,CAPC,EAAA,uBAAuB,EAAA,EAAA,KAAc,CAAK,EAAA,EAAA,MAAA,EAAA,GADpD,EAQS,UAAA;;MANL,MAAK;MACL,OAAM;MACL,OAAO,EAAA,CAAA,CAAE,CAAA,uBAAA;MACT,cAAY,EAAA,CAAA,CAAE,CAAA,uBAAA;MACd,SAAO;SACR,EAAoC,GAAA,EAA5B,MAAK,qBAAoB,CAAA,CAAA,GAAA,GAAA,EAAA,KAAA,EAAA,IAAA,EAAA,CAAA,CAAA"}
@@ -1,172 +0,0 @@
1
- import { c as e, o as t } from "./message-RohfrdWS.js";
2
- import { t as n } from "./PkStreamingMarkdown-DEhbK-3c.js";
3
- import { a as r, f as i, i as a, n as o, o as ee, r as s, s as c } from "./utils-BMa8jwJS.js";
4
- import { t as l } from "./PkChatbotStepToolDetail-ldThv0t5.js";
5
- import { VvIcon as u } from "@volverjs/ui-vue/components";
6
- import { Fragment as d, computed as f, createBlock as p, createCommentVNode as m, createElementBlock as h, createElementVNode as g, createTextVNode as _, createVNode as v, defineComponent as y, nextTick as b, normalizeClass as x, openBlock as S, reactive as te, ref as C, renderList as w, resolveDynamicComponent as T, toDisplayString as E, unref as D, watch as O, withCtx as k } from "vue";
7
- import { useI18n as A } from "vue-i18n";
8
- //#endregion
9
- //#region ../../packages/components/src/chat/PkStreamingMarkdownAutoscroll.vue
10
- var j = /* @__PURE__ */ y({
11
- __name: "PkStreamingMarkdownAutoscroll",
12
- props: {
13
- markdown: {},
14
- innerClass: {},
15
- isDark: { type: Boolean }
16
- },
17
- setup(e) {
18
- let t = e, r = C(), i = C(0), a = C(!1), o = () => {
19
- if (!r.value) return;
20
- let e = r.value.scrollTop;
21
- e < i.value && i.value - e < 50 && (a.value = !0), e > i.value && e === r.value.scrollHeight - r.value.clientHeight && (a.value = !1), i.value = e;
22
- };
23
- return O(() => t.markdown, async () => {
24
- await b(), r.value && !a.value && (r.value.scrollTop = r.value.scrollHeight);
25
- }, { immediate: !0 }), (t, i) => (S(), h("div", {
26
- ref_key: "scrollEl",
27
- ref: r,
28
- class: "overflow-auto light-scrollbar",
29
- onScroll: o
30
- }, [v(n, {
31
- markdown: e.markdown,
32
- "is-dark": e.isDark,
33
- class: x(e.innerClass)
34
- }, null, 8, [
35
- "markdown",
36
- "is-dark",
37
- "class"
38
- ])], 544));
39
- }
40
- }), M = {
41
- key: 0,
42
- class: "pk-chatbot-steps"
43
- }, ne = ["aria-expanded"], re = { class: "pk-chatbot-steps__title" }, ie = { class: "pk-chatbot-steps__meta" }, ae = {
44
- key: 0,
45
- class: "pk-chatbot-steps__list"
46
- }, N = { class: "pk-chatbot-steps__step-label" }, P = { class: "pk-chatbot-steps__step-summary" }, F = {
47
- key: 0,
48
- class: "pk-chatbot-steps__step-duration"
49
- }, I = {
50
- key: 0,
51
- class: "pk-chatbot-steps__step-body"
52
- }, L = {
53
- key: 2,
54
- class: "pk-chatbot-steps__step-payload pk-chatbot-steps__step-payload--error"
55
- }, R = { class: "pk-chatbot-steps__step-payload-label" }, z = {
56
- key: 0,
57
- class: "pk-chatbot-steps__step-payload"
58
- }, B = { class: "pk-chatbot-steps__step-payload-label" }, V = {
59
- key: 1,
60
- class: "pk-chatbot-steps__step-payload"
61
- }, H = { class: "pk-chatbot-steps__step-payload-label" }, U = /* @__PURE__ */ y({
62
- __name: "PkChatbotSteps",
63
- props: {
64
- message: {},
65
- isStreaming: { type: Boolean },
66
- isDark: { type: Boolean }
67
- },
68
- setup(y) {
69
- let b = y, { t: U, n: W } = A({ useScope: "global" }), G = f(() => {
70
- let n = b.message.parts, i = b.message.metadata?.partTimings, a = [];
71
- for (let [o, c] of n.entries()) {
72
- let l = t(c), u = e(c);
73
- if (!l && !u) continue;
74
- let d = "toolCallId" in c ? c.toolCallId : void 0;
75
- a.push({
76
- key: d ?? `${c.type}-${o}`,
77
- part: c,
78
- icon: s(c),
79
- label: r(U, c),
80
- summary: ee(c),
81
- durationMs: d ? i?.[d] : void 0,
82
- isActive: !!b.isStreaming && o === n.length - 1,
83
- text: l && c.text.trim() ? c.text : void 0,
84
- toolInput: u && "input" in c ? c.input : void 0,
85
- toolOutput: u && "output" in c ? c.output : void 0
86
- });
87
- }
88
- return a;
89
- }), K = f(() => {
90
- let { createdAt: e, completedAt: t } = b.message.metadata ?? {};
91
- if (!(!e || !t)) return t - e;
92
- }), q = (e) => o(W, e), J = (e) => a(e.part) === "output-error" && "errorText" in e.part && typeof e.part.errorText == "string" ? e.part.errorText : void 0, Y = (e) => e.text || J(e) ? !0 : c(e.part) ? e.toolInput !== void 0 || e.toolOutput !== void 0 : !!(i(e.toolInput) ?? i(e.toolOutput)), X = te(/* @__PURE__ */ new Map()), Z = (e) => X.get(e.key) ?? e.isActive, oe = (e) => {
93
- X.set(e.key, !Z(e));
94
- }, Q = C(void 0), $ = f(() => Q.value ?? !!b.isStreaming);
95
- return O(() => b.isStreaming, (e) => {
96
- e && (Q.value = void 0, X.clear());
97
- }), (e, t) => {
98
- let r = u;
99
- return G.value.length ? (S(), h("div", M, [g("button", {
100
- type: "button",
101
- class: "pk-chatbot-steps__header",
102
- "aria-expanded": $.value,
103
- onClick: t[0] ||= (e) => Q.value = !$.value
104
- }, [
105
- y.isStreaming ? (S(), p(r, {
106
- key: 0,
107
- name: "line-md:loading-loop",
108
- class: "shrink-0"
109
- })) : (S(), p(r, {
110
- key: 1,
111
- name: "ri:route-line",
112
- class: "shrink-0"
113
- })),
114
- g("span", re, E(D(U)("messagePart.steps")), 1),
115
- g("span", ie, [_(E(D(U)("messagePart.stepCount", G.value.length)) + " ", 1), q(K.value) ? (S(), h(d, { key: 0 }, [_(" · " + E(q(K.value)), 1)], 64)) : m("", !0)]),
116
- v(r, {
117
- name: $.value ? "ri:arrow-up-s-line" : "ri:arrow-down-s-line",
118
- class: "pk-chatbot-steps__chevron shrink-0 ml-auto"
119
- }, null, 8, ["name"])
120
- ], 8, ne), $.value ? (S(), h("ol", ae, [(S(!0), h(d, null, w(G.value, (e) => (S(), h("li", {
121
- key: e.key,
122
- class: x(["pk-chatbot-steps__step", { "pk-chatbot-steps__step--active": e.isActive }])
123
- }, [(S(), p(T(Y(e) ? "button" : "div"), {
124
- type: Y(e) ? "button" : void 0,
125
- class: "pk-chatbot-steps__step-header",
126
- "aria-expanded": Y(e) ? Z(e) : void 0,
127
- onClick: (t) => Y(e) ? oe(e) : void 0
128
- }, {
129
- default: k(() => [
130
- g("span", { class: x(["pk-chatbot-steps-marker", { "pk-chatbot-steps-marker--active": e.isActive }]) }, [e.isActive ? (S(), p(r, {
131
- key: 0,
132
- name: "line-md:loading-loop"
133
- })) : e.icon ? (S(), p(r, {
134
- key: 1,
135
- name: e.icon
136
- }, null, 8, ["name"])) : m("", !0)], 2),
137
- g("span", N, E(e.label), 1),
138
- g("span", P, E(e.summary), 1),
139
- q(e.durationMs) ? (S(), h("span", F, E(q(e.durationMs)), 1)) : m("", !0),
140
- Y(e) ? (S(), p(r, {
141
- key: 1,
142
- name: Z(e) ? "ri:arrow-up-s-line" : "ri:arrow-down-s-line",
143
- class: "pk-chatbot-steps__chevron shrink-0 ml-auto"
144
- }, null, 8, ["name"])) : m("", !0)
145
- ]),
146
- _: 2
147
- }, 1032, [
148
- "type",
149
- "aria-expanded",
150
- "onClick"
151
- ])), Y(e) && Z(e) ? (S(), h("div", I, [e.text && e.isActive ? (S(), p(j, {
152
- key: 0,
153
- markdown: e.text,
154
- "is-dark": y.isDark,
155
- "inner-class": "wysiwyg",
156
- class: "pk-chatbot-steps__step-content pk-chatbot-steps__step-content--scroll"
157
- }, null, 8, ["markdown", "is-dark"])) : e.text ? (S(), p(n, {
158
- key: 1,
159
- markdown: e.text,
160
- "is-dark": y.isDark,
161
- class: "wysiwyg pk-chatbot-steps__step-content"
162
- }, null, 8, ["markdown", "is-dark"])) : J(e) ? (S(), h("div", L, [g("span", R, E(D(U)("messagePart.stepError")), 1), g("pre", null, E(J(e)), 1)])) : D(c)(e.part) ? (S(), p(l, {
163
- key: 3,
164
- part: e.part
165
- }, null, 8, ["part"])) : (S(), h(d, { key: 4 }, [D(i)(e.toolInput) ? (S(), h("div", z, [g("span", B, E(D(U)("messagePart.stepInput")), 1), g("pre", null, E(D(i)(e.toolInput)), 1)])) : m("", !0), D(i)(e.toolOutput) ? (S(), h("div", V, [g("span", H, E(D(U)("messagePart.stepOutput")), 1), g("pre", null, E(D(i)(e.toolOutput)), 1)])) : m("", !0)], 64))])) : m("", !0)], 2))), 128))])) : m("", !0)])) : m("", !0);
166
- };
167
- }
168
- });
169
- //#endregion
170
- export { j as n, U as t };
171
-
172
- //# sourceMappingURL=PkChatbotSteps-BpqdFhsG.js.map