@8wave/ai-elements 0.95.0 → 0.97.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/_chunks/{PkToolShowArtifact-CX4u80Vm.js → PkToolShowArtifact-BHGuiacA.js} +2 -2
  2. package/dist/_chunks/PkToolShowArtifact-BHGuiacA.js.map +1 -0
  3. package/dist/_chunks/PkToolShowVideo-DoLoI8_N.js +121 -0
  4. package/dist/_chunks/PkToolShowVideo-DoLoI8_N.js.map +1 -0
  5. package/dist/ai-elements.es.js +15 -10
  6. package/dist/ai-elements.es.js.map +1 -1
  7. package/dist-vue/PkChatbot.js +1 -1
  8. package/dist-vue/PkChatbotMessages.js +1 -1
  9. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  10. package/dist-vue/PkChatbotSteps.js +1 -1
  11. package/dist-vue/PkChatbotViewChat.js +1 -1
  12. package/dist-vue/PkChatbotViewConversations.js +1 -1
  13. package/dist-vue/PkChatbotViewFiles.js +1 -1
  14. package/dist-vue/PkChatbotViewProfile.js +1 -1
  15. package/dist-vue/_chunks/{PkChatbot-DH5-1our.js → PkChatbot-Ckw-h8FO.js} +7 -7
  16. package/dist-vue/_chunks/{PkChatbot-DH5-1our.js.map → PkChatbot-Ckw-h8FO.js.map} +1 -1
  17. package/dist-vue/_chunks/{PkChatbotMessages-kRAjAYUH.js → PkChatbotMessages-CS2E757n.js} +5 -4
  18. package/dist-vue/_chunks/PkChatbotMessages-CS2E757n.js.map +1 -0
  19. package/dist-vue/_chunks/{PkChatbotStepToolDetail-Csp_kQG0.js → PkChatbotStepToolDetail-ldThv0t5.js} +2 -2
  20. package/dist-vue/_chunks/{PkChatbotStepToolDetail-Csp_kQG0.js.map → PkChatbotStepToolDetail-ldThv0t5.js.map} +1 -1
  21. package/dist-vue/_chunks/{PkChatbotSteps-DVQxL0Ti.js → PkChatbotSteps-BhqYCNWy.js} +3 -3
  22. package/dist-vue/_chunks/{PkChatbotSteps-DVQxL0Ti.js.map → PkChatbotSteps-BhqYCNWy.js.map} +1 -1
  23. package/dist-vue/_chunks/{PkChatbotViewChat-CvUQ6zSI.js → PkChatbotViewChat-BWzjnNms.js} +3 -3
  24. package/dist-vue/_chunks/{PkChatbotViewChat-CvUQ6zSI.js.map → PkChatbotViewChat-BWzjnNms.js.map} +1 -1
  25. package/dist-vue/_chunks/{PkChatbotViewConversations-DbnJaJw_.js → PkChatbotViewConversations-GwPi9aMc.js} +2 -2
  26. package/dist-vue/_chunks/{PkChatbotViewConversations-DbnJaJw_.js.map → PkChatbotViewConversations-GwPi9aMc.js.map} +1 -1
  27. package/dist-vue/_chunks/{PkChatbotViewFiles-B_HZ-Gjh.js → PkChatbotViewFiles-CIY-rAe5.js} +2 -2
  28. package/dist-vue/_chunks/{PkChatbotViewFiles-B_HZ-Gjh.js.map → PkChatbotViewFiles-CIY-rAe5.js.map} +1 -1
  29. package/dist-vue/_chunks/{PkChatbotViewProfile-BglHN7F5.js → PkChatbotViewProfile-UxuzAbbq.js} +2 -2
  30. package/dist-vue/_chunks/{PkChatbotViewProfile-BglHN7F5.js.map → PkChatbotViewProfile-UxuzAbbq.js.map} +1 -1
  31. package/dist-vue/_chunks/{PkToolShowArtifact-BCc4qcf0.js → PkToolShowArtifact-B2ilUNT0.js} +2 -2
  32. package/dist-vue/_chunks/PkToolShowArtifact-B2ilUNT0.js.map +1 -0
  33. package/dist-vue/_chunks/PkToolShowVideo-Ox8rFd7j.js +122 -0
  34. package/dist-vue/_chunks/PkToolShowVideo-Ox8rFd7j.js.map +1 -0
  35. package/dist-vue/_chunks/{createChatbotApiClient-C7cQhOuG.js → createChatbotApiClient-CfgsFWzF.js} +4 -3
  36. package/dist-vue/_chunks/createChatbotApiClient-CfgsFWzF.js.map +1 -0
  37. package/dist-vue/_chunks/{useChatbotStore-D6IdQhl-.js → useChatbotStore-w7tMG0F8.js} +2 -2
  38. package/dist-vue/_chunks/{useChatbotStore-D6IdQhl-.js.map → useChatbotStore-w7tMG0F8.js.map} +1 -1
  39. package/dist-vue/_chunks/{utils-CVZaf4tf.js → utils-BMa8jwJS.js} +3 -3
  40. package/dist-vue/_chunks/{utils-CVZaf4tf.js.map → utils-BMa8jwJS.js.map} +1 -1
  41. package/dist-vue/api.js +1 -1
  42. package/dist-vue/composables.js +3 -3
  43. package/dist-vue/index.js +12 -11
  44. package/dist-vue/index.js.map +1 -1
  45. package/dist-vue/locales.js +4 -0
  46. package/dist-vue/packages/components/src/chat/PkToolShowVideo.d.ts +7 -0
  47. package/dist-vue/packages/models/src/schema/Agent.d.ts +1 -0
  48. package/dist-vue/style.css +1 -1
  49. package/package.json +1 -1
  50. package/dist/_chunks/PkToolShowArtifact-CX4u80Vm.js.map +0 -1
  51. package/dist-vue/_chunks/PkChatbotMessages-kRAjAYUH.js.map +0 -1
  52. package/dist-vue/_chunks/PkToolShowArtifact-BCc4qcf0.js.map +0 -1
  53. package/dist-vue/_chunks/createChatbotApiClient-C7cQhOuG.js.map +0 -1
@@ -37,7 +37,7 @@ var y = ["innerHTML"], b = /* @__PURE__ */ a({
37
37
  }
38
38
  });
39
39
  e(), u(), s();
40
- var x = { class: "border border-surface-3 rounded-xl w-full overflow-hidden" }, S = { class: "px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center" }, C = { class: "flex flex-col items-start gap-4" }, w = { class: "text-10 opacity-60 font-normal" }, T = { class: "px-sm py-10" }, E = /* @__PURE__ */ a({
40
+ var x = { class: "border border-surface-3 rounded-xl w-full overflow-hidden" }, S = { class: "px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center" }, C = { class: "flex flex-col items-start gap-4" }, w = { class: "text-10 opacity-60 font-normal" }, T = { class: "px-sm py-10 bg-surface" }, E = /* @__PURE__ */ a({
41
41
  __name: "PkToolShowArtifact",
42
42
  props: { part: { type: null } },
43
43
  setup(e) {
@@ -90,4 +90,4 @@ var x = { class: "border border-surface-3 rounded-xl w-full overflow-hidden" },
90
90
  //#endregion
91
91
  export { E as default };
92
92
 
93
- //# sourceMappingURL=PkToolShowArtifact-CX4u80Vm.js.map
93
+ //# sourceMappingURL=PkToolShowArtifact-BHGuiacA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PkToolShowArtifact-BHGuiacA.js","names":["$attrs","$t"],"sources":["../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkCode.vue","../../../../packages/components/src/chat/PkToolShowArtifact.vue","../../../../packages/components/src/chat/PkToolShowArtifact.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref, watch } from 'vue'\n\n defineOptions({\n inheritAttrs: false,\n })\n\n const props = defineProps<{\n code: unknown\n language: string\n line?: boolean\n }>()\n\n const highlightedHtml = ref('')\n\n const hasCode = computed(() => {\n if (typeof props.code === 'string') {\n return props.code\n }\n return JSON.stringify(props.code, null, 2)\n })\n\n async function highlight() {\n const hljs = (await import('highlight.js/lib/common')).default\n try {\n const result = props.language\n ? hljs.highlight(hasCode.value, { language: props.language })\n : hljs.highlightAuto(hasCode.value)\n highlightedHtml.value = result.value\n } catch {\n highlightedHtml.value = hasCode.value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n }\n }\n\n watch(hasCode, highlight, { immediate: true })\n</script>\n\n<template>\n <pre\n :class=\"\n $attrs.class\n ? $attrs.class\n : 'font-mono leading-snug text-smaller bg-surface-1'\n \">\n <code :class=\"['hljs', line ? 'whitespace-pre-line' : 'whitespace-pre', language]\" v-html=\"highlightedHtml\"></code>\n </pre>\n</template>\n","<script setup lang=\"ts\">\n import { computed, ref, watch } from 'vue'\n\n defineOptions({\n inheritAttrs: false,\n })\n\n const props = defineProps<{\n code: unknown\n language: string\n line?: boolean\n }>()\n\n const highlightedHtml = ref('')\n\n const hasCode = computed(() => {\n if (typeof props.code === 'string') {\n return props.code\n }\n return JSON.stringify(props.code, null, 2)\n })\n\n async function highlight() {\n const hljs = (await import('highlight.js/lib/common')).default\n try {\n const result = props.language\n ? hljs.highlight(hasCode.value, { language: props.language })\n : hljs.highlightAuto(hasCode.value)\n highlightedHtml.value = result.value\n } catch {\n highlightedHtml.value = hasCode.value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n }\n }\n\n watch(hasCode, highlight, { immediate: true })\n</script>\n\n<template>\n <pre\n :class=\"\n $attrs.class\n ? $attrs.class\n : 'font-mono leading-snug text-smaller bg-surface-1'\n \">\n <code :class=\"['hljs', line ? 'whitespace-pre-line' : 'whitespace-pre', language]\" v-html=\"highlightedHtml\"></code>\n </pre>\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import PkCode from './PkCode.vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { copy, copied } = useClipboard()\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n title: string\n content: string\n artifactType: string\n language?: string\n }\n }\n return part\n })\n\n const artifactTypeLabel = computed(() => {\n const labels: Record<string, string> = {\n code: 'Code',\n document: 'Document',\n markdown: 'Markdown',\n json: 'JSON',\n xml: 'XML',\n csv: 'CSV',\n html: 'HTML',\n yaml: 'YAML',\n sql: 'SQL',\n text: 'Text',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'Artifact'\n }\n return labels[toolPart.value.input.artifactType] || 'Artifact'\n })\n\n const languageLabel = computed(() => {\n if (!toolPart.value.input?.language) {\n return ''\n }\n return ` (${toolPart.value.input.language})`\n })\n\n const isCodeType = computed(() => {\n return (\n toolPart.value.input?.artifactType === 'code' ||\n toolPart.value.input?.artifactType === 'json' ||\n toolPart.value.input?.artifactType === 'xml' ||\n toolPart.value.input?.artifactType === 'yaml' ||\n toolPart.value.input?.artifactType === 'html' ||\n toolPart.value.input?.artifactType === 'sql'\n )\n })\n\n const isMarkdownType = computed(() => {\n return toolPart.value.input?.artifactType === 'markdown'\n })\n\n const codeLanguage = computed(() => {\n if (toolPart.value.input?.language) {\n return toolPart.value.input.language\n }\n // Map artifact types to highlight.js languages\n const languageMap: Record<string, string> = {\n json: 'json',\n xml: 'xml',\n yaml: 'yaml',\n html: 'html',\n sql: 'sql',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'plaintext'\n }\n return languageMap[toolPart.value.input.artifactType] || 'plaintext'\n })\n</script>\n\n<template>\n <div class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center\">\n <div class=\"flex flex-col items-start gap-4\">\n <span>{{ toolPart?.input?.title }}</span>\n <span class=\"text-10 opacity-60 font-normal\">\n {{ artifactTypeLabel }}{{ languageLabel }}\n </span>\n </div>\n <VvButton\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n modifiers=\"action-quiet-small\"\n :title=\"$t('action.copy')\"\n class=\"shrink-0\"\n @click=\"copy(toolPart?.input?.content || '')\" />\n </div>\n <div class=\"px-sm py-10 bg-surface\">\n <PkCode\n v-if=\"isCodeType\"\n :code=\"toolPart?.input?.content\"\n :language=\"codeLanguage\" />\n <PkStreamingMarkdown\n v-else-if=\"isMarkdownType\"\n :markdown=\"toolPart?.input?.content\"\n class=\"wysiwyg text-word-2\" />\n <pre\n v-else\n class=\"text-word-2 whitespace-pre-wrap break-words\"\n :class=\"{\n italic:\n toolPart?.input?.artifactType === 'document' ||\n toolPart?.input?.artifactType === 'text',\n }\"\n >{{ toolPart?.input?.content }}</pre>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { useClipboard } from '@vueuse/core'\n import PkCode from './PkCode.vue'\n import PkStreamingMarkdown from './PkStreamingMarkdown.vue'\n\n const { copy, copied } = useClipboard()\n\n const props = defineProps<{\n part: unknown\n }>()\n\n const toolPart = computed(() => {\n const part = props.part as {\n input?: {\n title: string\n content: string\n artifactType: string\n language?: string\n }\n }\n return part\n })\n\n const artifactTypeLabel = computed(() => {\n const labels: Record<string, string> = {\n code: 'Code',\n document: 'Document',\n markdown: 'Markdown',\n json: 'JSON',\n xml: 'XML',\n csv: 'CSV',\n html: 'HTML',\n yaml: 'YAML',\n sql: 'SQL',\n text: 'Text',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'Artifact'\n }\n return labels[toolPart.value.input.artifactType] || 'Artifact'\n })\n\n const languageLabel = computed(() => {\n if (!toolPart.value.input?.language) {\n return ''\n }\n return ` (${toolPart.value.input.language})`\n })\n\n const isCodeType = computed(() => {\n return (\n toolPart.value.input?.artifactType === 'code' ||\n toolPart.value.input?.artifactType === 'json' ||\n toolPart.value.input?.artifactType === 'xml' ||\n toolPart.value.input?.artifactType === 'yaml' ||\n toolPart.value.input?.artifactType === 'html' ||\n toolPart.value.input?.artifactType === 'sql'\n )\n })\n\n const isMarkdownType = computed(() => {\n return toolPart.value.input?.artifactType === 'markdown'\n })\n\n const codeLanguage = computed(() => {\n if (toolPart.value.input?.language) {\n return toolPart.value.input.language\n }\n // Map artifact types to highlight.js languages\n const languageMap: Record<string, string> = {\n json: 'json',\n xml: 'xml',\n yaml: 'yaml',\n html: 'html',\n sql: 'sql',\n }\n if (!toolPart.value.input?.artifactType) {\n return 'plaintext'\n }\n return languageMap[toolPart.value.input.artifactType] || 'plaintext'\n })\n</script>\n\n<template>\n <div class=\"border border-surface-3 rounded-xl w-full overflow-hidden\">\n <div\n class=\"px-sm py-6 font-bold bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex justify-between items-center\">\n <div class=\"flex flex-col items-start gap-4\">\n <span>{{ toolPart?.input?.title }}</span>\n <span class=\"text-10 opacity-60 font-normal\">\n {{ artifactTypeLabel }}{{ languageLabel }}\n </span>\n </div>\n <VvButton\n :icon=\"copied ? 'ri:check-line' : 'ri:file-copy-line'\"\n :label=\"copied ? $t('action.copied') : $t('action.copy')\"\n modifiers=\"action-quiet-small\"\n :title=\"$t('action.copy')\"\n class=\"shrink-0\"\n @click=\"copy(toolPart?.input?.content || '')\" />\n </div>\n <div class=\"px-sm py-10 bg-surface\">\n <PkCode\n v-if=\"isCodeType\"\n :code=\"toolPart?.input?.content\"\n :language=\"codeLanguage\" />\n <PkStreamingMarkdown\n v-else-if=\"isMarkdownType\"\n :markdown=\"toolPart?.input?.content\"\n class=\"wysiwyg text-word-2\" />\n <pre\n v-else\n class=\"text-word-2 whitespace-pre-wrap break-words\"\n :class=\"{\n italic:\n toolPart?.input?.artifactType === 'document' ||\n toolPart?.input?.artifactType === 'text',\n }\"\n >{{ toolPart?.input?.content }}</pre>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;EAOI,IAAM,IAAQ,GAMR,IAAkB,EAAI,EAAE,GAExB,IAAU,QACR,OAAO,EAAM,QAAS,WACf,EAAM,OAEV,KAAK,UAAU,EAAM,MAAM,MAAM,CAAC,CAC5C;EAED,eAAe,IAAY;GACvB,IAAM,KAAQ,MAAM,OAAO,6DAAA,CAA4B;GACvD,IAAI;IACA,IAAM,IAAS,EAAM,WACf,EAAK,UAAU,EAAQ,OAAO,EAAE,UAAU,EAAM,SAAS,CAAC,IAC1D,EAAK,cAAc,EAAQ,KAAK;IACtC,EAAgB,QAAQ,EAAO;GACnC,QAAQ;IACJ,EAAgB,QAAQ,EAAQ,MAC3B,QAAQ,MAAM,OAAO,CAAA,CACrB,QAAQ,MAAM,MAAM,CAAA,CACpB,QAAQ,MAAM,MAAM;GAC7B;EACJ;SAEA,EAAM,GAAS,GAAW,EAAE,WAAW,GAAK,CAAC,mBAI7C,EAOM,OAAA,EAND,OAAK,EAAeA,EAAAA,OAAO,QAAwBA,EAAAA,OAAO,QAAA,kDAAA,EAAA,GAAA;cAIzD,YACF,EAAA;GAAA,EAAmH,QAAA;IAA5G,OAAK,EAAA;KAAA;KAAW,EAAA,OAAI,wBAAA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GAAE,eAAA,IAAoBA,EAAAA,GAAE,aAAA;IACzC,WAAU;IACT,OAAOA,EAAAA,GAAE,aAAA;IACV,OAAM;IACL,SAAK,AAAA,EAAA,QAAA,MAAE,EAAA,CAAA,CAAI,CAAC,EAAA,OAAU,OAAO,WAAO,EAAA;;;;;SAE7C,EAkBM,OAlBN,GAkBM,CAhBQ,EAAA,SAAA,EAAA,GADV,EAG+B,GAAA;;IAD1B,MAAM,EAAA,OAAU,OAAO;IACvB,UAAU,EAAA;wCAEA,EAAA,SAAA,EAAA,GADf,EAGkC,GAAA;;IAD7B,UAAU,EAAA,OAAU,OAAO;IAC5B,OAAM;sCACV,EAQyC,OAAA;;IANrC,OAAK,EAAA,CAAC,+CAA6C,EAAA,QACW,EAAA,OAAU,OAAO,iBAAY,cAA2C,EAAA,OAAU,OAAO,iBAAY,OAAA,CAAA,CAAA;QAK/J,EAAA,OAAU,OAAO,OAAO,GAAA,CAAA,EAAA,CAAA,CAAA,CAAA"}
@@ -0,0 +1,121 @@
1
+ import { A as e, C as t, T as n, V as r, _ as i, b as a, g as o, kt as s, p as c, qt as l, y as u, z as d } from "./vue.runtime.esm-bundler-DbhD_IvR.js";
2
+ import "./src-BGqVtumX.js";
3
+ import { l as f } from "./index.es-BYny0uhz.js";
4
+ //#region ../../packages/utils/src/video-source.ts
5
+ var p = (e) => e.replace(/[^a-zA-Z0-9_-]/g, ""), m = (e, t) => e === t || e.endsWith(`.${t}`), h = (e) => {
6
+ if (e.hostname.endsWith("youtu.be")) return p(e.pathname.split("/")[1] ?? "") || null;
7
+ let t = e.searchParams.get("v");
8
+ if (t) return p(t) || null;
9
+ let n = e.pathname.match(/^\/(?:shorts|embed|v)\/([^/?#]+)/);
10
+ return n && p(n[1]) || null;
11
+ }, g = (e) => {
12
+ let t = e.pathname.match(/(?:^|\/)(\d+)(?:$|[/?#])/);
13
+ return t ? t[1] : null;
14
+ };
15
+ function _(e, t) {
16
+ let n;
17
+ try {
18
+ n = new URL(e);
19
+ } catch {
20
+ return {
21
+ provider: "file",
22
+ url: e,
23
+ embedUrl: e
24
+ };
25
+ }
26
+ let r = n.hostname.toLowerCase();
27
+ if (m(r, "youtube.com") || m(r, "youtu.be") || m(r, "youtube-nocookie.com")) {
28
+ let t = h(n);
29
+ if (t) return {
30
+ provider: "youtube",
31
+ url: e,
32
+ videoId: t,
33
+ embedUrl: `https://www.youtube-nocookie.com/embed/${t}`,
34
+ thumbnailUrl: `https://img.youtube.com/vi/${t}/hqdefault.jpg`
35
+ };
36
+ }
37
+ if (m(r, "vimeo.com")) {
38
+ let t = g(n);
39
+ if (t) return {
40
+ provider: "vimeo",
41
+ url: e,
42
+ videoId: t,
43
+ embedUrl: `https://player.vimeo.com/video/${t}`
44
+ };
45
+ }
46
+ return t && t !== "file" ? {
47
+ provider: t,
48
+ url: e,
49
+ embedUrl: e
50
+ } : {
51
+ provider: "file",
52
+ url: e,
53
+ embedUrl: e
54
+ };
55
+ }
56
+ e(), s();
57
+ var v = {
58
+ key: 0,
59
+ class: "border border-surface-3 rounded-xl w-full overflow-hidden bg-surface"
60
+ }, y = { class: "px-sm py-6 bg-surface-1 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8 min-h-40" }, b = { class: "font-bold" }, x = { class: "p-sm flex flex-col gap-16" }, S = {
61
+ key: 0,
62
+ class: "font-bold text-14 mb-sm"
63
+ }, C = ["src", "poster"], w = ["href"], T = {
64
+ key: 2,
65
+ class: "relative w-full overflow-hidden rounded-xl bg-word-1",
66
+ style: { "aspect-ratio": "16 / 9" }
67
+ }, E = ["src", "title"], D = {
68
+ key: 3,
69
+ class: "text-12 text-word-3 mt-sm"
70
+ }, O = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share", k = /* @__PURE__ */ n({
71
+ __name: "PkToolShowVideo",
72
+ props: { part: { type: null } },
73
+ setup(e) {
74
+ let n = e, s = o(() => (n.part.input?.videos ?? []).map((e) => ({
75
+ ...e,
76
+ source: _(e.url, e.provider)
77
+ })));
78
+ return (e, n) => {
79
+ let o = f;
80
+ return s.value.length ? (d(), a("div", v, [i("div", y, [t(o, {
81
+ name: "ri:film-line",
82
+ class: "text-16"
83
+ }), i("strong", b, l(e.$t("label.video")), 1)]), i("div", x, [(d(!0), a(c, null, r(s.value, (e) => (d(), a("div", {
84
+ key: e.url,
85
+ class: "flex flex-col"
86
+ }, [
87
+ e.title ? (d(), a("strong", S, l(e.title), 1)) : u("", !0),
88
+ e.source.provider === "file" ? (d(), a("video", {
89
+ key: 1,
90
+ src: e.source.embedUrl,
91
+ poster: e.poster,
92
+ controls: "",
93
+ preload: "metadata",
94
+ playsinline: "",
95
+ class: "w-full rounded-xl bg-word-1",
96
+ style: {
97
+ "aspect-ratio": "16 / 9",
98
+ "max-height": "480px"
99
+ }
100
+ }, [i("a", {
101
+ href: e.url,
102
+ target: "_blank",
103
+ rel: "noopener noreferrer"
104
+ }, l(e.title ?? e.url), 9, w)], 8, C)) : (d(), a("div", T, [i("iframe", {
105
+ src: e.source.embedUrl,
106
+ title: e.title ?? e.url,
107
+ loading: "lazy",
108
+ referrerpolicy: "strict-origin-when-cross-origin",
109
+ allow: O,
110
+ allowfullscreen: "",
111
+ class: "absolute inset-0 w-full h-full border-0"
112
+ }, null, 8, E)])),
113
+ e.description ? (d(), a("span", D, l(e.description), 1)) : u("", !0)
114
+ ]))), 128))])])) : u("", !0);
115
+ };
116
+ }
117
+ });
118
+ //#endregion
119
+ export { k as default };
120
+
121
+ //# sourceMappingURL=PkToolShowVideo-DoLoI8_N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PkToolShowVideo-DoLoI8_N.js","names":["$t"],"sources":["../../../../packages/utils/src/video-source.ts","../../../../packages/components/src/chat/PkToolShowVideo.vue","../../../../packages/components/src/chat/PkToolShowVideo.vue"],"sourcesContent":["/**\n * Video source parsing shared by the backend platform renderer and the frontend\n * player component, so both classify a video URL the same way.\n *\n * A URL is either a known provider (YouTube/Vimeo), which plays through the\n * provider's iframe embed, or a direct media file (`file`), which plays in a\n * native `<video>` element. Detection is by URL shape; an explicit `hint` is\n * used only as a fallback when the URL alone is inconclusive.\n */\n\nexport type VideoProvider = 'youtube' | 'vimeo' | 'file'\n\nexport interface ParsedVideoSource {\n provider: VideoProvider\n /** The original URL, unchanged. */\n url: string\n /**\n * The URL to actually load: the provider iframe embed URL for\n * YouTube/Vimeo, or the direct file URL for `file`.\n */\n embedUrl: string\n /** The provider video id (providers only). */\n videoId?: string\n /**\n * A preview image URL derived from the provider, when one is available\n * without an extra API call (currently YouTube only). Lets a link-only\n * surface (e.g. a Teams card) show a thumbnail instead of a bare link.\n */\n thumbnailUrl?: string\n}\n\n/** Keep only characters that are legal in a provider video id. */\nconst sanitizeId = (raw: string): string => raw.replace(/[^a-zA-Z0-9_-]/g, '')\n\n/**\n * True when `host` is exactly `domain` or a subdomain of it. Guards against\n * lookalike hosts (e.g. `notyoutube.com`) that a bare substring check would\n * misclassify.\n */\nconst hostMatches = (host: string, domain: string): boolean =>\n host === domain || host.endsWith(`.${domain}`)\n\n/** Extract the YouTube video id from any of its URL shapes, or null. */\nconst youtubeId = (u: URL): string | null => {\n // youtu.be/<id>\n if (u.hostname.endsWith('youtu.be')) {\n return sanitizeId(u.pathname.split('/')[1] ?? '') || null\n }\n // youtube.com/watch?v=<id>\n const v = u.searchParams.get('v')\n if (v) {\n return sanitizeId(v) || null\n }\n // youtube.com/shorts/<id>, /embed/<id>, /v/<id>\n const m = u.pathname.match(/^\\/(?:shorts|embed|v)\\/([^/?#]+)/)\n return m ? sanitizeId(m[1]) || null : null\n}\n\n/** Extract the Vimeo (numeric) video id, or null. */\nconst vimeoId = (u: URL): string | null => {\n // player.vimeo.com/video/<id> or vimeo.com/<id>\n const m = u.pathname.match(/(?:^|\\/)(\\d+)(?:$|[/?#])/)\n return m ? m[1] : null\n}\n\n/**\n * Classify a video URL into a provider + a loadable embed/file URL.\n * Falls back to `file` (native `<video>`) for anything not recognized as a\n * supported provider, or when a provider is matched but no id can be extracted.\n */\nexport function parseVideoSource(\n url: string,\n hint?: VideoProvider,\n): ParsedVideoSource {\n let u: URL | undefined\n try {\n u = new URL(url)\n } catch {\n // Not an absolute URL: treat as a direct file reference.\n return { provider: 'file', url, embedUrl: url }\n }\n\n const host = u.hostname.toLowerCase()\n\n const isYouTube =\n hostMatches(host, 'youtube.com') ||\n hostMatches(host, 'youtu.be') ||\n hostMatches(host, 'youtube-nocookie.com')\n if (isYouTube) {\n const id = youtubeId(u)\n if (id) {\n return {\n provider: 'youtube',\n url,\n videoId: id,\n embedUrl: `https://www.youtube-nocookie.com/embed/${id}`,\n thumbnailUrl: `https://img.youtube.com/vi/${id}/hqdefault.jpg`,\n }\n }\n }\n\n if (hostMatches(host, 'vimeo.com')) {\n const id = vimeoId(u)\n if (id) {\n return {\n provider: 'vimeo',\n url,\n videoId: id,\n embedUrl: `https://player.vimeo.com/video/${id}`,\n }\n }\n }\n\n // Honor an explicit provider hint only if we could not extract an id from a\n // provider URL (so a caller-tagged provider link still routes to an iframe\n // via its original URL rather than a broken native <video>).\n if (hint && hint !== 'file') {\n return { provider: hint, url, embedUrl: url }\n }\n\n return { provider: 'file', url, embedUrl: url }\n}\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { parseVideoSource, type VideoProvider } from 'utils'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n interface VideoInput {\n url: string\n title?: string\n description?: string\n poster?: string\n provider?: VideoProvider\n }\n\n // Permissions granted to provider embeds (YouTube/Vimeo players).\n const IFRAME_ALLOW =\n 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share'\n\n const videos = computed(() => {\n const part = props.part as { input?: { videos?: VideoInput[] } }\n return (part.input?.videos ?? []).map((video) => ({\n ...video,\n source: parseVideoSource(video.url, video.provider),\n }))\n })\n</script>\n\n<template>\n <div\n v-if=\"videos.length\"\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 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8 min-h-40\">\n <VvIcon name=\"ri:film-line\" class=\"text-16\" />\n <strong class=\"font-bold\">\n {{ $t('label.video') }}\n </strong>\n </div>\n <div class=\"p-sm flex flex-col gap-16\">\n <div v-for=\"video in videos\" :key=\"video.url\" class=\"flex flex-col\">\n <strong v-if=\"video.title\" class=\"font-bold text-14 mb-sm\">\n {{ video.title }}\n </strong>\n <!-- Direct file: native player. Handles MP4/WebM/OGG and works\n inside the widget's Shadow DOM without any extra CSS. -->\n <video\n v-if=\"video.source.provider === 'file'\"\n :src=\"video.source.embedUrl\"\n :poster=\"video.poster\"\n controls\n preload=\"metadata\"\n playsinline\n class=\"w-full rounded-xl bg-word-1\"\n style=\"aspect-ratio: 16 / 9; max-height: 480px\">\n <a\n :href=\"video.url\"\n target=\"_blank\"\n rel=\"noopener noreferrer\">\n {{ video.title ?? video.url }}\n </a>\n </video>\n <!-- Provider (YouTube/Vimeo): iframe embed, 16:9 responsive. -->\n <div\n v-else\n class=\"relative w-full overflow-hidden rounded-xl bg-word-1\"\n style=\"aspect-ratio: 16 / 9\">\n <iframe\n :src=\"video.source.embedUrl\"\n :title=\"video.title ?? video.url\"\n loading=\"lazy\"\n referrerpolicy=\"strict-origin-when-cross-origin\"\n :allow=\"IFRAME_ALLOW\"\n allowfullscreen\n class=\"absolute inset-0 w-full h-full border-0\"></iframe>\n </div>\n <span\n v-if=\"video.description\"\n class=\"text-12 text-word-3 mt-sm\">\n {{ video.description }}\n </span>\n </div>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n import { computed } from 'vue'\n import { parseVideoSource, type VideoProvider } from 'utils'\n\n const props = defineProps<{\n part: unknown\n }>()\n\n interface VideoInput {\n url: string\n title?: string\n description?: string\n poster?: string\n provider?: VideoProvider\n }\n\n // Permissions granted to provider embeds (YouTube/Vimeo players).\n const IFRAME_ALLOW =\n 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share'\n\n const videos = computed(() => {\n const part = props.part as { input?: { videos?: VideoInput[] } }\n return (part.input?.videos ?? []).map((video) => ({\n ...video,\n source: parseVideoSource(video.url, video.provider),\n }))\n })\n</script>\n\n<template>\n <div\n v-if=\"videos.length\"\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 text-12 border-b border-surface-3 text-word-3 flex items-center gap-8 min-h-40\">\n <VvIcon name=\"ri:film-line\" class=\"text-16\" />\n <strong class=\"font-bold\">\n {{ $t('label.video') }}\n </strong>\n </div>\n <div class=\"p-sm flex flex-col gap-16\">\n <div v-for=\"video in videos\" :key=\"video.url\" class=\"flex flex-col\">\n <strong v-if=\"video.title\" class=\"font-bold text-14 mb-sm\">\n {{ video.title }}\n </strong>\n <!-- Direct file: native player. Handles MP4/WebM/OGG and works\n inside the widget's Shadow DOM without any extra CSS. -->\n <video\n v-if=\"video.source.provider === 'file'\"\n :src=\"video.source.embedUrl\"\n :poster=\"video.poster\"\n controls\n preload=\"metadata\"\n playsinline\n class=\"w-full rounded-xl bg-word-1\"\n style=\"aspect-ratio: 16 / 9; max-height: 480px\">\n <a\n :href=\"video.url\"\n target=\"_blank\"\n rel=\"noopener noreferrer\">\n {{ video.title ?? video.url }}\n </a>\n </video>\n <!-- Provider (YouTube/Vimeo): iframe embed, 16:9 responsive. -->\n <div\n v-else\n class=\"relative w-full overflow-hidden rounded-xl bg-word-1\"\n style=\"aspect-ratio: 16 / 9\">\n <iframe\n :src=\"video.source.embedUrl\"\n :title=\"video.title ?? video.url\"\n loading=\"lazy\"\n referrerpolicy=\"strict-origin-when-cross-origin\"\n :allow=\"IFRAME_ALLOW\"\n allowfullscreen\n class=\"absolute inset-0 w-full h-full border-0\"></iframe>\n </div>\n <span\n v-if=\"video.description\"\n class=\"text-12 text-word-3 mt-sm\">\n {{ video.description }}\n </span>\n </div>\n </div>\n </div>\n</template>\n"],"mappings":";;;;AAgCA,IAAM,KAAc,MAAwB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