@8wave/ai-elements 0.119.0-beta.45 → 0.119.0-beta.49
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/_chunks/{Agent-Gdgpd3LA.js → Agent-DU38SnNd.js} +411 -247
- package/dist/_chunks/Agent-DU38SnNd.js.map +1 -0
- package/dist/_chunks/{PkChatbotFilePreview-3i9jZIdS.js → PkChatbotFilePreview-Bdi4_IFu.js} +2 -2
- package/dist/_chunks/PkChatbotFilePreview-Bdi4_IFu.js.map +1 -0
- package/dist/_chunks/{PkStreamingMarkdown-B1t1tBvW.js → PkStreamingMarkdown-pEgm7m-B.js} +6 -6
- package/dist/_chunks/PkStreamingMarkdown-pEgm7m-B.js.map +1 -0
- package/dist/_chunks/{PkToolEditSpreadsheet-Xzum_9NH.js → PkToolEditSpreadsheet-Ct9pdQJ1.js} +3 -3
- package/dist/_chunks/{PkToolEditSpreadsheet-Xzum_9NH.js.map → PkToolEditSpreadsheet-Ct9pdQJ1.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestGeolocation-PxhQxMP1.js → PkToolRequestGeolocation-DzhrY8bg.js} +2 -2
- package/dist/_chunks/{PkToolRequestGeolocation-PxhQxMP1.js.map → PkToolRequestGeolocation-DzhrY8bg.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestOAuthConnection-W3ilzpr7.js → PkToolRequestOAuthConnection-CzRKRGoG.js} +2 -2
- package/dist/_chunks/{PkToolRequestOAuthConnection-W3ilzpr7.js.map → PkToolRequestOAuthConnection-CzRKRGoG.js.map} +1 -1
- package/dist/_chunks/{PkToolShowArtifact-DGGEb2LF.js → PkToolShowArtifact-D6ZTw5vh.js} +2 -2
- package/dist/_chunks/{PkToolShowArtifact-DGGEb2LF.js.map → PkToolShowArtifact-D6ZTw5vh.js.map} +1 -1
- package/dist/_chunks/{PkToolShowContactForm-Dn6CEXF_.js → PkToolShowContactForm-CW7gKQ7h.js} +2 -2
- package/dist/_chunks/{PkToolShowContactForm-Dn6CEXF_.js.map → PkToolShowContactForm-CW7gKQ7h.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-CbuToc8O.js → PkToolShowForm-D_2FmDwq.js} +3 -3
- package/dist/_chunks/{PkToolShowForm-CbuToc8O.js.map → PkToolShowForm-D_2FmDwq.js.map} +1 -1
- package/dist/_chunks/{PkToolShowImageGallery-Dh0v2Df8.js → PkToolShowImageGallery-KmMO4UuQ.js} +2 -2
- package/dist/_chunks/{PkToolShowImageGallery-Dh0v2Df8.js.map → PkToolShowImageGallery-KmMO4UuQ.js.map} +1 -1
- package/dist/_chunks/{PkToolShowProductList-bAis8u1t.js → PkToolShowProductList-cld-FOFb.js} +2 -2
- package/dist/_chunks/{PkToolShowProductList-bAis8u1t.js.map → PkToolShowProductList-cld-FOFb.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-B1zXilsH.js → PkToolShowSources-DyzheirE.js} +3 -3
- package/dist/_chunks/{PkToolShowSources-B1zXilsH.js.map → PkToolShowSources-DyzheirE.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSuggestedReply-BISQY1ce.js → PkToolShowSuggestedReply-xUBuqStM.js} +2 -2
- package/dist/_chunks/{PkToolShowSuggestedReply-BISQY1ce.js.map → PkToolShowSuggestedReply-xUBuqStM.js.map} +1 -1
- package/dist/_chunks/{PkToolShowVideo-DcMzLibC.js → PkToolShowVideo-KDNxItWl.js} +2 -2
- package/dist/_chunks/{PkToolShowVideo-DcMzLibC.js.map → PkToolShowVideo-KDNxItWl.js.map} +1 -1
- package/dist/_chunks/{PkToolShowWebPages-RuwkZDMH.js → PkToolShowWebPages-D35B7GzS.js} +2 -2
- package/dist/_chunks/{PkToolShowWebPages-RuwkZDMH.js.map → PkToolShowWebPages-D35B7GzS.js.map} +1 -1
- package/dist/_chunks/{chatImagePolicy-BL4O14e9.js → chatImagePolicy-B_6Xg-r7.js} +2 -2
- package/dist/_chunks/{chatImagePolicy-BL4O14e9.js.map → chatImagePolicy-B_6Xg-r7.js.map} +1 -1
- package/dist/_chunks/{markdown-DtdG9Krq.js → markdown-BKLfFJPr.js} +2 -2
- package/dist/_chunks/{markdown-DtdG9Krq.js.map → markdown-BKLfFJPr.js.map} +1 -1
- package/dist/ai-elements.es.js +2549 -2544
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotAuth.js +1 -1
- package/dist-vue/PkChatbotEmptyState.js +1 -1
- package/dist-vue/PkChatbotFilePreview.js +1 -1
- package/dist-vue/PkChatbotInput.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotStepPayload.js +1 -1
- package/dist-vue/PkChatbotStepToolDetail.js +1 -1
- package/dist-vue/PkChatbotSteps.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/{Agent-DGCZCx4Y.js → Agent-DDm9cCaN.js} +2 -2
- package/dist-vue/_chunks/{Agent-DGCZCx4Y.js.map → Agent-DDm9cCaN.js.map} +1 -1
- package/dist-vue/_chunks/{Document-BZea8ewV.js → Document-CZemm1AR.js} +11 -11
- package/dist-vue/_chunks/{Document-BZea8ewV.js.map → Document-CZemm1AR.js.map} +1 -1
- package/dist-vue/_chunks/Media-D-UGzdcW.js +301 -0
- package/dist-vue/_chunks/Media-D-UGzdcW.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbot-BVWLvaXb.js → PkChatbot-viqlDa9r.js} +8 -8
- package/dist-vue/_chunks/{PkChatbot-BVWLvaXb.js.map → PkChatbot-viqlDa9r.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotAuth-BVZzjbK9.js → PkChatbotAuth-CHoEXxmg.js} +8 -8
- package/dist-vue/_chunks/{PkChatbotAuth-BVZzjbK9.js.map → PkChatbotAuth-CHoEXxmg.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotEmptyState-B7fZ51v1.js → PkChatbotEmptyState-B-2GZ2ZU.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotEmptyState-B7fZ51v1.js.map → PkChatbotEmptyState-B-2GZ2ZU.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotFilePreview-Lxgu89Hg.js → PkChatbotFilePreview-D8XyjDPJ.js} +2 -2
- package/dist-vue/_chunks/PkChatbotFilePreview-D8XyjDPJ.js.map +1 -0
- package/dist-vue/_chunks/PkChatbotInput-D4bT_1be.js +392 -0
- package/dist-vue/_chunks/PkChatbotInput-D4bT_1be.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotMessages-DHZNG6YM.js → PkChatbotMessages-BgcGen7D.js} +19 -19
- package/dist-vue/_chunks/{PkChatbotMessages-DHZNG6YM.js.map → PkChatbotMessages-BgcGen7D.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepPayload-DuI9ZYqp.js → PkChatbotStepPayload-CzCHmvUG.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotStepPayload-DuI9ZYqp.js.map → PkChatbotStepPayload-CzCHmvUG.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-B9hBMl15.js → PkChatbotStepToolDetail-qSHrVOGO.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotStepToolDetail-B9hBMl15.js.map → PkChatbotStepToolDetail-qSHrVOGO.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotSteps-3qySSEYh.js → PkChatbotSteps-dgj6C2hA.js} +5 -5
- package/dist-vue/_chunks/{PkChatbotSteps-3qySSEYh.js.map → PkChatbotSteps-dgj6C2hA.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-CLyoZH3C.js → PkChatbotViewChat-BtbE6V2u.js} +259 -258
- package/dist-vue/_chunks/PkChatbotViewChat-BtbE6V2u.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotViewConversations-BbXFoEOv.js → PkChatbotViewConversations-Cw9fL47_.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewConversations-BbXFoEOv.js.map → PkChatbotViewConversations-Cw9fL47_.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewFiles-7vcERhnZ.js → PkChatbotViewFiles-DDEJqXct.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewFiles-7vcERhnZ.js.map → PkChatbotViewFiles-DDEJqXct.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewProfile-RgFp-LpV.js → PkChatbotViewProfile-B79UynQ8.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewProfile-RgFp-LpV.js.map → PkChatbotViewProfile-B79UynQ8.js.map} +1 -1
- package/dist-vue/_chunks/{PkStreamingMarkdown-Bmm1kZpL.js → PkStreamingMarkdown-DXoUbGsP.js} +3 -3
- package/dist-vue/_chunks/{PkStreamingMarkdown-Bmm1kZpL.js.map → PkStreamingMarkdown-DXoUbGsP.js.map} +1 -1
- package/dist-vue/_chunks/{PkSvgViewer-DU8K_gAD.js → PkSvgViewer-CZASatr4.js} +2 -2
- package/dist-vue/_chunks/{PkSvgViewer-DU8K_gAD.js.map → PkSvgViewer-CZASatr4.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolEditSpreadsheet-BIQky1RK.js → PkToolEditSpreadsheet-Dcp3VFzY.js} +3 -3
- package/dist-vue/_chunks/{PkToolEditSpreadsheet-BIQky1RK.js.map → PkToolEditSpreadsheet-Dcp3VFzY.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestGeolocation-CYEyXZSh.js → PkToolRequestGeolocation-DG4-qKRq.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestGeolocation-CYEyXZSh.js.map → PkToolRequestGeolocation-DG4-qKRq.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-B243GJ1-.js → PkToolRequestOAuthConnection-CZhNEM-o.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-B243GJ1-.js.map → PkToolRequestOAuthConnection-CZhNEM-o.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowArtifact-CJG-B9mE.js → PkToolShowArtifact-BRtz1x7K.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowArtifact-CJG-B9mE.js.map → PkToolShowArtifact-BRtz1x7K.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowContactForm-CG1H7xBz.js → PkToolShowContactForm-D0CR80e2.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowContactForm-CG1H7xBz.js.map → PkToolShowContactForm-D0CR80e2.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-Cq0457a3.js → PkToolShowDiagram-CYpqqWLo.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowDiagram-Cq0457a3.js.map → PkToolShowDiagram-CYpqqWLo.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-IJ8B8_yT.js → PkToolShowForm-BIsu4XhQ.js} +4 -4
- package/dist-vue/_chunks/{PkToolShowForm-IJ8B8_yT.js.map → PkToolShowForm-BIsu4XhQ.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowImageGallery-ala8nlAj.js → PkToolShowImageGallery-DkEv-6Nu.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowImageGallery-ala8nlAj.js.map → PkToolShowImageGallery-DkEv-6Nu.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowProductList-BDg84ZQN.js → PkToolShowProductList-Dr2mQqsb.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowProductList-BDg84ZQN.js.map → PkToolShowProductList-Dr2mQqsb.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-DaSijN_L.js → PkToolShowSources-CxUDh6cC.js} +3 -3
- package/dist-vue/_chunks/{PkToolShowSources-DaSijN_L.js.map → PkToolShowSources-CxUDh6cC.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-CLEFPrHP.js → PkToolShowSuggestedReply-Cl3Pswi4.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-CLEFPrHP.js.map → PkToolShowSuggestedReply-Cl3Pswi4.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowVideo-FmE-IRE7.js → PkToolShowVideo-Bh1oagOm.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowVideo-FmE-IRE7.js.map → PkToolShowVideo-Bh1oagOm.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowWebPages-B554-MlD.js → PkToolShowWebPages-ilQ1qTEC.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowWebPages-B554-MlD.js.map → PkToolShowWebPages-ilQ1qTEC.js.map} +1 -1
- package/dist-vue/_chunks/{createChatbotApiClient-CDS3C4i6.js → createChatbotApiClient-DrUsRvCw.js} +3 -3
- package/dist-vue/_chunks/{createChatbotApiClient-CDS3C4i6.js.map → createChatbotApiClient-DrUsRvCw.js.map} +1 -1
- package/dist-vue/_chunks/{useChatbotStore-CBjBe7GI.js → useChatbotStore-DHmjHPR5.js} +3 -3
- package/dist-vue/_chunks/{useChatbotStore-CBjBe7GI.js.map → useChatbotStore-DHmjHPR5.js.map} +1 -1
- package/dist-vue/_chunks/{utils-Cvijhryt.js → utils-Bopp5IPf.js} +5 -5
- package/dist-vue/_chunks/utils-Bopp5IPf.js.map +1 -0
- package/dist-vue/api.js +1 -1
- package/dist-vue/composables.js +7 -5
- package/dist-vue/composables.js.map +1 -1
- package/dist-vue/index.js +5194 -5189
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/locales.js +4 -0
- package/dist-vue/packages/models/src/schema/Media.d.ts +34 -0
- package/package.json +1 -1
- package/dist/_chunks/Agent-Gdgpd3LA.js.map +0 -1
- package/dist/_chunks/PkChatbotFilePreview-3i9jZIdS.js.map +0 -1
- package/dist/_chunks/PkStreamingMarkdown-B1t1tBvW.js.map +0 -1
- package/dist-vue/_chunks/Media-C6RS-s98.js +0 -139
- package/dist-vue/_chunks/Media-C6RS-s98.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotFilePreview-Lxgu89Hg.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotInput-Bo4Ewf6A.js +0 -388
- package/dist-vue/_chunks/PkChatbotInput-Bo4Ewf6A.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotViewChat-CLyoZH3C.js.map +0 -1
- package/dist-vue/_chunks/utils-Cvijhryt.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowContactForm-CG1H7xBz.js","names":["z.object","z.string","z.email","useForm","__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_Transition","_withCtx","_Fragment","_renderList","_createCommentVNode","_isRef","_createBlock","_createTextVNode","PkStreamingMarkdown","_sfc_main","__exportAll","string","email","object","VvButtonLocalized","PkStreamingMarkdown_default","formatPhoneNumber","useSafeLocalStorage","useLocalizedString","Se","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","PkToolShowContactForm_vue_vue_type_script_setup_true_lang_default","__emit","$t","useI18n","props","__props","toolPart","computed","input","prefilled","value","field","localSubmitted","LeadFormSchema","emit","watch","newInput","submitted","isSubmitted","submitLead","data","privacyNotice","_component_VvIcon","VvIcon","_component_VvAlert","VvAlert","_component_VvButton","openBlock","createElementBlock","createElementVNode","createVNode","toDisplayString","unref","Transition","withCtx","Fragment","renderList","createCommentVNode","VvForm","formData","_cache","isRef","$event","VvFormField","createBlock","createTextVNode","PkToolShowContactForm_exports","PkToolShowContactForm_default"],"sources":["../../../../packages/components/src/chat/PkToolShowContactForm.vue","../../../../packages/components/src/chat/PkToolShowContactForm.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, watch } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useForm } from '@volverjs/form-vue'\n import * as z from 'zod'\n import { useSafeLocalStorage, useLocalizedString } from 'composables'\n import type { LocalizedString } from 'models'\n import { formatPhoneNumber } from 'utils'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const props = defineProps<{\n part: unknown\n submitted?: boolean\n loading?: boolean\n error?: string\n readonly?: boolean\n privacyPolicyNotice?: LocalizedString\n /**\n * A conversation read back (the chat logs): the card is the record\n * of the form the agent showed, its prefilled values as text. Nothing\n * in the part says whether the visitor sent it, only the contacts do.\n */\n record?: boolean\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n type: string\n toolCallId: string\n input?: {\n name: string\n email: string\n phone?: string\n conversationContext?: Record<string, unknown>\n }\n }\n return part\n })\n\n const input = computed(() => toolPart.value.input)\n\n const prefilled = computed(() =>\n (\n [\n { name: 'name', label: $t('label.name') },\n { name: 'email', label: $t('label.email') },\n { name: 'phone', label: $t('label.phone') },\n ] as const\n )\n .map((field) => {\n const value = input.value?.[field.name]?.trim()\n return {\n ...field,\n // Written as the contacts page writes it\n value:\n field.name === 'phone' && value\n ? formatPhoneNumber(value) || value\n : value,\n }\n })\n .filter((field) => field.value),\n )\n\n const localSubmitted = useSafeLocalStorage<boolean>(\n computed(\n () =>\n `${toolPart.value.toolCallId}-${toolPart.value.type}-submitted`,\n ),\n false,\n )\n\n const LeadFormSchema = z.object({\n name: z.string().min(1).max(255).default(''),\n email: z.email().max(255).default(''),\n phone: z\n .string()\n .max(50)\n .regex(/^[+0-9\\s\\-.()]*$/, $t('validation.invalidPhoneNumber'))\n .optional(),\n })\n\n const emit = defineEmits<{\n submit: [data: Record<string, unknown>]\n }>()\n\n const { VvForm, VvFormField, formData } = useForm(LeadFormSchema, {\n lazyLoad: true,\n })\n\n // Pre-populate form with input values\n watch(\n input,\n (newInput) => {\n formData.value = {\n name: newInput?.name || '',\n email: newInput?.email || '',\n phone: newInput?.phone || '',\n }\n },\n { immediate: true },\n )\n\n watch(\n () => props.submitted,\n (submitted) => {\n if (submitted) {\n localSubmitted.value = true\n }\n },\n { immediate: true },\n )\n\n const isSubmitted = computed(() => {\n return props.submitted || localSubmitted.value\n })\n\n const submitLead = async (data: Record<string, unknown>): Promise<void> => {\n emit('submit', { ...data, metadata: input.value?.conversationContext })\n }\n\n const privacyNotice = useLocalizedString(\n () => props.privacyPolicyNotice,\n 'message.defaultPrivacyPolicyNotice',\n )\n</script>\n\n<template>\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface\">\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 min-h-40\">\n <VvIcon name=\"ri:send-plane-2-line\" class=\"text-16\" />\n <strong class=\"font-bold\">{{ $t('label.contactUs') }}</strong>\n </div>\n\n <Transition mode=\"out-in\">\n <div v-if=\"record\" class=\"p-sm flex flex-col gap-sm text-14\">\n <p class=\"text-word-2\">\n {{\n prefilled.length\n ? $t('message.contactFormRecordPrefilled')\n : $t('message.contactFormRecord')\n }}\n </p>\n <dl\n v-if=\"prefilled.length\"\n class=\"flex flex-wrap gap-x-lg gap-y-sm\">\n <div\n v-for=\"field in prefilled\"\n :key=\"field.name\"\n class=\"flex flex-col gap-4 min-w-0\">\n <dt class=\"text-12 text-word-3\">{{ field.label }}</dt>\n <dd class=\"text-word-1 break-words\">\n {{ field.value }}\n </dd>\n </div>\n </dl>\n </div>\n <div v-else-if=\"!isSubmitted\" class=\"p-sm\">\n <VvForm v-model=\"formData\" :readonly @submit=\"submitLead\">\n <VvFormField\n name=\"name\"\n type=\"text\"\n :label=\"$t('label.name')\"\n :placeholder=\"$t('placeholder.name')\"\n icon=\"ri:user-line\"\n modifiers=\"compact\"\n class=\"mb-md\" />\n <VvFormField\n name=\"email\"\n type=\"email\"\n :label=\"$t('label.email')\"\n :placeholder=\"$t('placeholder.email')\"\n icon=\"ri:mail-line\"\n modifiers=\"compact\"\n class=\"mb-md\" />\n <VvFormField\n name=\"phone\"\n type=\"tel\"\n :label=\"$t('label.phone')\"\n :placeholder=\"$t('placeholder.phone')\"\n icon=\"ri:phone-line\"\n class=\"mb-md\"\n modifiers=\"compact\" />\n\n <!-- A send that failed says so: the reason reached the\n card and was never drawn -->\n <VvAlert v-if=\"error\" modifiers=\"danger\" class=\"mb-md\">\n {{ error }}\n </VvAlert>\n\n <div class=\"flex justify-between items-center gap-16 mt-xs\">\n <div\n class=\"text-smaller text-word-3 flex items-center gap-8\">\n <VvIcon\n name=\"ri:shield-check-line\"\n class=\"text-16 shrink-0\" />\n <PkStreamingMarkdown\n :markdown=\"privacyNotice\"\n class=\"wysiwyg\" />\n </div>\n <!-- The library's default button is the brand, and in\n the chat the brand is the agent's color, as on the\n rest of the card: `primary` drew it neutral dark -->\n <VvButton\n type=\"submit\"\n :loading\n :disabled=\"loading || readonly\"\n icon-position=\"right\"\n class=\"shrink-0\"\n :label=\"$t('action.submit')\" />\n </div>\n </VvForm>\n </div>\n <div v-else class=\"p-sm\">\n <!-- One confirmation row across every tool card: a green\n check, the title in weight, the body quiet. The check is\n the outcome, so it alone carries the colour (DESIGN.md). -->\n <div class=\"flex items-center gap-sm\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <div>\n <strong class=\"font-medium block text-word-1\">\n {{ $t('message.leadSubmittedTitle') }}\n </strong>\n <p class=\"text-word-3\">\n {{ $t('message.leadSubmittedMessage') }}\n </p>\n </div>\n </div>\n </div>\n </Transition>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, watch } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useForm } from '@volverjs/form-vue'\n import * as z from 'zod'\n import { useSafeLocalStorage, useLocalizedString } from 'composables'\n import type { LocalizedString } from 'models'\n import { formatPhoneNumber } from 'utils'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const props = defineProps<{\n part: unknown\n submitted?: boolean\n loading?: boolean\n error?: string\n readonly?: boolean\n privacyPolicyNotice?: LocalizedString\n /**\n * A conversation read back (the chat logs): the card is the record\n * of the form the agent showed, its prefilled values as text. Nothing\n * in the part says whether the visitor sent it, only the contacts do.\n */\n record?: boolean\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n type: string\n toolCallId: string\n input?: {\n name: string\n email: string\n phone?: string\n conversationContext?: Record<string, unknown>\n }\n }\n return part\n })\n\n const input = computed(() => toolPart.value.input)\n\n const prefilled = computed(() =>\n (\n [\n { name: 'name', label: $t('label.name') },\n { name: 'email', label: $t('label.email') },\n { name: 'phone', label: $t('label.phone') },\n ] as const\n )\n .map((field) => {\n const value = input.value?.[field.name]?.trim()\n return {\n ...field,\n // Written as the contacts page writes it\n value:\n field.name === 'phone' && value\n ? formatPhoneNumber(value) || value\n : value,\n }\n })\n .filter((field) => field.value),\n )\n\n const localSubmitted = useSafeLocalStorage<boolean>(\n computed(\n () =>\n `${toolPart.value.toolCallId}-${toolPart.value.type}-submitted`,\n ),\n false,\n )\n\n const LeadFormSchema = z.object({\n name: z.string().min(1).max(255).default(''),\n email: z.email().max(255).default(''),\n phone: z\n .string()\n .max(50)\n .regex(/^[+0-9\\s\\-.()]*$/, $t('validation.invalidPhoneNumber'))\n .optional(),\n })\n\n const emit = defineEmits<{\n submit: [data: Record<string, unknown>]\n }>()\n\n const { VvForm, VvFormField, formData } = useForm(LeadFormSchema, {\n lazyLoad: true,\n })\n\n // Pre-populate form with input values\n watch(\n input,\n (newInput) => {\n formData.value = {\n name: newInput?.name || '',\n email: newInput?.email || '',\n phone: newInput?.phone || '',\n }\n },\n { immediate: true },\n )\n\n watch(\n () => props.submitted,\n (submitted) => {\n if (submitted) {\n localSubmitted.value = true\n }\n },\n { immediate: true },\n )\n\n const isSubmitted = computed(() => {\n return props.submitted || localSubmitted.value\n })\n\n const submitLead = async (data: Record<string, unknown>): Promise<void> => {\n emit('submit', { ...data, metadata: input.value?.conversationContext })\n }\n\n const privacyNotice = useLocalizedString(\n () => props.privacyPolicyNotice,\n 'message.defaultPrivacyPolicyNotice',\n )\n</script>\n\n<template>\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface\">\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 min-h-40\">\n <VvIcon name=\"ri:send-plane-2-line\" class=\"text-16\" />\n <strong class=\"font-bold\">{{ $t('label.contactUs') }}</strong>\n </div>\n\n <Transition mode=\"out-in\">\n <div v-if=\"record\" class=\"p-sm flex flex-col gap-sm text-14\">\n <p class=\"text-word-2\">\n {{\n prefilled.length\n ? $t('message.contactFormRecordPrefilled')\n : $t('message.contactFormRecord')\n }}\n </p>\n <dl\n v-if=\"prefilled.length\"\n class=\"flex flex-wrap gap-x-lg gap-y-sm\">\n <div\n v-for=\"field in prefilled\"\n :key=\"field.name\"\n class=\"flex flex-col gap-4 min-w-0\">\n <dt class=\"text-12 text-word-3\">{{ field.label }}</dt>\n <dd class=\"text-word-1 break-words\">\n {{ field.value }}\n </dd>\n </div>\n </dl>\n </div>\n <div v-else-if=\"!isSubmitted\" class=\"p-sm\">\n <VvForm v-model=\"formData\" :readonly @submit=\"submitLead\">\n <VvFormField\n name=\"name\"\n type=\"text\"\n :label=\"$t('label.name')\"\n :placeholder=\"$t('placeholder.name')\"\n icon=\"ri:user-line\"\n modifiers=\"compact\"\n class=\"mb-md\" />\n <VvFormField\n name=\"email\"\n type=\"email\"\n :label=\"$t('label.email')\"\n :placeholder=\"$t('placeholder.email')\"\n icon=\"ri:mail-line\"\n modifiers=\"compact\"\n class=\"mb-md\" />\n <VvFormField\n name=\"phone\"\n type=\"tel\"\n :label=\"$t('label.phone')\"\n :placeholder=\"$t('placeholder.phone')\"\n icon=\"ri:phone-line\"\n class=\"mb-md\"\n modifiers=\"compact\" />\n\n <!-- A send that failed says so: the reason reached the\n card and was never drawn -->\n <VvAlert v-if=\"error\" modifiers=\"danger\" class=\"mb-md\">\n {{ error }}\n </VvAlert>\n\n <div class=\"flex justify-between items-center gap-16 mt-xs\">\n <div\n class=\"text-smaller text-word-3 flex items-center gap-8\">\n <VvIcon\n name=\"ri:shield-check-line\"\n class=\"text-16 shrink-0\" />\n <PkStreamingMarkdown\n :markdown=\"privacyNotice\"\n class=\"wysiwyg\" />\n </div>\n <!-- The library's default button is the brand, and in\n the chat the brand is the agent's color, as on the\n rest of the card: `primary` drew it neutral dark -->\n <VvButton\n type=\"submit\"\n :loading\n :disabled=\"loading || readonly\"\n icon-position=\"right\"\n class=\"shrink-0\"\n :label=\"$t('action.submit')\" />\n </div>\n </VvForm>\n </div>\n <div v-else class=\"p-sm\">\n <!-- One confirmation row across every tool card: a green\n check, the title in weight, the body quiet. The check is\n the outcome, so it alone carries the colour (DESIGN.md). -->\n <div class=\"flex items-center gap-sm\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <div>\n <strong class=\"font-medium block text-word-1\">\n {{ $t('message.leadSubmittedTitle') }}\n </strong>\n <p class=\"text-word-3\">\n {{ $t('message.leadSubmittedMessage') }}\n </p>\n </div>\n </div>\n </div>\n </Transition>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUI,IAAM,EAAE,GAAGkD,MAAOC,EAAQ,EAAE,UAAU,SAAS,CAAC,GAE1CC,IAAQC,GAeRC,IAAWC,QACAH,EAAM,IAWtB,GAEKI,IAAQD,QAAeD,EAAS,MAAM,KAAK,GAE3CG,IAAYF,QAEV;GACI;IAAE,MAAM;IAAQ,OAAOL,EAAG,YAAY;GAAE;GACxC;IAAE,MAAM;IAAS,OAAOA,EAAG,aAAa;GAAE;GAC1C;IAAE,MAAM;IAAS,OAAOA,EAAG,aAAa;GAAE;EAC9C,CAAC,CAEA,KAAK,MAAU;GACZ,IAAMQ,IAAQF,EAAM,QAAQG,EAAM,KAAK,EAAE,KAAK;GAC9C,OAAO;IACH,GAAGA;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;OACJ,SAAArB,EAAA;OACA,UAAUA,EAAA,WAAWA,EAAA;OACtB,iBAAc;OACd,OAAM;OACL,OAAOzC,EAAAsC,CAAA,CAAE,CAAA,eAAA;;;;;;;;IAI1B3C,GAAAA,GAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,CAAAA,EAWqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"PkToolShowContactForm-D0CR80e2.js","names":["z.object","z.string","z.email","useForm","__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_Transition","_withCtx","_Fragment","_renderList","_createCommentVNode","_isRef","_createBlock","_createTextVNode","PkStreamingMarkdown","_sfc_main","__exportAll","string","email","object","VvButtonLocalized","PkStreamingMarkdown_default","formatPhoneNumber","useSafeLocalStorage","useLocalizedString","Se","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","PkToolShowContactForm_vue_vue_type_script_setup_true_lang_default","__emit","$t","useI18n","props","__props","toolPart","computed","input","prefilled","value","field","localSubmitted","LeadFormSchema","emit","watch","newInput","submitted","isSubmitted","submitLead","data","privacyNotice","_component_VvIcon","VvIcon","_component_VvAlert","VvAlert","_component_VvButton","openBlock","createElementBlock","createElementVNode","createVNode","toDisplayString","unref","Transition","withCtx","Fragment","renderList","createCommentVNode","VvForm","formData","_cache","isRef","$event","VvFormField","createBlock","createTextVNode","PkToolShowContactForm_exports","PkToolShowContactForm_default"],"sources":["../../../../packages/components/src/chat/PkToolShowContactForm.vue","../../../../packages/components/src/chat/PkToolShowContactForm.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, watch } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useForm } from '@volverjs/form-vue'\n import * as z from 'zod'\n import { useSafeLocalStorage, useLocalizedString } from 'composables'\n import type { LocalizedString } from 'models'\n import { formatPhoneNumber } from 'utils'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const props = defineProps<{\n part: unknown\n submitted?: boolean\n loading?: boolean\n error?: string\n readonly?: boolean\n privacyPolicyNotice?: LocalizedString\n /**\n * A conversation read back (the chat logs): the card is the record\n * of the form the agent showed, its prefilled values as text. Nothing\n * in the part says whether the visitor sent it, only the contacts do.\n */\n record?: boolean\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n type: string\n toolCallId: string\n input?: {\n name: string\n email: string\n phone?: string\n conversationContext?: Record<string, unknown>\n }\n }\n return part\n })\n\n const input = computed(() => toolPart.value.input)\n\n const prefilled = computed(() =>\n (\n [\n { name: 'name', label: $t('label.name') },\n { name: 'email', label: $t('label.email') },\n { name: 'phone', label: $t('label.phone') },\n ] as const\n )\n .map((field) => {\n const value = input.value?.[field.name]?.trim()\n return {\n ...field,\n // Written as the contacts page writes it\n value:\n field.name === 'phone' && value\n ? formatPhoneNumber(value) || value\n : value,\n }\n })\n .filter((field) => field.value),\n )\n\n const localSubmitted = useSafeLocalStorage<boolean>(\n computed(\n () =>\n `${toolPart.value.toolCallId}-${toolPart.value.type}-submitted`,\n ),\n false,\n )\n\n const LeadFormSchema = z.object({\n name: z.string().min(1).max(255).default(''),\n email: z.email().max(255).default(''),\n phone: z\n .string()\n .max(50)\n .regex(/^[+0-9\\s\\-.()]*$/, $t('validation.invalidPhoneNumber'))\n .optional(),\n })\n\n const emit = defineEmits<{\n submit: [data: Record<string, unknown>]\n }>()\n\n const { VvForm, VvFormField, formData } = useForm(LeadFormSchema, {\n lazyLoad: true,\n })\n\n // Pre-populate form with input values\n watch(\n input,\n (newInput) => {\n formData.value = {\n name: newInput?.name || '',\n email: newInput?.email || '',\n phone: newInput?.phone || '',\n }\n },\n { immediate: true },\n )\n\n watch(\n () => props.submitted,\n (submitted) => {\n if (submitted) {\n localSubmitted.value = true\n }\n },\n { immediate: true },\n )\n\n const isSubmitted = computed(() => {\n return props.submitted || localSubmitted.value\n })\n\n const submitLead = async (data: Record<string, unknown>): Promise<void> => {\n emit('submit', { ...data, metadata: input.value?.conversationContext })\n }\n\n const privacyNotice = useLocalizedString(\n () => props.privacyPolicyNotice,\n 'message.defaultPrivacyPolicyNotice',\n )\n</script>\n\n<template>\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface\">\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 min-h-40\">\n <VvIcon name=\"ri:send-plane-2-line\" class=\"text-16\" />\n <strong class=\"font-bold\">{{ $t('label.contactUs') }}</strong>\n </div>\n\n <Transition mode=\"out-in\">\n <div v-if=\"record\" class=\"p-sm flex flex-col gap-sm text-14\">\n <p class=\"text-word-2\">\n {{\n prefilled.length\n ? $t('message.contactFormRecordPrefilled')\n : $t('message.contactFormRecord')\n }}\n </p>\n <dl\n v-if=\"prefilled.length\"\n class=\"flex flex-wrap gap-x-lg gap-y-sm\">\n <div\n v-for=\"field in prefilled\"\n :key=\"field.name\"\n class=\"flex flex-col gap-4 min-w-0\">\n <dt class=\"text-12 text-word-3\">{{ field.label }}</dt>\n <dd class=\"text-word-1 break-words\">\n {{ field.value }}\n </dd>\n </div>\n </dl>\n </div>\n <div v-else-if=\"!isSubmitted\" class=\"p-sm\">\n <VvForm v-model=\"formData\" :readonly @submit=\"submitLead\">\n <VvFormField\n name=\"name\"\n type=\"text\"\n :label=\"$t('label.name')\"\n :placeholder=\"$t('placeholder.name')\"\n icon=\"ri:user-line\"\n modifiers=\"compact\"\n class=\"mb-md\" />\n <VvFormField\n name=\"email\"\n type=\"email\"\n :label=\"$t('label.email')\"\n :placeholder=\"$t('placeholder.email')\"\n icon=\"ri:mail-line\"\n modifiers=\"compact\"\n class=\"mb-md\" />\n <VvFormField\n name=\"phone\"\n type=\"tel\"\n :label=\"$t('label.phone')\"\n :placeholder=\"$t('placeholder.phone')\"\n icon=\"ri:phone-line\"\n class=\"mb-md\"\n modifiers=\"compact\" />\n\n <!-- A send that failed says so: the reason reached the\n card and was never drawn -->\n <VvAlert v-if=\"error\" modifiers=\"danger\" class=\"mb-md\">\n {{ error }}\n </VvAlert>\n\n <div class=\"flex justify-between items-center gap-16 mt-xs\">\n <div\n class=\"text-smaller text-word-3 flex items-center gap-8\">\n <VvIcon\n name=\"ri:shield-check-line\"\n class=\"text-16 shrink-0\" />\n <PkStreamingMarkdown\n :markdown=\"privacyNotice\"\n class=\"wysiwyg\" />\n </div>\n <!-- The library's default button is the brand, and in\n the chat the brand is the agent's color, as on the\n rest of the card: `primary` drew it neutral dark -->\n <VvButton\n type=\"submit\"\n :loading\n :disabled=\"loading || readonly\"\n icon-position=\"right\"\n class=\"shrink-0\"\n :label=\"$t('action.submit')\" />\n </div>\n </VvForm>\n </div>\n <div v-else class=\"p-sm\">\n <!-- One confirmation row across every tool card: a green\n check, the title in weight, the body quiet. The check is\n the outcome, so it alone carries the colour (DESIGN.md). -->\n <div class=\"flex items-center gap-sm\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <div>\n <strong class=\"font-medium block text-word-1\">\n {{ $t('message.leadSubmittedTitle') }}\n </strong>\n <p class=\"text-word-3\">\n {{ $t('message.leadSubmittedMessage') }}\n </p>\n </div>\n </div>\n </div>\n </Transition>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed, watch } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useForm } from '@volverjs/form-vue'\n import * as z from 'zod'\n import { useSafeLocalStorage, useLocalizedString } from 'composables'\n import type { LocalizedString } from 'models'\n import { formatPhoneNumber } from 'utils'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const props = defineProps<{\n part: unknown\n submitted?: boolean\n loading?: boolean\n error?: string\n readonly?: boolean\n privacyPolicyNotice?: LocalizedString\n /**\n * A conversation read back (the chat logs): the card is the record\n * of the form the agent showed, its prefilled values as text. Nothing\n * in the part says whether the visitor sent it, only the contacts do.\n */\n record?: boolean\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n type: string\n toolCallId: string\n input?: {\n name: string\n email: string\n phone?: string\n conversationContext?: Record<string, unknown>\n }\n }\n return part\n })\n\n const input = computed(() => toolPart.value.input)\n\n const prefilled = computed(() =>\n (\n [\n { name: 'name', label: $t('label.name') },\n { name: 'email', label: $t('label.email') },\n { name: 'phone', label: $t('label.phone') },\n ] as const\n )\n .map((field) => {\n const value = input.value?.[field.name]?.trim()\n return {\n ...field,\n // Written as the contacts page writes it\n value:\n field.name === 'phone' && value\n ? formatPhoneNumber(value) || value\n : value,\n }\n })\n .filter((field) => field.value),\n )\n\n const localSubmitted = useSafeLocalStorage<boolean>(\n computed(\n () =>\n `${toolPart.value.toolCallId}-${toolPart.value.type}-submitted`,\n ),\n false,\n )\n\n const LeadFormSchema = z.object({\n name: z.string().min(1).max(255).default(''),\n email: z.email().max(255).default(''),\n phone: z\n .string()\n .max(50)\n .regex(/^[+0-9\\s\\-.()]*$/, $t('validation.invalidPhoneNumber'))\n .optional(),\n })\n\n const emit = defineEmits<{\n submit: [data: Record<string, unknown>]\n }>()\n\n const { VvForm, VvFormField, formData } = useForm(LeadFormSchema, {\n lazyLoad: true,\n })\n\n // Pre-populate form with input values\n watch(\n input,\n (newInput) => {\n formData.value = {\n name: newInput?.name || '',\n email: newInput?.email || '',\n phone: newInput?.phone || '',\n }\n },\n { immediate: true },\n )\n\n watch(\n () => props.submitted,\n (submitted) => {\n if (submitted) {\n localSubmitted.value = true\n }\n },\n { immediate: true },\n )\n\n const isSubmitted = computed(() => {\n return props.submitted || localSubmitted.value\n })\n\n const submitLead = async (data: Record<string, unknown>): Promise<void> => {\n emit('submit', { ...data, metadata: input.value?.conversationContext })\n }\n\n const privacyNotice = useLocalizedString(\n () => props.privacyPolicyNotice,\n 'message.defaultPrivacyPolicyNotice',\n )\n</script>\n\n<template>\n <div\n class=\"border border-surface-3 rounded-xl w-full overflow-hidden bg-surface\">\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 min-h-40\">\n <VvIcon name=\"ri:send-plane-2-line\" class=\"text-16\" />\n <strong class=\"font-bold\">{{ $t('label.contactUs') }}</strong>\n </div>\n\n <Transition mode=\"out-in\">\n <div v-if=\"record\" class=\"p-sm flex flex-col gap-sm text-14\">\n <p class=\"text-word-2\">\n {{\n prefilled.length\n ? $t('message.contactFormRecordPrefilled')\n : $t('message.contactFormRecord')\n }}\n </p>\n <dl\n v-if=\"prefilled.length\"\n class=\"flex flex-wrap gap-x-lg gap-y-sm\">\n <div\n v-for=\"field in prefilled\"\n :key=\"field.name\"\n class=\"flex flex-col gap-4 min-w-0\">\n <dt class=\"text-12 text-word-3\">{{ field.label }}</dt>\n <dd class=\"text-word-1 break-words\">\n {{ field.value }}\n </dd>\n </div>\n </dl>\n </div>\n <div v-else-if=\"!isSubmitted\" class=\"p-sm\">\n <VvForm v-model=\"formData\" :readonly @submit=\"submitLead\">\n <VvFormField\n name=\"name\"\n type=\"text\"\n :label=\"$t('label.name')\"\n :placeholder=\"$t('placeholder.name')\"\n icon=\"ri:user-line\"\n modifiers=\"compact\"\n class=\"mb-md\" />\n <VvFormField\n name=\"email\"\n type=\"email\"\n :label=\"$t('label.email')\"\n :placeholder=\"$t('placeholder.email')\"\n icon=\"ri:mail-line\"\n modifiers=\"compact\"\n class=\"mb-md\" />\n <VvFormField\n name=\"phone\"\n type=\"tel\"\n :label=\"$t('label.phone')\"\n :placeholder=\"$t('placeholder.phone')\"\n icon=\"ri:phone-line\"\n class=\"mb-md\"\n modifiers=\"compact\" />\n\n <!-- A send that failed says so: the reason reached the\n card and was never drawn -->\n <VvAlert v-if=\"error\" modifiers=\"danger\" class=\"mb-md\">\n {{ error }}\n </VvAlert>\n\n <div class=\"flex justify-between items-center gap-16 mt-xs\">\n <div\n class=\"text-smaller text-word-3 flex items-center gap-8\">\n <VvIcon\n name=\"ri:shield-check-line\"\n class=\"text-16 shrink-0\" />\n <PkStreamingMarkdown\n :markdown=\"privacyNotice\"\n class=\"wysiwyg\" />\n </div>\n <!-- The library's default button is the brand, and in\n the chat the brand is the agent's color, as on the\n rest of the card: `primary` drew it neutral dark -->\n <VvButton\n type=\"submit\"\n :loading\n :disabled=\"loading || readonly\"\n icon-position=\"right\"\n class=\"shrink-0\"\n :label=\"$t('action.submit')\" />\n </div>\n </VvForm>\n </div>\n <div v-else class=\"p-sm\">\n <!-- One confirmation row across every tool card: a green\n check, the title in weight, the body quiet. The check is\n the outcome, so it alone carries the colour (DESIGN.md). -->\n <div class=\"flex items-center gap-sm\">\n <VvIcon name=\"ri:check-line\" class=\"text-16 text-success\" />\n <div>\n <strong class=\"font-medium block text-word-1\">\n {{ $t('message.leadSubmittedTitle') }}\n </strong>\n <p class=\"text-word-3\">\n {{ $t('message.leadSubmittedMessage') }}\n </p>\n </div>\n </div>\n </div>\n </Transition>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUI,IAAM,EAAE,GAAGkD,MAAOC,EAAQ,EAAE,UAAU,SAAS,CAAC,GAE1CC,IAAQC,GAeRC,IAAWC,QACAH,EAAM,IAWtB,GAEKI,IAAQD,QAAeD,EAAS,MAAM,KAAK,GAE3CG,IAAYF,QAEV;GACI;IAAE,MAAM;IAAQ,OAAOL,EAAG,YAAY;GAAE;GACxC;IAAE,MAAM;IAAS,OAAOA,EAAG,aAAa;GAAE;GAC1C;IAAE,MAAM;IAAS,OAAOA,EAAG,aAAa;GAAE;EAC9C,CAAC,CAEA,KAAK,MAAU;GACZ,IAAMQ,IAAQF,EAAM,QAAQG,EAAM,KAAK,EAAE,KAAK;GAC9C,OAAO;IACH,GAAGA;IAEH,OACIA,EAAM,SAAS,WAAWD,KACpB7B,EAAkB6B,CAAK,KAAKA;GAE1C;EACJ,CAAC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OAAOzC,EAAAsC,CAAA,CAAE,CAAA,eAAA;;;;;;;;IAI1B3C,GAAAA,GAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,CAAAA,EAWqB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./VvButtonLocalized-BuzLsXp3.js";
|
|
2
2
|
import "./src-BZRiAJsH.js";
|
|
3
|
-
import { P as t } from "./utils-
|
|
4
|
-
import { t as n } from "./PkSvgViewer-
|
|
3
|
+
import { P as t } from "./utils-Bopp5IPf.js";
|
|
4
|
+
import { t as n } from "./PkSvgViewer-CZASatr4.js";
|
|
5
5
|
import { VvButtonGroup as r, VvIcon as i } from "@volverjs/ui-vue/components";
|
|
6
6
|
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";
|
|
7
7
|
import { useI18n as y } from "vue-i18n";
|
|
@@ -120,4 +120,4 @@ var x = {
|
|
|
120
120
|
//#endregion
|
|
121
121
|
export { k as default };
|
|
122
122
|
|
|
123
|
-
//# sourceMappingURL=PkToolShowDiagram-
|
|
123
|
+
//# sourceMappingURL=PkToolShowDiagram-CYpqqWLo.js.map
|
package/dist-vue/_chunks/{PkToolShowDiagram-Cq0457a3.js.map → PkToolShowDiagram-CYpqqWLo.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkToolShowDiagram-Cq0457a3.js","names":["__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_withCtx","_createBlock","_createCommentVNode","PkSvgViewer","_sfc_main","VvButtonLocalized","toSnakeCase","PkSvgViewer_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","DiagramType","\"Sequence\"","\"Class\"","\"State\"","\"ER\"","\"XYChart\"","\"Flowchart\"","\"Graph\"","PkToolShowDiagram_default","defineComponent","props","__props","$t","$te","useI18n","useClipboard","toolPart","computed","svgError","ref","svgContent","diagramType","code","diagramTypeLabel","diagramTypeIcon","renderDiagram","theme","THEMES","renderMermaidSVG","watch","onMounted","downloadSvg","blob","url","anchor","copyCode","copy","_component_VvIcon","VvIcon","_component_VvButton","_component_VvButtonGroup","VvButtonGroup","openBlock","createElementBlock","createElementVNode","createVNode","toDisplayString","unref","withCtx","copied","createBlock","createCommentVNode"],"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) {\n return\n }\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=\"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) {\n return\n }\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=\"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":";;;;;;;;;;;;;;;;;;;;;GAkCSwB,IAAL,yBAAA,GAAA;QACI,EAAAC,WAAA,mBACA,EAAAC,QAAA,gBACA,EAAAC,QAAA,gBACA,EAAAC,KAAA,aACA,EAAAC,UAAA,WACA,EAAAC,YAAA,aACA,EAAAC,QAAA;AACJ,EARKP,KAAA,CAAA,CAQL;;;;;;;EAnCA,IAAMU,IAAQC,GAKR,EAAE,GAAGC,GAAI,IAAIC,MAAQC,EAAQ,EAC/B,UAAU,SACd,CAAC,GAEK,EAAE,SAAM,cAAWC,EAAa,GAEhCC,IAAWC,QACAP,EAAM,IAQtB,GAEKQ,IAAWC,EAAI,EAAK,GAGpBC,IAAaD,EAAI,EAAE,GAYnBE,IAAcJ,QAAwC;GACxD,IAAMK,IAAON,EAAS,MAAM,OAAO,MAAM,UAAU;GACnD,IAAKM,GAIL,QADkBA,EAAK,MAAM,aAAa,CAAC,GAAG,IAC9C;IACI,KAAK,mBACD,OAAOtB,EAAY;IACvB,KAAK,gBACD,OAAOA,EAAY;IACvB,KAAK,gBACD,OAAOA,EAAY;IACvB,KAAK,aACD,OAAOA,EAAY;IACvB,KAAK,gBACD,OAAOA,EAAY;IACvB,KAAK,aACD,OAAOA,EAAY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M,OAJNkB,GAIM,CADFhB,EAA4DuD,GAAA;KAApD,MAAK;KAAe,OAAM;;IAG5BrB,EAAA,MAAS,MAAM,WADzBrC,EAAA,GAAAC,EAIM,OAJNmB,GAIMhB,EADCiC,EAAA,MAAS,MAAM,OAAO,GAAA,CAAA,KAAAmC,EAAA,IAAA,EAAA"}
|
|
1
|
+
{"version":3,"file":"PkToolShowDiagram-CYpqqWLo.js","names":["__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_toDisplayString","_unref","_withCtx","_createBlock","_createCommentVNode","PkSvgViewer","_sfc_main","VvButtonLocalized","toSnakeCase","PkSvgViewer_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","DiagramType","\"Sequence\"","\"Class\"","\"State\"","\"ER\"","\"XYChart\"","\"Flowchart\"","\"Graph\"","PkToolShowDiagram_default","defineComponent","props","__props","$t","$te","useI18n","useClipboard","toolPart","computed","svgError","ref","svgContent","diagramType","code","diagramTypeLabel","diagramTypeIcon","renderDiagram","theme","THEMES","renderMermaidSVG","watch","onMounted","downloadSvg","blob","url","anchor","copyCode","copy","_component_VvIcon","VvIcon","_component_VvButton","_component_VvButtonGroup","VvButtonGroup","openBlock","createElementBlock","createElementVNode","createVNode","toDisplayString","unref","withCtx","copied","createBlock","createCommentVNode"],"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) {\n return\n }\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=\"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) {\n return\n }\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=\"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":";;;;;;;;;;;;;;;;;;;;;GAkCSwB,IAAL,yBAAA,GAAA;QACI,EAAAC,WAAA,mBACA,EAAAC,QAAA,gBACA,EAAAC,QAAA,gBACA,EAAAC,KAAA,aACA,EAAAC,UAAA,WACA,EAAAC,YAAA,aACA,EAAAC,QAAA;AACJ,EARKP,KAAA,CAAA,CAQL;;;;;;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A,CAAE,CAAA,aAAA;OACxC,SAAOuB;MAEF,GAAA,MAAA,GAAA,CAAA,QAAA,OAAA,CAAA,GAAAf,EAAA,SADVzC,EAAA,GAAAO,EAK2BqD,GAAA;;OAHvB,WAAU;OACV,MAAK;OACJ,OAAOvD,EAAA4B,CAAA,CAAE,CAAA,iBAAA;OACT,SAAOmB;;;;;IAGTb,EAAA,SAAXvC,EAAA,GAAAC,EAEM,OAFNiB,GAEMd,EADCC,EAAA4B,CAAA,CAAE,CAAA,4BAAA,CAAA,GAAA,CAAA,KAGMQ,EAAA,SADfzC,EAAA,GAAAO,EAIqCE,GAAA;;KAFjC,OAAM;KACL,KAAKgC,EAAA;KACL,OAAOJ,EAAA,MAAS,OAAO;IAC5BrC,GAAAA,MAAAA,GAAAA,CAAAA,OAAAA,OAAAA,CAAAA,MAAAA,EAAA,GAAAC,EAIM,OAJNkB,GAIM,CADFhB,EAA4DuD,GAAA;KAApD,MAAK;KAAe,OAAM;;IAG5BrB,EAAA,MAAS,MAAM,WADzBrC,EAAA,GAAAC,EAIM,OAJNmB,GAIMhB,EADCiC,EAAA,MAAS,MAAM,OAAO,GAAA,CAAA,KAAAmC,EAAA,IAAA,EAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { P as t } from "./Agent-
|
|
2
|
+
import { P as t } from "./Agent-DDm9cCaN.js";
|
|
3
3
|
import { t as n } from "./VvButtonLocalized-BuzLsXp3.js";
|
|
4
|
-
import { t as r } from "./PkStreamingMarkdown-
|
|
5
|
-
import { c as i, l as a } from "./utils-
|
|
4
|
+
import { t as r } from "./PkStreamingMarkdown-DXoUbGsP.js";
|
|
5
|
+
import { c as i, l as a } from "./utils-Bopp5IPf.js";
|
|
6
6
|
import { VvCheckbox as o, VvCheckboxGroup as s, VvIcon as ee, VvInputText as te, VvRadio as c, VvRadioGroup as l } from "@volverjs/ui-vue/components";
|
|
7
7
|
import { Fragment as u, computed as d, createBlock as f, createCommentVNode as p, createElementBlock as m, createElementVNode as h, createSlots as g, createTextVNode as _, createVNode as v, defineComponent as y, mergeModels as b, mergeProps as x, normalizeClass as ne, normalizeStyle as re, openBlock as S, reactive as ie, ref as C, renderList as w, renderSlot as T, toDisplayString as E, unref as D, useId as O, useModel as k, watch as A, withCtx as j, withKeys as ae, withModifiers as M } from "vue";
|
|
8
8
|
import { useI18n as oe } from "vue-i18n";
|
|
@@ -369,4 +369,4 @@ var N = /* @__PURE__ */ y({
|
|
|
369
369
|
//#endregion
|
|
370
370
|
export { N as i, L as n, P as r, R as t };
|
|
371
371
|
|
|
372
|
-
//# sourceMappingURL=PkToolShowForm-
|
|
372
|
+
//# sourceMappingURL=PkToolShowForm-BIsu4XhQ.js.map
|