@8wave/ai-elements 0.125.0-beta.15 → 0.125.0-beta.17

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 (104) hide show
  1. package/README.md +23 -0
  2. package/dist/_chunks/{PkFilePreview-8nVPKv8k.js → PkFilePreview-BIFkMsAC.js} +559 -718
  3. package/dist/_chunks/PkFilePreview-BIFkMsAC.js.map +1 -0
  4. package/dist/_chunks/{PkFilePreviewDialog-BHPcGlnF.js → PkFilePreviewDialog-NLk4gZMd.js} +8 -8
  5. package/dist/_chunks/{PkFilePreviewDialog-BHPcGlnF.js.map → PkFilePreviewDialog-NLk4gZMd.js.map} +1 -1
  6. package/dist/_chunks/PkSelectionActions-CUymhwsG.js +168 -0
  7. package/dist/_chunks/PkSelectionActions-CUymhwsG.js.map +1 -0
  8. package/dist/ai-elements.es.js +4564 -4169
  9. package/dist/ai-elements.es.js.map +1 -1
  10. package/dist-vue/PkChatbot.js +1 -1
  11. package/dist-vue/PkChatbotEmptyState.js +1 -1
  12. package/dist-vue/PkChatbotInput.js +1 -1
  13. package/dist-vue/PkChatbotMessages.js +1 -1
  14. package/dist-vue/PkChatbotStepPayload.js +1 -1
  15. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  16. package/dist-vue/PkChatbotSteps.js +1 -1
  17. package/dist-vue/PkChatbotViewChat.js +1 -1
  18. package/dist-vue/PkChatbotViewConversations.js +1 -1
  19. package/dist-vue/PkChatbotViewFiles.js +1 -1
  20. package/dist-vue/PkChatbotViewProfile.js +1 -1
  21. package/dist-vue/_chunks/{Agent-DmxsItHG.js → Agent-Cm1LrkYm.js} +162 -162
  22. package/dist-vue/_chunks/{Agent-DmxsItHG.js.map → Agent-Cm1LrkYm.js.map} +1 -1
  23. package/dist-vue/_chunks/{Document-CXfJxfu6.js → Document-DHBTrCuO.js} +10 -10
  24. package/dist-vue/_chunks/{Document-CXfJxfu6.js.map → Document-DHBTrCuO.js.map} +1 -1
  25. package/dist-vue/_chunks/{PkChatbot--fyFCXBu.js → PkChatbot-BtUaZ-LR.js} +10 -9
  26. package/dist-vue/_chunks/PkChatbot-BtUaZ-LR.js.map +1 -0
  27. package/dist-vue/_chunks/{PkChatbotEmptyState-CQ_Qdkge.js → PkChatbotEmptyState-DJIkAskP.js} +2 -2
  28. package/dist-vue/_chunks/{PkChatbotEmptyState-CQ_Qdkge.js.map → PkChatbotEmptyState-DJIkAskP.js.map} +1 -1
  29. package/dist-vue/_chunks/{PkChatbotInput-BVu1b2Te.js → PkChatbotInput-DzqaW3EE.js} +2 -2
  30. package/dist-vue/_chunks/{PkChatbotInput-BVu1b2Te.js.map → PkChatbotInput-DzqaW3EE.js.map} +1 -1
  31. package/dist-vue/_chunks/{PkChatbotMessages-DftNL5ZQ.js → PkChatbotMessages-vkbq5p1X.js} +17 -17
  32. package/dist-vue/_chunks/{PkChatbotMessages-DftNL5ZQ.js.map → PkChatbotMessages-vkbq5p1X.js.map} +1 -1
  33. package/dist-vue/_chunks/{PkChatbotStepPayload-AiDZPbds.js → PkChatbotStepPayload-cuYclK_2.js} +2 -2
  34. package/dist-vue/_chunks/{PkChatbotStepPayload-AiDZPbds.js.map → PkChatbotStepPayload-cuYclK_2.js.map} +1 -1
  35. package/dist-vue/_chunks/{PkChatbotStepToolDetail-CALZDpfQ.js → PkChatbotStepToolDetail-Yd8cUQJP.js} +3 -3
  36. package/dist-vue/_chunks/{PkChatbotStepToolDetail-CALZDpfQ.js.map → PkChatbotStepToolDetail-Yd8cUQJP.js.map} +1 -1
  37. package/dist-vue/_chunks/{PkChatbotSteps-CY7pN2Gl.js → PkChatbotSteps-D5yz8lut.js} +5 -5
  38. package/dist-vue/_chunks/{PkChatbotSteps-CY7pN2Gl.js.map → PkChatbotSteps-D5yz8lut.js.map} +1 -1
  39. package/dist-vue/_chunks/{PkChatbotViewChat-CgJlfyd0.js → PkChatbotViewChat-DCPRePrE.js} +289 -289
  40. package/dist-vue/_chunks/PkChatbotViewChat-DCPRePrE.js.map +1 -0
  41. package/dist-vue/_chunks/{PkChatbotViewConversations-C0KqM_Wq.js → PkChatbotViewConversations-BBd3XMmM.js} +3 -3
  42. package/dist-vue/_chunks/{PkChatbotViewConversations-C0KqM_Wq.js.map → PkChatbotViewConversations-BBd3XMmM.js.map} +1 -1
  43. package/dist-vue/_chunks/{PkChatbotViewFiles-B9mYRoNK.js → PkChatbotViewFiles-BiQzDqJg.js} +3 -3
  44. package/dist-vue/_chunks/{PkChatbotViewFiles-B9mYRoNK.js.map → PkChatbotViewFiles-BiQzDqJg.js.map} +1 -1
  45. package/dist-vue/_chunks/{PkChatbotViewProfile-BfNE3d7F.js → PkChatbotViewProfile-7266UiRM.js} +2 -2
  46. package/dist-vue/_chunks/{PkChatbotViewProfile-BfNE3d7F.js.map → PkChatbotViewProfile-7266UiRM.js.map} +1 -1
  47. package/dist-vue/_chunks/{PkFilePreview-z7JcRtjP.js → PkFilePreview-DLo9nI2g.js} +426 -426
  48. package/dist-vue/_chunks/PkFilePreview-DLo9nI2g.js.map +1 -0
  49. package/dist-vue/_chunks/{PkFilePreviewDialog-zVon3aPY.js → PkFilePreviewDialog-CgDJQgIJ.js} +2 -2
  50. package/dist-vue/_chunks/{PkFilePreviewDialog-zVon3aPY.js.map → PkFilePreviewDialog-CgDJQgIJ.js.map} +1 -1
  51. package/dist-vue/_chunks/{PkStreamingMarkdown-bJEDk-kM.js → PkStreamingMarkdown-C3UGCEXm.js} +3 -3
  52. package/dist-vue/_chunks/{PkStreamingMarkdown-bJEDk-kM.js.map → PkStreamingMarkdown-C3UGCEXm.js.map} +1 -1
  53. package/dist-vue/_chunks/{PkToolChatFile-DqLGwJxp.js → PkToolChatFile-Dy0rGC29.js} +3 -3
  54. package/dist-vue/_chunks/{PkToolChatFile-DqLGwJxp.js.map → PkToolChatFile-Dy0rGC29.js.map} +1 -1
  55. package/dist-vue/_chunks/{PkToolRequestGeolocation-BnV7A6SW.js → PkToolRequestGeolocation-p7Ip17F7.js} +2 -2
  56. package/dist-vue/_chunks/{PkToolRequestGeolocation-BnV7A6SW.js.map → PkToolRequestGeolocation-p7Ip17F7.js.map} +1 -1
  57. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-QCbQ7bnl.js → PkToolRequestOAuthConnection-CtXSzKzM.js} +2 -2
  58. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-QCbQ7bnl.js.map → PkToolRequestOAuthConnection-CtXSzKzM.js.map} +1 -1
  59. package/dist-vue/_chunks/{PkToolShowArtifact-DanzULWt.js → PkToolShowArtifact-B7udnhpb.js} +2 -2
  60. package/dist-vue/_chunks/{PkToolShowArtifact-DanzULWt.js.map → PkToolShowArtifact-B7udnhpb.js.map} +1 -1
  61. package/dist-vue/_chunks/{PkToolShowContactForm-DzttQBG6.js → PkToolShowContactForm-0SEgxn2S.js} +2 -2
  62. package/dist-vue/_chunks/{PkToolShowContactForm-DzttQBG6.js.map → PkToolShowContactForm-0SEgxn2S.js.map} +1 -1
  63. package/dist-vue/_chunks/{PkToolShowDiagram-BNa89wcw.js → PkToolShowDiagram-BqHBhZgd.js} +2 -2
  64. package/dist-vue/_chunks/{PkToolShowDiagram-BNa89wcw.js.map → PkToolShowDiagram-BqHBhZgd.js.map} +1 -1
  65. package/dist-vue/_chunks/{PkToolShowForm-BXol1WE3.js → PkToolShowForm-C4n_3mFL.js} +4 -4
  66. package/dist-vue/_chunks/{PkToolShowForm-BXol1WE3.js.map → PkToolShowForm-C4n_3mFL.js.map} +1 -1
  67. package/dist-vue/_chunks/{PkToolShowImageGallery-Dmr5zXTj.js → PkToolShowImageGallery-DEpdtLns.js} +2 -2
  68. package/dist-vue/_chunks/{PkToolShowImageGallery-Dmr5zXTj.js.map → PkToolShowImageGallery-DEpdtLns.js.map} +1 -1
  69. package/dist-vue/_chunks/{PkToolShowProductList-C_uIUG_G.js → PkToolShowProductList-Bm2NLUGS.js} +2 -2
  70. package/dist-vue/_chunks/{PkToolShowProductList-C_uIUG_G.js.map → PkToolShowProductList-Bm2NLUGS.js.map} +1 -1
  71. package/dist-vue/_chunks/{PkToolShowSources-BHRNGn4s.js → PkToolShowSources-DwFqlit2.js} +3 -3
  72. package/dist-vue/_chunks/{PkToolShowSources-BHRNGn4s.js.map → PkToolShowSources-DwFqlit2.js.map} +1 -1
  73. package/dist-vue/_chunks/{PkToolShowSuggestedReply-DHCqxA1P.js → PkToolShowSuggestedReply-BRIzGNwx.js} +2 -2
  74. package/dist-vue/_chunks/{PkToolShowSuggestedReply-DHCqxA1P.js.map → PkToolShowSuggestedReply-BRIzGNwx.js.map} +1 -1
  75. package/dist-vue/_chunks/{PkToolShowVideo-P4H5A7ke.js → PkToolShowVideo-BLEJ8tng.js} +2 -2
  76. package/dist-vue/_chunks/{PkToolShowVideo-P4H5A7ke.js.map → PkToolShowVideo-BLEJ8tng.js.map} +1 -1
  77. package/dist-vue/_chunks/{PkToolShowWebPages-BzNZHR7Q.js → PkToolShowWebPages-CeAXllAF.js} +2 -2
  78. package/dist-vue/_chunks/{PkToolShowWebPages-BzNZHR7Q.js.map → PkToolShowWebPages-CeAXllAF.js.map} +1 -1
  79. package/dist-vue/_chunks/{createChatbotApiClient-CQjxHqLr.js → createChatbotApiClient-BPN6cLGF.js} +14 -14
  80. package/dist-vue/_chunks/{createChatbotApiClient-CQjxHqLr.js.map → createChatbotApiClient-BPN6cLGF.js.map} +1 -1
  81. package/dist-vue/_chunks/{useChatbotStore-CyZha9pf.js → useChatbotStore-C4xhJtrb.js} +1242 -1242
  82. package/dist-vue/_chunks/{useChatbotStore-CyZha9pf.js.map → useChatbotStore-C4xhJtrb.js.map} +1 -1
  83. package/dist-vue/_chunks/{utils-8lO2Gj-m.js → utils-RwaXl9-x.js} +4 -4
  84. package/dist-vue/_chunks/{utils-8lO2Gj-m.js.map → utils-RwaXl9-x.js.map} +1 -1
  85. package/dist-vue/api.js +1 -1
  86. package/dist-vue/apps/web-component/src/components/EmbeddedChatWidget.ce.d.ts +4 -4
  87. package/dist-vue/apps/web-component/src/composables/usePagePointer.d.ts +14 -9
  88. package/dist-vue/apps/web-component/src/composables/usePendingMessage.d.ts +29 -15
  89. package/dist-vue/apps/web-component/src/composables/useSelectionActions.d.ts +77 -0
  90. package/dist-vue/composables.js +34 -8
  91. package/dist-vue/composables.js.map +1 -1
  92. package/dist-vue/index.js +5401 -5321
  93. package/dist-vue/index.js.map +1 -1
  94. package/dist-vue/locales.js +22 -2
  95. package/dist-vue/packages/components/src/chat/PkAgentSelectionActionsSettings.d.ts +25 -0
  96. package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +23 -3
  97. package/dist-vue/packages/components/src/chat/PkChatbot.d.ts +2 -1
  98. package/dist-vue/packages/components/src/chat/PkSelectionActions.d.ts +2 -12
  99. package/dist-vue/packages/components/src/chat/PkSelectionAnswerCard.d.ts +41 -0
  100. package/package.json +1 -1
  101. package/dist/_chunks/PkFilePreview-8nVPKv8k.js.map +0 -1
  102. package/dist-vue/_chunks/PkChatbot--fyFCXBu.js.map +0 -1
  103. package/dist-vue/_chunks/PkChatbotViewChat-CgJlfyd0.js.map +0 -1
  104. package/dist-vue/_chunks/PkFilePreview-z7JcRtjP.js.map +0 -1
@@ -1,11 +1,11 @@
1
1
  import { J as e, N as t, S as n, _ as r, k as i, tt as a, w as o, z as s } from "./vue.runtime.esm-bundler-C2U5uTqB.js";
2
2
  import { d as c } from "./index.es-D-aOuzzp.js";
3
- import { t as l } from "./PkFilePreview-8nVPKv8k.js";
4
- import { t as u } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
3
+ import { t as l } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
4
+ import { t as u } from "./PkFilePreview-BIFkMsAC.js";
5
5
  // ../../packages/components/src/chat/PkFilePreviewDialog.vue?vue&type=script&setup=true&lang.ts
6
6
  i();
7
7
  // ../../packages/components/src/chat/PkFilePreviewDialog.vue
8
- var d = /*#__PURE__*/ u(/* @__PURE__ */ o({
8
+ var d = /*#__PURE__*/ l(/* @__PURE__ */ o({
9
9
  __name: "PkFilePreviewDialog",
10
10
  props: /*@__PURE__*/ t({
11
11
  target: { type: Object },
@@ -44,7 +44,7 @@ var d = /*#__PURE__*/ u(/* @__PURE__ */ o({
44
44
  "update:fit"
45
45
  ]),
46
46
  setup(t, { emit: i }) {
47
- let o = i, u = e(t, "mode"), d = e(t, "sheet"), f = e(t, "zoom"), p = e(t, "fit");
47
+ let o = i, l = e(t, "mode"), d = e(t, "sheet"), f = e(t, "zoom"), p = e(t, "fit");
48
48
  return (e, i) => {
49
49
  let m = c;
50
50
  return s(), r(m, {
@@ -54,9 +54,9 @@ var d = /*#__PURE__*/ u(/* @__PURE__ */ o({
54
54
  class: "pk-file-preview-dialog",
55
55
  "onUpdate:modelValue": i[9] ||= (e) => !e && o("close")
56
56
  }, {
57
- default: a(() => [n(l, {
58
- mode: u.value,
59
- "onUpdate:mode": i[0] ||= (e) => u.value = e,
57
+ default: a(() => [n(u, {
58
+ mode: l.value,
59
+ "onUpdate:mode": i[0] ||= (e) => l.value = e,
60
60
  sheet: d.value,
61
61
  "onUpdate:sheet": i[1] ||= (e) => d.value = e,
62
62
  zoom: f.value,
@@ -107,4 +107,4 @@ var d = /*#__PURE__*/ u(/* @__PURE__ */ o({
107
107
  }), [["styles", [".pk-file-preview-dialog:not(.vv-dialog--fullscreen)>article{width:min(90rem,94dvw);height:92dvh}.pk-file-preview-dialog.vv-dialog--fullscreen>article{max-height:none}.pk-file-preview-dialog .vv-dialog__content{flex-direction:column;flex:1;min-height:0;padding:0;display:flex}"]]]);
108
108
  export { d as default };
109
109
 
110
- //# sourceMappingURL=PkFilePreviewDialog-BHPcGlnF.js.map
110
+ //# sourceMappingURL=PkFilePreviewDialog-NLk4gZMd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PkFilePreviewDialog-BHPcGlnF.js","names":["_useModel","__unplugin_components_0","_openBlock","_createBlock","_withCtx","_createVNode","PkFilePreview","_sfc_main","_style_0","useModel","mergeModels","createVNode","createBlock","init_runtime_core_esm_bundler","withCtx","defineComponent","openBlock","nu","PkFilePreview_default","_plugin_vue_export_helper_default","PkFilePreviewDialog_default","\"mode\"","\"modeModifiers\"","\"sheet\"","\"sheetModifiers\"","\"zoom\"","\"zoomModifiers\"","\"fit\"","\"fitModifiers\"","__emit","emit","mode","__props","sheet","zoom","fit","_component_VvDialog","_cache","$event","text","pointer","action"],"sources":["../../../../packages/components/src/chat/PkFilePreviewDialog.vue","../../../../packages/components/src/chat/PkFilePreviewDialog.vue","../../../../packages/components/src/chat/PkFilePreviewDialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCI,IAAM8B,IAAOD,GAaPE,IAAO/B,EAA4BgC,GAAC,MAAM,GAC1CC,IAAQjC,EAAmBgC,GAAC,OAAO,GACnCE,IAAOlC,EAAmBgC,GAAC,MAAM,GAGjCG,IAAMnC,EAAoBgC,GAAC,KAAwB;;;GAIzD,OAAA9B,EAAA,GAAAC,EAgCWiC,GAAA;IA/BN,eAAa;IACb,cAAYJ,EAAA,OAAO;IACnB,WAAWA,EAAA,aAAU,eAAkB,KAAA;IACxC,OAAM;IACL,uBAAkB,AAAAK,EAAA,QAAA,MAAA,CAAGC,KAAUR,EAAI,OAAA;;IACpC,SAAA1B,QAyB6B,CAzB7BC,EAyB6BC,GAAA;KAxBjB,MAAMyB,EAAA;KAAA,iBAAA,AAAAM,EAAA,QAAA,MAAA,EAAI,QAAAC;KACV,OAAOL,EAAA;KAAA,kBAAA,AAAAI,EAAA,QAAA,MAAA,EAAK,QAAAC;KACZ,MAAMJ,EAAA;KAAA,iBAAA,AAAAG,EAAA,QAAA,MAAA,EAAI,QAAAC;KACV,KAAKH,EAAA;KAAA,gBAAA,AAAAE,EAAA,QAAA,MAAA,EAAG,QAAAC;KACf,MAAMN,EAAA,OAAO;KACb,UAAUA,EAAA,OAAO;KACjB,SAASA,EAAA,OAAO;KAChB,UAAAA,EAAA;KACA,gBAAAA,EAAA;KACA,SAAAA,EAAA;KACA,SAAAA,EAAA;KACA,OAAAA,EAAA;KACA,YAAAA,EAAA;KACA,QAAAA,EAAA;KACA,WAASA,EAAA,OAAO;KAChB,oBAAkBA,EAAA,OAAO;KACzB,qBAAAA,EAAA;KACA,WAAO,AAAAK,EAAA,QAAA,MAAEP,EAAI,WAAYQ,CAAM;KAC/B,WAAO,AAAAD,EAAA,QAAA,MAAEP,EAAI,SAAA;KACb,UAAM,AAAAO,EAAA,QAAA,MAAEP,EAAI,QAAA;KACZ,iBAAc,AAAAO,EAAA,QAAoB,GAAM,GAAS,MAA+BP,EAAI,iBAAkBS,GAAMC,GAASC,CAAM;KAI3H,SAAK,AAAAJ,EAAA,QAAA,MAAEP,EAAI,OAAA"}
1
+ {"version":3,"file":"PkFilePreviewDialog-NLk4gZMd.js","names":["_useModel","__unplugin_components_0","_openBlock","_createBlock","_withCtx","_createVNode","PkFilePreview","_sfc_main","_style_0","useModel","mergeModels","createVNode","createBlock","init_runtime_core_esm_bundler","withCtx","defineComponent","openBlock","nu","_plugin_vue_export_helper_default","PkFilePreview_default","PkFilePreviewDialog_default","\"mode\"","\"modeModifiers\"","\"sheet\"","\"sheetModifiers\"","\"zoom\"","\"zoomModifiers\"","\"fit\"","\"fitModifiers\"","__emit","emit","mode","__props","sheet","zoom","fit","_component_VvDialog","_cache","$event","text","pointer","action"],"sources":["../../../../packages/components/src/chat/PkFilePreviewDialog.vue","../../../../packages/components/src/chat/PkFilePreviewDialog.vue","../../../../packages/components/src/chat/PkFilePreviewDialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCI,IAAM8B,IAAOD,GAaPE,IAAO/B,EAA4BgC,GAAC,MAAM,GAC1CC,IAAQjC,EAAmBgC,GAAC,OAAO,GACnCE,IAAOlC,EAAmBgC,GAAC,MAAM,GAGjCG,IAAMnC,EAAoBgC,GAAC,KAAwB;;;GAIzD,OAAA9B,EAAA,GAAAC,EAgCWiC,GAAA;IA/BN,eAAa;IACb,cAAYJ,EAAA,OAAO;IACnB,WAAWA,EAAA,aAAU,eAAkB,KAAA;IACxC,OAAM;IACL,uBAAkB,AAAAK,EAAA,QAAA,MAAA,CAAGC,KAAUR,EAAI,OAAA;;IACpC,SAAA1B,QAyB6B,CAzB7BC,EAyB6BC,GAAA;KAxBjB,MAAMyB,EAAA;KAAA,iBAAA,AAAAM,EAAA,QAAA,MAAA,EAAI,QAAAC;KACV,OAAOL,EAAA;KAAA,kBAAA,AAAAI,EAAA,QAAA,MAAA,EAAK,QAAAC;KACZ,MAAMJ,EAAA;KAAA,iBAAA,AAAAG,EAAA,QAAA,MAAA,EAAI,QAAAC;KACV,KAAKH,EAAA;KAAA,gBAAA,AAAAE,EAAA,QAAA,MAAA,EAAG,QAAAC;KACf,MAAMN,EAAA,OAAO;KACb,UAAUA,EAAA,OAAO;KACjB,SAASA,EAAA,OAAO;KAChB,UAAAA,EAAA;KACA,gBAAAA,EAAA;KACA,SAAAA,EAAA;KACA,SAAAA,EAAA;KACA,OAAAA,EAAA;KACA,YAAAA,EAAA;KACA,QAAAA,EAAA;KACA,WAASA,EAAA,OAAO;KAChB,oBAAkBA,EAAA,OAAO;KACzB,qBAAAA,EAAA;KACA,WAAO,AAAAK,EAAA,QAAA,MAAEP,EAAI,WAAYQ,CAAM;KAC/B,WAAO,AAAAD,EAAA,QAAA,MAAEP,EAAI,SAAA;KACb,UAAM,AAAAO,EAAA,QAAA,MAAEP,EAAI,QAAA;KACZ,iBAAc,AAAAO,EAAA,QAAoB,GAAM,GAAS,MAA+BP,EAAI,iBAAkBS,GAAMC,GAASC,CAAM;KAI3H,SAAK,AAAAJ,EAAA,QAAA,MAAEP,EAAI,OAAA"}
@@ -0,0 +1,168 @@
1
+ import { Et as e, F as t, J as n, N as r, Ot as i, Tt as a, V as o, X as s, c, d as l, f as u, g as d, gt as f, h as p, k as m, kt as h, nt as g, ot as _, pt as v, r as y, u as b, v as x, vt as S, w as C, wt as w, y as T, z as E } from "./vue.runtime.esm-bundler-C2U5uTqB.js";
2
+ import { r as D } from "./vue-i18n-POtLvOl1.js";
3
+ import { I as O } from "./utils-BZuri2jT.js";
4
+ import { l as k } from "./dist-D6oUr4J_.js";
5
+ import { t as A } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
6
+ // ../../packages/composable/src/useSettledSelection.ts
7
+ _();
8
+ var j = "(hover: hover) and (pointer: fine)";
9
+ function M(e) {
10
+ let t = document.getSelection();
11
+ if (!t || t.rangeCount === 0) return;
12
+ if (e.nodeType === Node.DOCUMENT_NODE) return t.getRangeAt(0).cloneRange();
13
+ let n = e;
14
+ if (t.getComposedRanges) {
15
+ let e;
16
+ try {
17
+ e = t.getComposedRanges({ shadowRoots: [n] });
18
+ } catch {
19
+ e = t.getComposedRanges(n);
20
+ }
21
+ let [r] = e;
22
+ if (!r) return;
23
+ let i = document.createRange();
24
+ return i.setStart(r.startContainer, r.startOffset), i.setEnd(r.endContainer, r.endOffset), i;
25
+ }
26
+ let r = n.getSelection?.();
27
+ return r && r.rangeCount > 0 ? r.getRangeAt(0).cloneRange() : void 0;
28
+ }
29
+ function N({ root: e, enabled: t = () => !0, delay: n = 150, minChars: r = 2 }) {
30
+ let i = S(), a, o = () => {
31
+ clearTimeout(a), i.value = void 0;
32
+ }, s = () => {
33
+ let n = e();
34
+ if (!n || !t()) return;
35
+ let i = M(n);
36
+ if (!i || i.collapsed || i.toString().trim().length < r) return;
37
+ let a = i.getBoundingClientRect();
38
+ return {
39
+ range: i,
40
+ start: i.getClientRects()[0] ?? a,
41
+ box: a
42
+ };
43
+ }, c = () => {
44
+ o(), a = setTimeout(() => {
45
+ i.value = s();
46
+ }, n);
47
+ };
48
+ return typeof document < "u" && typeof matchMedia == "function" && matchMedia(j).matches && (document.addEventListener("selectionchange", c), v(() => {
49
+ clearTimeout(a), document.removeEventListener("selectionchange", c);
50
+ })), {
51
+ selection: i,
52
+ clear: o
53
+ };
54
+ }
55
+ // ../../packages/components/src/chat/PkSelectionActions.vue?vue&type=script&setup=true&lang.ts
56
+ m(), y(), _(), a();
57
+ var P = ["onKeydown"], F = ["placeholder", "aria-label"], I = ["disabled"], L = ["aria-label"], R = { class: "pk-selection-actions__text" }, z = {
58
+ key: 0,
59
+ class: "pk-selection-actions__text"
60
+ }, B = ["onClick"], V = /*#__PURE__*/ A(/* @__PURE__ */ C({
61
+ __name: "PkSelectionActions",
62
+ props: /*@__PURE__*/ r({
63
+ actions: { type: Array },
64
+ anchor: { type: Object },
65
+ strategy: { type: String },
66
+ hint: { type: String },
67
+ note: { type: String },
68
+ noteAction: { type: String },
69
+ touch: { type: Boolean }
70
+ }, {
71
+ asking: {
72
+ type: Boolean,
73
+ default: !1
74
+ },
75
+ askingModifiers: {}
76
+ }),
77
+ emits: /*@__PURE__*/ r([
78
+ "action",
79
+ "ask",
80
+ "note",
81
+ "close"
82
+ ], ["update:asking"]),
83
+ setup(r, { emit: a }) {
84
+ let m = r, _ = a, v = n(r, "asking"), { t: y } = D({ useScope: "global" }), S = s("barEl"), C = s("inputEl"), { width: A, height: j } = k(S, void 0, { box: "border-box" }), M = p(() => O({
85
+ ...m.anchor,
86
+ bar: {
87
+ width: A.value,
88
+ height: j.value
89
+ },
90
+ touch: m.touch
91
+ })), N = f(), V = f(""), H = async (e, n) => {
92
+ N.value = {
93
+ id: e,
94
+ placeholder: n
95
+ }, V.value = "", v.value = !0, await t(), C.value?.focus();
96
+ }, U = () => {
97
+ N.value = void 0, v.value = !1;
98
+ }, W = (e) => {
99
+ e.asks ? H(e.id, e.asks) : _("action", e.id);
100
+ }, G = () => {
101
+ let e = V.value.trim();
102
+ e && N.value && (N.value.id ? _("action", N.value.id, e) : _("ask", e), U());
103
+ }, K = () => {
104
+ N.value ? U() : _("close");
105
+ };
106
+ return (t, n) => (E(), T("div", {
107
+ class: e(["pk-selection-actions", {
108
+ "pk-selection-actions--fixed": r.strategy === "fixed",
109
+ "pk-selection-actions--asking": !!N.value
110
+ }]),
111
+ style: i({
112
+ top: `${M.value.top}px`,
113
+ left: `${M.value.left}px`
114
+ }),
115
+ onKeydown: b(l(K, ["stop"]), ["esc"])
116
+ }, [N.value ? (E(), T("form", {
117
+ key: 0,
118
+ ref_key: "barEl",
119
+ ref: S,
120
+ class: "pk-selection-actions__bar pk-selection-actions__bar--field",
121
+ onSubmit: l(G, ["prevent"])
122
+ }, [g(d("input", {
123
+ ref_key: "inputEl",
124
+ ref: C,
125
+ "onUpdate:modelValue": n[0] ||= (e) => V.value = e,
126
+ class: "pk-selection-actions__input",
127
+ type: "text",
128
+ maxlength: "500",
129
+ placeholder: N.value.placeholder,
130
+ "aria-label": N.value.placeholder
131
+ }, null, 8, F), [[c, V.value]]), d("button", {
132
+ type: "submit",
133
+ class: "pk-selection-actions__button pk-selection-actions__button--send",
134
+ disabled: !V.value.trim()
135
+ }, h(w(y)("action.send")), 9, I)], 544)) : (E(), T("div", {
136
+ key: 1,
137
+ ref_key: "barEl",
138
+ ref: S,
139
+ class: "pk-selection-actions__bar",
140
+ role: "toolbar",
141
+ "aria-label": w(y)("selectionActions.label")
142
+ }, [r.note ? (E(), T(u, { key: 0 }, [d("span", R, h(r.note), 1), r.noteAction ? (E(), T("button", {
143
+ key: 0,
144
+ type: "button",
145
+ class: "pk-selection-actions__button",
146
+ onMousedown: n[1] ||= l(() => {}, ["prevent"]),
147
+ onClick: n[2] ||= (e) => _("note")
148
+ }, h(r.noteAction), 33)) : x("", !0)], 64)) : (E(), T(u, { key: 1 }, [
149
+ r.hint ? (E(), T("span", z, h(r.hint), 1)) : x("", !0),
150
+ (E(!0), T(u, null, o(r.actions, (e) => (E(), T("button", {
151
+ key: e.id,
152
+ type: "button",
153
+ class: "pk-selection-actions__button",
154
+ onMousedown: n[3] ||= l(() => {}, ["prevent"]),
155
+ onClick: (t) => W(e)
156
+ }, h(e.label), 41, B))), 128)),
157
+ d("button", {
158
+ type: "button",
159
+ class: "pk-selection-actions__button",
160
+ onMousedown: n[4] ||= l(() => {}, ["prevent"]),
161
+ onClick: n[5] ||= (e) => H(void 0, w(y)("selectionActions.askPlaceholder"))
162
+ }, h(w(y)("selectionActions.ask")), 33)
163
+ ], 64))], 8, L))], 46, P));
164
+ }
165
+ }), [["styles", [".pk-selection-actions{z-index:10;max-width:min(32rem, 100% - var(--spacing-16));position:absolute}.pk-selection-actions--fixed{z-index:2147483647;position:fixed}.pk-selection-actions--asking{width:min(var(--spacing-384), 100% - var(--spacing-16))}.pk-selection-actions__bar{align-items:center;gap:var(--spacing-4);width:max-content;max-width:100%;padding:var(--spacing-4);border-radius:var(--rounded-lg);background-color:var(--color-word-1);color:var(--color-surface);font-family:var(--font-sans);font-size:var(--text-14);font-weight:var(--font-medium);box-shadow:var(--shadow-lg);flex-wrap:wrap;display:flex}.pk-selection-actions__bar--field{flex-wrap:nowrap;width:100%}.pk-selection-actions__text{padding:0 var(--spacing-8);opacity:.75;font-size:var(--text-12);font-weight:var(--font-normal)}.pk-selection-actions__button{border-radius:var(--rounded);padding:var(--spacing-6) var(--spacing-10);color:inherit;font:inherit;cursor:pointer;background-color:#0000;border:0;flex-shrink:0}.pk-selection-actions__button:hover{background-color:color-mix(in srgb, var(--color-surface) 16%, transparent)}.pk-selection-actions__button:focus-visible{outline:var(--spacing-2) solid var(--color-surface);outline-offset:calc(-1 * var(--spacing-2))}.pk-selection-actions__button--send{background-color:var(--color-surface);color:var(--color-word-1)}.pk-selection-actions__button--send:hover{background-color:var(--color-surface)}.pk-selection-actions__button--send:disabled{opacity:.5;cursor:default}.pk-selection-actions__input{border-radius:var(--rounded);min-width:0;padding:var(--spacing-6) var(--spacing-8);background-color:color-mix(in srgb, var(--color-surface) 12%, transparent);color:inherit;font:inherit;font-weight:var(--font-normal);border:0;flex:1}.pk-selection-actions__input::placeholder{color:inherit;opacity:.6}.pk-selection-actions__input:focus-visible{outline:var(--spacing-2) solid var(--color-surface);outline-offset:calc(-1 * var(--spacing-2))}"]]]);
166
+ export { N as n, V as t };
167
+
168
+ //# sourceMappingURL=PkSelectionActions-CUymhwsG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PkSelectionActions-CUymhwsG.js","names":["settled","_useModel","_openBlock","_createElementBlock","_normalizeClass","_normalizeStyle","_withKeys","_withModifiers","_withDirectives","_createElementVNode","_vModelText","_toDisplayString","_unref","_Fragment","_createCommentVNode","_renderList","_sfc_main","_style_0","normalizeClass","nextTick","useModel","mergeModels","normalizeStyle","init_shared_esm_bundler","renderList","useTemplateRef","withModifiers","Fragment","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","withDirectives","init_reactivity_esm_bundler","onScopeDispose","init_runtime_dom_esm_bundler","withKeys","createCommentVNode","shallowRef","defineComponent","unref","createElementBlock","openBlock","useI18n","selectionBarPosition","useElementSize","_plugin_vue_export_helper_default","FINE_POINTER","rangeIn","selection","root","shadow","ranges","first","range","own","useSettledSelection","timer","clear","read","node","enabled","minChars","box","onChange","delay","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","PkSelectionActions_default","\"asking\"","\"askingModifiers\"","__emit","props","__props","emit","asking","$t","barEl","inputEl","position","width","height","field","text","openField","closeField","run","action","submit","value","onEscape","_cache","$event","vModelText"],"sources":["../../../../packages/composable/src/useSettledSelection.ts","../../../../packages/components/src/chat/PkSelectionActions.vue","../../../../packages/components/src/chat/PkSelectionActions.vue","../../../../packages/components/src/chat/PkSelectionActions.vue"],"sourcesContent":["import { onScopeDispose, shallowRef, type ShallowRef } from 'vue'\n\n/** A selection that stayed still: its range and where it is on screen. */\nexport interface SettledSelection {\n range: Range\n /** The box of its first line: a bar goes above the start of a selection. */\n start: DOMRect\n /** The box of the whole selection. */\n box: DOMRect\n}\n\nexport interface UseSettledSelectionOptions {\n /** Where the range is read: the document, or the shadow root the selection is in. */\n root: () => Document | ShadowRoot | null | undefined\n /** Held off while false: the page while the user points, under a modal, during a turn. */\n enabled?: () => boolean\n /** How long the selection stays still before it counts, in ms. */\n delay?: number\n /** The shortest text that counts. */\n minChars?: number\n}\n\n/** A pointer that hovers: on a touch screen the system has its own menu on a selection. */\nconst FINE_POINTER = '(hover: hover) and (pointer: fine)'\n\ntype ComposedSelection = Selection & {\n getComposedRanges?: (\n ...args: [{ shadowRoots: ShadowRoot[] }] | ShadowRoot[]\n ) => StaticRange[]\n}\n\n/**\n * The first range of the selection, read inside `root`, as a copy: the\n * selection's own range is live, and Chrome collapses it as soon as the\n * focus moves into the bar's field. In a shadow root the document's\n * selection stops at its host: the composed range reads past it (Chrome 137,\n * Safari 17, Firefox 142; Safari took the roots as arguments before the\n * options object), and Chromium's own selection of the root is the fallback.\n * Without either nothing is read, and no bar appears.\n */\nfunction rangeIn(root: Document | ShadowRoot): Range | undefined {\n const selection = document.getSelection() as ComposedSelection | null\n if (!selection || selection.rangeCount === 0) {\n return undefined\n }\n if (root.nodeType === Node.DOCUMENT_NODE) {\n return selection.getRangeAt(0).cloneRange()\n }\n const shadow = root as ShadowRoot\n if (selection.getComposedRanges) {\n let ranges: StaticRange[]\n try {\n ranges = selection.getComposedRanges({ shadowRoots: [shadow] })\n } catch {\n ranges = selection.getComposedRanges(shadow)\n }\n const [first] = ranges\n if (!first) {\n return undefined\n }\n const range = document.createRange()\n range.setStart(first.startContainer, first.startOffset)\n range.setEnd(first.endContainer, first.endOffset)\n return range\n }\n const own = (\n shadow as ShadowRoot & { getSelection?: () => Selection | null }\n ).getSelection?.()\n return own && own.rangeCount > 0\n ? own.getRangeAt(0).cloneRange()\n : undefined\n}\n\n/**\n * The selection once it stays still (spec `selection-actions.md`, \"Cosa è\n * comune\"): what the bar of actions appears on, on the page that embeds the\n * widget and in the chat's file viewer. `selectionchange` fires on the\n * document wherever the selection is, so the document is always listened to\n * and `root` only says where the range is read. Nothing on a touch screen.\n * Undefined while the selection moves, is collapsed or shorter than\n * `minChars`; each reader then checks that the range is its own.\n */\nexport function useSettledSelection({\n root,\n enabled = () => true,\n delay = 150,\n minChars = 2,\n}: UseSettledSelectionOptions) {\n const selection = shallowRef<SettledSelection | undefined>()\n let timer: ReturnType<typeof setTimeout> | undefined\n\n const clear = () => {\n clearTimeout(timer)\n selection.value = undefined\n }\n\n const read = (): SettledSelection | undefined => {\n const node = root()\n if (!node || !enabled()) {\n return undefined\n }\n const range = rangeIn(node)\n if (\n !range ||\n range.collapsed ||\n range.toString().trim().length < minChars\n ) {\n return undefined\n }\n const box = range.getBoundingClientRect()\n return { range, start: range.getClientRects()[0] ?? box, box }\n }\n\n const onChange = () => {\n clear()\n timer = setTimeout(() => {\n selection.value = read()\n }, delay)\n }\n\n const finePointer =\n typeof document !== 'undefined' &&\n typeof matchMedia === 'function' &&\n matchMedia(FINE_POINTER).matches\n if (finePointer) {\n document.addEventListener('selectionchange', onChange)\n onScopeDispose(() => {\n clearTimeout(timer)\n document.removeEventListener('selectionchange', onChange)\n })\n }\n\n // Not `readonly()`: its deep proxy around a Range breaks the Range's methods\n const settled: Readonly<ShallowRef<SettledSelection | undefined>> =\n selection\n return { selection: settled, clear }\n}\n","<script setup lang=\"ts\">\n import { computed, nextTick, ref, useTemplateRef } from 'vue'\n import { useElementSize } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import { selectionBarPosition } from './utils'\n\n /**\n * The bar of actions on a selection (spec `selection-actions.md`, \"Cosa\n * è comune\"), on the page that embeds the widget and in the chat's file\n * viewer: the agent's actions, then \"Ask…\", which turns the bar into a\n * field. An action may ask for a word first (`asks`: \"Translate\" asks the\n * language). It sits above the start of the selection, below it without\n * room there (`selectionBarPosition`). Its buttons take no focus on a\n * click, so the selection stays and Cmd+C still copies it; the keyboard\n * reaches them with Tab.\n */\n\n export type SelectionBarAction = {\n id: string\n label: string\n /** The placeholder of a field the action opens before it is sent. */\n asks?: string\n }\n\n const props = defineProps<{\n actions: SelectionBarAction[]\n /** The selection, in the coordinates of the box the bar is positioned in. */\n anchor: {\n start: { top: number; left: number }\n bottom: number\n bounds: { top: number; left: number; width: number; height: number }\n }\n /** `fixed` over the page, `absolute` inside the file viewer. */\n strategy?: 'fixed' | 'absolute'\n /** A line before the actions: why some are missing. */\n hint?: string\n /** In place of the actions: why there are none, with `noteAction` to act on it. */\n note?: string\n noteAction?: string\n /** On a touch screen the bar goes below, away from the system's menu. */\n touch?: boolean\n }>()\n\n const emit = defineEmits<{\n action: [id: string, value?: string]\n ask: [text: string]\n note: []\n close: []\n }>()\n\n /** The field is open: the selection may move into it, and the bar stays. */\n const asking = defineModel<boolean>('asking', { default: false })\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const barEl = useTemplateRef<HTMLElement>('barEl')\n const inputEl = useTemplateRef<HTMLInputElement>('inputEl')\n const { width, height } = useElementSize(barEl, undefined, {\n box: 'border-box',\n })\n const position = computed(() =>\n selectionBarPosition({\n ...props.anchor,\n bar: { width: width.value, height: height.value },\n touch: props.touch,\n }),\n )\n\n /** The action whose field is open, or \"Ask…\" (no id). */\n const field = ref<{ id?: string; placeholder: string }>()\n const text = ref('')\n\n const openField = async (id: string | undefined, placeholder: string) => {\n field.value = { id, placeholder }\n text.value = ''\n asking.value = true\n await nextTick()\n inputEl.value?.focus()\n }\n const closeField = () => {\n field.value = undefined\n asking.value = false\n }\n\n const run = (action: SelectionBarAction) => {\n if (action.asks) {\n void openField(action.id, action.asks)\n } else {\n emit('action', action.id)\n }\n }\n\n const submit = () => {\n const value = text.value.trim()\n if (!value || !field.value) {\n return\n }\n if (field.value.id) {\n emit('action', field.value.id, value)\n } else {\n emit('ask', value)\n }\n closeField()\n }\n\n const onEscape = () => {\n if (field.value) {\n closeField()\n } else {\n emit('close')\n }\n }\n</script>\n\n<template>\n <div\n class=\"pk-selection-actions\"\n :class=\"{\n 'pk-selection-actions--fixed': strategy === 'fixed',\n 'pk-selection-actions--asking': !!field,\n }\"\n :style=\"{\n top: `${position.top}px`,\n left: `${position.left}px`,\n }\"\n @keydown.esc.stop=\"onEscape\">\n <form\n v-if=\"field\"\n ref=\"barEl\"\n class=\"pk-selection-actions__bar pk-selection-actions__bar--field\"\n @submit.prevent=\"submit\">\n <input\n ref=\"inputEl\"\n v-model=\"text\"\n class=\"pk-selection-actions__input\"\n type=\"text\"\n maxlength=\"500\"\n :placeholder=\"field.placeholder\"\n :aria-label=\"field.placeholder\" />\n <button\n type=\"submit\"\n class=\"pk-selection-actions__button pk-selection-actions__button--send\"\n :disabled=\"!text.trim()\">\n {{ $t('action.send') }}\n </button>\n </form>\n <div\n v-else\n ref=\"barEl\"\n class=\"pk-selection-actions__bar\"\n role=\"toolbar\"\n :aria-label=\"$t('selectionActions.label')\">\n <template v-if=\"note\">\n <span class=\"pk-selection-actions__text\">{{ note }}</span>\n <button\n v-if=\"noteAction\"\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"emit('note')\">\n {{ noteAction }}\n </button>\n </template>\n <template v-else>\n <span v-if=\"hint\" class=\"pk-selection-actions__text\">\n {{ hint }}\n </span>\n <button\n v-for=\"action in actions\"\n :key=\"action.id\"\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"run(action)\">\n {{ action.label }}\n </button>\n <button\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"\n openField(\n undefined,\n $t('selectionActions.askPlaceholder'),\n )\n \">\n {{ $t('selectionActions.ask') }}\n </button>\n </template>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-selection-actions {\n position: absolute;\n z-index: 10;\n\n // The widths go here: a box placed absolutely takes its width from\n // its content, so a percentage inside it measured the content, and\n // the field shrank to a few words. Here 100% is the box it is in.\n max-width: min(32rem, calc(100% - var(--spacing-16)));\n\n &--fixed {\n position: fixed;\n\n // Above the site's own layers, as the page pointer's bar\n z-index: 2147483647;\n }\n\n &--asking {\n width: min(var(--spacing-384), calc(100% - var(--spacing-16)));\n }\n\n // As the page pointer's bar: the theme's colors swapped, readable over\n // any page and any document\n &__bar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--spacing-4);\n width: max-content;\n max-width: 100%;\n padding: var(--spacing-4);\n border-radius: var(--rounded-lg);\n background-color: var(--color-word-1);\n color: var(--color-surface);\n font-family: var(--font-sans);\n font-size: var(--text-14);\n font-weight: var(--font-medium);\n box-shadow: var(--shadow-lg);\n\n &--field {\n flex-wrap: nowrap;\n width: 100%;\n }\n }\n\n &__text {\n padding: 0 var(--spacing-8);\n opacity: 0.75;\n font-size: var(--text-12);\n font-weight: var(--font-normal);\n }\n\n &__button {\n flex-shrink: 0;\n border: 0;\n border-radius: var(--rounded);\n padding: var(--spacing-6) var(--spacing-10);\n background-color: transparent;\n color: inherit;\n font: inherit;\n cursor: pointer;\n\n &:hover {\n background-color: color-mix(\n in srgb,\n var(--color-surface) 16%,\n transparent\n );\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--color-surface);\n outline-offset: calc(-1 * var(--spacing-2));\n }\n\n &--send {\n background-color: var(--color-surface);\n color: var(--color-word-1);\n\n &:hover {\n background-color: var(--color-surface);\n }\n\n &:disabled {\n opacity: 0.5;\n cursor: default;\n }\n }\n }\n\n &__input {\n flex: 1;\n min-width: 0;\n border: 0;\n border-radius: var(--rounded);\n padding: var(--spacing-6) var(--spacing-8);\n background-color: color-mix(\n in srgb,\n var(--color-surface) 12%,\n transparent\n );\n color: inherit;\n font: inherit;\n font-weight: var(--font-normal);\n\n &::placeholder {\n color: inherit;\n opacity: 0.6;\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--color-surface);\n outline-offset: calc(-1 * var(--spacing-2));\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed, nextTick, ref, useTemplateRef } from 'vue'\n import { useElementSize } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import { selectionBarPosition } from './utils'\n\n /**\n * The bar of actions on a selection (spec `selection-actions.md`, \"Cosa\n * è comune\"), on the page that embeds the widget and in the chat's file\n * viewer: the agent's actions, then \"Ask…\", which turns the bar into a\n * field. An action may ask for a word first (`asks`: \"Translate\" asks the\n * language). It sits above the start of the selection, below it without\n * room there (`selectionBarPosition`). Its buttons take no focus on a\n * click, so the selection stays and Cmd+C still copies it; the keyboard\n * reaches them with Tab.\n */\n\n export type SelectionBarAction = {\n id: string\n label: string\n /** The placeholder of a field the action opens before it is sent. */\n asks?: string\n }\n\n const props = defineProps<{\n actions: SelectionBarAction[]\n /** The selection, in the coordinates of the box the bar is positioned in. */\n anchor: {\n start: { top: number; left: number }\n bottom: number\n bounds: { top: number; left: number; width: number; height: number }\n }\n /** `fixed` over the page, `absolute` inside the file viewer. */\n strategy?: 'fixed' | 'absolute'\n /** A line before the actions: why some are missing. */\n hint?: string\n /** In place of the actions: why there are none, with `noteAction` to act on it. */\n note?: string\n noteAction?: string\n /** On a touch screen the bar goes below, away from the system's menu. */\n touch?: boolean\n }>()\n\n const emit = defineEmits<{\n action: [id: string, value?: string]\n ask: [text: string]\n note: []\n close: []\n }>()\n\n /** The field is open: the selection may move into it, and the bar stays. */\n const asking = defineModel<boolean>('asking', { default: false })\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const barEl = useTemplateRef<HTMLElement>('barEl')\n const inputEl = useTemplateRef<HTMLInputElement>('inputEl')\n const { width, height } = useElementSize(barEl, undefined, {\n box: 'border-box',\n })\n const position = computed(() =>\n selectionBarPosition({\n ...props.anchor,\n bar: { width: width.value, height: height.value },\n touch: props.touch,\n }),\n )\n\n /** The action whose field is open, or \"Ask…\" (no id). */\n const field = ref<{ id?: string; placeholder: string }>()\n const text = ref('')\n\n const openField = async (id: string | undefined, placeholder: string) => {\n field.value = { id, placeholder }\n text.value = ''\n asking.value = true\n await nextTick()\n inputEl.value?.focus()\n }\n const closeField = () => {\n field.value = undefined\n asking.value = false\n }\n\n const run = (action: SelectionBarAction) => {\n if (action.asks) {\n void openField(action.id, action.asks)\n } else {\n emit('action', action.id)\n }\n }\n\n const submit = () => {\n const value = text.value.trim()\n if (!value || !field.value) {\n return\n }\n if (field.value.id) {\n emit('action', field.value.id, value)\n } else {\n emit('ask', value)\n }\n closeField()\n }\n\n const onEscape = () => {\n if (field.value) {\n closeField()\n } else {\n emit('close')\n }\n }\n</script>\n\n<template>\n <div\n class=\"pk-selection-actions\"\n :class=\"{\n 'pk-selection-actions--fixed': strategy === 'fixed',\n 'pk-selection-actions--asking': !!field,\n }\"\n :style=\"{\n top: `${position.top}px`,\n left: `${position.left}px`,\n }\"\n @keydown.esc.stop=\"onEscape\">\n <form\n v-if=\"field\"\n ref=\"barEl\"\n class=\"pk-selection-actions__bar pk-selection-actions__bar--field\"\n @submit.prevent=\"submit\">\n <input\n ref=\"inputEl\"\n v-model=\"text\"\n class=\"pk-selection-actions__input\"\n type=\"text\"\n maxlength=\"500\"\n :placeholder=\"field.placeholder\"\n :aria-label=\"field.placeholder\" />\n <button\n type=\"submit\"\n class=\"pk-selection-actions__button pk-selection-actions__button--send\"\n :disabled=\"!text.trim()\">\n {{ $t('action.send') }}\n </button>\n </form>\n <div\n v-else\n ref=\"barEl\"\n class=\"pk-selection-actions__bar\"\n role=\"toolbar\"\n :aria-label=\"$t('selectionActions.label')\">\n <template v-if=\"note\">\n <span class=\"pk-selection-actions__text\">{{ note }}</span>\n <button\n v-if=\"noteAction\"\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"emit('note')\">\n {{ noteAction }}\n </button>\n </template>\n <template v-else>\n <span v-if=\"hint\" class=\"pk-selection-actions__text\">\n {{ hint }}\n </span>\n <button\n v-for=\"action in actions\"\n :key=\"action.id\"\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"run(action)\">\n {{ action.label }}\n </button>\n <button\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"\n openField(\n undefined,\n $t('selectionActions.askPlaceholder'),\n )\n \">\n {{ $t('selectionActions.ask') }}\n </button>\n </template>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-selection-actions {\n position: absolute;\n z-index: 10;\n\n // The widths go here: a box placed absolutely takes its width from\n // its content, so a percentage inside it measured the content, and\n // the field shrank to a few words. Here 100% is the box it is in.\n max-width: min(32rem, calc(100% - var(--spacing-16)));\n\n &--fixed {\n position: fixed;\n\n // Above the site's own layers, as the page pointer's bar\n z-index: 2147483647;\n }\n\n &--asking {\n width: min(var(--spacing-384), calc(100% - var(--spacing-16)));\n }\n\n // As the page pointer's bar: the theme's colors swapped, readable over\n // any page and any document\n &__bar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--spacing-4);\n width: max-content;\n max-width: 100%;\n padding: var(--spacing-4);\n border-radius: var(--rounded-lg);\n background-color: var(--color-word-1);\n color: var(--color-surface);\n font-family: var(--font-sans);\n font-size: var(--text-14);\n font-weight: var(--font-medium);\n box-shadow: var(--shadow-lg);\n\n &--field {\n flex-wrap: nowrap;\n width: 100%;\n }\n }\n\n &__text {\n padding: 0 var(--spacing-8);\n opacity: 0.75;\n font-size: var(--text-12);\n font-weight: var(--font-normal);\n }\n\n &__button {\n flex-shrink: 0;\n border: 0;\n border-radius: var(--rounded);\n padding: var(--spacing-6) var(--spacing-10);\n background-color: transparent;\n color: inherit;\n font: inherit;\n cursor: pointer;\n\n &:hover {\n background-color: color-mix(\n in srgb,\n var(--color-surface) 16%,\n transparent\n );\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--color-surface);\n outline-offset: calc(-1 * var(--spacing-2));\n }\n\n &--send {\n background-color: var(--color-surface);\n color: var(--color-word-1);\n\n &:hover {\n background-color: var(--color-surface);\n }\n\n &:disabled {\n opacity: 0.5;\n cursor: default;\n }\n }\n }\n\n &__input {\n flex: 1;\n min-width: 0;\n border: 0;\n border-radius: var(--rounded);\n padding: var(--spacing-6) var(--spacing-8);\n background-color: color-mix(\n in srgb,\n var(--color-surface) 12%,\n transparent\n );\n color: inherit;\n font: inherit;\n font-weight: var(--font-normal);\n\n &::placeholder {\n color: inherit;\n opacity: 0.6;\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--color-surface);\n outline-offset: calc(-1 * var(--spacing-2));\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { computed, nextTick, ref, useTemplateRef } from 'vue'\n import { useElementSize } from '@vueuse/core'\n import { useI18n } from 'vue-i18n'\n import { selectionBarPosition } from './utils'\n\n /**\n * The bar of actions on a selection (spec `selection-actions.md`, \"Cosa\n * è comune\"), on the page that embeds the widget and in the chat's file\n * viewer: the agent's actions, then \"Ask…\", which turns the bar into a\n * field. An action may ask for a word first (`asks`: \"Translate\" asks the\n * language). It sits above the start of the selection, below it without\n * room there (`selectionBarPosition`). Its buttons take no focus on a\n * click, so the selection stays and Cmd+C still copies it; the keyboard\n * reaches them with Tab.\n */\n\n export type SelectionBarAction = {\n id: string\n label: string\n /** The placeholder of a field the action opens before it is sent. */\n asks?: string\n }\n\n const props = defineProps<{\n actions: SelectionBarAction[]\n /** The selection, in the coordinates of the box the bar is positioned in. */\n anchor: {\n start: { top: number; left: number }\n bottom: number\n bounds: { top: number; left: number; width: number; height: number }\n }\n /** `fixed` over the page, `absolute` inside the file viewer. */\n strategy?: 'fixed' | 'absolute'\n /** A line before the actions: why some are missing. */\n hint?: string\n /** In place of the actions: why there are none, with `noteAction` to act on it. */\n note?: string\n noteAction?: string\n /** On a touch screen the bar goes below, away from the system's menu. */\n touch?: boolean\n }>()\n\n const emit = defineEmits<{\n action: [id: string, value?: string]\n ask: [text: string]\n note: []\n close: []\n }>()\n\n /** The field is open: the selection may move into it, and the bar stays. */\n const asking = defineModel<boolean>('asking', { default: false })\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const barEl = useTemplateRef<HTMLElement>('barEl')\n const inputEl = useTemplateRef<HTMLInputElement>('inputEl')\n const { width, height } = useElementSize(barEl, undefined, {\n box: 'border-box',\n })\n const position = computed(() =>\n selectionBarPosition({\n ...props.anchor,\n bar: { width: width.value, height: height.value },\n touch: props.touch,\n }),\n )\n\n /** The action whose field is open, or \"Ask…\" (no id). */\n const field = ref<{ id?: string; placeholder: string }>()\n const text = ref('')\n\n const openField = async (id: string | undefined, placeholder: string) => {\n field.value = { id, placeholder }\n text.value = ''\n asking.value = true\n await nextTick()\n inputEl.value?.focus()\n }\n const closeField = () => {\n field.value = undefined\n asking.value = false\n }\n\n const run = (action: SelectionBarAction) => {\n if (action.asks) {\n void openField(action.id, action.asks)\n } else {\n emit('action', action.id)\n }\n }\n\n const submit = () => {\n const value = text.value.trim()\n if (!value || !field.value) {\n return\n }\n if (field.value.id) {\n emit('action', field.value.id, value)\n } else {\n emit('ask', value)\n }\n closeField()\n }\n\n const onEscape = () => {\n if (field.value) {\n closeField()\n } else {\n emit('close')\n }\n }\n</script>\n\n<template>\n <div\n class=\"pk-selection-actions\"\n :class=\"{\n 'pk-selection-actions--fixed': strategy === 'fixed',\n 'pk-selection-actions--asking': !!field,\n }\"\n :style=\"{\n top: `${position.top}px`,\n left: `${position.left}px`,\n }\"\n @keydown.esc.stop=\"onEscape\">\n <form\n v-if=\"field\"\n ref=\"barEl\"\n class=\"pk-selection-actions__bar pk-selection-actions__bar--field\"\n @submit.prevent=\"submit\">\n <input\n ref=\"inputEl\"\n v-model=\"text\"\n class=\"pk-selection-actions__input\"\n type=\"text\"\n maxlength=\"500\"\n :placeholder=\"field.placeholder\"\n :aria-label=\"field.placeholder\" />\n <button\n type=\"submit\"\n class=\"pk-selection-actions__button pk-selection-actions__button--send\"\n :disabled=\"!text.trim()\">\n {{ $t('action.send') }}\n </button>\n </form>\n <div\n v-else\n ref=\"barEl\"\n class=\"pk-selection-actions__bar\"\n role=\"toolbar\"\n :aria-label=\"$t('selectionActions.label')\">\n <template v-if=\"note\">\n <span class=\"pk-selection-actions__text\">{{ note }}</span>\n <button\n v-if=\"noteAction\"\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"emit('note')\">\n {{ noteAction }}\n </button>\n </template>\n <template v-else>\n <span v-if=\"hint\" class=\"pk-selection-actions__text\">\n {{ hint }}\n </span>\n <button\n v-for=\"action in actions\"\n :key=\"action.id\"\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"run(action)\">\n {{ action.label }}\n </button>\n <button\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"\n openField(\n undefined,\n $t('selectionActions.askPlaceholder'),\n )\n \">\n {{ $t('selectionActions.ask') }}\n </button>\n </template>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-selection-actions {\n position: absolute;\n z-index: 10;\n\n // The widths go here: a box placed absolutely takes its width from\n // its content, so a percentage inside it measured the content, and\n // the field shrank to a few words. Here 100% is the box it is in.\n max-width: min(32rem, calc(100% - var(--spacing-16)));\n\n &--fixed {\n position: fixed;\n\n // Above the site's own layers, as the page pointer's bar\n z-index: 2147483647;\n }\n\n &--asking {\n width: min(var(--spacing-384), calc(100% - var(--spacing-16)));\n }\n\n // As the page pointer's bar: the theme's colors swapped, readable over\n // any page and any document\n &__bar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--spacing-4);\n width: max-content;\n max-width: 100%;\n padding: var(--spacing-4);\n border-radius: var(--rounded-lg);\n background-color: var(--color-word-1);\n color: var(--color-surface);\n font-family: var(--font-sans);\n font-size: var(--text-14);\n font-weight: var(--font-medium);\n box-shadow: var(--shadow-lg);\n\n &--field {\n flex-wrap: nowrap;\n width: 100%;\n }\n }\n\n &__text {\n padding: 0 var(--spacing-8);\n opacity: 0.75;\n font-size: var(--text-12);\n font-weight: var(--font-normal);\n }\n\n &__button {\n flex-shrink: 0;\n border: 0;\n border-radius: var(--rounded);\n padding: var(--spacing-6) var(--spacing-10);\n background-color: transparent;\n color: inherit;\n font: inherit;\n cursor: pointer;\n\n &:hover {\n background-color: color-mix(\n in srgb,\n var(--color-surface) 16%,\n transparent\n );\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--color-surface);\n outline-offset: calc(-1 * var(--spacing-2));\n }\n\n &--send {\n background-color: var(--color-surface);\n color: var(--color-word-1);\n\n &:hover {\n background-color: var(--color-surface);\n }\n\n &:disabled {\n opacity: 0.5;\n cursor: default;\n }\n }\n }\n\n &__input {\n flex: 1;\n min-width: 0;\n border: 0;\n border-radius: var(--rounded);\n padding: var(--spacing-6) var(--spacing-8);\n background-color: color-mix(\n in srgb,\n var(--color-surface) 12%,\n transparent\n );\n color: inherit;\n font: inherit;\n font-weight: var(--font-normal);\n\n &::placeholder {\n color: inherit;\n opacity: 0.6;\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--color-surface);\n outline-offset: calc(-1 * var(--spacing-2));\n }\n }\n }\n</style>\n"],"mappings":"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"}