@8wave/ai-elements 0.110.0-beta.1 → 0.110.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-elements.es.js +678 -674
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/PkChatbotViewConversations.js +1 -1
- package/dist-vue/PkChatbotViewFiles.js +1 -1
- package/dist-vue/PkChatbotViewProfile.js +1 -1
- package/dist-vue/_chunks/{PkChatbot-CDciy1W-.js → PkChatbot-o7k7d-fj.js} +6 -6
- package/dist-vue/_chunks/{PkChatbot-CDciy1W-.js.map → PkChatbot-o7k7d-fj.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotMessages-5dW-ElPy.js → PkChatbotMessages-BFlU046I.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotMessages-5dW-ElPy.js.map → PkChatbotMessages-BFlU046I.js.map} +1 -1
- package/dist-vue/_chunks/PkChatbotStepPayload-BH6piqOi.js.map +1 -1
- package/dist-vue/_chunks/PkChatbotStepToolDetail-BJ7xUvgi.js.map +1 -1
- package/dist-vue/_chunks/PkChatbotSteps-DtV1beDc.js.map +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-C9PQWz8z.js → PkChatbotViewChat-CNH_glPI.js} +4 -4
- package/dist-vue/_chunks/{PkChatbotViewChat-C9PQWz8z.js.map → PkChatbotViewChat-CNH_glPI.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewConversations-Duc-I3pp.js → PkChatbotViewConversations-BENvHLZt.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewConversations-Duc-I3pp.js.map → PkChatbotViewConversations-BENvHLZt.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewFiles-B7KaE7rU.js → PkChatbotViewFiles-qmLESi1V.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewFiles-B7KaE7rU.js.map → PkChatbotViewFiles-qmLESi1V.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewProfile-tKK5Yazl.js → PkChatbotViewProfile-DzfZnitQ.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewProfile-tKK5Yazl.js.map → PkChatbotViewProfile-DzfZnitQ.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-CNBaJZlp.js → PkToolShowDiagram-DuDp5EHd.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-CNBaJZlp.js.map → PkToolShowDiagram-DuDp5EHd.js.map} +1 -1
- package/dist-vue/_chunks/{useChatbotStore-DufJlucU.js → useChatbotStore-CiRAuq7v.js} +82 -78
- package/dist-vue/_chunks/useChatbotStore-CiRAuq7v.js.map +1 -0
- package/dist-vue/apps/web-component/src/composables/useChatbotAgent.d.ts +14 -14
- package/dist-vue/composables.js +1 -1
- package/dist-vue/index.js +9 -9
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/packages/components/src/PkEditorMedia.d.ts +42 -42
- package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +14 -14
- package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +42 -42
- package/dist-vue/packages/models/src/schema/Agent.d.ts +112 -112
- package/dist-vue/packages/models/src/schema/Document.d.ts +126 -126
- package/dist-vue/packages/models/src/schema/Member.d.ts +14 -14
- package/dist-vue/packages/models/src/schema/Organization.d.ts +28 -28
- package/dist-vue/packages/models/src/schema/ReasoningChat.d.ts +28 -28
- package/dist-vue/packages/models/src/schema/SubAgent.d.ts +28 -28
- package/dist-vue/packages/models/src/schema/User.d.ts +42 -42
- package/dist-vue/style.css +1 -1
- package/package.json +2 -2
- package/dist-vue/_chunks/useChatbotStore-DufJlucU.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e } from "./useChatbotStore-
|
|
1
|
+
import { n as e } from "./useChatbotStore-CiRAuq7v.js";
|
|
2
2
|
import "./src-DT8FLE4_.js";
|
|
3
3
|
import { t } from "./markdown-CCMpGUA7.js";
|
|
4
4
|
import { n } from "./message-RohfrdWS.js";
|
|
@@ -192,4 +192,4 @@ var oe = { class: "flex flex-col flex-1 min-h-0 relative" }, se = {
|
|
|
192
192
|
//#endregion
|
|
193
193
|
export { O as n, k as r, V as t };
|
|
194
194
|
|
|
195
|
-
//# sourceMappingURL=PkChatbotViewConversations-
|
|
195
|
+
//# sourceMappingURL=PkChatbotViewConversations-BENvHLZt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkChatbotViewConversations-Duc-I3pp.js","names":[],"sources":["../../../../packages/composable/src/chatbot/useConversationActions.ts","../../../../packages/components/src/chat/PkChatbotViewConversations.vue","../../../../packages/components/src/chat/PkChatbotViewConversations.vue"],"sourcesContent":["import { ref } from 'vue'\nimport type { Chat as Conversation } from 'models'\nimport { getTextPart, stripMarkdown } from 'utils'\nimport { useDialogConfirm } from '../useDialogConfirm'\n\n/**\n * Single-line preview for a conversation: explicit title, otherwise the\n * first user message. Used as list label and as search haystack.\n */\nexport function getConversationPreview(conversation: Conversation): string {\n return (\n stripMarkdown(conversation.title) ||\n stripMarkdown(\n getTextPart(\n // The list endpoint isn't Zod-parsed: don't trust the\n // declared types at runtime\n conversation.messages?.find(\n (message) => message.role === 'user',\n ),\n ),\n ) ||\n ''\n )\n}\n\n/**\n * Inline-rename and delete-with-confirm state shared by the conversation\n * lists (PkChatbotViewConversations, PkChatSidebar). Renames are optimistic:\n * on failure the next conversations load reconciles with the server state.\n */\nexport function useConversationActions(actions: {\n renameChatTitle: (chatId: string, title: string) => Promise<unknown>\n deleteChat: (chatId: string) => Promise<unknown>\n}) {\n const editingId = ref<string | null>(null)\n const editingTitle = ref('')\n\n const startEdit = (conversation: Conversation, fallbackTitle = '') => {\n editingId.value = conversation.id\n editingTitle.value = stripMarkdown(conversation.title) || fallbackTitle\n }\n\n const confirmEdit = async (id: string) => {\n const trimmed = editingTitle.value.trim()\n editingId.value = null\n if (trimmed && trimmed.length <= 255) {\n try {\n await actions.renameChatTitle(id, trimmed)\n } catch {\n // Revert optimistically: reload will pick up server state\n }\n }\n }\n\n const cancelEdit = () => {\n editingId.value = null\n }\n\n const onRenameKeydown = (event: KeyboardEvent, id: string) => {\n if (event.key === 'Enter') {\n event.preventDefault()\n confirmEdit(id)\n } else if (event.key === 'Escape') {\n event.preventDefault()\n cancelEdit()\n }\n }\n\n const { openDialogConfirm } = useDialogConfirm()\n const requestDelete = async (id: string) => {\n try {\n const proceed = await openDialogConfirm()\n if (!proceed) {\n return\n }\n await actions.deleteChat(id)\n } catch {\n // Silently fail: next load will reconcile\n }\n }\n\n return {\n editingId,\n editingTitle,\n startEdit,\n confirmEdit,\n cancelEdit,\n onRenameKeydown,\n requestDelete,\n }\n}\n","<script setup lang=\"ts\">\n import { computed, inject, ref } from 'vue'\n import { storeToRefs } from 'pinia'\n import { useI18n } from 'vue-i18n'\n import type { Chat as Conversation, UIChatMessage } from 'models'\n import { stripMarkdown, getTextPart } from 'utils'\n import {\n useChatbotStore,\n useConversationActions,\n useDialogConfirm,\n } from 'composables'\n import PkRelativeTime from '../PkRelativeTime.vue'\n import { ChatbotProfileContextKey } from './chatbotProfileContext'\n\n const props = defineProps<{ agentId: string }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const store = useChatbotStore(props.agentId)\n const { conversations, isLoadingConversations, localChatId } =\n storeToRefs(store)\n const { navigate, startNewChat, renameChatTitle, deleteChat } = store\n\n const {\n editingId,\n editingTitle,\n startEdit: startEditConversation,\n confirmEdit,\n cancelEdit,\n onRenameKeydown,\n requestDelete: handleDelete,\n } = useConversationActions({ renameChatTitle, deleteChat })\n\n const openConversation = (id: string) => {\n if (editingId.value) {\n return\n }\n localChatId.value = id\n navigate('chat')\n }\n\n const isCurrentConversation = (conversation: Conversation) => {\n return localChatId.value === conversation.id\n }\n\n const getLastMessage = (\n messages: UIChatMessage[],\n role: 'user' | 'assistant',\n ) => {\n return stripMarkdown(\n getTextPart(messages.filter((m) => m.role === role).slice(-1)[0]) ||\n '',\n )\n }\n\n const startEdit = (conversation: Conversation) => {\n startEditConversation(\n conversation,\n getLastMessage(conversation.messages, 'assistant'),\n )\n }\n\n const { openDialogConfirm } = useDialogConfirm()\n\n // GDPR B.3 — bulk \"delete my conversations\", available to anonymous\n // sessions too (the host wires the endpoint through the profile context).\n // Hidden when the host application owns the session (external token or\n // host-session mode): the endpoint erases ALL conversations of the\n // session's user platform-wide, an account-scoped action that belongs to\n // the host, not to an embedded widget. Same gating as sign-out and\n // manage-profile in PkChatbotViewProfile.\n const profile = inject(ChatbotProfileContextKey, undefined)\n const canEraseConversations = computed(\n () =>\n !!profile?.eraseConversations &&\n !(profile.isExternalAuth?.value ?? false),\n )\n const isErasingConversations = ref(false)\n const handleEraseAll = async () => {\n const eraseConversations = profile?.eraseConversations\n if (!eraseConversations || !canEraseConversations.value) {\n return\n }\n const proceed = await openDialogConfirm({\n title: $t('confirmTitle.deleteMyConversations'),\n questionLabel: $t('message.deleteMyConversationsConfirm'),\n })\n if (!proceed) {\n return\n }\n isErasingConversations.value = true\n try {\n await eraseConversations()\n conversations.value = []\n startNewChat()\n } catch {\n // Same policy as single delete: fail silently and reconcile\n // with the server state\n store.loadConversations(props.agentId)\n } finally {\n isErasingConversations.value = false\n }\n }\n</script>\n\n<template>\n <div class=\"flex flex-col flex-1 min-h-0 relative\">\n <!-- Loading skeleton -->\n <div\n v-if=\"isLoadingConversations && conversations.length === 0\"\n class=\"u-pick-list__list u-pick-list__list--fill\">\n <div\n v-for=\"i in 5\"\n :key=\"i\"\n class=\"u-pick-list__row u-pick-list__row--skeleton\">\n <div class=\"u-pick-list__entry u-pick-list__entry--roomy\">\n <div class=\"flex flex-col gap-6 flex-1 min-w-0\">\n <div\n class=\"vv-skeleton h-16 rounded\"\n :class=\"i % 2 ? 'w-192' : 'w-128'\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"vv-skeleton h-12 rounded\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"vv-skeleton h-12 rounded w-160\">\n <div class=\"vv-skeleton__item\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Empty state -->\n <div\n v-else-if=\"conversations.length === 0\"\n class=\"flex flex-col flex-1 items-center justify-center gap-12 p-24 text-center\">\n <div\n class=\"w-64 h-64 rounded-full bg-surface-1 border border-surface-3 flex items-center justify-center\">\n <VvIcon name=\"ri:chat-3-line\" class=\"w-28 h-28 text-word-4\" />\n </div>\n <div class=\"flex flex-col gap-4\">\n <strong class=\"text-16 font-semibold text-word-1\">\n {{ $t('message.noConversations') }}\n </strong>\n <span class=\"text-14 text-word-3 leading-relaxed\">\n {{ $t('message.noConversationsHint') }}\n </span>\n </div>\n <VvButton\n modifiers=\"primary rounded\"\n icon=\"ri:add-line\"\n class=\"mt-8\"\n :label=\"$t('action.startNewChat')\"\n @click=\"startNewChat()\" />\n </div>\n\n <!-- Conversation list. The row is a container, not a button: the menu\n and the rename field are siblings of the entry, because a button\n cannot legally contain other controls (Firefox and Safari drop\n them from the accessibility tree). -->\n <ul\n v-else\n class=\"u-pick-list__list u-pick-list__list--fill overflow-y-auto pb-64 light-scrollbar\">\n <li\n v-for=\"conversation in conversations\"\n :key=\"conversation.id\"\n class=\"u-pick-list__row\"\n :class=\"{\n 'u-pick-list__row--current':\n isCurrentConversation(conversation),\n }\">\n <div\n v-if=\"editingId === conversation.id\"\n class=\"flex flex-1 items-center gap-8 min-w-0 px-md py-12\">\n <VvInputText\n v-model=\"editingTitle\"\n class=\"flex-1 mb-0\"\n modifiers=\"compact\"\n autofocus\n select-on-focus\n :maxlength=\"255\"\n :placeholder=\"$t('placeholder.insert')\"\n @keydown=\"onRenameKeydown($event, conversation.id)\" />\n <VvButtonGroup modifiers=\"compact\">\n <VvButton\n icon=\"ri:save-line\"\n :title=\"$t('action.save')\"\n modifiers=\"action-quiet-small\"\n @click=\"confirmEdit(conversation.id)\" />\n <VvButton\n icon=\"ri:close-line\"\n :title=\"$t('action.cancel')\"\n modifiers=\"action-quiet-small\"\n @click=\"cancelEdit()\" />\n </VvButtonGroup>\n </div>\n <template v-else>\n <button\n type=\"button\"\n class=\"u-pick-list__entry u-pick-list__entry--roomy leading-relaxed\"\n :aria-current=\"\n isCurrentConversation(conversation)\n ? 'true'\n : undefined\n \"\n @click=\"openConversation(conversation.id)\">\n <div class=\"min-w-0 flex-1\">\n <div class=\"flex items-center gap-8\">\n <strong\n class=\"u-pick-list__label font-medium flex-1\">\n {{\n stripMarkdown(conversation.title) ||\n getLastMessage(\n conversation.messages,\n 'assistant',\n )\n }}\n </strong>\n <PkRelativeTime\n class=\"text-word-4 text-smaller shrink-0\"\n :date=\"conversation.lastMessageAt\" />\n </div>\n <span class=\"text-12 text-word-4 line-clamp-2\">\n {{\n stripMarkdown(conversation.summary) ||\n getLastMessage(\n conversation.messages,\n 'user',\n )\n }}\n </span>\n </div>\n </button>\n <div class=\"u-pick-list__actions\">\n <VvDropdown\n v-bind=\"{\n placement: 'bottom-end',\n modifiers: 'menu',\n flip: true,\n offset: 3,\n strategy: 'fixed',\n }\">\n <VvButton\n icon=\"ri:more-2-fill\"\n :title=\"$t('action.moreActions')\"\n modifiers=\"action-quiet-small\" />\n <template #items>\n <VvDropdownAction\n @click=\"startEdit(conversation)\">\n <VvIcon name=\"ri:pencil-line\" />\n {{ $t('action.renameChat') }}\n </VvDropdownAction>\n <VvDropdownAction\n @click=\"handleDelete(conversation.id)\">\n <VvIcon name=\"ri:delete-bin-line\" />\n {{ $t('action.delete') }}\n </VvDropdownAction>\n </template>\n </VvDropdown>\n </div>\n </template>\n </li>\n </ul>\n\n <!-- Sticky \"new chat\" CTA (hidden on empty state, which has its own CTA) -->\n <div\n v-if=\"conversations.length > 0\"\n class=\"absolute bottom-0 left-0 right-0 flex flex-col items-center gap-4 px-16 pb-16 pt-32 pointer-events-none\"\n :style=\"{\n background:\n 'linear-gradient(to top, var(--color-surface) 55%, transparent)',\n }\">\n <VvButton\n class=\"text-14 pointer-events-auto\"\n modifiers=\"primary rounded\"\n icon=\"ri:add-line\"\n :label=\"$t('action.startNewChat')\"\n @click.stop=\"startNewChat()\" />\n <VvButton\n v-if=\"canEraseConversations\"\n class=\"text-12 pointer-events-auto\"\n modifiers=\"action-quiet-danger\"\n icon=\"ri:delete-bin-line\"\n :loading=\"isErasingConversations\"\n :disabled=\"isErasingConversations\"\n :label=\"$t('action.deleteMyConversations')\"\n @click.stop=\"handleEraseAll()\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, inject, ref } from 'vue'\n import { storeToRefs } from 'pinia'\n import { useI18n } from 'vue-i18n'\n import type { Chat as Conversation, UIChatMessage } from 'models'\n import { stripMarkdown, getTextPart } from 'utils'\n import {\n useChatbotStore,\n useConversationActions,\n useDialogConfirm,\n } from 'composables'\n import PkRelativeTime from '../PkRelativeTime.vue'\n import { ChatbotProfileContextKey } from './chatbotProfileContext'\n\n const props = defineProps<{ agentId: string }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const store = useChatbotStore(props.agentId)\n const { conversations, isLoadingConversations, localChatId } =\n storeToRefs(store)\n const { navigate, startNewChat, renameChatTitle, deleteChat } = store\n\n const {\n editingId,\n editingTitle,\n startEdit: startEditConversation,\n confirmEdit,\n cancelEdit,\n onRenameKeydown,\n requestDelete: handleDelete,\n } = useConversationActions({ renameChatTitle, deleteChat })\n\n const openConversation = (id: string) => {\n if (editingId.value) {\n return\n }\n localChatId.value = id\n navigate('chat')\n }\n\n const isCurrentConversation = (conversation: Conversation) => {\n return localChatId.value === conversation.id\n }\n\n const getLastMessage = (\n messages: UIChatMessage[],\n role: 'user' | 'assistant',\n ) => {\n return stripMarkdown(\n getTextPart(messages.filter((m) => m.role === role).slice(-1)[0]) ||\n '',\n )\n }\n\n const startEdit = (conversation: Conversation) => {\n startEditConversation(\n conversation,\n getLastMessage(conversation.messages, 'assistant'),\n )\n }\n\n const { openDialogConfirm } = useDialogConfirm()\n\n // GDPR B.3 — bulk \"delete my conversations\", available to anonymous\n // sessions too (the host wires the endpoint through the profile context).\n // Hidden when the host application owns the session (external token or\n // host-session mode): the endpoint erases ALL conversations of the\n // session's user platform-wide, an account-scoped action that belongs to\n // the host, not to an embedded widget. Same gating as sign-out and\n // manage-profile in PkChatbotViewProfile.\n const profile = inject(ChatbotProfileContextKey, undefined)\n const canEraseConversations = computed(\n () =>\n !!profile?.eraseConversations &&\n !(profile.isExternalAuth?.value ?? false),\n )\n const isErasingConversations = ref(false)\n const handleEraseAll = async () => {\n const eraseConversations = profile?.eraseConversations\n if (!eraseConversations || !canEraseConversations.value) {\n return\n }\n const proceed = await openDialogConfirm({\n title: $t('confirmTitle.deleteMyConversations'),\n questionLabel: $t('message.deleteMyConversationsConfirm'),\n })\n if (!proceed) {\n return\n }\n isErasingConversations.value = true\n try {\n await eraseConversations()\n conversations.value = []\n startNewChat()\n } catch {\n // Same policy as single delete: fail silently and reconcile\n // with the server state\n store.loadConversations(props.agentId)\n } finally {\n isErasingConversations.value = false\n }\n }\n</script>\n\n<template>\n <div class=\"flex flex-col flex-1 min-h-0 relative\">\n <!-- Loading skeleton -->\n <div\n v-if=\"isLoadingConversations && conversations.length === 0\"\n class=\"u-pick-list__list u-pick-list__list--fill\">\n <div\n v-for=\"i in 5\"\n :key=\"i\"\n class=\"u-pick-list__row u-pick-list__row--skeleton\">\n <div class=\"u-pick-list__entry u-pick-list__entry--roomy\">\n <div class=\"flex flex-col gap-6 flex-1 min-w-0\">\n <div\n class=\"vv-skeleton h-16 rounded\"\n :class=\"i % 2 ? 'w-192' : 'w-128'\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"vv-skeleton h-12 rounded\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"vv-skeleton h-12 rounded w-160\">\n <div class=\"vv-skeleton__item\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Empty state -->\n <div\n v-else-if=\"conversations.length === 0\"\n class=\"flex flex-col flex-1 items-center justify-center gap-12 p-24 text-center\">\n <div\n class=\"w-64 h-64 rounded-full bg-surface-1 border border-surface-3 flex items-center justify-center\">\n <VvIcon name=\"ri:chat-3-line\" class=\"w-28 h-28 text-word-4\" />\n </div>\n <div class=\"flex flex-col gap-4\">\n <strong class=\"text-16 font-semibold text-word-1\">\n {{ $t('message.noConversations') }}\n </strong>\n <span class=\"text-14 text-word-3 leading-relaxed\">\n {{ $t('message.noConversationsHint') }}\n </span>\n </div>\n <VvButton\n modifiers=\"primary rounded\"\n icon=\"ri:add-line\"\n class=\"mt-8\"\n :label=\"$t('action.startNewChat')\"\n @click=\"startNewChat()\" />\n </div>\n\n <!-- Conversation list. The row is a container, not a button: the menu\n and the rename field are siblings of the entry, because a button\n cannot legally contain other controls (Firefox and Safari drop\n them from the accessibility tree). -->\n <ul\n v-else\n class=\"u-pick-list__list u-pick-list__list--fill overflow-y-auto pb-64 light-scrollbar\">\n <li\n v-for=\"conversation in conversations\"\n :key=\"conversation.id\"\n class=\"u-pick-list__row\"\n :class=\"{\n 'u-pick-list__row--current':\n isCurrentConversation(conversation),\n }\">\n <div\n v-if=\"editingId === conversation.id\"\n class=\"flex flex-1 items-center gap-8 min-w-0 px-md py-12\">\n <VvInputText\n v-model=\"editingTitle\"\n class=\"flex-1 mb-0\"\n modifiers=\"compact\"\n autofocus\n select-on-focus\n :maxlength=\"255\"\n :placeholder=\"$t('placeholder.insert')\"\n @keydown=\"onRenameKeydown($event, conversation.id)\" />\n <VvButtonGroup modifiers=\"compact\">\n <VvButton\n icon=\"ri:save-line\"\n :title=\"$t('action.save')\"\n modifiers=\"action-quiet-small\"\n @click=\"confirmEdit(conversation.id)\" />\n <VvButton\n icon=\"ri:close-line\"\n :title=\"$t('action.cancel')\"\n modifiers=\"action-quiet-small\"\n @click=\"cancelEdit()\" />\n </VvButtonGroup>\n </div>\n <template v-else>\n <button\n type=\"button\"\n class=\"u-pick-list__entry u-pick-list__entry--roomy leading-relaxed\"\n :aria-current=\"\n isCurrentConversation(conversation)\n ? 'true'\n : undefined\n \"\n @click=\"openConversation(conversation.id)\">\n <div class=\"min-w-0 flex-1\">\n <div class=\"flex items-center gap-8\">\n <strong\n class=\"u-pick-list__label font-medium flex-1\">\n {{\n stripMarkdown(conversation.title) ||\n getLastMessage(\n conversation.messages,\n 'assistant',\n )\n }}\n </strong>\n <PkRelativeTime\n class=\"text-word-4 text-smaller shrink-0\"\n :date=\"conversation.lastMessageAt\" />\n </div>\n <span class=\"text-12 text-word-4 line-clamp-2\">\n {{\n stripMarkdown(conversation.summary) ||\n getLastMessage(\n conversation.messages,\n 'user',\n )\n }}\n </span>\n </div>\n </button>\n <div class=\"u-pick-list__actions\">\n <VvDropdown\n v-bind=\"{\n placement: 'bottom-end',\n modifiers: 'menu',\n flip: true,\n offset: 3,\n strategy: 'fixed',\n }\">\n <VvButton\n icon=\"ri:more-2-fill\"\n :title=\"$t('action.moreActions')\"\n modifiers=\"action-quiet-small\" />\n <template #items>\n <VvDropdownAction\n @click=\"startEdit(conversation)\">\n <VvIcon name=\"ri:pencil-line\" />\n {{ $t('action.renameChat') }}\n </VvDropdownAction>\n <VvDropdownAction\n @click=\"handleDelete(conversation.id)\">\n <VvIcon name=\"ri:delete-bin-line\" />\n {{ $t('action.delete') }}\n </VvDropdownAction>\n </template>\n </VvDropdown>\n </div>\n </template>\n </li>\n </ul>\n\n <!-- Sticky \"new chat\" CTA (hidden on empty state, which has its own CTA) -->\n <div\n v-if=\"conversations.length > 0\"\n class=\"absolute bottom-0 left-0 right-0 flex flex-col items-center gap-4 px-16 pb-16 pt-32 pointer-events-none\"\n :style=\"{\n background:\n 'linear-gradient(to top, var(--color-surface) 55%, transparent)',\n }\">\n <VvButton\n class=\"text-14 pointer-events-auto\"\n modifiers=\"primary rounded\"\n icon=\"ri:add-line\"\n :label=\"$t('action.startNewChat')\"\n @click.stop=\"startNewChat()\" />\n <VvButton\n v-if=\"canEraseConversations\"\n class=\"text-12 pointer-events-auto\"\n modifiers=\"action-quiet-danger\"\n icon=\"ri:delete-bin-line\"\n :loading=\"isErasingConversations\"\n :disabled=\"isErasingConversations\"\n :label=\"$t('action.deleteMyConversations')\"\n @click.stop=\"handleEraseAll()\" />\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;AASA,SAAgB,EAAuB,GAAoC;CACvE,OACI,EAAc,EAAa,KAAK,KAChC,EACI,EAGI,EAAa,UAAU,MAClB,MAAY,EAAQ,SAAS,MAClC,CACJ,CACJ,KACA;AAER;AAOA,SAAgB,EAAuB,GAGpC;CACC,IAAM,IAAY,EAAmB,IAAI,GACnC,IAAe,EAAI,EAAE,GAErB,KAAa,GAA4B,IAAgB,OAAO;EAElE,AADA,EAAU,QAAQ,EAAa,IAC/B,EAAa,QAAQ,EAAc,EAAa,KAAK,KAAK;CAC9D,GAEM,IAAc,OAAO,MAAe;EACtC,IAAM,IAAU,EAAa,MAAM,KAAK;EAExC,IADA,EAAU,QAAQ,MACd,KAAW,EAAQ,UAAU,KAC7B,IAAI;GACA,MAAM,EAAQ,gBAAgB,GAAI,CAAO;EAC7C,QAAQ,CAER;CAER,GAEM,UAAmB;EACrB,EAAU,QAAQ;CACtB,GAEM,KAAmB,GAAsB,MAAe;EAC1D,AAAI,EAAM,QAAQ,WACd,EAAM,eAAe,GACrB,EAAY,CAAE,KACP,EAAM,QAAQ,aACrB,EAAM,eAAe,GACrB,EAAW;CAEnB,GAEM,EAAE,yBAAsB,EAAiB;CAa/C,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA,sBAnByB,MAAe;GACxC,IAAI;IAEA,IAAI,CAAC,MADiB,EAAkB,GAEpC;IAEJ,MAAM,EAAQ,WAAW,CAAE;GAC/B,QAAQ,CAER;EACJ;CAUA;AACJ;;;;;;;;;;;;;;;;;;;;;;;EC5EI,IAAM,IAAQ,GAER,EAAE,GAAG,MAAO,GAAQ,EAAE,UAAU,SAAS,CAAC,GAE1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IACT,SAAK,AAAA,EAAA,OAAA,GAAA,MAAO,EAAA,CAAA,CAAY,CAAA,GAAA,CAAA,MAAA,CAAA;GAEnB,GAAA,MAAA,GAAA,CAAA,OAAA,CAAA,GAAA,EAAA,SADV,EAAA,GAAA,GAQqC,GAAA;;IANjC,OAAM;IACN,WAAU;IACV,MAAK;IACJ,SAAS,EAAA;IACT,UAAU,EAAA;IACV,OAAO,EAAA,CAAA,CAAE,CAAA,8BAAA;IACT,SAAK,AAAA,EAAA,OAAA,GAAA,MAAO,GAAc,GAAA,CAAA,MAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"PkChatbotViewConversations-BENvHLZt.js","names":[],"sources":["../../../../packages/composable/src/chatbot/useConversationActions.ts","../../../../packages/components/src/chat/PkChatbotViewConversations.vue","../../../../packages/components/src/chat/PkChatbotViewConversations.vue"],"sourcesContent":["import { ref } from 'vue'\nimport type { Chat as Conversation } from 'models'\nimport { getTextPart, stripMarkdown } from 'utils'\nimport { useDialogConfirm } from '../useDialogConfirm'\n\n/**\n * Single-line preview for a conversation: explicit title, otherwise the\n * first user message. Used as list label and as search haystack.\n */\nexport function getConversationPreview(conversation: Conversation): string {\n return (\n stripMarkdown(conversation.title) ||\n stripMarkdown(\n getTextPart(\n // The list endpoint isn't Zod-parsed: don't trust the\n // declared types at runtime\n conversation.messages?.find(\n (message) => message.role === 'user',\n ),\n ),\n ) ||\n ''\n )\n}\n\n/**\n * Inline-rename and delete-with-confirm state shared by the conversation\n * lists (PkChatbotViewConversations, PkChatSidebar). Renames are optimistic:\n * on failure the next conversations load reconciles with the server state.\n */\nexport function useConversationActions(actions: {\n renameChatTitle: (chatId: string, title: string) => Promise<unknown>\n deleteChat: (chatId: string) => Promise<unknown>\n}) {\n const editingId = ref<string | null>(null)\n const editingTitle = ref('')\n\n const startEdit = (conversation: Conversation, fallbackTitle = '') => {\n editingId.value = conversation.id\n editingTitle.value = stripMarkdown(conversation.title) || fallbackTitle\n }\n\n const confirmEdit = async (id: string) => {\n const trimmed = editingTitle.value.trim()\n editingId.value = null\n if (trimmed && trimmed.length <= 255) {\n try {\n await actions.renameChatTitle(id, trimmed)\n } catch {\n // Revert optimistically: reload will pick up server state\n }\n }\n }\n\n const cancelEdit = () => {\n editingId.value = null\n }\n\n const onRenameKeydown = (event: KeyboardEvent, id: string) => {\n if (event.key === 'Enter') {\n event.preventDefault()\n confirmEdit(id)\n } else if (event.key === 'Escape') {\n event.preventDefault()\n cancelEdit()\n }\n }\n\n const { openDialogConfirm } = useDialogConfirm()\n const requestDelete = async (id: string) => {\n try {\n const proceed = await openDialogConfirm()\n if (!proceed) {\n return\n }\n await actions.deleteChat(id)\n } catch {\n // Silently fail: next load will reconcile\n }\n }\n\n return {\n editingId,\n editingTitle,\n startEdit,\n confirmEdit,\n cancelEdit,\n onRenameKeydown,\n requestDelete,\n }\n}\n","<script setup lang=\"ts\">\n import { computed, inject, ref } from 'vue'\n import { storeToRefs } from 'pinia'\n import { useI18n } from 'vue-i18n'\n import type { Chat as Conversation, UIChatMessage } from 'models'\n import { stripMarkdown, getTextPart } from 'utils'\n import {\n useChatbotStore,\n useConversationActions,\n useDialogConfirm,\n } from 'composables'\n import PkRelativeTime from '../PkRelativeTime.vue'\n import { ChatbotProfileContextKey } from './chatbotProfileContext'\n\n const props = defineProps<{ agentId: string }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const store = useChatbotStore(props.agentId)\n const { conversations, isLoadingConversations, localChatId } =\n storeToRefs(store)\n const { navigate, startNewChat, renameChatTitle, deleteChat } = store\n\n const {\n editingId,\n editingTitle,\n startEdit: startEditConversation,\n confirmEdit,\n cancelEdit,\n onRenameKeydown,\n requestDelete: handleDelete,\n } = useConversationActions({ renameChatTitle, deleteChat })\n\n const openConversation = (id: string) => {\n if (editingId.value) {\n return\n }\n localChatId.value = id\n navigate('chat')\n }\n\n const isCurrentConversation = (conversation: Conversation) => {\n return localChatId.value === conversation.id\n }\n\n const getLastMessage = (\n messages: UIChatMessage[],\n role: 'user' | 'assistant',\n ) => {\n return stripMarkdown(\n getTextPart(messages.filter((m) => m.role === role).slice(-1)[0]) ||\n '',\n )\n }\n\n const startEdit = (conversation: Conversation) => {\n startEditConversation(\n conversation,\n getLastMessage(conversation.messages, 'assistant'),\n )\n }\n\n const { openDialogConfirm } = useDialogConfirm()\n\n // GDPR B.3 — bulk \"delete my conversations\", available to anonymous\n // sessions too (the host wires the endpoint through the profile context).\n // Hidden when the host application owns the session (external token or\n // host-session mode): the endpoint erases ALL conversations of the\n // session's user platform-wide, an account-scoped action that belongs to\n // the host, not to an embedded widget. Same gating as sign-out and\n // manage-profile in PkChatbotViewProfile.\n const profile = inject(ChatbotProfileContextKey, undefined)\n const canEraseConversations = computed(\n () =>\n !!profile?.eraseConversations &&\n !(profile.isExternalAuth?.value ?? false),\n )\n const isErasingConversations = ref(false)\n const handleEraseAll = async () => {\n const eraseConversations = profile?.eraseConversations\n if (!eraseConversations || !canEraseConversations.value) {\n return\n }\n const proceed = await openDialogConfirm({\n title: $t('confirmTitle.deleteMyConversations'),\n questionLabel: $t('message.deleteMyConversationsConfirm'),\n })\n if (!proceed) {\n return\n }\n isErasingConversations.value = true\n try {\n await eraseConversations()\n conversations.value = []\n startNewChat()\n } catch {\n // Same policy as single delete: fail silently and reconcile\n // with the server state\n store.loadConversations(props.agentId)\n } finally {\n isErasingConversations.value = false\n }\n }\n</script>\n\n<template>\n <div class=\"flex flex-col flex-1 min-h-0 relative\">\n <!-- Loading skeleton -->\n <div\n v-if=\"isLoadingConversations && conversations.length === 0\"\n class=\"u-pick-list__list u-pick-list__list--fill\">\n <div\n v-for=\"i in 5\"\n :key=\"i\"\n class=\"u-pick-list__row u-pick-list__row--skeleton\">\n <div class=\"u-pick-list__entry u-pick-list__entry--roomy\">\n <div class=\"flex flex-col gap-6 flex-1 min-w-0\">\n <div\n class=\"vv-skeleton h-16 rounded\"\n :class=\"i % 2 ? 'w-192' : 'w-128'\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"vv-skeleton h-12 rounded\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"vv-skeleton h-12 rounded w-160\">\n <div class=\"vv-skeleton__item\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Empty state -->\n <div\n v-else-if=\"conversations.length === 0\"\n class=\"flex flex-col flex-1 items-center justify-center gap-12 p-24 text-center\">\n <div\n class=\"w-64 h-64 rounded-full bg-surface-1 border border-surface-3 flex items-center justify-center\">\n <VvIcon name=\"ri:chat-3-line\" class=\"w-28 h-28 text-word-4\" />\n </div>\n <div class=\"flex flex-col gap-4\">\n <strong class=\"text-16 font-semibold text-word-1\">\n {{ $t('message.noConversations') }}\n </strong>\n <span class=\"text-14 text-word-3 leading-relaxed\">\n {{ $t('message.noConversationsHint') }}\n </span>\n </div>\n <VvButton\n modifiers=\"primary rounded\"\n icon=\"ri:add-line\"\n class=\"mt-8\"\n :label=\"$t('action.startNewChat')\"\n @click=\"startNewChat()\" />\n </div>\n\n <!-- Conversation list. The row is a container, not a button: the menu\n and the rename field are siblings of the entry, because a button\n cannot legally contain other controls (Firefox and Safari drop\n them from the accessibility tree). -->\n <ul\n v-else\n class=\"u-pick-list__list u-pick-list__list--fill overflow-y-auto pb-64 light-scrollbar\">\n <li\n v-for=\"conversation in conversations\"\n :key=\"conversation.id\"\n class=\"u-pick-list__row\"\n :class=\"{\n 'u-pick-list__row--current':\n isCurrentConversation(conversation),\n }\">\n <div\n v-if=\"editingId === conversation.id\"\n class=\"flex flex-1 items-center gap-8 min-w-0 px-md py-12\">\n <VvInputText\n v-model=\"editingTitle\"\n class=\"flex-1 mb-0\"\n modifiers=\"compact\"\n autofocus\n select-on-focus\n :maxlength=\"255\"\n :placeholder=\"$t('placeholder.insert')\"\n @keydown=\"onRenameKeydown($event, conversation.id)\" />\n <VvButtonGroup modifiers=\"compact\">\n <VvButton\n icon=\"ri:save-line\"\n :title=\"$t('action.save')\"\n modifiers=\"action-quiet-small\"\n @click=\"confirmEdit(conversation.id)\" />\n <VvButton\n icon=\"ri:close-line\"\n :title=\"$t('action.cancel')\"\n modifiers=\"action-quiet-small\"\n @click=\"cancelEdit()\" />\n </VvButtonGroup>\n </div>\n <template v-else>\n <button\n type=\"button\"\n class=\"u-pick-list__entry u-pick-list__entry--roomy leading-relaxed\"\n :aria-current=\"\n isCurrentConversation(conversation)\n ? 'true'\n : undefined\n \"\n @click=\"openConversation(conversation.id)\">\n <div class=\"min-w-0 flex-1\">\n <div class=\"flex items-center gap-8\">\n <strong\n class=\"u-pick-list__label font-medium flex-1\">\n {{\n stripMarkdown(conversation.title) ||\n getLastMessage(\n conversation.messages,\n 'assistant',\n )\n }}\n </strong>\n <PkRelativeTime\n class=\"text-word-4 text-smaller shrink-0\"\n :date=\"conversation.lastMessageAt\" />\n </div>\n <span class=\"text-12 text-word-4 line-clamp-2\">\n {{\n stripMarkdown(conversation.summary) ||\n getLastMessage(\n conversation.messages,\n 'user',\n )\n }}\n </span>\n </div>\n </button>\n <div class=\"u-pick-list__actions\">\n <VvDropdown\n v-bind=\"{\n placement: 'bottom-end',\n modifiers: 'menu',\n flip: true,\n offset: 3,\n strategy: 'fixed',\n }\">\n <VvButton\n icon=\"ri:more-2-fill\"\n :title=\"$t('action.moreActions')\"\n modifiers=\"action-quiet-small\" />\n <template #items>\n <VvDropdownAction\n @click=\"startEdit(conversation)\">\n <VvIcon name=\"ri:pencil-line\" />\n {{ $t('action.renameChat') }}\n </VvDropdownAction>\n <VvDropdownAction\n @click=\"handleDelete(conversation.id)\">\n <VvIcon name=\"ri:delete-bin-line\" />\n {{ $t('action.delete') }}\n </VvDropdownAction>\n </template>\n </VvDropdown>\n </div>\n </template>\n </li>\n </ul>\n\n <!-- Sticky \"new chat\" CTA (hidden on empty state, which has its own CTA) -->\n <div\n v-if=\"conversations.length > 0\"\n class=\"absolute bottom-0 left-0 right-0 flex flex-col items-center gap-4 px-16 pb-16 pt-32 pointer-events-none\"\n :style=\"{\n background:\n 'linear-gradient(to top, var(--color-surface) 55%, transparent)',\n }\">\n <VvButton\n class=\"text-14 pointer-events-auto\"\n modifiers=\"primary rounded\"\n icon=\"ri:add-line\"\n :label=\"$t('action.startNewChat')\"\n @click.stop=\"startNewChat()\" />\n <VvButton\n v-if=\"canEraseConversations\"\n class=\"text-12 pointer-events-auto\"\n modifiers=\"action-quiet-danger\"\n icon=\"ri:delete-bin-line\"\n :loading=\"isErasingConversations\"\n :disabled=\"isErasingConversations\"\n :label=\"$t('action.deleteMyConversations')\"\n @click.stop=\"handleEraseAll()\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, inject, ref } from 'vue'\n import { storeToRefs } from 'pinia'\n import { useI18n } from 'vue-i18n'\n import type { Chat as Conversation, UIChatMessage } from 'models'\n import { stripMarkdown, getTextPart } from 'utils'\n import {\n useChatbotStore,\n useConversationActions,\n useDialogConfirm,\n } from 'composables'\n import PkRelativeTime from '../PkRelativeTime.vue'\n import { ChatbotProfileContextKey } from './chatbotProfileContext'\n\n const props = defineProps<{ agentId: string }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const store = useChatbotStore(props.agentId)\n const { conversations, isLoadingConversations, localChatId } =\n storeToRefs(store)\n const { navigate, startNewChat, renameChatTitle, deleteChat } = store\n\n const {\n editingId,\n editingTitle,\n startEdit: startEditConversation,\n confirmEdit,\n cancelEdit,\n onRenameKeydown,\n requestDelete: handleDelete,\n } = useConversationActions({ renameChatTitle, deleteChat })\n\n const openConversation = (id: string) => {\n if (editingId.value) {\n return\n }\n localChatId.value = id\n navigate('chat')\n }\n\n const isCurrentConversation = (conversation: Conversation) => {\n return localChatId.value === conversation.id\n }\n\n const getLastMessage = (\n messages: UIChatMessage[],\n role: 'user' | 'assistant',\n ) => {\n return stripMarkdown(\n getTextPart(messages.filter((m) => m.role === role).slice(-1)[0]) ||\n '',\n )\n }\n\n const startEdit = (conversation: Conversation) => {\n startEditConversation(\n conversation,\n getLastMessage(conversation.messages, 'assistant'),\n )\n }\n\n const { openDialogConfirm } = useDialogConfirm()\n\n // GDPR B.3 — bulk \"delete my conversations\", available to anonymous\n // sessions too (the host wires the endpoint through the profile context).\n // Hidden when the host application owns the session (external token or\n // host-session mode): the endpoint erases ALL conversations of the\n // session's user platform-wide, an account-scoped action that belongs to\n // the host, not to an embedded widget. Same gating as sign-out and\n // manage-profile in PkChatbotViewProfile.\n const profile = inject(ChatbotProfileContextKey, undefined)\n const canEraseConversations = computed(\n () =>\n !!profile?.eraseConversations &&\n !(profile.isExternalAuth?.value ?? false),\n )\n const isErasingConversations = ref(false)\n const handleEraseAll = async () => {\n const eraseConversations = profile?.eraseConversations\n if (!eraseConversations || !canEraseConversations.value) {\n return\n }\n const proceed = await openDialogConfirm({\n title: $t('confirmTitle.deleteMyConversations'),\n questionLabel: $t('message.deleteMyConversationsConfirm'),\n })\n if (!proceed) {\n return\n }\n isErasingConversations.value = true\n try {\n await eraseConversations()\n conversations.value = []\n startNewChat()\n } catch {\n // Same policy as single delete: fail silently and reconcile\n // with the server state\n store.loadConversations(props.agentId)\n } finally {\n isErasingConversations.value = false\n }\n }\n</script>\n\n<template>\n <div class=\"flex flex-col flex-1 min-h-0 relative\">\n <!-- Loading skeleton -->\n <div\n v-if=\"isLoadingConversations && conversations.length === 0\"\n class=\"u-pick-list__list u-pick-list__list--fill\">\n <div\n v-for=\"i in 5\"\n :key=\"i\"\n class=\"u-pick-list__row u-pick-list__row--skeleton\">\n <div class=\"u-pick-list__entry u-pick-list__entry--roomy\">\n <div class=\"flex flex-col gap-6 flex-1 min-w-0\">\n <div\n class=\"vv-skeleton h-16 rounded\"\n :class=\"i % 2 ? 'w-192' : 'w-128'\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"vv-skeleton h-12 rounded\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"vv-skeleton h-12 rounded w-160\">\n <div class=\"vv-skeleton__item\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Empty state -->\n <div\n v-else-if=\"conversations.length === 0\"\n class=\"flex flex-col flex-1 items-center justify-center gap-12 p-24 text-center\">\n <div\n class=\"w-64 h-64 rounded-full bg-surface-1 border border-surface-3 flex items-center justify-center\">\n <VvIcon name=\"ri:chat-3-line\" class=\"w-28 h-28 text-word-4\" />\n </div>\n <div class=\"flex flex-col gap-4\">\n <strong class=\"text-16 font-semibold text-word-1\">\n {{ $t('message.noConversations') }}\n </strong>\n <span class=\"text-14 text-word-3 leading-relaxed\">\n {{ $t('message.noConversationsHint') }}\n </span>\n </div>\n <VvButton\n modifiers=\"primary rounded\"\n icon=\"ri:add-line\"\n class=\"mt-8\"\n :label=\"$t('action.startNewChat')\"\n @click=\"startNewChat()\" />\n </div>\n\n <!-- Conversation list. The row is a container, not a button: the menu\n and the rename field are siblings of the entry, because a button\n cannot legally contain other controls (Firefox and Safari drop\n them from the accessibility tree). -->\n <ul\n v-else\n class=\"u-pick-list__list u-pick-list__list--fill overflow-y-auto pb-64 light-scrollbar\">\n <li\n v-for=\"conversation in conversations\"\n :key=\"conversation.id\"\n class=\"u-pick-list__row\"\n :class=\"{\n 'u-pick-list__row--current':\n isCurrentConversation(conversation),\n }\">\n <div\n v-if=\"editingId === conversation.id\"\n class=\"flex flex-1 items-center gap-8 min-w-0 px-md py-12\">\n <VvInputText\n v-model=\"editingTitle\"\n class=\"flex-1 mb-0\"\n modifiers=\"compact\"\n autofocus\n select-on-focus\n :maxlength=\"255\"\n :placeholder=\"$t('placeholder.insert')\"\n @keydown=\"onRenameKeydown($event, conversation.id)\" />\n <VvButtonGroup modifiers=\"compact\">\n <VvButton\n icon=\"ri:save-line\"\n :title=\"$t('action.save')\"\n modifiers=\"action-quiet-small\"\n @click=\"confirmEdit(conversation.id)\" />\n <VvButton\n icon=\"ri:close-line\"\n :title=\"$t('action.cancel')\"\n modifiers=\"action-quiet-small\"\n @click=\"cancelEdit()\" />\n </VvButtonGroup>\n </div>\n <template v-else>\n <button\n type=\"button\"\n class=\"u-pick-list__entry u-pick-list__entry--roomy leading-relaxed\"\n :aria-current=\"\n isCurrentConversation(conversation)\n ? 'true'\n : undefined\n \"\n @click=\"openConversation(conversation.id)\">\n <div class=\"min-w-0 flex-1\">\n <div class=\"flex items-center gap-8\">\n <strong\n class=\"u-pick-list__label font-medium flex-1\">\n {{\n stripMarkdown(conversation.title) ||\n getLastMessage(\n conversation.messages,\n 'assistant',\n )\n }}\n </strong>\n <PkRelativeTime\n class=\"text-word-4 text-smaller shrink-0\"\n :date=\"conversation.lastMessageAt\" />\n </div>\n <span class=\"text-12 text-word-4 line-clamp-2\">\n {{\n stripMarkdown(conversation.summary) ||\n getLastMessage(\n conversation.messages,\n 'user',\n )\n }}\n </span>\n </div>\n </button>\n <div class=\"u-pick-list__actions\">\n <VvDropdown\n v-bind=\"{\n placement: 'bottom-end',\n modifiers: 'menu',\n flip: true,\n offset: 3,\n strategy: 'fixed',\n }\">\n <VvButton\n icon=\"ri:more-2-fill\"\n :title=\"$t('action.moreActions')\"\n modifiers=\"action-quiet-small\" />\n <template #items>\n <VvDropdownAction\n @click=\"startEdit(conversation)\">\n <VvIcon name=\"ri:pencil-line\" />\n {{ $t('action.renameChat') }}\n </VvDropdownAction>\n <VvDropdownAction\n @click=\"handleDelete(conversation.id)\">\n <VvIcon name=\"ri:delete-bin-line\" />\n {{ $t('action.delete') }}\n </VvDropdownAction>\n </template>\n </VvDropdown>\n </div>\n </template>\n </li>\n </ul>\n\n <!-- Sticky \"new chat\" CTA (hidden on empty state, which has its own CTA) -->\n <div\n v-if=\"conversations.length > 0\"\n class=\"absolute bottom-0 left-0 right-0 flex flex-col items-center gap-4 px-16 pb-16 pt-32 pointer-events-none\"\n :style=\"{\n background:\n 'linear-gradient(to top, var(--color-surface) 55%, transparent)',\n }\">\n <VvButton\n class=\"text-14 pointer-events-auto\"\n modifiers=\"primary rounded\"\n icon=\"ri:add-line\"\n :label=\"$t('action.startNewChat')\"\n @click.stop=\"startNewChat()\" />\n <VvButton\n v-if=\"canEraseConversations\"\n class=\"text-12 pointer-events-auto\"\n modifiers=\"action-quiet-danger\"\n icon=\"ri:delete-bin-line\"\n :loading=\"isErasingConversations\"\n :disabled=\"isErasingConversations\"\n :label=\"$t('action.deleteMyConversations')\"\n @click.stop=\"handleEraseAll()\" />\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;AASA,SAAgB,EAAuB,GAAoC;CACvE,OACI,EAAc,EAAa,KAAK,KAChC,EACI,EAGI,EAAa,UAAU,MAClB,MAAY,EAAQ,SAAS,MAClC,CACJ,CACJ,KACA;AAER;AAOA,SAAgB,EAAuB,GAGpC;CACC,IAAM,IAAY,EAAmB,IAAI,GACnC,IAAe,EAAI,EAAE,GAErB,KAAa,GAA4B,IAAgB,OAAO;EAElE,AADA,EAAU,QAAQ,EAAa,IAC/B,EAAa,QAAQ,EAAc,EAAa,KAAK,KAAK;CAC9D,GAEM,IAAc,OAAO,MAAe;EACtC,IAAM,IAAU,EAAa,MAAM,KAAK;EAExC,IADA,EAAU,QAAQ,MACd,KAAW,EAAQ,UAAU,KAC7B,IAAI;GACA,MAAM,EAAQ,gBAAgB,GAAI,CAAO;EAC7C,QAAQ,CAER;CAER,GAEM,UAAmB;EACrB,EAAU,QAAQ;CACtB,GAEM,KAAmB,GAAsB,MAAe;EAC1D,AAAI,EAAM,QAAQ,WACd,EAAM,eAAe,GACrB,EAAY,CAAE,KACP,EAAM,QAAQ,aACrB,EAAM,eAAe,GACrB,EAAW;CAEnB,GAEM,EAAE,yBAAsB,EAAiB;CAa/C,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA,sBAnByB,MAAe;GACxC,IAAI;IAEA,IAAI,CAAC,MADiB,EAAkB,GAEpC;IAEJ,MAAM,EAAQ,WAAW,CAAE;GAC/B,QAAQ,CAER;EACJ;CAUA;AACJ;;;;;;;;;;;;;;;;;;;;;;;EC5EI,IAAM,IAAQ,GAER,EAAE,GAAG,MAAO,GAAQ,EAAE,UAAU,SAAS,CAAC,GAE1C,IA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SAAK,AAAA,EAAA,OAAA,GAAA,MAAO,EAAA,CAAA,CAAY,CAAA,GAAA,CAAA,MAAA,CAAA;GAEnB,GAAA,MAAA,GAAA,CAAA,OAAA,CAAA,GAAA,EAAA,SADV,EAAA,GAAA,GAQqC,GAAA;;IANjC,OAAM;IACN,WAAU;IACV,MAAK;IACJ,SAAS,EAAA;IACT,UAAU,EAAA;IACV,OAAO,EAAA,CAAA,CAAE,CAAA,8BAAA;IACT,SAAK,AAAA,EAAA,OAAA,GAAA,MAAO,GAAc,GAAA,CAAA,MAAA,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as e, n as t, o as n } from "./Document-CaUfI_SZ.js";
|
|
2
|
-
import { n as r } from "./useChatbotStore-
|
|
2
|
+
import { n as r } from "./useChatbotStore-CiRAuq7v.js";
|
|
3
3
|
import { t as i } from "./useDialogConfirm-KWz0ohCQ.js";
|
|
4
4
|
import { t as a } from "./useImageFallback-5vQIO0pC.js";
|
|
5
5
|
import { VvButton as o, VvIcon as s } from "@volverjs/ui-vue/components";
|
|
@@ -108,4 +108,4 @@ var C = { class: "flex flex-col flex-1 min-h-0 relative" }, w = {
|
|
|
108
108
|
//#endregion
|
|
109
109
|
export { R as t };
|
|
110
110
|
|
|
111
|
-
//# sourceMappingURL=PkChatbotViewFiles-
|
|
111
|
+
//# sourceMappingURL=PkChatbotViewFiles-qmLESi1V.js.map
|
package/dist-vue/_chunks/{PkChatbotViewFiles-B7KaE7rU.js.map → PkChatbotViewFiles-qmLESi1V.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkChatbotViewFiles-B7KaE7rU.js","names":[],"sources":["../../../../packages/composable/src/useFileRow.ts","../../../../packages/components/src/chat/PkChatbotViewFiles.vue","../../../../packages/components/src/chat/PkChatbotViewFiles.vue"],"sourcesContent":["import { useI18n } from 'vue-i18n'\nimport { isImageMime, isInlineViewable } from 'models'\nimport { useImageFallback } from './useImageFallback'\n\n/** Minimal shape a file-list row needs for the shared display helpers. */\nexport interface FileRowLike {\n documentId: string\n mimeType: string | null\n}\n\n/**\n * Shared display logic for the user-files list rows, used by both the in-app\n * table (PjUserFilesTable) and the embedded widget (PkChatbotViewFiles). The two\n * surfaces differ only in how they build URLs (authenticated store vs widget API\n * client), so the URL builders are injected.\n *\n * - `view(id, inline)` → opens/downloads the original file.\n * - `preview(id)` → small resized blob for the row thumbnail.\n */\nexport function useFileRow(urls: {\n view: (documentId: string, inline: boolean) => string\n preview: (documentId: string) => string\n}) {\n const { locale } = useI18n({ useScope: 'global' })\n\n // Image rows show a thumbnail; if it fails to load (auth/redirect, or the\n // preview isn't generated yet) we fall back to the file-type icon.\n const { canShowImage, onImageError } = useImageFallback()\n const thumbUrl = (file: FileRowLike): string =>\n urls.preview(file.documentId)\n const showThumb = (file: FileRowLike): boolean =>\n isImageMime(file.mimeType) && canShowImage(thumbUrl(file))\n const onThumbError = (file: FileRowLike): void => {\n onImageError(thumbUrl(file))\n }\n\n // Name click previews images/PDF inline; an explicit download forces an\n // attachment (inline=false → download SAS).\n const openFile = (file: FileRowLike, download = false): void => {\n const inline = !download && isInlineViewable(file.mimeType)\n window.open(urls.view(file.documentId, inline), '_blank', 'noopener')\n }\n\n const formatDate = (iso: string): string =>\n new Date(iso).toLocaleDateString(locale.value, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n })\n\n return { showThumb, thumbUrl, onThumbError, openFile, formatDate }\n}\n","<script setup lang=\"ts\">\n import { ref } from 'vue'\n import { storeToRefs } from 'pinia'\n import { useI18n } from 'vue-i18n'\n import { fileIconForMime } from 'models'\n import {\n useChatbotStore,\n useDialogConfirm,\n useFileRow,\n type ChatbotFile,\n } from 'composables'\n\n const props = defineProps<{ agentId: string }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n const { openDialogConfirm } = useDialogConfirm()\n\n const store = useChatbotStore(props.agentId)\n const { chatFiles, isLoadingChatFiles } = storeToRefs(store)\n const { showThumb, thumbUrl, onThumbError, openFile, formatDate } =\n useFileRow({\n view: store.getChatFileUrl,\n preview: store.getChatFilePreviewUrl,\n })\n\n const deletingId = ref<string | null>(null)\n\n const handleExclude = async (file: ChatbotFile) => {\n const proceed = await openDialogConfirm({\n title: $t('confirmTitle.excludeUserFile'),\n questionLabel: $t('userFiles.excludeConfirm'),\n })\n if (!proceed) {\n return\n }\n deletingId.value = file.documentId\n try {\n await store.deleteChatFile(file.documentId)\n } catch {\n // surfaced by the host's error handling\n } finally {\n deletingId.value = null\n }\n }\n</script>\n\n<template>\n <div class=\"flex flex-col flex-1 min-h-0 relative\">\n <!-- Loading skeleton, shaped like the rows it replaces -->\n <div\n v-if=\"isLoadingChatFiles && chatFiles.length === 0\"\n class=\"u-pick-list__list u-pick-list__list--fill\">\n <div\n v-for=\"i in 4\"\n :key=\"i\"\n class=\"u-pick-list__row u-pick-list__row--skeleton\">\n <div class=\"u-pick-list__entry u-pick-list__entry--roomy\">\n <div class=\"vv-skeleton w-36 h-36 shrink-0 rounded-md\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"flex flex-col gap-6 flex-1 min-w-0\">\n <div\n class=\"vv-skeleton h-14 rounded\"\n :class=\"i % 2 ? 'w-192' : 'w-128'\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"vv-skeleton h-12 rounded w-96\">\n <div class=\"vv-skeleton__item\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Empty state -->\n <div\n v-else-if=\"chatFiles.length === 0\"\n class=\"flex flex-col flex-1 items-center justify-center gap-12 p-24 text-center\">\n <div\n class=\"w-64 h-64 rounded-full bg-surface-1 border border-surface-3 flex items-center justify-center\">\n <VvIcon\n name=\"ri:folder-open-line\"\n class=\"w-28 h-28 text-word-4\" />\n </div>\n <span class=\"text-14 text-word-3 leading-relaxed\">\n {{ $t('userFiles.chatFilesEmpty') }}\n </span>\n </div>\n\n <!-- File list -->\n <ul\n v-else\n class=\"pk-chatbot-files u-pick-list__list u-pick-list__list--fill overflow-y-auto light-scrollbar\">\n <li\n v-for=\"file in chatFiles\"\n :key=\"file.documentId\"\n class=\"u-pick-list__row\">\n <button\n type=\"button\"\n class=\"u-pick-list__entry u-pick-list__entry--roomy\"\n :title=\"$t('userFiles.open')\"\n @click=\"openFile(file)\">\n <span class=\"pk-chatbot-files__icon\">\n <img\n v-if=\"showThumb(file)\"\n :src=\"thumbUrl(file)\"\n loading=\"lazy\"\n decoding=\"async\"\n alt=\"\"\n class=\"pk-chatbot-files__thumb\"\n @error=\"onThumbError(file)\" />\n <VvIcon v-else :name=\"fileIconForMime(file.mimeType)\" />\n </span>\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"u-pick-list__label\">\n {{ file.name || $t('userFiles.untitled') }}\n </span>\n <span class=\"text-12 text-word-3\">\n {{ formatDate(file.createdAt) }}\n </span>\n </span>\n </button>\n <div class=\"u-pick-list__actions pk-chatbot-files__actions\">\n <VvButton\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :title=\"$t('action.download')\"\n @click=\"openFile(file, true)\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n icon=\"ri:delete-bin-line\"\n :title=\"$t('userFiles.exclude')\"\n :loading=\"deletingId === file.documentId\"\n :disabled=\"deletingId === file.documentId\"\n @click=\"handleExclude(file)\" />\n </div>\n </li>\n </ul>\n </div>\n</template>\n\n<style lang=\"scss\">\n // The frame, the rows and the label come from `u-pick-list`; what is left\n // here is the file tile and the pair of row actions.\n .pk-chatbot-files {\n list-style: none;\n margin: 0;\n padding: 0;\n\n // The box exists to clip a thumbnail and to keep the labels of rows\n // with and without one on the same left edge: with a file icon in it\n // there is nothing to draw, so it stays transparent.\n &__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: var(--spacing-36);\n height: var(--spacing-36);\n flex-shrink: 0;\n border-radius: var(--rounded-md);\n color: var(--color-word-3);\n overflow: hidden;\n\n svg {\n width: var(--spacing-20);\n height: var(--spacing-20);\n }\n }\n\n &__thumb {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n &__actions {\n gap: var(--spacing-2);\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { ref } from 'vue'\n import { storeToRefs } from 'pinia'\n import { useI18n } from 'vue-i18n'\n import { fileIconForMime } from 'models'\n import {\n useChatbotStore,\n useDialogConfirm,\n useFileRow,\n type ChatbotFile,\n } from 'composables'\n\n const props = defineProps<{ agentId: string }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n const { openDialogConfirm } = useDialogConfirm()\n\n const store = useChatbotStore(props.agentId)\n const { chatFiles, isLoadingChatFiles } = storeToRefs(store)\n const { showThumb, thumbUrl, onThumbError, openFile, formatDate } =\n useFileRow({\n view: store.getChatFileUrl,\n preview: store.getChatFilePreviewUrl,\n })\n\n const deletingId = ref<string | null>(null)\n\n const handleExclude = async (file: ChatbotFile) => {\n const proceed = await openDialogConfirm({\n title: $t('confirmTitle.excludeUserFile'),\n questionLabel: $t('userFiles.excludeConfirm'),\n })\n if (!proceed) {\n return\n }\n deletingId.value = file.documentId\n try {\n await store.deleteChatFile(file.documentId)\n } catch {\n // surfaced by the host's error handling\n } finally {\n deletingId.value = null\n }\n }\n</script>\n\n<template>\n <div class=\"flex flex-col flex-1 min-h-0 relative\">\n <!-- Loading skeleton, shaped like the rows it replaces -->\n <div\n v-if=\"isLoadingChatFiles && chatFiles.length === 0\"\n class=\"u-pick-list__list u-pick-list__list--fill\">\n <div\n v-for=\"i in 4\"\n :key=\"i\"\n class=\"u-pick-list__row u-pick-list__row--skeleton\">\n <div class=\"u-pick-list__entry u-pick-list__entry--roomy\">\n <div class=\"vv-skeleton w-36 h-36 shrink-0 rounded-md\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"flex flex-col gap-6 flex-1 min-w-0\">\n <div\n class=\"vv-skeleton h-14 rounded\"\n :class=\"i % 2 ? 'w-192' : 'w-128'\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"vv-skeleton h-12 rounded w-96\">\n <div class=\"vv-skeleton__item\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Empty state -->\n <div\n v-else-if=\"chatFiles.length === 0\"\n class=\"flex flex-col flex-1 items-center justify-center gap-12 p-24 text-center\">\n <div\n class=\"w-64 h-64 rounded-full bg-surface-1 border border-surface-3 flex items-center justify-center\">\n <VvIcon\n name=\"ri:folder-open-line\"\n class=\"w-28 h-28 text-word-4\" />\n </div>\n <span class=\"text-14 text-word-3 leading-relaxed\">\n {{ $t('userFiles.chatFilesEmpty') }}\n </span>\n </div>\n\n <!-- File list -->\n <ul\n v-else\n class=\"pk-chatbot-files u-pick-list__list u-pick-list__list--fill overflow-y-auto light-scrollbar\">\n <li\n v-for=\"file in chatFiles\"\n :key=\"file.documentId\"\n class=\"u-pick-list__row\">\n <button\n type=\"button\"\n class=\"u-pick-list__entry u-pick-list__entry--roomy\"\n :title=\"$t('userFiles.open')\"\n @click=\"openFile(file)\">\n <span class=\"pk-chatbot-files__icon\">\n <img\n v-if=\"showThumb(file)\"\n :src=\"thumbUrl(file)\"\n loading=\"lazy\"\n decoding=\"async\"\n alt=\"\"\n class=\"pk-chatbot-files__thumb\"\n @error=\"onThumbError(file)\" />\n <VvIcon v-else :name=\"fileIconForMime(file.mimeType)\" />\n </span>\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"u-pick-list__label\">\n {{ file.name || $t('userFiles.untitled') }}\n </span>\n <span class=\"text-12 text-word-3\">\n {{ formatDate(file.createdAt) }}\n </span>\n </span>\n </button>\n <div class=\"u-pick-list__actions pk-chatbot-files__actions\">\n <VvButton\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :title=\"$t('action.download')\"\n @click=\"openFile(file, true)\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n icon=\"ri:delete-bin-line\"\n :title=\"$t('userFiles.exclude')\"\n :loading=\"deletingId === file.documentId\"\n :disabled=\"deletingId === file.documentId\"\n @click=\"handleExclude(file)\" />\n </div>\n </li>\n </ul>\n </div>\n</template>\n\n<style lang=\"scss\">\n // The frame, the rows and the label come from `u-pick-list`; what is left\n // here is the file tile and the pair of row actions.\n .pk-chatbot-files {\n list-style: none;\n margin: 0;\n padding: 0;\n\n // The box exists to clip a thumbnail and to keep the labels of rows\n // with and without one on the same left edge: with a file icon in it\n // there is nothing to draw, so it stays transparent.\n &__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: var(--spacing-36);\n height: var(--spacing-36);\n flex-shrink: 0;\n border-radius: var(--rounded-md);\n color: var(--color-word-3);\n overflow: hidden;\n\n svg {\n width: var(--spacing-20);\n height: var(--spacing-20);\n }\n }\n\n &__thumb {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n &__actions {\n gap: var(--spacing-2);\n }\n }\n</style>\n"],"mappings":";;;;;;;;;AAmBA,SAAgB,EAAW,GAGxB;CACC,IAAM,EAAE,cAAW,EAAQ,EAAE,UAAU,SAAS,CAAC,GAI3C,EAAE,iBAAc,oBAAiB,EAAiB,GAClD,KAAY,MACd,EAAK,QAAQ,EAAK,UAAU;CAqBhC,OAAO;EAAE,YApBU,MACf,EAAY,EAAK,QAAQ,KAAK,EAAa,EAAS,CAAI,CAAC;EAmBzC;EAAU,eAlBR,MAA4B;GAC9C,EAAa,EAAS,CAAI,CAAC;EAC/B;EAgB4C,WAZ1B,GAAmB,IAAW,OAAgB;GAC5D,IAAM,IAAS,CAAC,KAAY,EAAiB,EAAK,QAAQ;GAC1D,OAAO,KAAK,EAAK,KAAK,EAAK,YAAY,CAAM,GAAG,UAAU,UAAU;EACxE;EASsD,aAPlC,MAChB,IAAI,KAAK,CAAG,CAAC,CAAC,mBAAmB,EAAO,OAAO;GAC3C,MAAM;GACN,OAAO;GACP,KAAK;EACT,CAAC;CAE4D;AACrE;;;;;;;;;;;;;;;;ECvCI,IAAM,IAAQ,GAER,EAAE,GAAG,MAAO,EAAQ,EAAE,UAAU,SAAS,CAAC,GAC1C,EAAE,yBAAsB,EAAiB,G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A,CAAA,GAIxC,EAaM,OAbN,GAaM,CAZF,EAIoC,GAAA;IAHhC,WAAU;IACV,MAAK;IACJ,OAAO,EAAA,CAAA,CAAE,CAAA,iBAAA;IACT,UAAK,MAAE,EAAA,CAAA,CAAQ,CAAC,GAAI,EAAA;GACzB,GAAA,MAAA,GAAA,CAAA,SAAA,SAAA,CAAA,GAAA,EAMmC,GAAA;IAL/B,WAAU;IACV,MAAK;IACJ,OAAO,EAAA,CAAA,CAAE,CAAA,mBAAA;IACT,SAAS,EAAA,UAAe,EAAK;IAC7B,UAAU,EAAA,UAAe,EAAK;IAC9B,UAAK,MAAE,EAAc,CAAI"}
|
|
1
|
+
{"version":3,"file":"PkChatbotViewFiles-qmLESi1V.js","names":[],"sources":["../../../../packages/composable/src/useFileRow.ts","../../../../packages/components/src/chat/PkChatbotViewFiles.vue","../../../../packages/components/src/chat/PkChatbotViewFiles.vue"],"sourcesContent":["import { useI18n } from 'vue-i18n'\nimport { isImageMime, isInlineViewable } from 'models'\nimport { useImageFallback } from './useImageFallback'\n\n/** Minimal shape a file-list row needs for the shared display helpers. */\nexport interface FileRowLike {\n documentId: string\n mimeType: string | null\n}\n\n/**\n * Shared display logic for the user-files list rows, used by both the in-app\n * table (PjUserFilesTable) and the embedded widget (PkChatbotViewFiles). The two\n * surfaces differ only in how they build URLs (authenticated store vs widget API\n * client), so the URL builders are injected.\n *\n * - `view(id, inline)` → opens/downloads the original file.\n * - `preview(id)` → small resized blob for the row thumbnail.\n */\nexport function useFileRow(urls: {\n view: (documentId: string, inline: boolean) => string\n preview: (documentId: string) => string\n}) {\n const { locale } = useI18n({ useScope: 'global' })\n\n // Image rows show a thumbnail; if it fails to load (auth/redirect, or the\n // preview isn't generated yet) we fall back to the file-type icon.\n const { canShowImage, onImageError } = useImageFallback()\n const thumbUrl = (file: FileRowLike): string =>\n urls.preview(file.documentId)\n const showThumb = (file: FileRowLike): boolean =>\n isImageMime(file.mimeType) && canShowImage(thumbUrl(file))\n const onThumbError = (file: FileRowLike): void => {\n onImageError(thumbUrl(file))\n }\n\n // Name click previews images/PDF inline; an explicit download forces an\n // attachment (inline=false → download SAS).\n const openFile = (file: FileRowLike, download = false): void => {\n const inline = !download && isInlineViewable(file.mimeType)\n window.open(urls.view(file.documentId, inline), '_blank', 'noopener')\n }\n\n const formatDate = (iso: string): string =>\n new Date(iso).toLocaleDateString(locale.value, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n })\n\n return { showThumb, thumbUrl, onThumbError, openFile, formatDate }\n}\n","<script setup lang=\"ts\">\n import { ref } from 'vue'\n import { storeToRefs } from 'pinia'\n import { useI18n } from 'vue-i18n'\n import { fileIconForMime } from 'models'\n import {\n useChatbotStore,\n useDialogConfirm,\n useFileRow,\n type ChatbotFile,\n } from 'composables'\n\n const props = defineProps<{ agentId: string }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n const { openDialogConfirm } = useDialogConfirm()\n\n const store = useChatbotStore(props.agentId)\n const { chatFiles, isLoadingChatFiles } = storeToRefs(store)\n const { showThumb, thumbUrl, onThumbError, openFile, formatDate } =\n useFileRow({\n view: store.getChatFileUrl,\n preview: store.getChatFilePreviewUrl,\n })\n\n const deletingId = ref<string | null>(null)\n\n const handleExclude = async (file: ChatbotFile) => {\n const proceed = await openDialogConfirm({\n title: $t('confirmTitle.excludeUserFile'),\n questionLabel: $t('userFiles.excludeConfirm'),\n })\n if (!proceed) {\n return\n }\n deletingId.value = file.documentId\n try {\n await store.deleteChatFile(file.documentId)\n } catch {\n // surfaced by the host's error handling\n } finally {\n deletingId.value = null\n }\n }\n</script>\n\n<template>\n <div class=\"flex flex-col flex-1 min-h-0 relative\">\n <!-- Loading skeleton, shaped like the rows it replaces -->\n <div\n v-if=\"isLoadingChatFiles && chatFiles.length === 0\"\n class=\"u-pick-list__list u-pick-list__list--fill\">\n <div\n v-for=\"i in 4\"\n :key=\"i\"\n class=\"u-pick-list__row u-pick-list__row--skeleton\">\n <div class=\"u-pick-list__entry u-pick-list__entry--roomy\">\n <div class=\"vv-skeleton w-36 h-36 shrink-0 rounded-md\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"flex flex-col gap-6 flex-1 min-w-0\">\n <div\n class=\"vv-skeleton h-14 rounded\"\n :class=\"i % 2 ? 'w-192' : 'w-128'\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"vv-skeleton h-12 rounded w-96\">\n <div class=\"vv-skeleton__item\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Empty state -->\n <div\n v-else-if=\"chatFiles.length === 0\"\n class=\"flex flex-col flex-1 items-center justify-center gap-12 p-24 text-center\">\n <div\n class=\"w-64 h-64 rounded-full bg-surface-1 border border-surface-3 flex items-center justify-center\">\n <VvIcon\n name=\"ri:folder-open-line\"\n class=\"w-28 h-28 text-word-4\" />\n </div>\n <span class=\"text-14 text-word-3 leading-relaxed\">\n {{ $t('userFiles.chatFilesEmpty') }}\n </span>\n </div>\n\n <!-- File list -->\n <ul\n v-else\n class=\"pk-chatbot-files u-pick-list__list u-pick-list__list--fill overflow-y-auto light-scrollbar\">\n <li\n v-for=\"file in chatFiles\"\n :key=\"file.documentId\"\n class=\"u-pick-list__row\">\n <button\n type=\"button\"\n class=\"u-pick-list__entry u-pick-list__entry--roomy\"\n :title=\"$t('userFiles.open')\"\n @click=\"openFile(file)\">\n <span class=\"pk-chatbot-files__icon\">\n <img\n v-if=\"showThumb(file)\"\n :src=\"thumbUrl(file)\"\n loading=\"lazy\"\n decoding=\"async\"\n alt=\"\"\n class=\"pk-chatbot-files__thumb\"\n @error=\"onThumbError(file)\" />\n <VvIcon v-else :name=\"fileIconForMime(file.mimeType)\" />\n </span>\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"u-pick-list__label\">\n {{ file.name || $t('userFiles.untitled') }}\n </span>\n <span class=\"text-12 text-word-3\">\n {{ formatDate(file.createdAt) }}\n </span>\n </span>\n </button>\n <div class=\"u-pick-list__actions pk-chatbot-files__actions\">\n <VvButton\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :title=\"$t('action.download')\"\n @click=\"openFile(file, true)\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n icon=\"ri:delete-bin-line\"\n :title=\"$t('userFiles.exclude')\"\n :loading=\"deletingId === file.documentId\"\n :disabled=\"deletingId === file.documentId\"\n @click=\"handleExclude(file)\" />\n </div>\n </li>\n </ul>\n </div>\n</template>\n\n<style lang=\"scss\">\n // The frame, the rows and the label come from `u-pick-list`; what is left\n // here is the file tile and the pair of row actions.\n .pk-chatbot-files {\n list-style: none;\n margin: 0;\n padding: 0;\n\n // The box exists to clip a thumbnail and to keep the labels of rows\n // with and without one on the same left edge: with a file icon in it\n // there is nothing to draw, so it stays transparent.\n &__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: var(--spacing-36);\n height: var(--spacing-36);\n flex-shrink: 0;\n border-radius: var(--rounded-md);\n color: var(--color-word-3);\n overflow: hidden;\n\n svg {\n width: var(--spacing-20);\n height: var(--spacing-20);\n }\n }\n\n &__thumb {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n &__actions {\n gap: var(--spacing-2);\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { ref } from 'vue'\n import { storeToRefs } from 'pinia'\n import { useI18n } from 'vue-i18n'\n import { fileIconForMime } from 'models'\n import {\n useChatbotStore,\n useDialogConfirm,\n useFileRow,\n type ChatbotFile,\n } from 'composables'\n\n const props = defineProps<{ agentId: string }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n const { openDialogConfirm } = useDialogConfirm()\n\n const store = useChatbotStore(props.agentId)\n const { chatFiles, isLoadingChatFiles } = storeToRefs(store)\n const { showThumb, thumbUrl, onThumbError, openFile, formatDate } =\n useFileRow({\n view: store.getChatFileUrl,\n preview: store.getChatFilePreviewUrl,\n })\n\n const deletingId = ref<string | null>(null)\n\n const handleExclude = async (file: ChatbotFile) => {\n const proceed = await openDialogConfirm({\n title: $t('confirmTitle.excludeUserFile'),\n questionLabel: $t('userFiles.excludeConfirm'),\n })\n if (!proceed) {\n return\n }\n deletingId.value = file.documentId\n try {\n await store.deleteChatFile(file.documentId)\n } catch {\n // surfaced by the host's error handling\n } finally {\n deletingId.value = null\n }\n }\n</script>\n\n<template>\n <div class=\"flex flex-col flex-1 min-h-0 relative\">\n <!-- Loading skeleton, shaped like the rows it replaces -->\n <div\n v-if=\"isLoadingChatFiles && chatFiles.length === 0\"\n class=\"u-pick-list__list u-pick-list__list--fill\">\n <div\n v-for=\"i in 4\"\n :key=\"i\"\n class=\"u-pick-list__row u-pick-list__row--skeleton\">\n <div class=\"u-pick-list__entry u-pick-list__entry--roomy\">\n <div class=\"vv-skeleton w-36 h-36 shrink-0 rounded-md\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"flex flex-col gap-6 flex-1 min-w-0\">\n <div\n class=\"vv-skeleton h-14 rounded\"\n :class=\"i % 2 ? 'w-192' : 'w-128'\">\n <div class=\"vv-skeleton__item\" />\n </div>\n <div class=\"vv-skeleton h-12 rounded w-96\">\n <div class=\"vv-skeleton__item\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Empty state -->\n <div\n v-else-if=\"chatFiles.length === 0\"\n class=\"flex flex-col flex-1 items-center justify-center gap-12 p-24 text-center\">\n <div\n class=\"w-64 h-64 rounded-full bg-surface-1 border border-surface-3 flex items-center justify-center\">\n <VvIcon\n name=\"ri:folder-open-line\"\n class=\"w-28 h-28 text-word-4\" />\n </div>\n <span class=\"text-14 text-word-3 leading-relaxed\">\n {{ $t('userFiles.chatFilesEmpty') }}\n </span>\n </div>\n\n <!-- File list -->\n <ul\n v-else\n class=\"pk-chatbot-files u-pick-list__list u-pick-list__list--fill overflow-y-auto light-scrollbar\">\n <li\n v-for=\"file in chatFiles\"\n :key=\"file.documentId\"\n class=\"u-pick-list__row\">\n <button\n type=\"button\"\n class=\"u-pick-list__entry u-pick-list__entry--roomy\"\n :title=\"$t('userFiles.open')\"\n @click=\"openFile(file)\">\n <span class=\"pk-chatbot-files__icon\">\n <img\n v-if=\"showThumb(file)\"\n :src=\"thumbUrl(file)\"\n loading=\"lazy\"\n decoding=\"async\"\n alt=\"\"\n class=\"pk-chatbot-files__thumb\"\n @error=\"onThumbError(file)\" />\n <VvIcon v-else :name=\"fileIconForMime(file.mimeType)\" />\n </span>\n <span class=\"flex flex-col min-w-0 flex-1\">\n <span class=\"u-pick-list__label\">\n {{ file.name || $t('userFiles.untitled') }}\n </span>\n <span class=\"text-12 text-word-3\">\n {{ formatDate(file.createdAt) }}\n </span>\n </span>\n </button>\n <div class=\"u-pick-list__actions pk-chatbot-files__actions\">\n <VvButton\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :title=\"$t('action.download')\"\n @click=\"openFile(file, true)\" />\n <VvButton\n modifiers=\"action-quiet-small\"\n icon=\"ri:delete-bin-line\"\n :title=\"$t('userFiles.exclude')\"\n :loading=\"deletingId === file.documentId\"\n :disabled=\"deletingId === file.documentId\"\n @click=\"handleExclude(file)\" />\n </div>\n </li>\n </ul>\n </div>\n</template>\n\n<style lang=\"scss\">\n // The frame, the rows and the label come from `u-pick-list`; what is left\n // here is the file tile and the pair of row actions.\n .pk-chatbot-files {\n list-style: none;\n margin: 0;\n padding: 0;\n\n // The box exists to clip a thumbnail and to keep the labels of rows\n // with and without one on the same left edge: with a file icon in it\n // there is nothing to draw, so it stays transparent.\n &__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: var(--spacing-36);\n height: var(--spacing-36);\n flex-shrink: 0;\n border-radius: var(--rounded-md);\n color: var(--color-word-3);\n overflow: hidden;\n\n svg {\n width: var(--spacing-20);\n height: var(--spacing-20);\n }\n }\n\n &__thumb {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n &__actions {\n gap: var(--spacing-2);\n }\n }\n</style>\n"],"mappings":";;;;;;;;;AAmBA,SAAgB,EAAW,GAGxB;CACC,IAAM,EAAE,cAAW,EAAQ,EAAE,UAAU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RAuq7v.js";
|
|
2
2
|
import { t } from "./PkAvatar-paEJByEA.js";
|
|
3
3
|
import { t as n } from "./chatbotProfileContext-CgnFhNPn.js";
|
|
4
4
|
import { VvAlert as r, VvButton as i, VvIcon as a } from "@volverjs/ui-vue/components";
|
|
@@ -83,4 +83,4 @@ var x = { class: "flex flex-col flex-1 min-h-0 overflow-y-auto" }, S = { class:
|
|
|
83
83
|
//#endregion
|
|
84
84
|
export { N as t };
|
|
85
85
|
|
|
86
|
-
//# sourceMappingURL=PkChatbotViewProfile-
|
|
86
|
+
//# sourceMappingURL=PkChatbotViewProfile-DzfZnitQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkChatbotViewProfile-tKK5Yazl.js","names":[],"sources":["../../../../packages/components/src/chat/PkChatbotViewProfile.vue","../../../../packages/components/src/chat/PkChatbotViewProfile.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, inject, ref } from 'vue'\n import { storeToRefs } from 'pinia'\n import { useI18n } from 'vue-i18n'\n import { useChatbotStore } from 'composables'\n import PkAvatar from './PkAvatar.vue'\n import { ChatbotProfileContextKey } from './chatbotProfileContext'\n\n const props = defineProps<{ agentId: string }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const store = useChatbotStore(props.agentId)\n const { name: agentName, agentInterface } = storeToRefs(store)\n\n const profile = inject(ChatbotProfileContextKey, undefined)\n const user = computed(() => profile?.user.value ?? null)\n const canManage = computed(() => profile?.canManageProfile.value ?? false)\n const profileUrl = computed(() => profile?.profileUrl.value)\n // External token mode: the host owns the auth lifecycle, so the widget\n // offers no sign-out nor profile management (the main site is not\n // accessible to externally authenticated users).\n const isExternalAuth = computed(\n () => profile?.isExternalAuth?.value ?? false,\n )\n\n const isSigningOut = ref(false)\n const errorMessage = ref<string>()\n\n async function onSignOut() {\n if (!profile) {\n return\n }\n isSigningOut.value = true\n try {\n await profile.signOut()\n } catch (error) {\n errorMessage.value =\n error instanceof Error ? error.message : $t('message.error')\n } finally {\n isSigningOut.value = false\n }\n }\n</script>\n\n<template>\n <div class=\"flex flex-col flex-1 min-h-0 overflow-y-auto\">\n <!-- Hero: user identity -->\n <div\n class=\"flex flex-col items-center gap-sm pt-lg px-lg pb-md bg-surface-1 border-b border-surface-3\">\n <PkAvatar\n modifiers=\"surface ring\"\n class=\"w-64 h-64\"\n :name=\"user?.name ?? agentName\"\n :img-src=\"user?.image ?? agentInterface?.logo\" />\n <div class=\"flex flex-col items-center gap-6 text-center\">\n <strong\n v-if=\"user?.name ?? agentName\"\n class=\"text-16 font-semibold text-word-1 leading-tight\">\n {{ user?.name ?? agentName }}\n </strong>\n <span\n v-if=\"user?.email\"\n class=\"text-12 text-word-3 leading-none\">\n {{ user.email }}\n </span>\n </div>\n </div>\n\n <!-- Actions -->\n <div class=\"flex flex-col gap-sm p-md flex-1\">\n <VvAlert\n v-if=\"errorMessage\"\n modifiers=\"danger\"\n :content=\"errorMessage\" />\n\n <!-- Manage profile link card -->\n <a\n v-if=\"canManage && profileUrl && !isExternalAuth\"\n :href=\"profileUrl\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"flex items-center gap-12 p-12 rounded-lg border border-surface-3 hover:border-surface-5 hover:bg-surface-1 transition-colors cursor-pointer no-underline\">\n <div\n class=\"w-40 h-40 rounded-lg bg-surface-2 border border-surface-3 flex items-center justify-center shrink-0\">\n <VvIcon\n name=\"ri:user-settings-line\"\n class=\"w-20 h-20 text-word-2\" />\n </div>\n <div class=\"flex flex-col flex-1 min-w-0 gap-1\">\n <span class=\"text-14 font-medium text-word-1 leading-tight\">\n {{ $t('action.manageProfile') }}\n </span>\n <span class=\"text-12 text-word-3 leading-tight\">\n {{ $t('label.manageProfileDescription') }}\n </span>\n </div>\n <VvIcon\n name=\"ri:arrow-right-s-line\"\n class=\"w-16 h-16 text-word-4 shrink-0\" />\n </a>\n </div>\n\n <!-- Footer: sign out -->\n <div v-if=\"!isExternalAuth\" class=\"px-md py-sm\">\n <VvButton\n modifiers=\"secondary-danger\"\n class=\"w-full\"\n icon=\"ri:logout-box-line\"\n :loading=\"isSigningOut\"\n :disabled=\"isSigningOut\"\n :label=\"$t('action.signOut')\"\n @click=\"onSignOut\" />\n </div>\n\n <slot />\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, inject, ref } from 'vue'\n import { storeToRefs } from 'pinia'\n import { useI18n } from 'vue-i18n'\n import { useChatbotStore } from 'composables'\n import PkAvatar from './PkAvatar.vue'\n import { ChatbotProfileContextKey } from './chatbotProfileContext'\n\n const props = defineProps<{ agentId: string }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const store = useChatbotStore(props.agentId)\n const { name: agentName, agentInterface } = storeToRefs(store)\n\n const profile = inject(ChatbotProfileContextKey, undefined)\n const user = computed(() => profile?.user.value ?? null)\n const canManage = computed(() => profile?.canManageProfile.value ?? false)\n const profileUrl = computed(() => profile?.profileUrl.value)\n // External token mode: the host owns the auth lifecycle, so the widget\n // offers no sign-out nor profile management (the main site is not\n // accessible to externally authenticated users).\n const isExternalAuth = computed(\n () => profile?.isExternalAuth?.value ?? false,\n )\n\n const isSigningOut = ref(false)\n const errorMessage = ref<string>()\n\n async function onSignOut() {\n if (!profile) {\n return\n }\n isSigningOut.value = true\n try {\n await profile.signOut()\n } catch (error) {\n errorMessage.value =\n error instanceof Error ? error.message : $t('message.error')\n } finally {\n isSigningOut.value = false\n }\n }\n</script>\n\n<template>\n <div class=\"flex flex-col flex-1 min-h-0 overflow-y-auto\">\n <!-- Hero: user identity -->\n <div\n class=\"flex flex-col items-center gap-sm pt-lg px-lg pb-md bg-surface-1 border-b border-surface-3\">\n <PkAvatar\n modifiers=\"surface ring\"\n class=\"w-64 h-64\"\n :name=\"user?.name ?? agentName\"\n :img-src=\"user?.image ?? agentInterface?.logo\" />\n <div class=\"flex flex-col items-center gap-6 text-center\">\n <strong\n v-if=\"user?.name ?? agentName\"\n class=\"text-16 font-semibold text-word-1 leading-tight\">\n {{ user?.name ?? agentName }}\n </strong>\n <span\n v-if=\"user?.email\"\n class=\"text-12 text-word-3 leading-none\">\n {{ user.email }}\n </span>\n </div>\n </div>\n\n <!-- Actions -->\n <div class=\"flex flex-col gap-sm p-md flex-1\">\n <VvAlert\n v-if=\"errorMessage\"\n modifiers=\"danger\"\n :content=\"errorMessage\" />\n\n <!-- Manage profile link card -->\n <a\n v-if=\"canManage && profileUrl && !isExternalAuth\"\n :href=\"profileUrl\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"flex items-center gap-12 p-12 rounded-lg border border-surface-3 hover:border-surface-5 hover:bg-surface-1 transition-colors cursor-pointer no-underline\">\n <div\n class=\"w-40 h-40 rounded-lg bg-surface-2 border border-surface-3 flex items-center justify-center shrink-0\">\n <VvIcon\n name=\"ri:user-settings-line\"\n class=\"w-20 h-20 text-word-2\" />\n </div>\n <div class=\"flex flex-col flex-1 min-w-0 gap-1\">\n <span class=\"text-14 font-medium text-word-1 leading-tight\">\n {{ $t('action.manageProfile') }}\n </span>\n <span class=\"text-12 text-word-3 leading-tight\">\n {{ $t('label.manageProfileDescription') }}\n </span>\n </div>\n <VvIcon\n name=\"ri:arrow-right-s-line\"\n class=\"w-16 h-16 text-word-4 shrink-0\" />\n </a>\n </div>\n\n <!-- Footer: sign out -->\n <div v-if=\"!isExternalAuth\" class=\"px-md py-sm\">\n <VvButton\n modifiers=\"secondary-danger\"\n class=\"w-full\"\n icon=\"ri:logout-box-line\"\n :loading=\"isSigningOut\"\n :disabled=\"isSigningOut\"\n :label=\"$t('action.signOut')\"\n @click=\"onSignOut\" />\n </div>\n\n <slot />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAQI,IAAM,IAAQ,GAER,EAAE,GAAG,MAAO,EAAQ,EAAE,UAAU,SAAS,CAAC,GAE1C,IAAQ,EAAgB,EAAM,OAAO,GACrC,EAAE,MAAM,GAAW,sBAAmB,EAAY,CAAK,GAEvD,IAAU,EAAO,GAA0B,KAAA,CAA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AuBI,KAAA;;KArBC,MAAM,EAAA;KACP,QAAO;KACP,KAAI;KACJ,OAAM;;KACN,EAKM,OALN,GAKM,CAHF,EAEoC,GAAA;MADhC,MAAK;MACL,OAAM;;KAEd,EAOM,OAPN,GAOM,CANF,EAEO,QAFP,GAEO,EADA,EAAA,CAAA,CAAE,CAAA,sBAAA,CAAA,GAAA,CAAA,GAET,EAEO,QAFP,GAEO,EADA,EAAA,CAAA,CAAE,CAAA,gCAAA,CAAA,GAAA,CAAA,CAAA,CAAA;KAGb,EAE6C,GAAA;MADzC,MAAK;MACL,OAAM;;;IAKN,EAAA,qBAAZ,EAAA,GAAA,EASM,OATN,GASM,CARF,EAOyB,GAAA;KANrB,WAAU;KACV,OAAM;KACN,MAAK;KACJ,SAAS,EAAA;KACT,UAAU,EAAA;KACV,OAAO,EAAA,CAAA,CAAE,CAAA,gBAAA;KACT,SAAO;;;;;;IAGhB,EAAQ,EAAA,QAAA,SAAA"}
|
|
1
|
+
{"version":3,"file":"PkChatbotViewProfile-DzfZnitQ.js","names":[],"sources":["../../../../packages/components/src/chat/PkChatbotViewProfile.vue","../../../../packages/components/src/chat/PkChatbotViewProfile.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, inject, ref } from 'vue'\n import { storeToRefs } from 'pinia'\n import { useI18n } from 'vue-i18n'\n import { useChatbotStore } from 'composables'\n import PkAvatar from './PkAvatar.vue'\n import { ChatbotProfileContextKey } from './chatbotProfileContext'\n\n const props = defineProps<{ agentId: string }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const store = useChatbotStore(props.agentId)\n const { name: agentName, agentInterface } = storeToRefs(store)\n\n const profile = inject(ChatbotProfileContextKey, undefined)\n const user = computed(() => profile?.user.value ?? null)\n const canManage = computed(() => profile?.canManageProfile.value ?? false)\n const profileUrl = computed(() => profile?.profileUrl.value)\n // External token mode: the host owns the auth lifecycle, so the widget\n // offers no sign-out nor profile management (the main site is not\n // accessible to externally authenticated users).\n const isExternalAuth = computed(\n () => profile?.isExternalAuth?.value ?? false,\n )\n\n const isSigningOut = ref(false)\n const errorMessage = ref<string>()\n\n async function onSignOut() {\n if (!profile) {\n return\n }\n isSigningOut.value = true\n try {\n await profile.signOut()\n } catch (error) {\n errorMessage.value =\n error instanceof Error ? error.message : $t('message.error')\n } finally {\n isSigningOut.value = false\n }\n }\n</script>\n\n<template>\n <div class=\"flex flex-col flex-1 min-h-0 overflow-y-auto\">\n <!-- Hero: user identity -->\n <div\n class=\"flex flex-col items-center gap-sm pt-lg px-lg pb-md bg-surface-1 border-b border-surface-3\">\n <PkAvatar\n modifiers=\"surface ring\"\n class=\"w-64 h-64\"\n :name=\"user?.name ?? agentName\"\n :img-src=\"user?.image ?? agentInterface?.logo\" />\n <div class=\"flex flex-col items-center gap-6 text-center\">\n <strong\n v-if=\"user?.name ?? agentName\"\n class=\"text-16 font-semibold text-word-1 leading-tight\">\n {{ user?.name ?? agentName }}\n </strong>\n <span\n v-if=\"user?.email\"\n class=\"text-12 text-word-3 leading-none\">\n {{ user.email }}\n </span>\n </div>\n </div>\n\n <!-- Actions -->\n <div class=\"flex flex-col gap-sm p-md flex-1\">\n <VvAlert\n v-if=\"errorMessage\"\n modifiers=\"danger\"\n :content=\"errorMessage\" />\n\n <!-- Manage profile link card -->\n <a\n v-if=\"canManage && profileUrl && !isExternalAuth\"\n :href=\"profileUrl\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"flex items-center gap-12 p-12 rounded-lg border border-surface-3 hover:border-surface-5 hover:bg-surface-1 transition-colors cursor-pointer no-underline\">\n <div\n class=\"w-40 h-40 rounded-lg bg-surface-2 border border-surface-3 flex items-center justify-center shrink-0\">\n <VvIcon\n name=\"ri:user-settings-line\"\n class=\"w-20 h-20 text-word-2\" />\n </div>\n <div class=\"flex flex-col flex-1 min-w-0 gap-1\">\n <span class=\"text-14 font-medium text-word-1 leading-tight\">\n {{ $t('action.manageProfile') }}\n </span>\n <span class=\"text-12 text-word-3 leading-tight\">\n {{ $t('label.manageProfileDescription') }}\n </span>\n </div>\n <VvIcon\n name=\"ri:arrow-right-s-line\"\n class=\"w-16 h-16 text-word-4 shrink-0\" />\n </a>\n </div>\n\n <!-- Footer: sign out -->\n <div v-if=\"!isExternalAuth\" class=\"px-md py-sm\">\n <VvButton\n modifiers=\"secondary-danger\"\n class=\"w-full\"\n icon=\"ri:logout-box-line\"\n :loading=\"isSigningOut\"\n :disabled=\"isSigningOut\"\n :label=\"$t('action.signOut')\"\n @click=\"onSignOut\" />\n </div>\n\n <slot />\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, inject, ref } from 'vue'\n import { storeToRefs } from 'pinia'\n import { useI18n } from 'vue-i18n'\n import { useChatbotStore } from 'composables'\n import PkAvatar from './PkAvatar.vue'\n import { ChatbotProfileContextKey } from './chatbotProfileContext'\n\n const props = defineProps<{ agentId: string }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const store = useChatbotStore(props.agentId)\n const { name: agentName, agentInterface } = storeToRefs(store)\n\n const profile = inject(ChatbotProfileContextKey, undefined)\n const user = computed(() => profile?.user.value ?? null)\n const canManage = computed(() => profile?.canManageProfile.value ?? false)\n const profileUrl = computed(() => profile?.profileUrl.value)\n // External token mode: the host owns the auth lifecycle, so the widget\n // offers no sign-out nor profile management (the main site is not\n // accessible to externally authenticated users).\n const isExternalAuth = computed(\n () => profile?.isExternalAuth?.value ?? false,\n )\n\n const isSigningOut = ref(false)\n const errorMessage = ref<string>()\n\n async function onSignOut() {\n if (!profile) {\n return\n }\n isSigningOut.value = true\n try {\n await profile.signOut()\n } catch (error) {\n errorMessage.value =\n error instanceof Error ? error.message : $t('message.error')\n } finally {\n isSigningOut.value = false\n }\n }\n</script>\n\n<template>\n <div class=\"flex flex-col flex-1 min-h-0 overflow-y-auto\">\n <!-- Hero: user identity -->\n <div\n class=\"flex flex-col items-center gap-sm pt-lg px-lg pb-md bg-surface-1 border-b border-surface-3\">\n <PkAvatar\n modifiers=\"surface ring\"\n class=\"w-64 h-64\"\n :name=\"user?.name ?? agentName\"\n :img-src=\"user?.image ?? agentInterface?.logo\" />\n <div class=\"flex flex-col items-center gap-6 text-center\">\n <strong\n v-if=\"user?.name ?? agentName\"\n class=\"text-16 font-semibold text-word-1 leading-tight\">\n {{ user?.name ?? agentName }}\n </strong>\n <span\n v-if=\"user?.email\"\n class=\"text-12 text-word-3 leading-none\">\n {{ user.email }}\n </span>\n </div>\n </div>\n\n <!-- Actions -->\n <div class=\"flex flex-col gap-sm p-md flex-1\">\n <VvAlert\n v-if=\"errorMessage\"\n modifiers=\"danger\"\n :content=\"errorMessage\" />\n\n <!-- Manage profile link card -->\n <a\n v-if=\"canManage && profileUrl && !isExternalAuth\"\n :href=\"profileUrl\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"flex items-center gap-12 p-12 rounded-lg border border-surface-3 hover:border-surface-5 hover:bg-surface-1 transition-colors cursor-pointer no-underline\">\n <div\n class=\"w-40 h-40 rounded-lg bg-surface-2 border border-surface-3 flex items-center justify-center shrink-0\">\n <VvIcon\n name=\"ri:user-settings-line\"\n class=\"w-20 h-20 text-word-2\" />\n </div>\n <div class=\"flex flex-col flex-1 min-w-0 gap-1\">\n <span class=\"text-14 font-medium text-word-1 leading-tight\">\n {{ $t('action.manageProfile') }}\n </span>\n <span class=\"text-12 text-word-3 leading-tight\">\n {{ $t('label.manageProfileDescription') }}\n </span>\n </div>\n <VvIcon\n name=\"ri:arrow-right-s-line\"\n class=\"w-16 h-16 text-word-4 shrink-0\" />\n </a>\n </div>\n\n <!-- Footer: sign out -->\n <div v-if=\"!isExternalAuth\" class=\"px-md py-sm\">\n <VvButton\n modifiers=\"secondary-danger\"\n class=\"w-full\"\n icon=\"ri:logout-box-line\"\n :loading=\"isSigningOut\"\n :disabled=\"isSigningOut\"\n :label=\"$t('action.signOut')\"\n @click=\"onSignOut\" />\n </div>\n\n <slot />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAQI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AA,GAAA,EAG8B,GAAA;;KAD1B,WAAU;KACT,SAAS,EAAA;IAIJ,GAAA,MAAA,GAAA,CAAA,SAAA,CAAA,KAAA,EAAA,IAAA,EAAA,GAAA,EAAA,SAAa,EAAA,SAAU,CAAK,EAAA,SADtC,EAAA,GAAA,EAuBI,KAAA;;KArBC,MAAM,EAAA;KACP,QAAO;KACP,KAAI;KACJ,OAAM;;KACN,EAKM,OALN,GAKM,CAHF,EAEoC,GAAA;MADhC,MAAK;MACL,OAAM;;KAEd,EAOM,OAPN,GAOM,CANF,EAEO,QAFP,GAEO,EADA,EAAA,CAAA,CAAE,CAAA,sBAAA,CAAA,GAAA,CAAA,GAET,EAEO,QAFP,GAEO,EADA,EAAA,CAAA,CAAE,CAAA,gCAAA,CAAA,GAAA,CAAA,CAAA,CAAA;KAGb,EAE6C,GAAA;MADzC,MAAK;MACL,OAAM;;;IAKN,EAAA,qBAAZ,EAAA,GAAA,EASM,OATN,GASM,CARF,EAOyB,GAAA;KANrB,WAAU;KACV,OAAM;KACN,MAAK;KACJ,SAAS,EAAA;KACT,UAAU,EAAA;KACV,OAAO,EAAA,CAAA,CAAE,CAAA,gBAAA;KACT,SAAO;;;;;;IAGhB,EAAQ,EAAA,QAAA,SAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./src-DT8FLE4_.js";
|
|
2
|
-
import { a as e } from "./PkChatbotMessages-
|
|
2
|
+
import { a as e } from "./PkChatbotMessages-BFlU046I.js";
|
|
3
3
|
import { t } from "./PkSvgViewer-DPpE9fiz.js";
|
|
4
4
|
import { VvButton as n, VvButtonGroup as r, VvIcon as i } from "@volverjs/ui-vue/components";
|
|
5
5
|
import { computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createVNode as u, defineComponent as d, onMounted as f, openBlock as p, ref as m, toDisplayString as h, unref as g, watch as _, withCtx as v } from "vue";
|
|
@@ -119,4 +119,4 @@ var x = {
|
|
|
119
119
|
//#endregion
|
|
120
120
|
export { k as default };
|
|
121
121
|
|
|
122
|
-
//# sourceMappingURL=PkToolShowDiagram-
|
|
122
|
+
//# sourceMappingURL=PkToolShowDiagram-DuDp5EHd.js.map
|
package/dist-vue/_chunks/{PkToolShowDiagram-CNBaJZlp.js.map → PkToolShowDiagram-DuDp5EHd.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowDiagram-CNBaJZlp.js","names":[],"sources":["../../../../packages/components/src/chat/PkToolShowDiagram.vue","../../../../packages/components/src/chat/PkToolShowDiagram.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, onMounted, ref, watch } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import { toSnakeCase } from 'utils'\n import PkSvgViewer from '../PkSvgViewer.vue'\n\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const { t: $t, te: $te } = useI18n({\n useScope: 'global',\n })\n\n const { copy, copied } = useClipboard()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n code: string\n title?: string\n caption?: string\n }\n }\n return part\n })\n\n const svgError = ref(false)\n\n // Serialized SVG content\n const svgContent = ref('')\n\n enum DiagramType {\n Sequence = 'sequenceDiagram',\n Class = 'classDiagram',\n State = 'stateDiagram',\n ER = 'erDiagram',\n XYChart = 'xychart',\n Flowchart = 'flowchart',\n Graph = 'graph',\n }\n\n const diagramType = computed<DiagramType | undefined>(() => {\n const code = toolPart.value.input?.code?.trimStart()\n if (!code) {\n return undefined\n }\n const firstWord = code.match(/^[A-Za-z-]+/)?.[0]\n switch (firstWord) {\n case 'sequenceDiagram':\n return DiagramType.Sequence\n case 'classDiagram':\n return DiagramType.Class\n case 'stateDiagram':\n return DiagramType.State\n case 'erDiagram':\n return DiagramType.ER\n case 'xychart-beta':\n return DiagramType.XYChart\n case 'flowchart':\n return DiagramType.Flowchart\n case 'graph':\n return DiagramType.Graph\n default:\n return undefined\n }\n })\n\n const diagramTypeLabel = computed(() => {\n if (!diagramType.value) {\n return ''\n }\n return $te(`diagram.${diagramType.value}`)\n ? $t(`diagram.${diagramType.value}`)\n : diagramType.value\n })\n\n const diagramTypeIcon = computed(() => {\n switch (diagramType.value) {\n case DiagramType.Sequence:\n return 'ri:timeline-view'\n case DiagramType.Class:\n return 'ri:organization-chart'\n case DiagramType.State:\n return 'ri:organization-chart'\n case DiagramType.ER:\n return 'ri:organization-chart'\n case DiagramType.XYChart:\n return 'ri:line-chart-line'\n case DiagramType.Flowchart:\n return 'ri:flow-chart'\n case DiagramType.Graph:\n return 'ri:flow-chart'\n default:\n return 'ri:flow-chart'\n }\n })\n\n async function renderDiagram() {\n const code = toolPart.value.input?.code\n if (!code) return\n\n svgError.value = false\n try {\n const { renderMermaidSVG, THEMES } =\n await import('beautiful-mermaid')\n const theme = props.isDark\n ? THEMES['github-dark']\n : THEMES['github-light']\n svgContent.value = renderMermaidSVG(code, theme)\n } catch {\n svgError.value = true\n }\n }\n\n watch([() => toolPart.value.input?.code, () => props.isDark], renderDiagram)\n onMounted(async () => {\n await renderDiagram()\n })\n\n const downloadSvg = () => {\n if (!svgContent.value) {\n return\n }\n const blob = new Blob([svgContent.value], {\n type: 'image/svg+xml;charset=utf-8',\n })\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(toolPart.value.input?.title || 'diagram')}.svg`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n\n const copyCode = () => {\n const code = toolPart.value.input?.code\n if (code) {\n copy(code)\n }\n }\n</script>\n\n<template>\n <div\n v-if=\"toolPart?.input?.code\"\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"diagramTypeIcon\" class=\"text-16\" />\n <div class=\"flex flex-col items-start gap-2\">\n <strong class=\"font-bold\">{{\n diagramTypeLabel ?? $t('label.diagram')\n }}</strong>\n </div>\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n @click=\"copyCode\" />\n <VvButton\n v-if=\"svgContent\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n @click=\"downloadSvg\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"svgError\" class=\"text-12 text-danger py-8 px-sm\">\n {{ $t('message.diagramRenderError') }}\n </div>\n <PkSvgViewer\n v-else-if=\"svgContent\"\n class=\"pk-tool-show-diagram__stage\"\n :svg=\"svgContent\"\n :title=\"toolPart.input?.title\" />\n <div\n v-else\n class=\"pk-tool-show-diagram__stage flex justify-center items-center\">\n <VvIcon name=\"line-md:loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-if=\"toolPart.input.caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ toolPart.input.caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-diagram {\n // Fixed stage height: the diagram renders lazily (async chunk +\n // dynamic mermaid import), so the loader and the rendered SVG must\n // occupy the same space or the chat scroll position jumps around.\n // The SVG scales to fit; zoom/pan and the lightbox cover the rest.\n &__stage {\n height: 384px;\n\n .pk-svg-viewer__stage,\n .pk-svg-viewer__content {\n height: 100%;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed, onMounted, ref, watch } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import { toSnakeCase } from 'utils'\n import PkSvgViewer from '../PkSvgViewer.vue'\n\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const { t: $t, te: $te } = useI18n({\n useScope: 'global',\n })\n\n const { copy, copied } = useClipboard()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n code: string\n title?: string\n caption?: string\n }\n }\n return part\n })\n\n const svgError = ref(false)\n\n // Serialized SVG content\n const svgContent = ref('')\n\n enum DiagramType {\n Sequence = 'sequenceDiagram',\n Class = 'classDiagram',\n State = 'stateDiagram',\n ER = 'erDiagram',\n XYChart = 'xychart',\n Flowchart = 'flowchart',\n Graph = 'graph',\n }\n\n const diagramType = computed<DiagramType | undefined>(() => {\n const code = toolPart.value.input?.code?.trimStart()\n if (!code) {\n return undefined\n }\n const firstWord = code.match(/^[A-Za-z-]+/)?.[0]\n switch (firstWord) {\n case 'sequenceDiagram':\n return DiagramType.Sequence\n case 'classDiagram':\n return DiagramType.Class\n case 'stateDiagram':\n return DiagramType.State\n case 'erDiagram':\n return DiagramType.ER\n case 'xychart-beta':\n return DiagramType.XYChart\n case 'flowchart':\n return DiagramType.Flowchart\n case 'graph':\n return DiagramType.Graph\n default:\n return undefined\n }\n })\n\n const diagramTypeLabel = computed(() => {\n if (!diagramType.value) {\n return ''\n }\n return $te(`diagram.${diagramType.value}`)\n ? $t(`diagram.${diagramType.value}`)\n : diagramType.value\n })\n\n const diagramTypeIcon = computed(() => {\n switch (diagramType.value) {\n case DiagramType.Sequence:\n return 'ri:timeline-view'\n case DiagramType.Class:\n return 'ri:organization-chart'\n case DiagramType.State:\n return 'ri:organization-chart'\n case DiagramType.ER:\n return 'ri:organization-chart'\n case DiagramType.XYChart:\n return 'ri:line-chart-line'\n case DiagramType.Flowchart:\n return 'ri:flow-chart'\n case DiagramType.Graph:\n return 'ri:flow-chart'\n default:\n return 'ri:flow-chart'\n }\n })\n\n async function renderDiagram() {\n const code = toolPart.value.input?.code\n if (!code) return\n\n svgError.value = false\n try {\n const { renderMermaidSVG, THEMES } =\n await import('beautiful-mermaid')\n const theme = props.isDark\n ? THEMES['github-dark']\n : THEMES['github-light']\n svgContent.value = renderMermaidSVG(code, theme)\n } catch {\n svgError.value = true\n }\n }\n\n watch([() => toolPart.value.input?.code, () => props.isDark], renderDiagram)\n onMounted(async () => {\n await renderDiagram()\n })\n\n const downloadSvg = () => {\n if (!svgContent.value) {\n return\n }\n const blob = new Blob([svgContent.value], {\n type: 'image/svg+xml;charset=utf-8',\n })\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(toolPart.value.input?.title || 'diagram')}.svg`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n\n const copyCode = () => {\n const code = toolPart.value.input?.code\n if (code) {\n copy(code)\n }\n }\n</script>\n\n<template>\n <div\n v-if=\"toolPart?.input?.code\"\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"diagramTypeIcon\" class=\"text-16\" />\n <div class=\"flex flex-col items-start gap-2\">\n <strong class=\"font-bold\">{{\n diagramTypeLabel ?? $t('label.diagram')\n }}</strong>\n </div>\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n @click=\"copyCode\" />\n <VvButton\n v-if=\"svgContent\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n @click=\"downloadSvg\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"svgError\" class=\"text-12 text-danger py-8 px-sm\">\n {{ $t('message.diagramRenderError') }}\n </div>\n <PkSvgViewer\n v-else-if=\"svgContent\"\n class=\"pk-tool-show-diagram__stage\"\n :svg=\"svgContent\"\n :title=\"toolPart.input?.title\" />\n <div\n v-else\n class=\"pk-tool-show-diagram__stage flex justify-center items-center\">\n <VvIcon name=\"line-md:loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-if=\"toolPart.input.caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ toolPart.input.caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-diagram {\n // Fixed stage height: the diagram renders lazily (async chunk +\n // dynamic mermaid import), so the loader and the rendered SVG must\n // occupy the same space or the chat scroll position jumps around.\n // The SVG scales to fit; zoom/pan and the lightbox cover the rest.\n &__stage {\n height: 384px;\n\n .pk-svg-viewer__stage,\n .pk-svg-viewer__content {\n height: 100%;\n }\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;GAkCS,IAAL,yBAAA,GAAA;QACI,EAAA,WAAA,mBACA,EAAA,QAAA,gBACA,EAAA,QAAA,gBACA,EAAA,KAAA,aACA,EAAA,UAAA,WACA,EAAA,YAAA,aACA,EAAA,QAAA;AACJ,EARK,KAAA,CAAA,CAQL;;;;;;;EAnCA,IAAM,IAAQ,GAKR,EAAE,GAAG,GAAI,IAAI,MAAQ,EAAQ,EAC/B,UAAU,SACd,CAAC,GAEK,EAAE,SAAM,cAAW,EAAa,GAEhC,IAAW,QACA,EAAM,IAQtB,GAEK,IAAW,EAAI,EAAK,GAGpB,IAAa,EAAI,EAAE,GAYnB,IAAc,QAAwC;GACxD,IAAM,IAAO,EAAS,MAAM,OAAO,MAAM,UAAU;GAC9C,OAIL,QADkB,EAAK,MAAM,aAAa,CAAC,GAAG,IAC9C;IACI,KAAK,mBACD,OAAO,EAAY;IACvB,KAAK,gBACD,OAAO,EAAY;IACvB,KAAK,gBACD,OAAO,EAAY;IACvB,KAAK,aACD,OAAO,EAAY;IACvB,KAAK,gBACD,OAAO,EAAY;IACvB,KAAK,aACD,OAAO,EAAY;IACvB,KAAK,SACD,OAAO,EAAY;IACvB,SACI;GACR;EACJ,CAAC,GAEK,IAAmB,QAChB,EAAY,QAGV,EAAI,WAAW,E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../packages/components/src/chat/PkToolShowDiagram.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, onMounted, ref, watch } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import { toSnakeCase } from 'utils'\n import PkSvgViewer from '../PkSvgViewer.vue'\n\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const { t: $t, te: $te } = useI18n({\n useScope: 'global',\n })\n\n const { copy, copied } = useClipboard()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n code: string\n title?: string\n caption?: string\n }\n }\n return part\n })\n\n const svgError = ref(false)\n\n // Serialized SVG content\n const svgContent = ref('')\n\n enum DiagramType {\n Sequence = 'sequenceDiagram',\n Class = 'classDiagram',\n State = 'stateDiagram',\n ER = 'erDiagram',\n XYChart = 'xychart',\n Flowchart = 'flowchart',\n Graph = 'graph',\n }\n\n const diagramType = computed<DiagramType | undefined>(() => {\n const code = toolPart.value.input?.code?.trimStart()\n if (!code) {\n return undefined\n }\n const firstWord = code.match(/^[A-Za-z-]+/)?.[0]\n switch (firstWord) {\n case 'sequenceDiagram':\n return DiagramType.Sequence\n case 'classDiagram':\n return DiagramType.Class\n case 'stateDiagram':\n return DiagramType.State\n case 'erDiagram':\n return DiagramType.ER\n case 'xychart-beta':\n return DiagramType.XYChart\n case 'flowchart':\n return DiagramType.Flowchart\n case 'graph':\n return DiagramType.Graph\n default:\n return undefined\n }\n })\n\n const diagramTypeLabel = computed(() => {\n if (!diagramType.value) {\n return ''\n }\n return $te(`diagram.${diagramType.value}`)\n ? $t(`diagram.${diagramType.value}`)\n : diagramType.value\n })\n\n const diagramTypeIcon = computed(() => {\n switch (diagramType.value) {\n case DiagramType.Sequence:\n return 'ri:timeline-view'\n case DiagramType.Class:\n return 'ri:organization-chart'\n case DiagramType.State:\n return 'ri:organization-chart'\n case DiagramType.ER:\n return 'ri:organization-chart'\n case DiagramType.XYChart:\n return 'ri:line-chart-line'\n case DiagramType.Flowchart:\n return 'ri:flow-chart'\n case DiagramType.Graph:\n return 'ri:flow-chart'\n default:\n return 'ri:flow-chart'\n }\n })\n\n async function renderDiagram() {\n const code = toolPart.value.input?.code\n if (!code) return\n\n svgError.value = false\n try {\n const { renderMermaidSVG, THEMES } =\n await import('beautiful-mermaid')\n const theme = props.isDark\n ? THEMES['github-dark']\n : THEMES['github-light']\n svgContent.value = renderMermaidSVG(code, theme)\n } catch {\n svgError.value = true\n }\n }\n\n watch([() => toolPart.value.input?.code, () => props.isDark], renderDiagram)\n onMounted(async () => {\n await renderDiagram()\n })\n\n const downloadSvg = () => {\n if (!svgContent.value) {\n return\n }\n const blob = new Blob([svgContent.value], {\n type: 'image/svg+xml;charset=utf-8',\n })\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(toolPart.value.input?.title || 'diagram')}.svg`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n\n const copyCode = () => {\n const code = toolPart.value.input?.code\n if (code) {\n copy(code)\n }\n }\n</script>\n\n<template>\n <div\n v-if=\"toolPart?.input?.code\"\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"diagramTypeIcon\" class=\"text-16\" />\n <div class=\"flex flex-col items-start gap-2\">\n <strong class=\"font-bold\">{{\n diagramTypeLabel ?? $t('label.diagram')\n }}</strong>\n </div>\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n @click=\"copyCode\" />\n <VvButton\n v-if=\"svgContent\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n @click=\"downloadSvg\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"svgError\" class=\"text-12 text-danger py-8 px-sm\">\n {{ $t('message.diagramRenderError') }}\n </div>\n <PkSvgViewer\n v-else-if=\"svgContent\"\n class=\"pk-tool-show-diagram__stage\"\n :svg=\"svgContent\"\n :title=\"toolPart.input?.title\" />\n <div\n v-else\n class=\"pk-tool-show-diagram__stage flex justify-center items-center\">\n <VvIcon name=\"line-md:loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-if=\"toolPart.input.caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ toolPart.input.caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-diagram {\n // Fixed stage height: the diagram renders lazily (async chunk +\n // dynamic mermaid import), so the loader and the rendered SVG must\n // occupy the same space or the chat scroll position jumps around.\n // The SVG scales to fit; zoom/pan and the lightbox cover the rest.\n &__stage {\n height: 384px;\n\n .pk-svg-viewer__stage,\n .pk-svg-viewer__content {\n height: 100%;\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed, onMounted, ref, watch } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import { toSnakeCase } from 'utils'\n import PkSvgViewer from '../PkSvgViewer.vue'\n\n const props = defineProps<{\n part: unknown\n isDark?: boolean\n }>()\n\n const { t: $t, te: $te } = useI18n({\n useScope: 'global',\n })\n\n const { copy, copied } = useClipboard()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n code: string\n title?: string\n caption?: string\n }\n }\n return part\n })\n\n const svgError = ref(false)\n\n // Serialized SVG content\n const svgContent = ref('')\n\n enum DiagramType {\n Sequence = 'sequenceDiagram',\n Class = 'classDiagram',\n State = 'stateDiagram',\n ER = 'erDiagram',\n XYChart = 'xychart',\n Flowchart = 'flowchart',\n Graph = 'graph',\n }\n\n const diagramType = computed<DiagramType | undefined>(() => {\n const code = toolPart.value.input?.code?.trimStart()\n if (!code) {\n return undefined\n }\n const firstWord = code.match(/^[A-Za-z-]+/)?.[0]\n switch (firstWord) {\n case 'sequenceDiagram':\n return DiagramType.Sequence\n case 'classDiagram':\n return DiagramType.Class\n case 'stateDiagram':\n return DiagramType.State\n case 'erDiagram':\n return DiagramType.ER\n case 'xychart-beta':\n return DiagramType.XYChart\n case 'flowchart':\n return DiagramType.Flowchart\n case 'graph':\n return DiagramType.Graph\n default:\n return undefined\n }\n })\n\n const diagramTypeLabel = computed(() => {\n if (!diagramType.value) {\n return ''\n }\n return $te(`diagram.${diagramType.value}`)\n ? $t(`diagram.${diagramType.value}`)\n : diagramType.value\n })\n\n const diagramTypeIcon = computed(() => {\n switch (diagramType.value) {\n case DiagramType.Sequence:\n return 'ri:timeline-view'\n case DiagramType.Class:\n return 'ri:organization-chart'\n case DiagramType.State:\n return 'ri:organization-chart'\n case DiagramType.ER:\n return 'ri:organization-chart'\n case DiagramType.XYChart:\n return 'ri:line-chart-line'\n case DiagramType.Flowchart:\n return 'ri:flow-chart'\n case DiagramType.Graph:\n return 'ri:flow-chart'\n default:\n return 'ri:flow-chart'\n }\n })\n\n async function renderDiagram() {\n const code = toolPart.value.input?.code\n if (!code) return\n\n svgError.value = false\n try {\n const { renderMermaidSVG, THEMES } =\n await import('beautiful-mermaid')\n const theme = props.isDark\n ? THEMES['github-dark']\n : THEMES['github-light']\n svgContent.value = renderMermaidSVG(code, theme)\n } catch {\n svgError.value = true\n }\n }\n\n watch([() => toolPart.value.input?.code, () => props.isDark], renderDiagram)\n onMounted(async () => {\n await renderDiagram()\n })\n\n const downloadSvg = () => {\n if (!svgContent.value) {\n return\n }\n const blob = new Blob([svgContent.value], {\n type: 'image/svg+xml;charset=utf-8',\n })\n const url = URL.createObjectURL(blob)\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.download = `${toSnakeCase(toolPart.value.input?.title || 'diagram')}.svg`\n document.body.appendChild(anchor)\n anchor.click()\n document.body.removeChild(anchor)\n URL.revokeObjectURL(url)\n }\n\n const copyCode = () => {\n const code = toolPart.value.input?.code\n if (code) {\n copy(code)\n }\n }\n</script>\n\n<template>\n <div\n v-if=\"toolPart?.input?.code\"\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8\">\n <VvIcon :name=\"diagramTypeIcon\" class=\"text-16\" />\n <div class=\"flex flex-col items-start gap-2\">\n <strong class=\"font-bold\">{{\n diagramTypeLabel ?? $t('label.diagram')\n }}</strong>\n </div>\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto shrink-0\">\n <VvButton\n modifiers=\"action-quiet-small\"\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n @click=\"copyCode\" />\n <VvButton\n v-if=\"svgContent\"\n modifiers=\"action-quiet-small\"\n icon=\"ri:download-line\"\n :label=\"$t('action.download')\"\n @click=\"downloadSvg\" />\n </VvButtonGroup>\n </div>\n <div v-if=\"svgError\" class=\"text-12 text-danger py-8 px-sm\">\n {{ $t('message.diagramRenderError') }}\n </div>\n <PkSvgViewer\n v-else-if=\"svgContent\"\n class=\"pk-tool-show-diagram__stage\"\n :svg=\"svgContent\"\n :title=\"toolPart.input?.title\" />\n <div\n v-else\n class=\"pk-tool-show-diagram__stage flex justify-center items-center\">\n <VvIcon name=\"line-md:loading-loop\" class=\"w-24 h-24 text-word-5\" />\n </div>\n <div\n v-if=\"toolPart.input.caption\"\n class=\"px-sm py-6 bg-surface-1 min-h-40 text-12 border-t border-surface-3 text-word-3\">\n {{ toolPart.input.caption }}\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-tool-show-diagram {\n // Fixed stage height: the diagram renders lazily (async chunk +\n // dynamic mermaid import), so the loader and the rendered SVG must\n // occupy the same space or the chat scroll position jumps around.\n // The SVG scales to fit; zoom/pan and the lightbox cover the rest.\n &__stage {\n height: 384px;\n\n .pk-svg-viewer__stage,\n .pk-svg-viewer__content {\n height: 100%;\n }\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;GAkCS,IAAL,yBAAA,GAAA;QACI,EAAA,WAAA,mBACA,EAAA,QAAA,gBACA,EAAA,QAAA,gBACA,EAAA,KAAA,aACA,EAAA,UAAA,WACA,EAAA,YAAA,aACA,EAAA,QAAA;AACJ,EARK,KAAA,CAAA,CAQL;;;;;;;EAnCA,IAAM,IAAQ,GAKR,EAAE,GAAG,GAAI,IAAI,MAAQ,EAAQ,EAC/B,UAAU,SACd,CAAC,GAEK,EAAE,SAAM,cAAW,EAAa,GAEhC,IAAW,QACA,EAAM,IAQtB,GAEK,IAAW,EAAI,EAAK,GAGpB,IAAa,EAAI,EAAE,GAYnB,IAAc,QAAwC;GACxD,IAAM,IAAO,EAAS,MAAM,OAAO,MAAM,UAAU;GAC9C,OAIL,QADkB,EAAK,MAAM,aAAa,CAAC,GAAG,IAC9C;IACI,KAAK,mBACD,OAAO,EAAY;IACvB,KAAK,gBACD,OAAO,EAAY;IACvB,KAAK,gBACD,OAAO,EAAY;IACvB,KAAK,aACD,OAAO,EAAY;IACvB,KAAK,gBACD,OAAO,EAAY;IACvB,KAAK,aACD,OAAO,EAAY;IACvB,KAAK,SACD,OAAO,EAAY;IACvB,SACI;GACR;EACJ,CAAC,GAEK,IAAmB,QAChB,EAAY,QAGV,EAAI,WAAW,EAAY,OAAO,IACnC,EAAG,WAAW,EAAY,OAAO,IACjC,EAAY,QAJP,EAKd,GAEK,IAAkB,QAAe;GACnC,QAAQ,EAAY,OAApB;IACI,KAAK,EAAY,UACb,OAAO;IACX,KAAK,EAAY,OACb,OAAO;IACX,KAAK,EAAY,OACb,OAAO;IACX,KAAK,EAAY,IACb,OAAO;IACX,KAAK,EAAY,SACb,OAAO;IACX,KAAK,EAAY,WACb,OAAO;IACX,KAAK,EAAY,OACb,OAAO;IACX,SACI,OAAO;GAC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