@8wave/ai-elements 0.127.0-beta.2 → 0.127.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/_chunks/{PkChatbotFilePreview-BpiLld3D.js → PkChatbotFilePreview-CWzGSq-b.js} +2 -2
  2. package/dist/_chunks/{PkChatbotFilePreview-BpiLld3D.js.map → PkChatbotFilePreview-CWzGSq-b.js.map} +1 -1
  3. package/dist/_chunks/{PkEditorRadioButtons-BtAGtjNW.js → PkEditorRadioButtons-CA1ul6tY.js} +3 -3
  4. package/dist/_chunks/{PkEditorRadioButtons-BtAGtjNW.js.map → PkEditorRadioButtons-CA1ul6tY.js.map} +1 -1
  5. package/dist/_chunks/{PkFilePreview-qTCDbut0.js → PkFilePreview-BaJet5cw.js} +5 -5
  6. package/dist/_chunks/{PkFilePreview-qTCDbut0.js.map → PkFilePreview-BaJet5cw.js.map} +1 -1
  7. package/dist/_chunks/{PkFilePreviewDialog-m5d4zZDi.js → PkFilePreviewDialog-Cq8DGCD1.js} +3 -3
  8. package/dist/_chunks/{PkFilePreviewDialog-m5d4zZDi.js.map → PkFilePreviewDialog-Cq8DGCD1.js.map} +1 -1
  9. package/dist/_chunks/{PkHeldImage-5nu3We9d.js → PkHeldImage-BWz13OCH.js} +2 -2
  10. package/dist/_chunks/{PkHeldImage-5nu3We9d.js.map → PkHeldImage-BWz13OCH.js.map} +1 -1
  11. package/dist/_chunks/{PkImageEditorDialog-aekpEqWD.js → PkImageEditorDialog-5Px7Y_8G.js} +5 -5
  12. package/dist/_chunks/{PkImageEditorDialog-aekpEqWD.js.map → PkImageEditorDialog-5Px7Y_8G.js.map} +1 -1
  13. package/dist/_chunks/{PkLazyImg-DZaX3wM4.js → PkLazyImg-DYjihkLA.js} +2 -2
  14. package/dist/_chunks/{PkLazyImg-DZaX3wM4.js.map → PkLazyImg-DYjihkLA.js.map} +1 -1
  15. package/dist/_chunks/{PkSelectionActions-DDhRX6cs.js → PkSelectionActions-DDhbwE4U.js} +2 -2
  16. package/dist/_chunks/{PkSelectionActions-DDhRX6cs.js.map → PkSelectionActions-DDhbwE4U.js.map} +1 -1
  17. package/dist/_chunks/{PkToolChatFile-C3B9q2OL.js → PkToolChatFile-fTo6gdqx.js} +3 -3
  18. package/dist/_chunks/{PkToolChatFile-C3B9q2OL.js.map → PkToolChatFile-fTo6gdqx.js.map} +1 -1
  19. package/dist/_chunks/{PkToolRequestGeolocation-D4pYnCW5.js → PkToolRequestGeolocation-BeFZQQxz.js} +2 -2
  20. package/dist/_chunks/{PkToolRequestGeolocation-D4pYnCW5.js.map → PkToolRequestGeolocation-BeFZQQxz.js.map} +1 -1
  21. package/dist/_chunks/{PkToolRequestOAuthConnection-DnnRY2rt.js → PkToolRequestOAuthConnection-_01ct5du.js} +3 -3
  22. package/dist/_chunks/{PkToolRequestOAuthConnection-DnnRY2rt.js.map → PkToolRequestOAuthConnection-_01ct5du.js.map} +1 -1
  23. package/dist/_chunks/{PkToolShareDocument-Dn1XC44S.js → PkToolShareDocument-Vpv1an0N.js} +3 -3
  24. package/dist/_chunks/{PkToolShareDocument-Dn1XC44S.js.map → PkToolShareDocument-Vpv1an0N.js.map} +1 -1
  25. package/dist/_chunks/{PkToolShowArtifact-DQln7TsF.js → PkToolShowArtifact-C28dOM5W.js} +2 -2
  26. package/dist/_chunks/{PkToolShowArtifact-DQln7TsF.js.map → PkToolShowArtifact-C28dOM5W.js.map} +1 -1
  27. package/dist/_chunks/{PkToolShowCalendarEvent-B1vPVEhc.js → PkToolShowCalendarEvent-Cee5xnJM.js} +4 -4
  28. package/dist/_chunks/{PkToolShowCalendarEvent-B1vPVEhc.js.map → PkToolShowCalendarEvent-Cee5xnJM.js.map} +1 -1
  29. package/dist/_chunks/{PkToolShowChart-DfDB9BeZ.js → PkToolShowChart-kgCDHWEf.js} +3 -3
  30. package/dist/_chunks/{PkToolShowChart-DfDB9BeZ.js.map → PkToolShowChart-kgCDHWEf.js.map} +1 -1
  31. package/dist/_chunks/{PkToolShowComparison-VRck6_nr.js → PkToolShowComparison-cXfmgJ1H.js} +3 -3
  32. package/dist/_chunks/{PkToolShowComparison-VRck6_nr.js.map → PkToolShowComparison-cXfmgJ1H.js.map} +1 -1
  33. package/dist/_chunks/{PkToolShowContactForm-Dkb8AiqL.js → PkToolShowContactForm-D06qrkHm.js} +4 -4
  34. package/dist/_chunks/{PkToolShowContactForm-Dkb8AiqL.js.map → PkToolShowContactForm-D06qrkHm.js.map} +1 -1
  35. package/dist/_chunks/{PkToolShowDiagram-B2dBogUW.js → PkToolShowDiagram-B2NX-FOw.js} +3 -3
  36. package/dist/_chunks/{PkToolShowDiagram-B2dBogUW.js.map → PkToolShowDiagram-B2NX-FOw.js.map} +1 -1
  37. package/dist/_chunks/{PkToolShowEmail-DcFaseV8.js → PkToolShowEmail-D-JnkL9A.js} +4 -4
  38. package/dist/_chunks/{PkToolShowEmail-DcFaseV8.js.map → PkToolShowEmail-D-JnkL9A.js.map} +1 -1
  39. package/dist/_chunks/{PkToolShowForm-CtDcwJs4.js → PkToolShowForm-qj_f9Z5D.js} +16 -16
  40. package/dist/_chunks/{PkToolShowForm-CtDcwJs4.js.map → PkToolShowForm-qj_f9Z5D.js.map} +1 -1
  41. package/dist/_chunks/{PkToolShowImageGallery-dLMI3SM7.js → PkToolShowImageGallery-Dm2UEfWl.js} +3 -3
  42. package/dist/_chunks/{PkToolShowImageGallery-dLMI3SM7.js.map → PkToolShowImageGallery-Dm2UEfWl.js.map} +1 -1
  43. package/dist/_chunks/{PkToolShowLocation-B3YOn2fH.js → PkToolShowLocation-McS9sMWJ.js} +4 -4
  44. package/dist/_chunks/{PkToolShowLocation-B3YOn2fH.js.map → PkToolShowLocation-McS9sMWJ.js.map} +1 -1
  45. package/dist/_chunks/{PkToolShowMessage-BJ0nNGNK.js → PkToolShowMessage-C3jjCRB3.js} +4 -4
  46. package/dist/_chunks/{PkToolShowMessage-BJ0nNGNK.js.map → PkToolShowMessage-C3jjCRB3.js.map} +1 -1
  47. package/dist/_chunks/{PkToolShowProductList-DE6BEdr_.js → PkToolShowProductList-DorHQJMd.js} +4 -4
  48. package/dist/_chunks/{PkToolShowProductList-DE6BEdr_.js.map → PkToolShowProductList-DorHQJMd.js.map} +1 -1
  49. package/dist/_chunks/{PkToolShowQrCode-BcE0yKiC.js → PkToolShowQrCode-CIwiAzOS.js} +3 -3
  50. package/dist/_chunks/{PkToolShowQrCode-BcE0yKiC.js.map → PkToolShowQrCode-CIwiAzOS.js.map} +1 -1
  51. package/dist/_chunks/{PkToolShowSources-vSr080EU.js → PkToolShowSources-BMJeacz7.js} +3 -3
  52. package/dist/_chunks/{PkToolShowSources-vSr080EU.js.map → PkToolShowSources-BMJeacz7.js.map} +1 -1
  53. package/dist/_chunks/{PkToolShowSuggestedReply-HuKn3loC.js → PkToolShowSuggestedReply-DBfeOl05.js} +2 -2
  54. package/dist/_chunks/{PkToolShowSuggestedReply-HuKn3loC.js.map → PkToolShowSuggestedReply-DBfeOl05.js.map} +1 -1
  55. package/dist/_chunks/{PkToolShowVideo-BL-9CiYe.js → PkToolShowVideo-YwSq8c2P.js} +3 -3
  56. package/dist/_chunks/{PkToolShowVideo-BL-9CiYe.js.map → PkToolShowVideo-YwSq8c2P.js.map} +1 -1
  57. package/dist/_chunks/{PkToolShowWeather-CHAuNe7p.js → PkToolShowWeather-DFNz0ZAW.js} +2 -2
  58. package/dist/_chunks/{PkToolShowWeather-CHAuNe7p.js.map → PkToolShowWeather-DFNz0ZAW.js.map} +1 -1
  59. package/dist/_chunks/{PkToolShowWebPages-DQfODZdD.js → PkToolShowWebPages-DtZC0KHO.js} +4 -4
  60. package/dist/_chunks/{PkToolShowWebPages-DQfODZdD.js.map → PkToolShowWebPages-DtZC0KHO.js.map} +1 -1
  61. package/dist/_chunks/{VvButtonLocalized-C3bg4fNl.js → VvButtonLocalized-DfLLySHy.js} +2 -2
  62. package/dist/_chunks/{VvButtonLocalized-C3bg4fNl.js.map → VvButtonLocalized-DfLLySHy.js.map} +1 -1
  63. package/dist/_chunks/{VvCheckbox.es-D44kGZc-.js → VvCheckbox.es-CEwVNJz3.js} +2 -2
  64. package/dist/_chunks/{VvCheckbox.es-D44kGZc-.js.map → VvCheckbox.es-CEwVNJz3.js.map} +1 -1
  65. package/dist/_chunks/{VvCheckboxGroup.es-Da5Vuel0.js → VvCheckboxGroup.es-BC9At7ZZ.js} +2 -2
  66. package/dist/_chunks/{VvCheckboxGroup.es-Da5Vuel0.js.map → VvCheckboxGroup.es-BC9At7ZZ.js.map} +1 -1
  67. package/dist/_chunks/{VvCombobox.es-BJzmLeTh.js → VvCombobox.es-ZJ44baFa.js} +741 -705
  68. package/dist/_chunks/VvCombobox.es-ZJ44baFa.js.map +1 -0
  69. package/dist/_chunks/{VvInputText.es-CHcdm2K-.js → VvInputText.es-D1K-kOt5.js} +356 -320
  70. package/dist/_chunks/VvInputText.es-D1K-kOt5.js.map +1 -0
  71. package/dist/_chunks/{VvRadio.es-B3IskaN4.js → VvRadio.es-Bkn-qtRB.js} +2 -2
  72. package/dist/_chunks/{VvRadio.es-B3IskaN4.js.map → VvRadio.es-Bkn-qtRB.js.map} +1 -1
  73. package/dist/_chunks/{VvRadioGroup.es-CBivcD0v.js → VvRadioGroup.es-BtyqGx_o.js} +2 -2
  74. package/dist/_chunks/{VvRadioGroup.es-CBivcD0v.js.map → VvRadioGroup.es-BtyqGx_o.js.map} +1 -1
  75. package/dist/_chunks/{VvSelect.es-CAVvkyxB.js → VvSelect.es-CKHcpSZS.js} +2 -2
  76. package/dist/_chunks/{VvSelect.es-CAVvkyxB.js.map → VvSelect.es-CKHcpSZS.js.map} +1 -1
  77. package/dist/_chunks/{VvTextarea.es-CgvZOWO4.js → VvTextarea.es-Ewp88vJ2.js} +397 -361
  78. package/dist/_chunks/VvTextarea.es-Ewp88vJ2.js.map +1 -0
  79. package/dist/_chunks/{index.es-B9l77u9z.js → index.es-DHeth3Ja.js} +660 -624
  80. package/dist/_chunks/index.es-DHeth3Ja.js.map +1 -0
  81. package/dist/_chunks/{index.es-vCE-6U81.js → index.es-EKiTmBsm.js} +10 -10
  82. package/dist/_chunks/{index.es-vCE-6U81.js.map → index.es-EKiTmBsm.js.map} +1 -1
  83. package/dist/ai-elements.es.js +434 -434
  84. package/dist/ai-elements.es.js.map +1 -1
  85. package/dist-vue/PkChatbot.js +1 -1
  86. package/dist-vue/PkChatbotAuth.js +1 -1
  87. package/dist-vue/PkChatbotFeedbackForm.js +1 -1
  88. package/dist-vue/PkChatbotMessages.js +1 -1
  89. package/dist-vue/PkChatbotViewChat.js +1 -1
  90. package/dist-vue/PkChatbotWakeupBar.js +1 -1
  91. package/dist-vue/_chunks/{PkChatbot-8Fqlhwq5.js → PkChatbot-CuCgECW2.js} +2 -2
  92. package/dist-vue/_chunks/{PkChatbot-8Fqlhwq5.js.map → PkChatbot-CuCgECW2.js.map} +1 -1
  93. package/dist-vue/_chunks/{PkChatbotAuth-CIK2CFy-.js → PkChatbotAuth-Bx14Ld4t.js} +2 -2
  94. package/dist-vue/_chunks/{PkChatbotAuth-CIK2CFy-.js.map → PkChatbotAuth-Bx14Ld4t.js.map} +1 -1
  95. package/dist-vue/_chunks/{PkChatbotFeedbackForm-DmpoOuoW.js → PkChatbotFeedbackForm-Dwsln0GO.js} +2 -2
  96. package/dist-vue/_chunks/{PkChatbotFeedbackForm-DmpoOuoW.js.map → PkChatbotFeedbackForm-Dwsln0GO.js.map} +1 -1
  97. package/dist-vue/_chunks/{PkChatbotMessages-DY8r4UKe.js → PkChatbotMessages-CDDoxZAf.js} +3 -3
  98. package/dist-vue/_chunks/{PkChatbotMessages-DY8r4UKe.js.map → PkChatbotMessages-CDDoxZAf.js.map} +1 -1
  99. package/dist-vue/_chunks/{PkChatbotViewChat-DTKfW1kr.js → PkChatbotViewChat-FtOpDmks.js} +4 -4
  100. package/dist-vue/_chunks/{PkChatbotViewChat-DTKfW1kr.js.map → PkChatbotViewChat-FtOpDmks.js.map} +1 -1
  101. package/dist-vue/_chunks/{PkChatbotWakeupBar-Bx1zqFAX.js → PkChatbotWakeupBar-IoQJdUjI.js} +11 -11
  102. package/dist-vue/_chunks/PkChatbotWakeupBar-IoQJdUjI.js.map +1 -0
  103. package/dist-vue/_chunks/{PkFilePreview-sSb1Mmr2.js → PkFilePreview-B6PSJcvA.js} +2 -2
  104. package/dist-vue/_chunks/{PkFilePreview-sSb1Mmr2.js.map → PkFilePreview-B6PSJcvA.js.map} +1 -1
  105. package/dist-vue/_chunks/{PkFilePreviewDialog-DquXMRJD.js → PkFilePreviewDialog-3HJbVudc.js} +2 -2
  106. package/dist-vue/_chunks/{PkFilePreviewDialog-DquXMRJD.js.map → PkFilePreviewDialog-3HJbVudc.js.map} +1 -1
  107. package/dist-vue/_chunks/{PkToolShowContactForm-DAdKUU4X.js → PkToolShowContactForm-Cg2TiqP1.js} +2 -2
  108. package/dist-vue/_chunks/{PkToolShowContactForm-DAdKUU4X.js.map → PkToolShowContactForm-Cg2TiqP1.js.map} +1 -1
  109. package/dist-vue/_chunks/{index.es-Snvt_nNd.js → index.es-B9iCRzfa.js} +2 -2
  110. package/dist-vue/_chunks/{index.es-Snvt_nNd.js.map → index.es-B9iCRzfa.js.map} +1 -1
  111. package/dist-vue/index.js +9 -9
  112. package/dist-vue/style.css +1 -1
  113. package/package.json +2 -2
  114. package/dist/_chunks/VvCombobox.es-BJzmLeTh.js.map +0 -1
  115. package/dist/_chunks/VvInputText.es-CHcdm2K-.js.map +0 -1
  116. package/dist/_chunks/VvTextarea.es-CgvZOWO4.js.map +0 -1
  117. package/dist/_chunks/index.es-B9l77u9z.js.map +0 -1
  118. package/dist-vue/_chunks/PkChatbotWakeupBar-Bx1zqFAX.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { r as e } from "./index.es-B9l77u9z.js";
1
+ import { r as e } from "./index.es-DHeth3Ja.js";
2
2
  import { S as t, h as n, k as r, ot as i, v as a, w as o, wt as s, y as c, z as l } from "./vue.runtime.esm-bundler-DZgpK-ja.js";
3
3
  import { t as u } from "./useImageFallback-DSKCe5aP.js";
4
4
  // ../../packages/components/src/PkLazyImg.vue?vue&type=script&setup=true&lang.ts
@@ -32,4 +32,4 @@ var d = ["src"], f = {
32
32
  });
33
33
  export { p as t };
34
34
 
35
- //# sourceMappingURL=PkLazyImg-DZaX3wM4.js.map
35
+ //# sourceMappingURL=PkLazyImg-DYjihkLA.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PkLazyImg-DZaX3wM4.js","names":["_openBlock","_createElementBlock","_unref","_createVNode","De","createVNode","computed","init_runtime_core_esm_bundler","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createElementBlock","openBlock","useImageFallback","_hoisted_1","_hoisted_2","PkLazyImg_default","props","__props","currentSrc","canShowImage","_component_VvIcon","_cache","onImageError"],"sources":["../../../../packages/components/src/PkLazyImg.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n import { computed } from 'vue'\n import { useImageFallback } from 'composables'\n\n const props = defineProps<{\n src: string\n /** Second-best source, tried when `src` fails (e.g. og:image -> favicon). */\n altSrc?: string\n /**\n * Icon rendered in place of the image once every source has failed.\n * Without it the element is dropped, leaving no gap in the layout.\n */\n fallbackIcon?: string\n }>()\n\n // Degrade src -> altSrc -> icon. The failure is tracked per url, so a\n // re-render keeps the fallback instead of re-requesting a dead source.\n const { canShowImage, onImageError } = useImageFallback()\n const currentSrc = computed(() => {\n if (canShowImage(props.src)) {\n return props.src\n }\n if (canShowImage(props.altSrc)) {\n return props.altSrc\n }\n return undefined\n })\n</script>\n\n<template>\n <!-- Decorative unless the caller passes an alt, which replaces this -->\n <img\n v-if=\"currentSrc\"\n :src=\"currentSrc\"\n alt=\"\"\n loading=\"lazy\"\n @error=\"onImageError(currentSrc)\" />\n <span\n v-else-if=\"fallbackIcon\"\n class=\"flex items-center justify-center text-18 text-word-4\">\n <VvIcon :name=\"fallbackIcon\" />\n </span>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;EAII,IAAMkB,IAAQC,GAaR,EAAE,iBAAc,oBAAiBL,EAAiB,GAClDM,IAAad,QAAe;GAC9B,IAAIe,EAAaH,EAAM,GAAG,GACtB,OAAOA,EAAM;GAEjB,IAAIG,EAAaH,EAAM,MAAM,GACzB,OAAOA,EAAM;EAGrB,CAAC;;;GAMS,OAAAE,EAAA,SADVpB,EAAA,GAAAC,EAKwC,OAAA;;IAHnC,KAAKmB,EAAA;IACN,KAAI;IACJ,SAAQ;IACP,SAAK,AAAAG,EAAA,QAAA,MAAErB,EAAAsB,CAAA,CAAY,CAACJ,EAAA,KAAU;G,mBAEpBD,EAAA,gBADfnB,EAAA,GAAAC,EAIO,QAJPe,GAIO,CADHb,EAA+BmB,GAAA,EAAtB,MAAMH,EAAA,aAAY,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,C"}
1
+ {"version":3,"file":"PkLazyImg-DYjihkLA.js","names":["_openBlock","_createElementBlock","_unref","_createVNode","Te","createVNode","computed","init_runtime_core_esm_bundler","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createElementBlock","openBlock","useImageFallback","_hoisted_1","_hoisted_2","PkLazyImg_default","props","__props","currentSrc","canShowImage","_component_VvIcon","_cache","onImageError"],"sources":["../../../../packages/components/src/PkLazyImg.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n import { computed } from 'vue'\n import { useImageFallback } from 'composables'\n\n const props = defineProps<{\n src: string\n /** Second-best source, tried when `src` fails (e.g. og:image -> favicon). */\n altSrc?: string\n /**\n * Icon rendered in place of the image once every source has failed.\n * Without it the element is dropped, leaving no gap in the layout.\n */\n fallbackIcon?: string\n }>()\n\n // Degrade src -> altSrc -> icon. The failure is tracked per url, so a\n // re-render keeps the fallback instead of re-requesting a dead source.\n const { canShowImage, onImageError } = useImageFallback()\n const currentSrc = computed(() => {\n if (canShowImage(props.src)) {\n return props.src\n }\n if (canShowImage(props.altSrc)) {\n return props.altSrc\n }\n return undefined\n })\n</script>\n\n<template>\n <!-- Decorative unless the caller passes an alt, which replaces this -->\n <img\n v-if=\"currentSrc\"\n :src=\"currentSrc\"\n alt=\"\"\n loading=\"lazy\"\n @error=\"onImageError(currentSrc)\" />\n <span\n v-else-if=\"fallbackIcon\"\n class=\"flex items-center justify-center text-18 text-word-4\">\n <VvIcon :name=\"fallbackIcon\" />\n </span>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;EAII,IAAMkB,IAAQC,GAaR,EAAE,iBAAc,oBAAiBL,EAAiB,GAClDM,IAAad,QAAe;GAC9B,IAAIe,EAAaH,EAAM,GAAG,GACtB,OAAOA,EAAM;GAEjB,IAAIG,EAAaH,EAAM,MAAM,GACzB,OAAOA,EAAM;EAGrB,CAAC;;;GAMS,OAAAE,EAAA,SADVpB,EAAA,GAAAC,EAKwC,OAAA;;IAHnC,KAAKmB,EAAA;IACN,KAAI;IACJ,SAAQ;IACP,SAAK,AAAAG,EAAA,QAAA,MAAErB,EAAAsB,CAAA,CAAY,CAACJ,EAAA,KAAU;G,mBAEpBD,EAAA,gBADfnB,EAAA,GAAAC,EAIO,QAJPe,GAIO,CADHb,EAA+BmB,GAAA,EAAtB,MAAMH,EAAA,aAAY,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,C"}
@@ -2,7 +2,7 @@ import { Et as e, F as t, J as n, N as r, Ot as i, S as a, Tt as o, V as s, X as
2
2
  import { r as k } from "./vue-i18n-CDYWo9pX.js";
3
3
  import { z as A } from "./utils-CRy3kzE3.js";
4
4
  import { l as j } from "./dist-CR8l0inH.js";
5
- import { r as M } from "./index.es-B9l77u9z.js";
5
+ import { r as M } from "./index.es-DHeth3Ja.js";
6
6
  import { t as N } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
7
7
  // ../../packages/composable/src/useSettledSelection.ts
8
8
  v();
@@ -398,4 +398,4 @@ var Q = ["placeholder", "aria-label"], $ = ["disabled"], ee = ["aria-label"], te
398
398
  }), [["styles", [".pk-selection-actions{z-index:10;max-width:min(20rem, 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));max-width:none}.pk-selection-actions__menu{width:max-content;min-width:11rem;max-width:100%;padding:var(--spacing-4);border:var(--spacing-1) solid var(--color-surface-5);border-radius:var(--rounded-lg);background-color:var(--color-surface);color:var(--color-word-2);font-family:var(--font-sans);font-size:var(--text-12);box-shadow:var(--shadow-lg);flex-direction:column;display:flex}.pk-selection-actions__menu--field{align-items:center;gap:var(--spacing-4);flex-direction:row;width:100%}.pk-selection-actions__text{max-width:16rem;padding:var(--spacing-4) var(--spacing-8) var(--spacing-6);color:var(--color-word-3);font-size:var(--text-12);margin:0}.pk-selection-actions__button{align-items:center;gap:var(--spacing-8);border-radius:var(--rounded);padding:var(--spacing-6) var(--spacing-12) var(--spacing-6) var(--spacing-8);color:inherit;font:inherit;text-align:start;white-space:nowrap;cursor:pointer;background-color:#0000;border:0;flex-shrink:0;display:flex}@media (pointer:coarse){.pk-selection-actions__button{min-height:var(--spacing-40)}}.pk-selection-actions__button:hover{background-color:var(--color-surface-1);color:var(--color-word-1)}.pk-selection-actions__button:focus-visible{outline:var(--spacing-2) solid var(--color-brand);outline-offset:calc(-1 * var(--spacing-2))}.pk-selection-actions__button--send{padding:var(--spacing-6) var(--spacing-10);background-color:var(--color-word-1);color:var(--color-surface);font-weight:var(--font-medium)}.pk-selection-actions__button--send:hover{background-color:var(--color-word-1);color:var(--color-surface)}.pk-selection-actions__button--send:disabled{opacity:.5;cursor:default}.pk-selection-actions__icon{width:var(--spacing-16);height:var(--spacing-16);color:var(--color-word-3);flex-shrink:0}.pk-selection-actions__rule{margin:var(--spacing-4) 0;border:0;border-top:var(--spacing-1) solid var(--color-surface-3)}.pk-selection-actions__input{border-radius:var(--rounded);min-width:0;padding:var(--spacing-6) var(--spacing-8);background-color:var(--color-surface-1);color:var(--color-word-1);font:inherit;border:0;flex:1}@media (pointer:coarse){.pk-selection-actions__input{min-height:var(--spacing-40);font-size:var(--text-16)}}.pk-selection-actions__input::placeholder{color:var(--color-word-3)}.pk-selection-actions__input:focus-visible{outline:var(--spacing-2) solid var(--color-brand);outline-offset:calc(-1 * var(--spacing-2))}"]]]);
399
399
  export { z as a, L as i, J as n, Y as r, ie as t };
400
400
 
401
- //# sourceMappingURL=PkSelectionActions-DDhRX6cs.js.map
401
+ //# sourceMappingURL=PkSelectionActions-DDhbwE4U.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PkSelectionActions-DDhRX6cs.js","names":["settled","_useModel","_openBlock","_createElementBlock","_normalizeClass","_normalizeStyle","_withKeys","_withModifiers","_withDirectives","_createElementVNode","_vModelText","_toDisplayString","_unref","_Fragment","_createVNode","_createTextVNode","_renderList","normalizeClass","nextTick","useModel","mergeModels","normalizeStyle","createVNode","init_shared_esm_bundler","renderList","useTemplateRef","vModelText","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","unref","createTextVNode","createElementBlock","openBlock","useI18n","selectionBarPosition","useElementSize","De","_plugin_vue_export_helper_default","FINE_POINTER","TOUCH_SCREEN","TOUCH_DELAY","isTouchScreen","rangeIn","selection","root","shadow","ranges","first","range","own","useSettledSelection","timer","clear","read","node","enabled","minChars","box","finePointer","byTouch","touch","wait","delay","onChange","MAX_ALIGNED_PAIRS","unmatchedItems","start","before","after","end","n","m","out","gap","j","j0","j1","i","i0","i1","lengths","withoutIds","key","value","contentOf","changedCellIds","idsOf","cells","c","was","old","cell","wordChanges","paragraphs","blocks","b","block","id","cellContents","sheet","preview","spreadsheetChanges","s","now","changed","at","content","chatFilePreviewChanges","revealFirstChange","el","scroller","selector","SELECTION_ACTION_ICON_NAMES","agentActionIcon","icon","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","PkSelectionActions_default","defineComponent","\"asking\"","\"askingModifiers\"","__emit","BUILT_IN_ICONS","props","__props","emit","asking","$t","barEl","inputEl","position","width","height","field","text","openField","closeField","openAsk","iconOf","action","run","onTap","row","event","under","act","submit","onEscape","_component_VvIcon","_cache","$event"],"sources":["../../../../packages/composable/src/useSettledSelection.ts","../../../../packages/components/src/chat/previewChanges.ts","../../../../packages/components/src/chat/selectionActionIcons.ts","../../../../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 * Also on a touch screen, where the bar goes below the selection, away\n * from the system's menu: the chat's file viewer (spec\n * `chat-file-selection-edit.md`, F4) and the page's bar of actions (spec\n * `selection-actions.md`, F3).\n */\n touch?: boolean\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/** A screen read by touch: no hover, a coarse pointer. */\nconst TOUCH_SCREEN = '(hover: none) and (pointer: coarse)'\n/**\n * How long a touch selection stays still before it counts: the finger rests\n * between two moves of a handle, and the bar would flash below it.\n */\nconst TOUCH_DELAY = 400\n\n/** True on a touch screen, where a selection's bar goes below it. */\nexport function isTouchScreen(): boolean {\n return typeof matchMedia === 'function' && matchMedia(TOUCH_SCREEN).matches\n}\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 * unless `touch`. Undefined while the selection moves, is collapsed or\n * shorter than `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 touch = false,\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 finePointer =\n typeof document !== 'undefined' &&\n typeof matchMedia === 'function' &&\n matchMedia(FINE_POINTER).matches\n const byTouch = touch && typeof document !== 'undefined' && isTouchScreen()\n const wait = byTouch ? Math.max(delay, TOUCH_DELAY) : delay\n\n const onChange = () => {\n clear()\n timer = setTimeout(() => {\n selection.value = read()\n }, wait)\n }\n\n if (finePointer || byTouch) {\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","import type {\n ChatFilePreview,\n SpreadsheetPreview,\n SpreadsheetPreviewSheet,\n WordPreview,\n WordPreviewBlock,\n WordPreviewCell,\n} from 'models'\n\n/**\n * What a version of a file changed from the one the viewer showed before it\n * (spec `chat-file-selection-edit.md`): the paragraphs of a Word document by\n * their ids in the new version, or the cells of each sheet, by its name, as\n * `row:col`. The viewer marks them for a moment when it follows an edit.\n */\nexport type ChatFilePreviewChanges =\n | { kind: 'word'; paragraphs: ReadonlySet<string> }\n | {\n kind: 'spreadsheet'\n cells: ReadonlyMap<string, ReadonlySet<string>>\n }\n\n/**\n * Past this many pairs the middle of the two lists is not aligned: all of\n * the new one there counts as changed. A thousand paragraphs each side.\n */\nconst MAX_ALIGNED_PAIRS = 1_000_000\n\n/**\n * The items of `after` that `before` does not hold in the same order, each\n * with the item of `before` it took the place of, if any: the one at the\n * same distance from the start of the stretch both lists differ in. The\n * common start and end are skipped, the middle is aligned by its longest\n * common subsequence.\n */\nexport const unmatchedItems = (\n before: readonly string[],\n after: readonly string[],\n): Map<number, number | undefined> => {\n let start = 0\n while (\n start < before.length &&\n start < after.length &&\n before[start] === after[start]\n ) {\n start += 1\n }\n let end = 0\n while (\n end < before.length - start &&\n end < after.length - start &&\n before[before.length - 1 - end] === after[after.length - 1 - end]\n ) {\n end += 1\n }\n const n = before.length - start - end\n const m = after.length - start - end\n const out = new Map<number, number | undefined>()\n // Each stretch between two kept items: its new items stand for its old\n // ones in order\n const gap = (i0: number, i1: number, j0: number, j1: number) => {\n for (let j = j0; j < j1; j++) {\n const i = i0 + (j - j0)\n out.set(j, i < i1 ? i : undefined)\n }\n }\n if (!m) {\n return out\n }\n if (!n || n * m > MAX_ALIGNED_PAIRS) {\n gap(start, start + n, start, start + m)\n return out\n }\n // lengths[i * (m + 1) + j]: the longest common subsequence of the old\n // middle from i and the new one from j\n const lengths = new Uint32Array((n + 1) * (m + 1))\n for (let i = n - 1; i >= 0; i--) {\n for (let j = m - 1; j >= 0; j--) {\n lengths[i * (m + 1) + j] =\n before[start + i] === after[start + j]\n ? lengths[(i + 1) * (m + 1) + j + 1] + 1\n : Math.max(\n lengths[(i + 1) * (m + 1) + j],\n lengths[i * (m + 1) + j + 1],\n )\n }\n }\n let i = 0\n let j = 0\n let i0 = 0\n let j0 = 0\n while (i < n && j < m) {\n if (before[start + i] === after[start + j]) {\n gap(start + i0, start + i, start + j0, start + j)\n i += 1\n j += 1\n i0 = i\n j0 = j\n } else if (\n lengths[(i + 1) * (m + 1) + j] >= lengths[i * (m + 1) + j + 1]\n ) {\n i += 1\n } else {\n j += 1\n }\n }\n gap(start + i0, start + n, start + j0, start + m)\n return out\n}\n\n/** A paragraph's id moves when one is added before it: it is not its content. */\nconst withoutIds = (key: string, value: unknown) =>\n key === 'id' || key === 'ids' ? undefined : value\n\nconst contentOf = (value: unknown) => JSON.stringify(value, withoutIds)\n\n/** The ids of a table's cells that differ from the table it took the place of. */\nconst changedCellIds = (\n after: WordPreviewBlock & { kind: 'table' },\n before: WordPreviewBlock | undefined,\n): string[] => {\n const idsOf = (cells: WordPreviewCell[]) =>\n cells.flatMap((c) => c.ids ?? [])\n if (before?.kind !== 'table') {\n return idsOf(after.rows.flat())\n }\n const rows = unmatchedItems(\n before.rows.map(contentOf),\n after.rows.map(contentOf),\n )\n return [...rows].flatMap(([r, was]) => {\n const old = was === undefined ? undefined : before.rows[was]\n return idsOf(\n after.rows[r].filter(\n (cell, c) => !old?.[c] || contentOf(old[c]) !== contentOf(cell),\n ),\n )\n })\n}\n\nconst wordChanges = (before: WordPreview, after: WordPreview) => {\n const paragraphs = new Set<string>()\n const blocks = unmatchedItems(\n before.blocks.map(contentOf),\n after.blocks.map(contentOf),\n )\n for (const [b, was] of blocks) {\n const block = after.blocks[b]\n if (block.kind === 'table') {\n const old = was === undefined ? undefined : before.blocks[was]\n for (const id of changedCellIds(block, old)) {\n paragraphs.add(id)\n }\n } else if (block.id) {\n paragraphs.add(block.id)\n }\n }\n return paragraphs\n}\n\n/**\n * A cell as it shows: its look and number format by what they are, as each\n * version numbers its own lists of them.\n */\nconst cellContents = (\n preview: SpreadsheetPreview,\n sheet: SpreadsheetPreviewSheet,\n) => {\n const out = new Map<string, string>()\n for (const r of sheet.rows) {\n for (const cell of r.cells) {\n out.set(\n `${r.row}:${cell.col}`,\n JSON.stringify({\n ...cell,\n style:\n cell.style === undefined\n ? undefined\n : preview.styles[cell.style],\n numFmt:\n cell.numFmt === undefined\n ? undefined\n : preview.numberFormats?.[cell.numFmt],\n }),\n )\n }\n }\n return out\n}\n\nconst spreadsheetChanges = (\n before: SpreadsheetPreview,\n after: SpreadsheetPreview,\n) => {\n const cells = new Map<string, ReadonlySet<string>>()\n for (const sheet of after.sheets) {\n const old = before.sheets.find((s) => s.name === sheet.name)\n const now = cellContents(after, sheet)\n const was = old ? cellContents(before, old) : new Map<string, string>()\n const changed = new Set<string>()\n for (const [at, content] of now) {\n if (was.get(at) !== content) {\n changed.add(at)\n }\n }\n // A cell emptied is gone from the new version's list\n for (const at of was.keys()) {\n if (!now.has(at)) {\n changed.add(at)\n }\n }\n if (changed.size) {\n cells.set(sheet.name, changed)\n }\n }\n return cells\n}\n\n/**\n * What `after` changed from `before`, two versions of the same file: none\n * when nothing the viewer draws differs, or the two are not of one format.\n */\nexport const chatFilePreviewChanges = (\n before: ChatFilePreview,\n after: ChatFilePreview,\n): ChatFilePreviewChanges | undefined => {\n if (before.kind === 'word' && after.kind === 'word') {\n const paragraphs = wordChanges(before, after)\n return paragraphs.size ? { kind: 'word', paragraphs } : undefined\n }\n if (before.kind === 'spreadsheet' && after.kind === 'spreadsheet') {\n const cells = spreadsheetChanges(before, after)\n return cells.size ? { kind: 'spreadsheet', cells } : undefined\n }\n return undefined\n}\n\n/**\n * Brings the first marked change into the middle of the viewer's own scroll\n * box, when it is not in sight already. Not `scrollIntoView`: it would scroll\n * the page around the viewer too. False while there is none drawn yet.\n */\nexport const revealFirstChange = (\n scroller: HTMLElement | null | undefined,\n selector: string,\n): boolean => {\n const el = scroller?.querySelector(selector)\n if (!scroller || !el) {\n return false\n }\n const box = scroller.getBoundingClientRect()\n const at = el.getBoundingClientRect()\n if (at.top < box.top || at.bottom > box.bottom) {\n scroller.scrollTop += at.top - box.top - (box.height - at.height) / 2\n }\n if (at.left < box.left || at.right > box.right) {\n scroller.scrollLeft += at.left - box.left - (box.width - at.width) / 2\n }\n return true\n}\n","import type { SelectionActionIcon } from 'models'\n\n/**\n * The Remix icon of each name an action of the agent can wear on the\n * selection menu (`SELECTION_ACTION_ICONS` in `models`): the menu draws it,\n * the backoffice offers it in the grid of the action.\n */\nexport const SELECTION_ACTION_ICON_NAMES: Record<SelectionActionIcon, string> =\n {\n sparkles: 'ri:sparkling-line',\n magic: 'ri:magic-line',\n idea: 'ri:lightbulb-line',\n star: 'ri:star-line',\n heart: 'ri:heart-line',\n lightning: 'ri:flashlight-line',\n fire: 'ri:fire-line',\n rocket: 'ri:rocket-line',\n pen: 'ri:quill-pen-line',\n pencil: 'ri:pencil-line',\n text: 'ri:text',\n paragraph: 'ri:paragraph',\n quote: 'ri:double-quotes-l',\n list: 'ri:list-unordered',\n checklist: 'ri:list-check-2',\n highlighter: 'ri:mark-pen-line',\n document: 'ri:file-text-line',\n folder: 'ri:folder-line',\n book: 'ri:book-open-line',\n bookmark: 'ri:bookmark-line',\n clipboard: 'ri:clipboard-line',\n draft: 'ri:draft-line',\n contract: 'ri:file-paper-2-line',\n attachment: 'ri:attachment-2',\n archive: 'ri:archive-line',\n search: 'ri:search-line',\n filter: 'ri:filter-3-line',\n eye: 'ri:eye-line',\n questions: 'ri:question-answer-line',\n 'pie-chart': 'ri:pie-chart-line',\n 'line-chart': 'ri:line-chart-line',\n table: 'ri:table-line',\n database: 'ri:database-2-line',\n calculator: 'ri:calculator-line',\n percent: 'ri:percent-line',\n scales: 'ri:scales-3-line',\n euro: 'ri:money-euro-circle-line',\n dollar: 'ri:money-dollar-circle-line',\n wallet: 'ri:wallet-3-line',\n bank: 'ri:bank-line',\n card: 'ri:bank-card-line',\n cart: 'ri:shopping-cart-2-line',\n 'price-tag': 'ri:price-tag-3-line',\n bill: 'ri:bill-line',\n gift: 'ri:gift-line',\n shop: 'ri:store-2-line',\n truck: 'ri:truck-line',\n shield: 'ri:shield-check-line',\n lock: 'ri:lock-line',\n key: 'ri:key-2-line',\n gavel: 'ri:auction-line',\n institution: 'ri:government-line',\n passport: 'ri:passport-line',\n person: 'ri:user-line',\n team: 'ri:team-line',\n group: 'ri:group-line',\n smile: 'ri:emotion-happy-line',\n handshake: 'ri:shake-hands-line',\n support: 'ri:customer-service-2-line',\n contacts: 'ri:contacts-book-line',\n mail: 'ri:mail-line',\n send: 'ri:send-plane-line',\n speech: 'ri:chat-3-line',\n phone: 'ri:phone-line',\n megaphone: 'ri:megaphone-line',\n bell: 'ri:notification-3-line',\n share: 'ri:share-line',\n link: 'ri:link',\n globe: 'ri:global-line',\n calendar: 'ri:calendar-line',\n event: 'ri:calendar-event-line',\n clock: 'ri:time-line',\n timer: 'ri:timer-line',\n history: 'ri:history-line',\n hourglass: 'ri:hourglass-line',\n plane: 'ri:plane-line',\n car: 'ri:car-line',\n train: 'ri:train-line',\n ship: 'ri:ship-line',\n map: 'ri:map-2-line',\n pin: 'ri:map-pin-line',\n compass: 'ri:compass-3-line',\n bed: 'ri:hotel-bed-line',\n suitcase: 'ri:suitcase-line',\n home: 'ri:home-4-line',\n building: 'ri:building-line',\n flag: 'ri:flag-line',\n earth: 'ri:earth-line',\n sun: 'ri:sun-line',\n umbrella: 'ri:umbrella-line',\n heartbeat: 'ri:heart-pulse-line',\n capsule: 'ri:capsule-line',\n 'first-aid': 'ri:first-aid-kit-line',\n restaurant: 'ri:restaurant-line',\n cup: 'ri:cup-line',\n leaf: 'ri:leaf-line',\n plant: 'ri:plant-line',\n recycle: 'ri:recycle-line',\n school: 'ri:school-line',\n graduation: 'ri:graduation-cap-line',\n brain: 'ri:brain-line',\n puzzle: 'ri:puzzle-line',\n award: 'ri:award-line',\n trophy: 'ri:trophy-line',\n settings: 'ri:settings-3-line',\n tools: 'ri:tools-line',\n code: 'ri:code-s-slash-line',\n bug: 'ri:bug-line',\n robot: 'ri:robot-2-line',\n cloud: 'ri:cloud-line',\n flask: 'ri:flask-line',\n microscope: 'ri:microscope-line',\n check: 'ri:checkbox-circle-line',\n cross: 'ri:close-circle-line',\n warning: 'ri:alert-line',\n information: 'ri:information-line',\n refresh: 'ri:refresh-line',\n swap: 'ri:arrow-left-right-line',\n arrow: 'ri:arrow-right-circle-line',\n 'thumbs-up': 'ri:thumb-up-line',\n target: 'ri:focus-3-line',\n palette: 'ri:palette-line',\n image: 'ri:image-line',\n music: 'ri:music-2-line',\n video: 'ri:video-line',\n microphone: 'ri:mic-line',\n }\n\n/** The icon of an action of the agent: the one its author chose, else the sparkle. */\nexport const agentActionIcon = (icon?: SelectionActionIcon) =>\n SELECTION_ACTION_ICON_NAMES[icon ?? 'sparkles']\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 type { SelectionActionIcon } from 'models'\n import { agentActionIcon } from './selectionActionIcons'\n import { selectionBarPosition } from './utils'\n\n /**\n * The menu 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: a row per action with its icon, the agent's after the built-in\n * ones, then \"Ask…\" below a rule, which turns the menu into a field. An\n * 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 rows take no focus on a click,\n * so the selection stays and Cmd+C still copies it; the keyboard reaches\n * them with Tab.\n */\n\n /**\n * The built-in actions by their icon, from the Remix set the app's menus\n * use; an action of the agent has the one its author chose\n * (`agentActionIcon`), the sparkle without one.\n */\n const BUILT_IN_ICONS: Record<string, string> = {\n explain: 'ri:question-line',\n summarize: 'ri:file-list-3-line',\n rewrite: 'ri:edit-line',\n shorten: 'ri:scissors-cut-line',\n proofread: 'ri:check-double-line',\n translate: 'ri:translate-2',\n chart: 'ri:bar-chart-2-line',\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 /** An action of the agent: the icon its author chose. */\n icon?: SelectionActionIcon\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 const openAsk = () =>\n openField(undefined, $t('selectionActions.askPlaceholder'))\n\n const iconOf = (action: SelectionBarAction) =>\n BUILT_IN_ICONS[action.id] ?? agentActionIcon(action.icon)\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 /**\n * A finger lifted on the row it touched. The menu turns the touch's\n * default off as it starts: on a phone a tap outside the text clears\n * the selection before the click, and the menu went with it. With the\n * default off no click follows, so the row acts here.\n */\n const onTap = (event: TouchEvent, act: () => void) => {\n const row = event.currentTarget as HTMLElement\n const touch = event.changedTouches[0]\n const root = row.getRootNode() as Document | ShadowRoot\n const under =\n touch && root.elementFromPoint(touch.clientX, touch.clientY)\n if (under && row.contains(under)) {\n act()\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 /**\n * Esc closes the field, or the menu, and nothing else: its default would\n * also close the dialog the file viewer is in. Not while an input method\n * composes: there Esc cancels the composition.\n */\n const onEscape = (event: KeyboardEvent) => {\n if (event.isComposing) {\n return\n }\n event.stopPropagation()\n event.preventDefault()\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=\"onEscape\">\n <form\n v-if=\"field\"\n ref=\"barEl\"\n class=\"pk-selection-actions__menu pk-selection-actions__menu--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__menu\"\n role=\"toolbar\"\n aria-orientation=\"vertical\"\n :aria-label=\"$t('selectionActions.label')\"\n @touchstart.prevent>\n <template v-if=\"note\">\n <p class=\"pk-selection-actions__text\">{{ note }}</p>\n <button\n v-if=\"noteAction\"\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"emit('note')\"\n @touchend=\"onTap($event, () => emit('note'))\">\n <VvIcon\n name=\"ri:arrow-right-line\"\n class=\"pk-selection-actions__icon\" />\n {{ noteAction }}\n </button>\n </template>\n <template v-else>\n <p v-if=\"hint\" class=\"pk-selection-actions__text\">\n {{ hint }}\n </p>\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 @touchend=\"onTap($event, () => run(action))\">\n <VvIcon\n :name=\"iconOf(action)\"\n class=\"pk-selection-actions__icon\" />\n {{ action.label }}\n </button>\n <hr class=\"pk-selection-actions__rule\" />\n <button\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"openAsk\"\n @touchend=\"onTap($event, openAsk)\">\n <VvIcon\n name=\"ri:chat-1-line\"\n class=\"pk-selection-actions__icon\" />\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(20rem, 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 max-width: none;\n }\n\n // As the app's menus (the ⋮ of a conversation): the surface, its\n // hairline and its shadow, readable over a document and over a page\n &__menu {\n display: flex;\n flex-direction: column;\n min-width: 11rem;\n width: max-content;\n max-width: 100%;\n padding: var(--spacing-4);\n border: var(--spacing-1) solid var(--color-surface-5);\n border-radius: var(--rounded-lg);\n background-color: var(--color-surface);\n color: var(--color-word-2);\n font-family: var(--font-sans);\n font-size: var(--text-12);\n box-shadow: var(--shadow-lg);\n\n &--field {\n flex-direction: row;\n align-items: center;\n gap: var(--spacing-4);\n width: 100%;\n }\n }\n\n &__text {\n max-width: 16rem;\n margin: 0;\n padding: var(--spacing-4) var(--spacing-8) var(--spacing-6);\n color: var(--color-word-3);\n font-size: var(--text-12);\n }\n\n &__button {\n display: flex;\n flex-shrink: 0;\n align-items: center;\n gap: var(--spacing-8);\n border: 0;\n border-radius: var(--rounded);\n padding: var(--spacing-6) var(--spacing-12) var(--spacing-6)\n var(--spacing-8);\n background-color: transparent;\n color: inherit;\n font: inherit;\n text-align: start;\n white-space: nowrap;\n cursor: pointer;\n\n // A finger gets 40px (DESIGN.md, principle 15): the row grows,\n // the text keeps its size\n @media (pointer: coarse) {\n min-height: var(--spacing-40);\n }\n\n &:hover {\n background-color: var(--color-surface-1);\n color: var(--color-word-1);\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--color-brand);\n outline-offset: calc(-1 * var(--spacing-2));\n }\n\n &--send {\n padding: var(--spacing-6) var(--spacing-10);\n background-color: var(--color-word-1);\n color: var(--color-surface);\n font-weight: var(--font-medium);\n\n &:hover {\n background-color: var(--color-word-1);\n color: var(--color-surface);\n }\n\n &:disabled {\n opacity: 0.5;\n cursor: default;\n }\n }\n }\n\n &__icon {\n flex-shrink: 0;\n width: var(--spacing-16);\n height: var(--spacing-16);\n color: var(--color-word-3);\n }\n\n &__rule {\n margin: var(--spacing-4) 0;\n border: 0;\n border-top: var(--spacing-1) solid var(--color-surface-3);\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: var(--color-surface-1);\n color: var(--color-word-1);\n font: inherit;\n\n @media (pointer: coarse) {\n min-height: var(--spacing-40);\n\n // Below 16px Safari on iOS zooms the page on the focus\n font-size: var(--text-16);\n }\n\n &::placeholder {\n color: var(--color-word-3);\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--color-brand);\n outline-offset: calc(-1 * var(--spacing-2));\n }\n }\n }\n</style>\n"],"mappings":";;;;;;;;AA8BA,IAAMkD,IAAe,sCAEfC,IAAe,uCAKfC,IAAc;AAGpB,SAAgBC,IAAyB;CACrC,OAAO,OAAO,cAAe,cAAc,WAAWF,CAAY,CAAC,CAAC;AACxE;AAiBA,SAASG,EAAQ,GAAgD;CAC7D,IAAMC,IAAY,SAAS,aAAa;CACxC,IAAI,CAACA,KAAaA,EAAU,eAAe,GACvC;CAEJ,IAAIC,EAAK,aAAa,KAAK,eACvB,OAAOD,EAAU,WAAW,CAAC,CAAC,CAAC,WAAW;CAE9C,IAAME,IAASD;CACf,IAAID,EAAU,mBAAmB;EAC7B,IAAIG;EACJ,IAAI;GACA,IAASH,EAAU,kBAAkB,EAAE,aAAa,CAACE,CAAM,EAAE,CAAC;EAClE,QAAQ;GACJ,IAASF,EAAU,kBAAkBE,CAAM;EAC/C;EACA,IAAM,CAACE,KAASD;EAChB,IAAI,CAACC,GACD;EAEJ,IAAMC,IAAQ,SAAS,YAAY;EAGnC,OAFAA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AAS,AAAA4J,EAAA,OAAA9J,QAAV,CAAA,GAAkB,CAAA,SAAA,CAAA;KACjB,SAAOkJ;KACP,YAAQ,AAAAY,EAAA,QAAA,MAAER,EAAMS,GAAQb,CAAO;I,IAChC3I,EAEyCsJ,GAAA;KADrC,MAAK;KACL,OAAM;I,IAA+BrJ,EAAA,MACzCJ,EAAGC,EAAAmI,CAAA,CAAE,CAAA,sBAAA,CAAA,GAAA,CAAA,C"}
1
+ {"version":3,"file":"PkSelectionActions-DDhbwE4U.js","names":["settled","_useModel","_openBlock","_createElementBlock","_normalizeClass","_normalizeStyle","_withKeys","_withModifiers","_withDirectives","_createElementVNode","_vModelText","_toDisplayString","_unref","_Fragment","_createVNode","_createTextVNode","_renderList","normalizeClass","nextTick","useModel","mergeModels","normalizeStyle","createVNode","init_shared_esm_bundler","renderList","useTemplateRef","vModelText","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","unref","createTextVNode","createElementBlock","openBlock","useI18n","selectionBarPosition","useElementSize","Te","_plugin_vue_export_helper_default","FINE_POINTER","TOUCH_SCREEN","TOUCH_DELAY","isTouchScreen","rangeIn","selection","root","shadow","ranges","first","range","own","useSettledSelection","timer","clear","read","node","enabled","minChars","box","finePointer","byTouch","touch","wait","delay","onChange","MAX_ALIGNED_PAIRS","unmatchedItems","start","before","after","end","n","m","out","gap","j","j0","j1","i","i0","i1","lengths","withoutIds","key","value","contentOf","changedCellIds","idsOf","cells","c","was","old","cell","wordChanges","paragraphs","blocks","b","block","id","cellContents","sheet","preview","spreadsheetChanges","s","now","changed","at","content","chatFilePreviewChanges","revealFirstChange","el","scroller","selector","SELECTION_ACTION_ICON_NAMES","agentActionIcon","icon","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","PkSelectionActions_default","defineComponent","\"asking\"","\"askingModifiers\"","__emit","BUILT_IN_ICONS","props","__props","emit","asking","$t","barEl","inputEl","position","width","height","field","text","openField","closeField","openAsk","iconOf","action","run","onTap","row","event","under","act","submit","onEscape","_component_VvIcon","_cache","$event"],"sources":["../../../../packages/composable/src/useSettledSelection.ts","../../../../packages/components/src/chat/previewChanges.ts","../../../../packages/components/src/chat/selectionActionIcons.ts","../../../../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 * Also on a touch screen, where the bar goes below the selection, away\n * from the system's menu: the chat's file viewer (spec\n * `chat-file-selection-edit.md`, F4) and the page's bar of actions (spec\n * `selection-actions.md`, F3).\n */\n touch?: boolean\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/** A screen read by touch: no hover, a coarse pointer. */\nconst TOUCH_SCREEN = '(hover: none) and (pointer: coarse)'\n/**\n * How long a touch selection stays still before it counts: the finger rests\n * between two moves of a handle, and the bar would flash below it.\n */\nconst TOUCH_DELAY = 400\n\n/** True on a touch screen, where a selection's bar goes below it. */\nexport function isTouchScreen(): boolean {\n return typeof matchMedia === 'function' && matchMedia(TOUCH_SCREEN).matches\n}\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 * unless `touch`. Undefined while the selection moves, is collapsed or\n * shorter than `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 touch = false,\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 finePointer =\n typeof document !== 'undefined' &&\n typeof matchMedia === 'function' &&\n matchMedia(FINE_POINTER).matches\n const byTouch = touch && typeof document !== 'undefined' && isTouchScreen()\n const wait = byTouch ? Math.max(delay, TOUCH_DELAY) : delay\n\n const onChange = () => {\n clear()\n timer = setTimeout(() => {\n selection.value = read()\n }, wait)\n }\n\n if (finePointer || byTouch) {\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","import type {\n ChatFilePreview,\n SpreadsheetPreview,\n SpreadsheetPreviewSheet,\n WordPreview,\n WordPreviewBlock,\n WordPreviewCell,\n} from 'models'\n\n/**\n * What a version of a file changed from the one the viewer showed before it\n * (spec `chat-file-selection-edit.md`): the paragraphs of a Word document by\n * their ids in the new version, or the cells of each sheet, by its name, as\n * `row:col`. The viewer marks them for a moment when it follows an edit.\n */\nexport type ChatFilePreviewChanges =\n | { kind: 'word'; paragraphs: ReadonlySet<string> }\n | {\n kind: 'spreadsheet'\n cells: ReadonlyMap<string, ReadonlySet<string>>\n }\n\n/**\n * Past this many pairs the middle of the two lists is not aligned: all of\n * the new one there counts as changed. A thousand paragraphs each side.\n */\nconst MAX_ALIGNED_PAIRS = 1_000_000\n\n/**\n * The items of `after` that `before` does not hold in the same order, each\n * with the item of `before` it took the place of, if any: the one at the\n * same distance from the start of the stretch both lists differ in. The\n * common start and end are skipped, the middle is aligned by its longest\n * common subsequence.\n */\nexport const unmatchedItems = (\n before: readonly string[],\n after: readonly string[],\n): Map<number, number | undefined> => {\n let start = 0\n while (\n start < before.length &&\n start < after.length &&\n before[start] === after[start]\n ) {\n start += 1\n }\n let end = 0\n while (\n end < before.length - start &&\n end < after.length - start &&\n before[before.length - 1 - end] === after[after.length - 1 - end]\n ) {\n end += 1\n }\n const n = before.length - start - end\n const m = after.length - start - end\n const out = new Map<number, number | undefined>()\n // Each stretch between two kept items: its new items stand for its old\n // ones in order\n const gap = (i0: number, i1: number, j0: number, j1: number) => {\n for (let j = j0; j < j1; j++) {\n const i = i0 + (j - j0)\n out.set(j, i < i1 ? i : undefined)\n }\n }\n if (!m) {\n return out\n }\n if (!n || n * m > MAX_ALIGNED_PAIRS) {\n gap(start, start + n, start, start + m)\n return out\n }\n // lengths[i * (m + 1) + j]: the longest common subsequence of the old\n // middle from i and the new one from j\n const lengths = new Uint32Array((n + 1) * (m + 1))\n for (let i = n - 1; i >= 0; i--) {\n for (let j = m - 1; j >= 0; j--) {\n lengths[i * (m + 1) + j] =\n before[start + i] === after[start + j]\n ? lengths[(i + 1) * (m + 1) + j + 1] + 1\n : Math.max(\n lengths[(i + 1) * (m + 1) + j],\n lengths[i * (m + 1) + j + 1],\n )\n }\n }\n let i = 0\n let j = 0\n let i0 = 0\n let j0 = 0\n while (i < n && j < m) {\n if (before[start + i] === after[start + j]) {\n gap(start + i0, start + i, start + j0, start + j)\n i += 1\n j += 1\n i0 = i\n j0 = j\n } else if (\n lengths[(i + 1) * (m + 1) + j] >= lengths[i * (m + 1) + j + 1]\n ) {\n i += 1\n } else {\n j += 1\n }\n }\n gap(start + i0, start + n, start + j0, start + m)\n return out\n}\n\n/** A paragraph's id moves when one is added before it: it is not its content. */\nconst withoutIds = (key: string, value: unknown) =>\n key === 'id' || key === 'ids' ? undefined : value\n\nconst contentOf = (value: unknown) => JSON.stringify(value, withoutIds)\n\n/** The ids of a table's cells that differ from the table it took the place of. */\nconst changedCellIds = (\n after: WordPreviewBlock & { kind: 'table' },\n before: WordPreviewBlock | undefined,\n): string[] => {\n const idsOf = (cells: WordPreviewCell[]) =>\n cells.flatMap((c) => c.ids ?? [])\n if (before?.kind !== 'table') {\n return idsOf(after.rows.flat())\n }\n const rows = unmatchedItems(\n before.rows.map(contentOf),\n after.rows.map(contentOf),\n )\n return [...rows].flatMap(([r, was]) => {\n const old = was === undefined ? undefined : before.rows[was]\n return idsOf(\n after.rows[r].filter(\n (cell, c) => !old?.[c] || contentOf(old[c]) !== contentOf(cell),\n ),\n )\n })\n}\n\nconst wordChanges = (before: WordPreview, after: WordPreview) => {\n const paragraphs = new Set<string>()\n const blocks = unmatchedItems(\n before.blocks.map(contentOf),\n after.blocks.map(contentOf),\n )\n for (const [b, was] of blocks) {\n const block = after.blocks[b]\n if (block.kind === 'table') {\n const old = was === undefined ? undefined : before.blocks[was]\n for (const id of changedCellIds(block, old)) {\n paragraphs.add(id)\n }\n } else if (block.id) {\n paragraphs.add(block.id)\n }\n }\n return paragraphs\n}\n\n/**\n * A cell as it shows: its look and number format by what they are, as each\n * version numbers its own lists of them.\n */\nconst cellContents = (\n preview: SpreadsheetPreview,\n sheet: SpreadsheetPreviewSheet,\n) => {\n const out = new Map<string, string>()\n for (const r of sheet.rows) {\n for (const cell of r.cells) {\n out.set(\n `${r.row}:${cell.col}`,\n JSON.stringify({\n ...cell,\n style:\n cell.style === undefined\n ? undefined\n : preview.styles[cell.style],\n numFmt:\n cell.numFmt === undefined\n ? undefined\n : preview.numberFormats?.[cell.numFmt],\n }),\n )\n }\n }\n return out\n}\n\nconst spreadsheetChanges = (\n before: SpreadsheetPreview,\n after: SpreadsheetPreview,\n) => {\n const cells = new Map<string, ReadonlySet<string>>()\n for (const sheet of after.sheets) {\n const old = before.sheets.find((s) => s.name === sheet.name)\n const now = cellContents(after, sheet)\n const was = old ? cellContents(before, old) : new Map<string, string>()\n const changed = new Set<string>()\n for (const [at, content] of now) {\n if (was.get(at) !== content) {\n changed.add(at)\n }\n }\n // A cell emptied is gone from the new version's list\n for (const at of was.keys()) {\n if (!now.has(at)) {\n changed.add(at)\n }\n }\n if (changed.size) {\n cells.set(sheet.name, changed)\n }\n }\n return cells\n}\n\n/**\n * What `after` changed from `before`, two versions of the same file: none\n * when nothing the viewer draws differs, or the two are not of one format.\n */\nexport const chatFilePreviewChanges = (\n before: ChatFilePreview,\n after: ChatFilePreview,\n): ChatFilePreviewChanges | undefined => {\n if (before.kind === 'word' && after.kind === 'word') {\n const paragraphs = wordChanges(before, after)\n return paragraphs.size ? { kind: 'word', paragraphs } : undefined\n }\n if (before.kind === 'spreadsheet' && after.kind === 'spreadsheet') {\n const cells = spreadsheetChanges(before, after)\n return cells.size ? { kind: 'spreadsheet', cells } : undefined\n }\n return undefined\n}\n\n/**\n * Brings the first marked change into the middle of the viewer's own scroll\n * box, when it is not in sight already. Not `scrollIntoView`: it would scroll\n * the page around the viewer too. False while there is none drawn yet.\n */\nexport const revealFirstChange = (\n scroller: HTMLElement | null | undefined,\n selector: string,\n): boolean => {\n const el = scroller?.querySelector(selector)\n if (!scroller || !el) {\n return false\n }\n const box = scroller.getBoundingClientRect()\n const at = el.getBoundingClientRect()\n if (at.top < box.top || at.bottom > box.bottom) {\n scroller.scrollTop += at.top - box.top - (box.height - at.height) / 2\n }\n if (at.left < box.left || at.right > box.right) {\n scroller.scrollLeft += at.left - box.left - (box.width - at.width) / 2\n }\n return true\n}\n","import type { SelectionActionIcon } from 'models'\n\n/**\n * The Remix icon of each name an action of the agent can wear on the\n * selection menu (`SELECTION_ACTION_ICONS` in `models`): the menu draws it,\n * the backoffice offers it in the grid of the action.\n */\nexport const SELECTION_ACTION_ICON_NAMES: Record<SelectionActionIcon, string> =\n {\n sparkles: 'ri:sparkling-line',\n magic: 'ri:magic-line',\n idea: 'ri:lightbulb-line',\n star: 'ri:star-line',\n heart: 'ri:heart-line',\n lightning: 'ri:flashlight-line',\n fire: 'ri:fire-line',\n rocket: 'ri:rocket-line',\n pen: 'ri:quill-pen-line',\n pencil: 'ri:pencil-line',\n text: 'ri:text',\n paragraph: 'ri:paragraph',\n quote: 'ri:double-quotes-l',\n list: 'ri:list-unordered',\n checklist: 'ri:list-check-2',\n highlighter: 'ri:mark-pen-line',\n document: 'ri:file-text-line',\n folder: 'ri:folder-line',\n book: 'ri:book-open-line',\n bookmark: 'ri:bookmark-line',\n clipboard: 'ri:clipboard-line',\n draft: 'ri:draft-line',\n contract: 'ri:file-paper-2-line',\n attachment: 'ri:attachment-2',\n archive: 'ri:archive-line',\n search: 'ri:search-line',\n filter: 'ri:filter-3-line',\n eye: 'ri:eye-line',\n questions: 'ri:question-answer-line',\n 'pie-chart': 'ri:pie-chart-line',\n 'line-chart': 'ri:line-chart-line',\n table: 'ri:table-line',\n database: 'ri:database-2-line',\n calculator: 'ri:calculator-line',\n percent: 'ri:percent-line',\n scales: 'ri:scales-3-line',\n euro: 'ri:money-euro-circle-line',\n dollar: 'ri:money-dollar-circle-line',\n wallet: 'ri:wallet-3-line',\n bank: 'ri:bank-line',\n card: 'ri:bank-card-line',\n cart: 'ri:shopping-cart-2-line',\n 'price-tag': 'ri:price-tag-3-line',\n bill: 'ri:bill-line',\n gift: 'ri:gift-line',\n shop: 'ri:store-2-line',\n truck: 'ri:truck-line',\n shield: 'ri:shield-check-line',\n lock: 'ri:lock-line',\n key: 'ri:key-2-line',\n gavel: 'ri:auction-line',\n institution: 'ri:government-line',\n passport: 'ri:passport-line',\n person: 'ri:user-line',\n team: 'ri:team-line',\n group: 'ri:group-line',\n smile: 'ri:emotion-happy-line',\n handshake: 'ri:shake-hands-line',\n support: 'ri:customer-service-2-line',\n contacts: 'ri:contacts-book-line',\n mail: 'ri:mail-line',\n send: 'ri:send-plane-line',\n speech: 'ri:chat-3-line',\n phone: 'ri:phone-line',\n megaphone: 'ri:megaphone-line',\n bell: 'ri:notification-3-line',\n share: 'ri:share-line',\n link: 'ri:link',\n globe: 'ri:global-line',\n calendar: 'ri:calendar-line',\n event: 'ri:calendar-event-line',\n clock: 'ri:time-line',\n timer: 'ri:timer-line',\n history: 'ri:history-line',\n hourglass: 'ri:hourglass-line',\n plane: 'ri:plane-line',\n car: 'ri:car-line',\n train: 'ri:train-line',\n ship: 'ri:ship-line',\n map: 'ri:map-2-line',\n pin: 'ri:map-pin-line',\n compass: 'ri:compass-3-line',\n bed: 'ri:hotel-bed-line',\n suitcase: 'ri:suitcase-line',\n home: 'ri:home-4-line',\n building: 'ri:building-line',\n flag: 'ri:flag-line',\n earth: 'ri:earth-line',\n sun: 'ri:sun-line',\n umbrella: 'ri:umbrella-line',\n heartbeat: 'ri:heart-pulse-line',\n capsule: 'ri:capsule-line',\n 'first-aid': 'ri:first-aid-kit-line',\n restaurant: 'ri:restaurant-line',\n cup: 'ri:cup-line',\n leaf: 'ri:leaf-line',\n plant: 'ri:plant-line',\n recycle: 'ri:recycle-line',\n school: 'ri:school-line',\n graduation: 'ri:graduation-cap-line',\n brain: 'ri:brain-line',\n puzzle: 'ri:puzzle-line',\n award: 'ri:award-line',\n trophy: 'ri:trophy-line',\n settings: 'ri:settings-3-line',\n tools: 'ri:tools-line',\n code: 'ri:code-s-slash-line',\n bug: 'ri:bug-line',\n robot: 'ri:robot-2-line',\n cloud: 'ri:cloud-line',\n flask: 'ri:flask-line',\n microscope: 'ri:microscope-line',\n check: 'ri:checkbox-circle-line',\n cross: 'ri:close-circle-line',\n warning: 'ri:alert-line',\n information: 'ri:information-line',\n refresh: 'ri:refresh-line',\n swap: 'ri:arrow-left-right-line',\n arrow: 'ri:arrow-right-circle-line',\n 'thumbs-up': 'ri:thumb-up-line',\n target: 'ri:focus-3-line',\n palette: 'ri:palette-line',\n image: 'ri:image-line',\n music: 'ri:music-2-line',\n video: 'ri:video-line',\n microphone: 'ri:mic-line',\n }\n\n/** The icon of an action of the agent: the one its author chose, else the sparkle. */\nexport const agentActionIcon = (icon?: SelectionActionIcon) =>\n SELECTION_ACTION_ICON_NAMES[icon ?? 'sparkles']\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 type { SelectionActionIcon } from 'models'\n import { agentActionIcon } from './selectionActionIcons'\n import { selectionBarPosition } from './utils'\n\n /**\n * The menu 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: a row per action with its icon, the agent's after the built-in\n * ones, then \"Ask…\" below a rule, which turns the menu into a field. An\n * 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 rows take no focus on a click,\n * so the selection stays and Cmd+C still copies it; the keyboard reaches\n * them with Tab.\n */\n\n /**\n * The built-in actions by their icon, from the Remix set the app's menus\n * use; an action of the agent has the one its author chose\n * (`agentActionIcon`), the sparkle without one.\n */\n const BUILT_IN_ICONS: Record<string, string> = {\n explain: 'ri:question-line',\n summarize: 'ri:file-list-3-line',\n rewrite: 'ri:edit-line',\n shorten: 'ri:scissors-cut-line',\n proofread: 'ri:check-double-line',\n translate: 'ri:translate-2',\n chart: 'ri:bar-chart-2-line',\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 /** An action of the agent: the icon its author chose. */\n icon?: SelectionActionIcon\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 const openAsk = () =>\n openField(undefined, $t('selectionActions.askPlaceholder'))\n\n const iconOf = (action: SelectionBarAction) =>\n BUILT_IN_ICONS[action.id] ?? agentActionIcon(action.icon)\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 /**\n * A finger lifted on the row it touched. The menu turns the touch's\n * default off as it starts: on a phone a tap outside the text clears\n * the selection before the click, and the menu went with it. With the\n * default off no click follows, so the row acts here.\n */\n const onTap = (event: TouchEvent, act: () => void) => {\n const row = event.currentTarget as HTMLElement\n const touch = event.changedTouches[0]\n const root = row.getRootNode() as Document | ShadowRoot\n const under =\n touch && root.elementFromPoint(touch.clientX, touch.clientY)\n if (under && row.contains(under)) {\n act()\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 /**\n * Esc closes the field, or the menu, and nothing else: its default would\n * also close the dialog the file viewer is in. Not while an input method\n * composes: there Esc cancels the composition.\n */\n const onEscape = (event: KeyboardEvent) => {\n if (event.isComposing) {\n return\n }\n event.stopPropagation()\n event.preventDefault()\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=\"onEscape\">\n <form\n v-if=\"field\"\n ref=\"barEl\"\n class=\"pk-selection-actions__menu pk-selection-actions__menu--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__menu\"\n role=\"toolbar\"\n aria-orientation=\"vertical\"\n :aria-label=\"$t('selectionActions.label')\"\n @touchstart.prevent>\n <template v-if=\"note\">\n <p class=\"pk-selection-actions__text\">{{ note }}</p>\n <button\n v-if=\"noteAction\"\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"emit('note')\"\n @touchend=\"onTap($event, () => emit('note'))\">\n <VvIcon\n name=\"ri:arrow-right-line\"\n class=\"pk-selection-actions__icon\" />\n {{ noteAction }}\n </button>\n </template>\n <template v-else>\n <p v-if=\"hint\" class=\"pk-selection-actions__text\">\n {{ hint }}\n </p>\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 @touchend=\"onTap($event, () => run(action))\">\n <VvIcon\n :name=\"iconOf(action)\"\n class=\"pk-selection-actions__icon\" />\n {{ action.label }}\n </button>\n <hr class=\"pk-selection-actions__rule\" />\n <button\n type=\"button\"\n class=\"pk-selection-actions__button\"\n @mousedown.prevent\n @click=\"openAsk\"\n @touchend=\"onTap($event, openAsk)\">\n <VvIcon\n name=\"ri:chat-1-line\"\n class=\"pk-selection-actions__icon\" />\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(20rem, 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 max-width: none;\n }\n\n // As the app's menus (the ⋮ of a conversation): the surface, its\n // hairline and its shadow, readable over a document and over a page\n &__menu {\n display: flex;\n flex-direction: column;\n min-width: 11rem;\n width: max-content;\n max-width: 100%;\n padding: var(--spacing-4);\n border: var(--spacing-1) solid var(--color-surface-5);\n border-radius: var(--rounded-lg);\n background-color: var(--color-surface);\n color: var(--color-word-2);\n font-family: var(--font-sans);\n font-size: var(--text-12);\n box-shadow: var(--shadow-lg);\n\n &--field {\n flex-direction: row;\n align-items: center;\n gap: var(--spacing-4);\n width: 100%;\n }\n }\n\n &__text {\n max-width: 16rem;\n margin: 0;\n padding: var(--spacing-4) var(--spacing-8) var(--spacing-6);\n color: var(--color-word-3);\n font-size: var(--text-12);\n }\n\n &__button {\n display: flex;\n flex-shrink: 0;\n align-items: center;\n gap: var(--spacing-8);\n border: 0;\n border-radius: var(--rounded);\n padding: var(--spacing-6) var(--spacing-12) var(--spacing-6)\n var(--spacing-8);\n background-color: transparent;\n color: inherit;\n font: inherit;\n text-align: start;\n white-space: nowrap;\n cursor: pointer;\n\n // A finger gets 40px (DESIGN.md, principle 15): the row grows,\n // the text keeps its size\n @media (pointer: coarse) {\n min-height: var(--spacing-40);\n }\n\n &:hover {\n background-color: var(--color-surface-1);\n color: var(--color-word-1);\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--color-brand);\n outline-offset: calc(-1 * var(--spacing-2));\n }\n\n &--send {\n padding: var(--spacing-6) var(--spacing-10);\n background-color: var(--color-word-1);\n color: var(--color-surface);\n font-weight: var(--font-medium);\n\n &:hover {\n background-color: var(--color-word-1);\n color: var(--color-surface);\n }\n\n &:disabled {\n opacity: 0.5;\n cursor: default;\n }\n }\n }\n\n &__icon {\n flex-shrink: 0;\n width: var(--spacing-16);\n height: var(--spacing-16);\n color: var(--color-word-3);\n }\n\n &__rule {\n margin: var(--spacing-4) 0;\n border: 0;\n border-top: var(--spacing-1) solid var(--color-surface-3);\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: var(--color-surface-1);\n color: var(--color-word-1);\n font: inherit;\n\n @media (pointer: coarse) {\n min-height: var(--spacing-40);\n\n // Below 16px Safari on iOS zooms the page on the focus\n font-size: var(--text-16);\n }\n\n &::placeholder {\n color: var(--color-word-3);\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--color-brand);\n outline-offset: calc(-1 * var(--spacing-2));\n }\n }\n }\n</style>\n"],"mappings":";;;;;;;;AA8BA,IAAMkD,IAAe,sCAEfC,IAAe,uCAKfC,IAAc;AAGpB,SAAgBC,IAAyB;CACrC,OAAO,OAAO,cAAe,cAAc,WAAWF,CAAY,CAAC,CAAC;AACxE;AAiBA,SAASG,EAAQ,GAAgD;CAC7D,IAAMC,IAAY,SAAS,aAAa;CACxC,IAAI,CAACA,KAAaA,EAAU,eAAe,GACvC;CAEJ,IAAIC,EAAK,aAAa,KAAK,eACvB,OAAOD,EAAU,WAAW,CAAC,CAAC,CAAC,WAAW;CAE9C,IAAME,IAASD;CACf,IAAID,EAAU,mBAAmB;EAC7B,IAAIG;EACJ,IAAI;GACA,IAASH,EAAU,kBAAkB,EAAE,aAAa,CAACE,CAAM,EAAE,CAAC;EAClE,QAAQ;GACJ,IAASF,EAAU,kBAAkBE,CAAM;EAC/C;EACA,IAAM,CAACE,KAASD;EAChB,IAAI,CAACC,GACD;EAEJ,IAAMC,IAAQ,SAAS,YAAY;EAGnC,OAFAA,EA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,AAAA4J,EAAA,OAAA9J,QAAV,CAAA,GAAkB,CAAA,SAAA,CAAA;KACjB,SAAOkJ;KACP,YAAQ,AAAAY,EAAA,QAAA,MAAER,EAAMS,GAAQb,CAAO;I,IAChC3I,EAEyCsJ,GAAA;KADrC,MAAK;KACL,OAAM;I,IAA+BrJ,EAAA,MACzCJ,EAAGC,EAAAmI,CAAA,CAAE,CAAA,sBAAA,CAAA,GAAA,CAAA,C"}
@@ -1,9 +1,9 @@
1
- import { r as e } from "./index.es-B9l77u9z.js";
1
+ import { r as e } from "./index.es-DHeth3Ja.js";
2
2
  import { S as t, Tt as n, V as r, f as i, g as a, gt as o, h as s, k as c, kt as l, ot as u, v as d, w as f, wt as p, x as m, y as h, z as g } from "./vue.runtime.esm-bundler-DZgpK-ja.js";
3
3
  import { r as ee } from "./vue-i18n-CDYWo9pX.js";
4
4
  import { i as te, r as _, t as v } from "./excelNumberFormat-CHDmkcUW.js";
5
5
  import { p as y, y as ne } from "./Agent-nB9V45mr.js";
6
- import { t as re } from "./PkChatbotFilePreview-BpiLld3D.js";
6
+ import { t as re } from "./PkChatbotFilePreview-CWzGSq-b.js";
7
7
  import { u as b } from "./utils-CRy3kzE3.js";
8
8
  import { t as x } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
9
9
  // ../../packages/components/src/chat/PkToolChatFile.vue?vue&type=script&setup=true&lang.ts
@@ -225,4 +225,4 @@ var ie = {
225
225
  }), [["styles", [".pk-tool-chat-file__changes{border:var(--border) solid var(--color-surface-3);border-radius:var(--rounded-lg);background-color:var(--color-surface);max-width:36rem;font-size:var(--text-12);overflow:hidden}.pk-tool-chat-file__summary{padding:var(--spacing-8) var(--spacing-12);border-bottom:var(--border) solid var(--color-surface-3);color:var(--color-word-2);font-size:var(--text-12);font-weight:var(--font-medium);margin:0}.pk-tool-chat-file__summary:last-child{border-bottom:0}.pk-tool-chat-file__scroll{max-height:20rem;overflow-y:auto}.pk-tool-chat-file__table{border-collapse:collapse;width:100%}.pk-tool-chat-file__table th,.pk-tool-chat-file__table td{padding:var(--spacing-8) var(--spacing-12);border-bottom:var(--border) solid var(--color-surface-2);text-align:start;vertical-align:top;overflow-wrap:anywhere}.pk-tool-chat-file__table th{color:var(--color-word-3);font-weight:var(--font-medium)}.pk-tool-chat-file__table tbody:last-child tr:last-child td{border-bottom:0}.pk-tool-chat-file__table .pk-tool-chat-file__sheet{padding-block:var(--spacing-6);background-color:var(--color-surface-1);color:var(--color-word-2)}.pk-tool-chat-file__cell{width:1%;color:var(--color-word-2);font-variant-numeric:tabular-nums;white-space:nowrap}.pk-tool-chat-file__before{width:50%;color:var(--color-word-3)}.pk-tool-chat-file__after{width:50%;color:var(--color-word-1)}.pk-tool-chat-file__paragraphs{margin:0;padding:0;list-style:none}.pk-tool-chat-file__paragraph{gap:var(--spacing-4) var(--spacing-md);padding:var(--spacing-8) var(--spacing-12);border-bottom:var(--border) solid var(--color-surface-2);grid-template-columns:minmax(4rem,max-content) 1fr;display:grid}.pk-tool-chat-file__paragraph:last-child{border-bottom:0}.pk-tool-chat-file__what{color:var(--color-word-3);white-space:nowrap}.pk-tool-chat-file__text{min-width:0;color:var(--color-word-2);overflow-wrap:anywhere}.pk-tool-chat-file__removed{color:var(--u-danger-text);text-decoration:line-through}.pk-tool-chat-file__added{color:var(--u-success-text);font-weight:var(--font-medium);text-underline-offset:.2em;text-decoration:underline}.pk-tool-chat-file__removed+.pk-tool-chat-file__added{margin-inline-start:var(--spacing-4)}.pk-tool-chat-file__note{padding:var(--spacing-8) var(--spacing-12);border-top:var(--border) solid var(--color-surface-2);color:var(--color-word-3);margin:0}.pk-tool-chat-file__more{justify-content:center;align-items:center;gap:var(--spacing-4);width:100%;padding:var(--spacing-8) var(--spacing-12);border:0;border-top:var(--border) solid var(--color-surface-2);color:var(--color-word-2);font:inherit;cursor:pointer;transition:background-color var(--duration-150) var(--ease-out);background:0 0;display:flex}.pk-tool-chat-file__more:hover{background-color:var(--color-surface-1)}.pk-tool-chat-file__more:focus-visible{outline:var(--spacing-2) solid var(--input-focus-color);outline-offset:calc(var(--spacing-2) * -1)}.pk-tool-chat-file__reminder{align-items:flex-start;gap:var(--spacing-8);padding:var(--spacing-8) var(--spacing-12);border-top:var(--border) solid var(--color-surface-2);color:var(--color-word-2);margin:0;display:flex}.pk-tool-chat-file__reminder-icon{margin-top:var(--spacing-2);color:var(--color-word-3);font-size:var(--text-14);flex-shrink:0}"]]]);
226
226
  export { H as default };
227
227
 
228
- //# sourceMappingURL=PkToolChatFile-C3B9q2OL.js.map
228
+ //# sourceMappingURL=PkToolChatFile-fTo6gdqx.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PkToolChatFile-C3B9q2OL.js","names":["_openBlock","_createElementBlock","_createVNode","PkChatbotFilePreview","_createElementVNode","_toDisplayString","_unref","_Fragment","_renderList","_createTextVNode","De","createVNode","init_shared_esm_bundler","renderList","Fragment","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","isSpreadsheetDateFormat","formatExcelNumber","excelDateText","SPREADSHEET_MIME_TYPE","WORD_MIME_TYPE","PkChatbotFilePreview_default","chatFileName","_plugin_vue_export_helper_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","_hoisted_19","_hoisted_20","_hoisted_21","_hoisted_22","SHOWN_CHANGES","PkToolChatFile_default","WORD_TOOL_PARTS","props","__props","$t","showAll","withoutLength","text","contextOf","runs","before","after","excerptOf","a","b","common","i","j","push","last","kind","run","k","wordChangeLabel","op","paragraphRow","change","cellRow","legacy","rows","bang","cell","appended","shownAs","raw","format","locale","file","part","output","word","changed","changes","reminders","summary","shown","shownParagraphs","shownSheets","groups","row","group","hiddenRows","olderVersion","latest","restoreThis","openPreview","_component_VvIcon","g","index","s","segment","_cache","reminder"],"sources":["../../../../packages/components/src/chat/PkToolChatFile.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import {\n isSpreadsheetDateFormat,\n SPREADSHEET_MIME_TYPE,\n WORD_MIME_TYPE,\n } from 'models'\n import PkChatbotFilePreview from './PkChatbotFilePreview.vue'\n import { excelDateText, formatExcelNumber } from './excelNumberFormat'\n import {\n chatFileName,\n type ChatFilePreviewTarget,\n type ChatFileRestoreTarget,\n } from './utils'\n\n /**\n * One entry of `changes`: a cell (or an appended row, or a new sheet) of\n * `editSpreadsheet`, a paragraph or a table row of `editWordDocument`.\n */\n type ChatFileChange = {\n cell?: string\n op?: string\n before?: string\n after?: string\n newSheetRows?: number\n /**\n * The number format code of a side that is a number in the file,\n * from edits made since it was added.\n */\n beforeFormat?: string\n afterFormat?: string\n }\n\n /** What the four file tools return that the card shows. */\n type ChatFileOutput = {\n /** The file every version of it answers to. */\n fileId?: string\n storedFileName: string\n filename?: string\n sizeBytes?: number\n version?: number\n changedCells?: number\n changedParagraphs?: number\n changes?: ChatFileChange[]\n moreChanges?: number\n /** Of a Word edit: the changes are revisions. */\n tracked?: boolean\n stalePivots?: true\n staleTableOfContents?: true\n /** Of a restore: the version this one writes again. */\n restoredFrom?: number\n }\n\n /** A run of an excerpt: text kept, taken away or put in. */\n type Segment = { text: string; kind: 'same' | 'removed' | 'added' }\n\n /**\n * A changed cell as a row of the table: its value before and after, or\n * the line that stands for a new sheet.\n */\n type CellRow = {\n sheet: string\n cell?: string\n before?: string\n after?: string\n newSheet?: string\n }\n\n /** The rows of one sheet, under its name. */\n type SheetGroup = { sheet: string; rows: CellRow[] }\n\n /** A changed paragraph or table row: what happened, and its words. */\n type ParagraphRow = { what: string; segments: Segment[] }\n\n /** The tools whose output is a Word document; the others write a spreadsheet. */\n const WORD_TOOL_PARTS = new Set([\n 'tool-editWordDocument',\n 'tool-createWordDocument',\n ])\n\n /** Rows shown before \"View more\": most edits are one to three changes. */\n const SHOWN_CHANGES = 3\n /** Words of context kept on each side of a change in a paragraph. */\n const CONTEXT_WORDS = 6\n\n /**\n * The file a call of `editSpreadsheet`, `editWordDocument`,\n * `createSpreadsheet` or `createWordDocument` wrote, a new version or a\n * new file, to download. Drawn once the call has an output: while it runs,\n * the feed's activity indicator names it, and a refused call is explained\n * by the answer. Under an edit, a frame says what changed, its first\n * rows shown: a table of cells for a spreadsheet, the changed words of\n * each paragraph for a Word document, and what is left to do in Office.\n */\n const props = defineProps<{\n part: unknown\n /** The authenticated download URL of a file stored in this chat. */\n fileUrl: (storedFileName: string) => string\n /** Opens the preview of the file, where the chat has one. */\n preview?: (file: ChatFilePreviewTarget) => void\n /** The latest version of each file the conversation shows, by fileId. */\n latestVersions?: ReadonlyMap<string, number>\n /**\n * Asks the agent to write an earlier version again as the newest one,\n * where the chat can send a message.\n */\n restore?: (file: ChatFileRestoreTarget) => void\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n\n const showAll = ref(false)\n\n /**\n * The services cut a long text for the model and give its length\n * (`… (523 characters)`, the marker of every tool result, written by\n * `wordDocument.service.ts` and `spreadsheet.service.ts`): the card keeps\n * the ellipsis only.\n */\n const withoutLength = (text: string | undefined) =>\n text?.replace(/… \\(\\d+ characters\\)$/, '…')\n\n /**\n * A run of unchanged words cut to a few words on the side of each change\n * it touches: the head of the text keeps its end, the tail its start, a\n * run between two changes both, with an ellipsis where words went.\n */\n const contextOf = (text: string, before: boolean, after: boolean) => {\n const runs = text.split(/(\\s+)/).filter(Boolean)\n // Every word is followed by its space: twice as many runs.\n const keep = CONTEXT_WORDS * 2\n if (runs.length <= (before && after ? keep * 2 : keep)) {\n return text\n }\n if (before && after) {\n return `${runs.slice(0, keep).join('')}… ${runs.slice(-keep).join('')}`\n }\n return after\n ? `…${runs.slice(-keep).join('')}`\n : `${runs.slice(0, keep).join('')}…`\n }\n\n /**\n * The words of `before` and `after` that differ, word by word, so the\n * words two changes share between them stay plain. An echoed paragraph\n * is at most a few hundred characters, a few dozen words for the table.\n */\n const excerptOf = (before: string, after: string): Segment[] => {\n const a = before.split(/(\\s+)/).filter(Boolean)\n const b = after.split(/(\\s+)/).filter(Boolean)\n // Longest common subsequence, from the end\n const common = Array.from({ length: a.length + 1 }, () =>\n new Array<number>(b.length + 1).fill(0),\n )\n for (let i = a.length - 1; i >= 0; i--) {\n for (let j = b.length - 1; j >= 0; j--) {\n common[i][j] =\n a[i] === b[j]\n ? common[i + 1][j + 1] + 1\n : Math.max(common[i + 1][j], common[i][j + 1])\n }\n }\n const runs: Segment[] = []\n const push = (text: string, kind: Segment['kind']) => {\n const last = runs[runs.length - 1]\n if (last?.kind === kind) {\n last.text += text\n } else {\n runs.push({ text, kind })\n }\n }\n let i = 0\n let j = 0\n while (i < a.length || j < b.length) {\n if (i < a.length && j < b.length && a[i] === b[j]) {\n push(a[i++], 'same')\n j++\n } else if (\n j >= b.length ||\n (i < a.length && common[i + 1][j] >= common[i][j + 1])\n ) {\n push(a[i++], 'removed')\n } else {\n push(b[j++], 'added')\n }\n }\n return runs.map((run, k) =>\n run.kind === 'same'\n ? {\n ...run,\n text: contextOf(run.text, k > 0, k < runs.length - 1),\n }\n : run,\n )\n }\n\n /** What a Word operation did, as the row says it. */\n const wordChangeLabel = (op: string | undefined) => {\n switch (op) {\n case 'insertParagraphs':\n return $t('messagePart.chatFileParagraphAdded')\n case 'deleteParagraphs':\n return $t('messagePart.chatFileParagraphDeleted')\n case 'insertTableRow':\n return $t('messagePart.chatFileTableRowAdded')\n case 'deleteTableRow':\n return $t('messagePart.chatFileTableRowDeleted')\n case 'acceptRevisions':\n return $t('messagePart.chatFileRevisionAccepted')\n case 'rejectRevisions':\n return $t('messagePart.chatFileRevisionRejected')\n default:\n return $t('messagePart.chatFileParagraphChanged')\n }\n }\n\n /**\n * A paragraph marked as Word marks a revision, struck where words went\n * and underlined where they came. A paragraph only added or only removed\n * is said by its label: the text added stays plain, the text removed\n * stays struck.\n */\n const paragraphRow = (change: ChatFileChange): ParagraphRow => {\n const before = withoutLength(change.before)\n const after = withoutLength(change.after)\n return {\n what: wordChangeLabel(change.op),\n segments:\n before && after\n ? excerptOf(before, after)\n : [\n before\n ? { text: before, kind: 'removed' }\n : { text: after ?? '', kind: 'same' },\n ],\n }\n }\n\n /**\n * A cell as a person reads it: its sheet heads the group of its rows, so\n * the row says `C5` and not Excel's `Listino!C5`, and a row the edit\n * appended says \"Row 10\" and not `A10:F10`.\n */\n const cellRow = (change: ChatFileChange): CellRow => {\n const ref = change.cell ?? ''\n // A new sheet is named alone, with no cell. An edit made before the\n // card read `newSheetRows` said it only in the model's words.\n const legacy = change.before\n ? undefined\n : /^new sheet, (\\d+) row\\(s\\)$/.exec(change.after ?? '')?.[1]\n const rows =\n change.newSheetRows ?? (legacy ? Number(legacy) : undefined)\n if (rows !== undefined) {\n return {\n sheet: ref,\n newSheet: $t('messagePart.chatFileNewSheet', rows),\n }\n }\n\n const bang = ref.lastIndexOf('!')\n const cell = ref.slice(bang + 1)\n const appended = /^A(\\d+):[A-Z]+(\\d+)$/.exec(cell)\n return {\n sheet: ref.slice(0, Math.max(bang, 0)),\n cell:\n appended && appended[1] === appended[2]\n ? $t('messagePart.chatFileRow', { row: appended[1] })\n : cell,\n before: shownAs(withoutLength(change.before), change.beforeFormat),\n after: shownAs(withoutLength(change.after), change.afterFormat),\n }\n }\n\n /**\n * A value as its cell shows it, `0.05` as `5%` and a date serial as the\n * date; a formula, a text and a cell with no format stay as written.\n */\n const shownAs = (\n raw: string | undefined,\n format: string | undefined,\n ): string | undefined => {\n if (!raw || !format || raw.startsWith('=')) {\n return raw || undefined\n }\n try {\n if (isSpreadsheetDateFormat(format)) {\n return excelDateText(raw, format, locale.value) ?? raw\n }\n return /^-?\\d+(\\.\\d+)?(e[+-]?\\d+)?$/i.test(raw)\n ? formatExcelNumber(format, Number(raw), locale.value).text\n : raw\n } catch {\n // A code the interpreter cannot read: the value as written\n return raw\n }\n }\n\n const file = computed(() => {\n const part = props.part as {\n type?: string\n state?: string\n output?: Partial<ChatFileOutput>\n }\n if (part.state !== 'output-available' || !part.output?.storedFileName) {\n return undefined\n }\n const output = part.output as ChatFileOutput\n const word = WORD_TOOL_PARTS.has(part.type ?? '')\n // A new file has no count of changes. Each key is written out in its\n // own call: the widget ships only the keys it finds that way.\n let changed: string | undefined\n if (word && output.changedParagraphs !== undefined) {\n changed = output.tracked\n ? $t(\n 'messagePart.editWordDocumentRevisions',\n output.changedParagraphs,\n )\n : $t(\n 'messagePart.editWordDocumentParagraphs',\n output.changedParagraphs,\n )\n } else if (!word && output.changedCells !== undefined) {\n changed = $t(\n 'messagePart.editSpreadsheetCells',\n output.changedCells,\n )\n }\n const changes = changed ? (output.changes ?? []) : []\n const reminders: string[] = []\n if (output.stalePivots) {\n reminders.push($t('messagePart.chatFileRefreshPivots'))\n }\n if (output.staleTableOfContents) {\n reminders.push($t('messagePart.chatFileUpdateTableOfContents'))\n }\n let summary =\n changed && output.version\n ? $t('messagePart.chatFileVersionSummary', {\n version: output.version,\n changed,\n })\n : changed\n if (output.restoredFrom) {\n summary = $t('messagePart.chatFileRestored', {\n version: output.version,\n restored: output.restoredFrom,\n })\n }\n return {\n output,\n mediaType: word ? WORD_MIME_TYPE : SPREADSHEET_MIME_TYPE,\n summary,\n cells: word ? [] : changes.map(cellRow),\n paragraphs: word ? changes.map(paragraphRow) : [],\n count: changes.length,\n more: output.moreChanges ?? 0,\n reminders,\n }\n })\n\n const shown = <T,>(rows: T[] | undefined): T[] =>\n showAll.value ? (rows ?? []) : (rows ?? []).slice(0, SHOWN_CHANGES)\n const shownParagraphs = computed(() => shown(file.value?.paragraphs))\n /** The rows shown, a group per sheet in the order the edit reached it. */\n const shownSheets = computed(() => {\n const groups = new Map<string, SheetGroup>()\n for (const row of shown(file.value?.cells)) {\n const group = groups.get(row.sheet)\n if (group) {\n group.rows.push(row)\n } else {\n groups.set(row.sheet, { sheet: row.sheet, rows: [row] })\n }\n }\n return [...groups.values()]\n })\n const hiddenRows = computed(() => (file.value?.count ?? 0) - SHOWN_CHANGES)\n\n /**\n * The version this card wrote, when a later one of the same file is in\n * the conversation: the one the user can ask to have back.\n */\n const olderVersion = computed(() => {\n const output = file.value?.output\n const latest = output?.fileId\n ? props.latestVersions?.get(output.fileId)\n : undefined\n return output?.fileId &&\n output.version &&\n latest &&\n output.version < latest\n ? {\n fileId: output.fileId,\n version: output.version,\n filename: chatFileName(\n output.filename ?? output.storedFileName,\n output.version,\n ),\n }\n : undefined\n })\n\n /** Asks the agent for this version back. */\n const restoreThis = () => {\n if (olderVersion.value) {\n props.restore?.(olderVersion.value)\n }\n }\n\n /** Opens this version in the chat's viewer. */\n const openPreview = () => {\n const output = file.value?.output\n if (!output || !props.preview) {\n return\n }\n props.preview({\n kind:\n file.value?.mediaType === WORD_MIME_TYPE\n ? 'word'\n : 'spreadsheet',\n storedFileName: output.storedFileName,\n filename: chatFileName(\n output.filename ?? output.storedFileName,\n output.version,\n ),\n version: output.version,\n fileId: output.fileId,\n })\n }\n</script>\n\n<template>\n <div v-if=\"file\" class=\"pk-tool-chat-file\">\n <!-- Restore and open live in the file, beside its download: a\n bordered button under it weighed more than the file and the\n answer it belongs to -->\n <PkChatbotFilePreview\n :media-type=\"file.mediaType\"\n :url=\"fileUrl(file.output.storedFileName)\"\n :filename=\"file.output.filename\"\n :size=\"file.output.sizeBytes\"\n show-download\n :on-preview=\"preview ? openPreview : undefined\"\n :on-restore=\"restore && olderVersion ? restoreThis : undefined\" />\n <section\n v-if=\"file.count || file.output.restoredFrom\"\n class=\"pk-tool-chat-file__changes mt-xs\">\n <h4 class=\"pk-tool-chat-file__summary\">\n {{ file.summary }}\n </h4>\n <div v-if=\"file.count\" class=\"pk-tool-chat-file__scroll\">\n <table\n v-if=\"file.cells.length\"\n class=\"pk-tool-chat-file__table\">\n <thead>\n <tr>\n <th scope=\"col\" class=\"pk-tool-chat-file__cell\">\n {{ $t('messagePart.chatFileCell') }}\n </th>\n <th scope=\"col\">\n {{ $t('messagePart.chatFileBefore') }}\n </th>\n <th scope=\"col\">\n {{ $t('messagePart.chatFileAfter') }}\n </th>\n </tr>\n </thead>\n <tbody v-for=\"(group, g) in shownSheets\" :key=\"g\">\n <tr>\n <th\n colspan=\"3\"\n scope=\"rowgroup\"\n class=\"pk-tool-chat-file__sheet\">\n {{\n $t('messagePart.chatFileSheet', {\n name: group.sheet,\n })\n }}\n </th>\n </tr>\n <tr v-for=\"(row, index) in group.rows\" :key=\"index\">\n <td\n v-if=\"row.newSheet\"\n colspan=\"3\"\n class=\"pk-tool-chat-file__after\">\n {{ row.newSheet }}\n </td>\n <template v-else>\n <td class=\"pk-tool-chat-file__cell\">\n {{ row.cell }}\n </td>\n <td class=\"pk-tool-chat-file__before\">\n {{ row.before }}\n </td>\n <td class=\"pk-tool-chat-file__after\">\n {{ row.after }}\n </td>\n </template>\n </tr>\n </tbody>\n </table>\n <ul v-else class=\"pk-tool-chat-file__paragraphs\">\n <li\n v-for=\"(row, index) in shownParagraphs\"\n :key=\"index\"\n class=\"pk-tool-chat-file__paragraph\">\n <span class=\"pk-tool-chat-file__what\">\n {{ row.what }}\n </span>\n <span class=\"pk-tool-chat-file__text\">\n <template\n v-for=\"(segment, s) in row.segments\"\n :key=\"s\">\n <del\n v-if=\"segment.kind === 'removed'\"\n class=\"pk-tool-chat-file__removed\">\n {{ segment.text }}\n </del>\n <ins\n v-else-if=\"segment.kind === 'added'\"\n class=\"pk-tool-chat-file__added\">\n {{ segment.text }}\n </ins>\n <span v-else>{{ segment.text }}</span>\n </template>\n </span>\n </li>\n </ul>\n <p v-if=\"showAll && file.more\" class=\"pk-tool-chat-file__note\">\n {{ $t('messagePart.chatFileMoreChanges', file.more) }}\n </p>\n </div>\n <button\n v-if=\"hiddenRows > 0\"\n type=\"button\"\n class=\"pk-tool-chat-file__more\"\n :aria-expanded=\"showAll\"\n @click=\"showAll = !showAll\">\n <VvIcon\n :name=\"\n showAll ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\n \"\n class=\"text-16\"\n aria-hidden=\"true\" />\n {{\n showAll\n ? $t('action.showLess')\n : $t('action.showMore', { count: hiddenRows })\n }}\n </button>\n <p\n v-for=\"reminder in file.reminders\"\n :key=\"reminder\"\n class=\"pk-tool-chat-file__reminder\">\n <VvIcon\n name=\"ri:information-line\"\n class=\"pk-tool-chat-file__reminder-icon\"\n aria-hidden=\"true\" />\n {{ reminder }}\n </p>\n </section>\n <p v-else-if=\"file.summary\" class=\"text-12 text-word-3 mt-xs mb-0\">\n {{ file.summary }}\n </p>\n </div>\n</template>\n\n<style lang=\"scss\">\n // One frame (DESIGN.md, principle 4): a hairline at surface-3, rounded-lg,\n // a solid ground over the dots of the chat, as wide as a short paragraph\n // while the file above keeps its 280px. Inside it every divider is one\n // hairline at surface-2.\n .pk-tool-chat-file__changes {\n max-width: 36rem;\n overflow: hidden;\n border: var(--border) solid var(--color-surface-3);\n border-radius: var(--rounded-lg);\n background-color: var(--color-surface);\n font-size: var(--text-12);\n }\n\n .pk-tool-chat-file__summary {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-3);\n color: var(--color-word-2);\n font-size: var(--text-12);\n font-weight: var(--font-medium);\n\n // A restore says only what it wrote back\n &:last-child {\n border-bottom: 0;\n }\n }\n\n // Bounded, so fifty changes scroll inside the frame\n .pk-tool-chat-file__scroll {\n max-height: 20rem;\n overflow-y: auto;\n }\n\n .pk-tool-chat-file__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-2);\n text-align: start;\n vertical-align: top;\n overflow-wrap: anywhere;\n }\n\n // Told apart by its weight and colour, no heavier rule\n th {\n color: var(--color-word-3);\n font-weight: var(--font-medium);\n }\n\n tbody:last-child tr:last-child td {\n border-bottom: 0;\n }\n }\n\n // The name of a sheet heads its rows, one step of surface under it\n .pk-tool-chat-file__table .pk-tool-chat-file__sheet {\n padding-block: var(--spacing-6);\n background-color: var(--color-surface-1);\n color: var(--color-word-2);\n }\n\n .pk-tool-chat-file__cell {\n width: 1%;\n color: var(--color-word-2);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n }\n\n .pk-tool-chat-file__before {\n width: 50%;\n color: var(--color-word-3);\n }\n\n .pk-tool-chat-file__after {\n width: 50%;\n color: var(--color-word-1);\n }\n\n .pk-tool-chat-file__paragraphs {\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n .pk-tool-chat-file__paragraph {\n display: grid;\n grid-template-columns: minmax(4rem, max-content) 1fr;\n gap: var(--spacing-4) var(--spacing-md);\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-2);\n\n &:last-child {\n border-bottom: 0;\n }\n }\n\n .pk-tool-chat-file__what {\n color: var(--color-word-3);\n white-space: nowrap;\n }\n\n .pk-tool-chat-file__text {\n min-width: 0;\n color: var(--color-word-2);\n overflow-wrap: anywhere;\n }\n\n // Marked as Word marks a revision, struck where words went and\n // underlined where they came, in the red and green of a comparison: the\n // change is what the row exists to report, the verdict exception of\n // DESIGN.md (principle 2). The readable text tokens hold the contrast in\n // both themes. The base styles take the line off `del`.\n .pk-tool-chat-file__removed {\n color: var(--u-danger-text);\n text-decoration: line-through;\n }\n\n .pk-tool-chat-file__added {\n color: var(--u-success-text);\n font-weight: var(--font-medium);\n text-decoration: underline;\n text-underline-offset: 0.2em;\n }\n\n .pk-tool-chat-file__removed + .pk-tool-chat-file__added {\n margin-inline-start: var(--spacing-4);\n }\n\n .pk-tool-chat-file__note {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-top: var(--border) solid var(--color-surface-2);\n color: var(--color-word-3);\n }\n\n .pk-tool-chat-file__more {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: var(--spacing-4);\n width: 100%;\n padding: var(--spacing-8) var(--spacing-12);\n border: 0;\n border-top: var(--border) solid var(--color-surface-2);\n background: none;\n color: var(--color-word-2);\n font: inherit;\n cursor: pointer;\n transition: background-color var(--duration-150) var(--ease-out);\n\n &:hover {\n background-color: var(--color-surface-1);\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--input-focus-color);\n outline-offset: calc(var(--spacing-2) * -1);\n }\n }\n\n .pk-tool-chat-file__reminder {\n display: flex;\n align-items: flex-start;\n gap: var(--spacing-8);\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-top: var(--border) solid var(--color-surface-2);\n color: var(--color-word-2);\n }\n\n .pk-tool-chat-file__reminder-icon {\n flex-shrink: 0;\n margin-top: var(--spacing-2);\n color: var(--color-word-3);\n font-size: var(--text-14);\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A,GAkFU0D,IAAgB,G;;;;;;;;;;EANtB,IAAME,oBAAkB,IAAI,IAAI,CAC5B,yBACA,yBACJ,CAAC,GAgBKC,IAAQC,GAeR,EAAE,GAAGC,GAAI,cAAWpC,GAAQ,EAAE,UAAU,SAAS,CAAC,GAElDqC,IAAUhD,EAAI,EAAK,GAQnBiD,KAAiB,MACnBC,GAAM,QAAQ,yBAAyB,GAAG,GAOxCC,KAAa,GAAc,GAAiB,MAAmB;GACjE,IAAMC,IAAOF,EAAK,MAAM,OAAO,CAAC,CAAC,OAAO,OAAO;GAS/C,OANIE,EAAK,WAAWC,KAAUC,IAAQ,KAAW,MACtCJ,IAEPG,KAAUC,IACH,GAAGF,EAAK,MAAM,GAAG,EAAI,CAAC,CAAC,KAAK,EAAE,EAAE,IAAIA,EAAK,MAAM,GAAK,CAAC,CAAC,KAAK,EAAE,MAEjEE,IACD,IAAIF,EAAK,MAAM,GAAK,CAAC,CAAC,KAAK,EAAE,MAC7B,GAAGA,EAAK,MAAM,GAAG,EAAI,CAAC,CAAC,KAAK,EAAE,EAAE;EAC1C,GAOMG,KAAa,GA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openBlock","_createElementBlock","_createVNode","PkChatbotFilePreview","_createElementVNode","_toDisplayString","_unref","_Fragment","_renderList","_createTextVNode","Te","createVNode","init_shared_esm_bundler","renderList","Fragment","createBaseVNode","ref","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","isSpreadsheetDateFormat","formatExcelNumber","excelDateText","SPREADSHEET_MIME_TYPE","WORD_MIME_TYPE","PkChatbotFilePreview_default","chatFileName","_plugin_vue_export_helper_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","_hoisted_19","_hoisted_20","_hoisted_21","_hoisted_22","SHOWN_CHANGES","PkToolChatFile_default","WORD_TOOL_PARTS","props","__props","$t","showAll","withoutLength","text","contextOf","runs","before","after","excerptOf","a","b","common","i","j","push","last","kind","run","k","wordChangeLabel","op","paragraphRow","change","cellRow","legacy","rows","bang","cell","appended","shownAs","raw","format","locale","file","part","output","word","changed","changes","reminders","summary","shown","shownParagraphs","shownSheets","groups","row","group","hiddenRows","olderVersion","latest","restoreThis","openPreview","_component_VvIcon","g","index","s","segment","_cache","reminder"],"sources":["../../../../packages/components/src/chat/PkToolChatFile.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, ref } from 'vue'\n import { useI18n } from 'vue-i18n'\n import {\n isSpreadsheetDateFormat,\n SPREADSHEET_MIME_TYPE,\n WORD_MIME_TYPE,\n } from 'models'\n import PkChatbotFilePreview from './PkChatbotFilePreview.vue'\n import { excelDateText, formatExcelNumber } from './excelNumberFormat'\n import {\n chatFileName,\n type ChatFilePreviewTarget,\n type ChatFileRestoreTarget,\n } from './utils'\n\n /**\n * One entry of `changes`: a cell (or an appended row, or a new sheet) of\n * `editSpreadsheet`, a paragraph or a table row of `editWordDocument`.\n */\n type ChatFileChange = {\n cell?: string\n op?: string\n before?: string\n after?: string\n newSheetRows?: number\n /**\n * The number format code of a side that is a number in the file,\n * from edits made since it was added.\n */\n beforeFormat?: string\n afterFormat?: string\n }\n\n /** What the four file tools return that the card shows. */\n type ChatFileOutput = {\n /** The file every version of it answers to. */\n fileId?: string\n storedFileName: string\n filename?: string\n sizeBytes?: number\n version?: number\n changedCells?: number\n changedParagraphs?: number\n changes?: ChatFileChange[]\n moreChanges?: number\n /** Of a Word edit: the changes are revisions. */\n tracked?: boolean\n stalePivots?: true\n staleTableOfContents?: true\n /** Of a restore: the version this one writes again. */\n restoredFrom?: number\n }\n\n /** A run of an excerpt: text kept, taken away or put in. */\n type Segment = { text: string; kind: 'same' | 'removed' | 'added' }\n\n /**\n * A changed cell as a row of the table: its value before and after, or\n * the line that stands for a new sheet.\n */\n type CellRow = {\n sheet: string\n cell?: string\n before?: string\n after?: string\n newSheet?: string\n }\n\n /** The rows of one sheet, under its name. */\n type SheetGroup = { sheet: string; rows: CellRow[] }\n\n /** A changed paragraph or table row: what happened, and its words. */\n type ParagraphRow = { what: string; segments: Segment[] }\n\n /** The tools whose output is a Word document; the others write a spreadsheet. */\n const WORD_TOOL_PARTS = new Set([\n 'tool-editWordDocument',\n 'tool-createWordDocument',\n ])\n\n /** Rows shown before \"View more\": most edits are one to three changes. */\n const SHOWN_CHANGES = 3\n /** Words of context kept on each side of a change in a paragraph. */\n const CONTEXT_WORDS = 6\n\n /**\n * The file a call of `editSpreadsheet`, `editWordDocument`,\n * `createSpreadsheet` or `createWordDocument` wrote, a new version or a\n * new file, to download. Drawn once the call has an output: while it runs,\n * the feed's activity indicator names it, and a refused call is explained\n * by the answer. Under an edit, a frame says what changed, its first\n * rows shown: a table of cells for a spreadsheet, the changed words of\n * each paragraph for a Word document, and what is left to do in Office.\n */\n const props = defineProps<{\n part: unknown\n /** The authenticated download URL of a file stored in this chat. */\n fileUrl: (storedFileName: string) => string\n /** Opens the preview of the file, where the chat has one. */\n preview?: (file: ChatFilePreviewTarget) => void\n /** The latest version of each file the conversation shows, by fileId. */\n latestVersions?: ReadonlyMap<string, number>\n /**\n * Asks the agent to write an earlier version again as the newest one,\n * where the chat can send a message.\n */\n restore?: (file: ChatFileRestoreTarget) => void\n }>()\n\n const { t: $t, locale } = useI18n({ useScope: 'global' })\n\n const showAll = ref(false)\n\n /**\n * The services cut a long text for the model and give its length\n * (`… (523 characters)`, the marker of every tool result, written by\n * `wordDocument.service.ts` and `spreadsheet.service.ts`): the card keeps\n * the ellipsis only.\n */\n const withoutLength = (text: string | undefined) =>\n text?.replace(/… \\(\\d+ characters\\)$/, '…')\n\n /**\n * A run of unchanged words cut to a few words on the side of each change\n * it touches: the head of the text keeps its end, the tail its start, a\n * run between two changes both, with an ellipsis where words went.\n */\n const contextOf = (text: string, before: boolean, after: boolean) => {\n const runs = text.split(/(\\s+)/).filter(Boolean)\n // Every word is followed by its space: twice as many runs.\n const keep = CONTEXT_WORDS * 2\n if (runs.length <= (before && after ? keep * 2 : keep)) {\n return text\n }\n if (before && after) {\n return `${runs.slice(0, keep).join('')}… ${runs.slice(-keep).join('')}`\n }\n return after\n ? `…${runs.slice(-keep).join('')}`\n : `${runs.slice(0, keep).join('')}…`\n }\n\n /**\n * The words of `before` and `after` that differ, word by word, so the\n * words two changes share between them stay plain. An echoed paragraph\n * is at most a few hundred characters, a few dozen words for the table.\n */\n const excerptOf = (before: string, after: string): Segment[] => {\n const a = before.split(/(\\s+)/).filter(Boolean)\n const b = after.split(/(\\s+)/).filter(Boolean)\n // Longest common subsequence, from the end\n const common = Array.from({ length: a.length + 1 }, () =>\n new Array<number>(b.length + 1).fill(0),\n )\n for (let i = a.length - 1; i >= 0; i--) {\n for (let j = b.length - 1; j >= 0; j--) {\n common[i][j] =\n a[i] === b[j]\n ? common[i + 1][j + 1] + 1\n : Math.max(common[i + 1][j], common[i][j + 1])\n }\n }\n const runs: Segment[] = []\n const push = (text: string, kind: Segment['kind']) => {\n const last = runs[runs.length - 1]\n if (last?.kind === kind) {\n last.text += text\n } else {\n runs.push({ text, kind })\n }\n }\n let i = 0\n let j = 0\n while (i < a.length || j < b.length) {\n if (i < a.length && j < b.length && a[i] === b[j]) {\n push(a[i++], 'same')\n j++\n } else if (\n j >= b.length ||\n (i < a.length && common[i + 1][j] >= common[i][j + 1])\n ) {\n push(a[i++], 'removed')\n } else {\n push(b[j++], 'added')\n }\n }\n return runs.map((run, k) =>\n run.kind === 'same'\n ? {\n ...run,\n text: contextOf(run.text, k > 0, k < runs.length - 1),\n }\n : run,\n )\n }\n\n /** What a Word operation did, as the row says it. */\n const wordChangeLabel = (op: string | undefined) => {\n switch (op) {\n case 'insertParagraphs':\n return $t('messagePart.chatFileParagraphAdded')\n case 'deleteParagraphs':\n return $t('messagePart.chatFileParagraphDeleted')\n case 'insertTableRow':\n return $t('messagePart.chatFileTableRowAdded')\n case 'deleteTableRow':\n return $t('messagePart.chatFileTableRowDeleted')\n case 'acceptRevisions':\n return $t('messagePart.chatFileRevisionAccepted')\n case 'rejectRevisions':\n return $t('messagePart.chatFileRevisionRejected')\n default:\n return $t('messagePart.chatFileParagraphChanged')\n }\n }\n\n /**\n * A paragraph marked as Word marks a revision, struck where words went\n * and underlined where they came. A paragraph only added or only removed\n * is said by its label: the text added stays plain, the text removed\n * stays struck.\n */\n const paragraphRow = (change: ChatFileChange): ParagraphRow => {\n const before = withoutLength(change.before)\n const after = withoutLength(change.after)\n return {\n what: wordChangeLabel(change.op),\n segments:\n before && after\n ? excerptOf(before, after)\n : [\n before\n ? { text: before, kind: 'removed' }\n : { text: after ?? '', kind: 'same' },\n ],\n }\n }\n\n /**\n * A cell as a person reads it: its sheet heads the group of its rows, so\n * the row says `C5` and not Excel's `Listino!C5`, and a row the edit\n * appended says \"Row 10\" and not `A10:F10`.\n */\n const cellRow = (change: ChatFileChange): CellRow => {\n const ref = change.cell ?? ''\n // A new sheet is named alone, with no cell. An edit made before the\n // card read `newSheetRows` said it only in the model's words.\n const legacy = change.before\n ? undefined\n : /^new sheet, (\\d+) row\\(s\\)$/.exec(change.after ?? '')?.[1]\n const rows =\n change.newSheetRows ?? (legacy ? Number(legacy) : undefined)\n if (rows !== undefined) {\n return {\n sheet: ref,\n newSheet: $t('messagePart.chatFileNewSheet', rows),\n }\n }\n\n const bang = ref.lastIndexOf('!')\n const cell = ref.slice(bang + 1)\n const appended = /^A(\\d+):[A-Z]+(\\d+)$/.exec(cell)\n return {\n sheet: ref.slice(0, Math.max(bang, 0)),\n cell:\n appended && appended[1] === appended[2]\n ? $t('messagePart.chatFileRow', { row: appended[1] })\n : cell,\n before: shownAs(withoutLength(change.before), change.beforeFormat),\n after: shownAs(withoutLength(change.after), change.afterFormat),\n }\n }\n\n /**\n * A value as its cell shows it, `0.05` as `5%` and a date serial as the\n * date; a formula, a text and a cell with no format stay as written.\n */\n const shownAs = (\n raw: string | undefined,\n format: string | undefined,\n ): string | undefined => {\n if (!raw || !format || raw.startsWith('=')) {\n return raw || undefined\n }\n try {\n if (isSpreadsheetDateFormat(format)) {\n return excelDateText(raw, format, locale.value) ?? raw\n }\n return /^-?\\d+(\\.\\d+)?(e[+-]?\\d+)?$/i.test(raw)\n ? formatExcelNumber(format, Number(raw), locale.value).text\n : raw\n } catch {\n // A code the interpreter cannot read: the value as written\n return raw\n }\n }\n\n const file = computed(() => {\n const part = props.part as {\n type?: string\n state?: string\n output?: Partial<ChatFileOutput>\n }\n if (part.state !== 'output-available' || !part.output?.storedFileName) {\n return undefined\n }\n const output = part.output as ChatFileOutput\n const word = WORD_TOOL_PARTS.has(part.type ?? '')\n // A new file has no count of changes. Each key is written out in its\n // own call: the widget ships only the keys it finds that way.\n let changed: string | undefined\n if (word && output.changedParagraphs !== undefined) {\n changed = output.tracked\n ? $t(\n 'messagePart.editWordDocumentRevisions',\n output.changedParagraphs,\n )\n : $t(\n 'messagePart.editWordDocumentParagraphs',\n output.changedParagraphs,\n )\n } else if (!word && output.changedCells !== undefined) {\n changed = $t(\n 'messagePart.editSpreadsheetCells',\n output.changedCells,\n )\n }\n const changes = changed ? (output.changes ?? []) : []\n const reminders: string[] = []\n if (output.stalePivots) {\n reminders.push($t('messagePart.chatFileRefreshPivots'))\n }\n if (output.staleTableOfContents) {\n reminders.push($t('messagePart.chatFileUpdateTableOfContents'))\n }\n let summary =\n changed && output.version\n ? $t('messagePart.chatFileVersionSummary', {\n version: output.version,\n changed,\n })\n : changed\n if (output.restoredFrom) {\n summary = $t('messagePart.chatFileRestored', {\n version: output.version,\n restored: output.restoredFrom,\n })\n }\n return {\n output,\n mediaType: word ? WORD_MIME_TYPE : SPREADSHEET_MIME_TYPE,\n summary,\n cells: word ? [] : changes.map(cellRow),\n paragraphs: word ? changes.map(paragraphRow) : [],\n count: changes.length,\n more: output.moreChanges ?? 0,\n reminders,\n }\n })\n\n const shown = <T,>(rows: T[] | undefined): T[] =>\n showAll.value ? (rows ?? []) : (rows ?? []).slice(0, SHOWN_CHANGES)\n const shownParagraphs = computed(() => shown(file.value?.paragraphs))\n /** The rows shown, a group per sheet in the order the edit reached it. */\n const shownSheets = computed(() => {\n const groups = new Map<string, SheetGroup>()\n for (const row of shown(file.value?.cells)) {\n const group = groups.get(row.sheet)\n if (group) {\n group.rows.push(row)\n } else {\n groups.set(row.sheet, { sheet: row.sheet, rows: [row] })\n }\n }\n return [...groups.values()]\n })\n const hiddenRows = computed(() => (file.value?.count ?? 0) - SHOWN_CHANGES)\n\n /**\n * The version this card wrote, when a later one of the same file is in\n * the conversation: the one the user can ask to have back.\n */\n const olderVersion = computed(() => {\n const output = file.value?.output\n const latest = output?.fileId\n ? props.latestVersions?.get(output.fileId)\n : undefined\n return output?.fileId &&\n output.version &&\n latest &&\n output.version < latest\n ? {\n fileId: output.fileId,\n version: output.version,\n filename: chatFileName(\n output.filename ?? output.storedFileName,\n output.version,\n ),\n }\n : undefined\n })\n\n /** Asks the agent for this version back. */\n const restoreThis = () => {\n if (olderVersion.value) {\n props.restore?.(olderVersion.value)\n }\n }\n\n /** Opens this version in the chat's viewer. */\n const openPreview = () => {\n const output = file.value?.output\n if (!output || !props.preview) {\n return\n }\n props.preview({\n kind:\n file.value?.mediaType === WORD_MIME_TYPE\n ? 'word'\n : 'spreadsheet',\n storedFileName: output.storedFileName,\n filename: chatFileName(\n output.filename ?? output.storedFileName,\n output.version,\n ),\n version: output.version,\n fileId: output.fileId,\n })\n }\n</script>\n\n<template>\n <div v-if=\"file\" class=\"pk-tool-chat-file\">\n <!-- Restore and open live in the file, beside its download: a\n bordered button under it weighed more than the file and the\n answer it belongs to -->\n <PkChatbotFilePreview\n :media-type=\"file.mediaType\"\n :url=\"fileUrl(file.output.storedFileName)\"\n :filename=\"file.output.filename\"\n :size=\"file.output.sizeBytes\"\n show-download\n :on-preview=\"preview ? openPreview : undefined\"\n :on-restore=\"restore && olderVersion ? restoreThis : undefined\" />\n <section\n v-if=\"file.count || file.output.restoredFrom\"\n class=\"pk-tool-chat-file__changes mt-xs\">\n <h4 class=\"pk-tool-chat-file__summary\">\n {{ file.summary }}\n </h4>\n <div v-if=\"file.count\" class=\"pk-tool-chat-file__scroll\">\n <table\n v-if=\"file.cells.length\"\n class=\"pk-tool-chat-file__table\">\n <thead>\n <tr>\n <th scope=\"col\" class=\"pk-tool-chat-file__cell\">\n {{ $t('messagePart.chatFileCell') }}\n </th>\n <th scope=\"col\">\n {{ $t('messagePart.chatFileBefore') }}\n </th>\n <th scope=\"col\">\n {{ $t('messagePart.chatFileAfter') }}\n </th>\n </tr>\n </thead>\n <tbody v-for=\"(group, g) in shownSheets\" :key=\"g\">\n <tr>\n <th\n colspan=\"3\"\n scope=\"rowgroup\"\n class=\"pk-tool-chat-file__sheet\">\n {{\n $t('messagePart.chatFileSheet', {\n name: group.sheet,\n })\n }}\n </th>\n </tr>\n <tr v-for=\"(row, index) in group.rows\" :key=\"index\">\n <td\n v-if=\"row.newSheet\"\n colspan=\"3\"\n class=\"pk-tool-chat-file__after\">\n {{ row.newSheet }}\n </td>\n <template v-else>\n <td class=\"pk-tool-chat-file__cell\">\n {{ row.cell }}\n </td>\n <td class=\"pk-tool-chat-file__before\">\n {{ row.before }}\n </td>\n <td class=\"pk-tool-chat-file__after\">\n {{ row.after }}\n </td>\n </template>\n </tr>\n </tbody>\n </table>\n <ul v-else class=\"pk-tool-chat-file__paragraphs\">\n <li\n v-for=\"(row, index) in shownParagraphs\"\n :key=\"index\"\n class=\"pk-tool-chat-file__paragraph\">\n <span class=\"pk-tool-chat-file__what\">\n {{ row.what }}\n </span>\n <span class=\"pk-tool-chat-file__text\">\n <template\n v-for=\"(segment, s) in row.segments\"\n :key=\"s\">\n <del\n v-if=\"segment.kind === 'removed'\"\n class=\"pk-tool-chat-file__removed\">\n {{ segment.text }}\n </del>\n <ins\n v-else-if=\"segment.kind === 'added'\"\n class=\"pk-tool-chat-file__added\">\n {{ segment.text }}\n </ins>\n <span v-else>{{ segment.text }}</span>\n </template>\n </span>\n </li>\n </ul>\n <p v-if=\"showAll && file.more\" class=\"pk-tool-chat-file__note\">\n {{ $t('messagePart.chatFileMoreChanges', file.more) }}\n </p>\n </div>\n <button\n v-if=\"hiddenRows > 0\"\n type=\"button\"\n class=\"pk-tool-chat-file__more\"\n :aria-expanded=\"showAll\"\n @click=\"showAll = !showAll\">\n <VvIcon\n :name=\"\n showAll ? 'ri:arrow-up-s-line' : 'ri:arrow-down-s-line'\n \"\n class=\"text-16\"\n aria-hidden=\"true\" />\n {{\n showAll\n ? $t('action.showLess')\n : $t('action.showMore', { count: hiddenRows })\n }}\n </button>\n <p\n v-for=\"reminder in file.reminders\"\n :key=\"reminder\"\n class=\"pk-tool-chat-file__reminder\">\n <VvIcon\n name=\"ri:information-line\"\n class=\"pk-tool-chat-file__reminder-icon\"\n aria-hidden=\"true\" />\n {{ reminder }}\n </p>\n </section>\n <p v-else-if=\"file.summary\" class=\"text-12 text-word-3 mt-xs mb-0\">\n {{ file.summary }}\n </p>\n </div>\n</template>\n\n<style lang=\"scss\">\n // One frame (DESIGN.md, principle 4): a hairline at surface-3, rounded-lg,\n // a solid ground over the dots of the chat, as wide as a short paragraph\n // while the file above keeps its 280px. Inside it every divider is one\n // hairline at surface-2.\n .pk-tool-chat-file__changes {\n max-width: 36rem;\n overflow: hidden;\n border: var(--border) solid var(--color-surface-3);\n border-radius: var(--rounded-lg);\n background-color: var(--color-surface);\n font-size: var(--text-12);\n }\n\n .pk-tool-chat-file__summary {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-3);\n color: var(--color-word-2);\n font-size: var(--text-12);\n font-weight: var(--font-medium);\n\n // A restore says only what it wrote back\n &:last-child {\n border-bottom: 0;\n }\n }\n\n // Bounded, so fifty changes scroll inside the frame\n .pk-tool-chat-file__scroll {\n max-height: 20rem;\n overflow-y: auto;\n }\n\n .pk-tool-chat-file__table {\n width: 100%;\n border-collapse: collapse;\n\n th,\n td {\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-2);\n text-align: start;\n vertical-align: top;\n overflow-wrap: anywhere;\n }\n\n // Told apart by its weight and colour, no heavier rule\n th {\n color: var(--color-word-3);\n font-weight: var(--font-medium);\n }\n\n tbody:last-child tr:last-child td {\n border-bottom: 0;\n }\n }\n\n // The name of a sheet heads its rows, one step of surface under it\n .pk-tool-chat-file__table .pk-tool-chat-file__sheet {\n padding-block: var(--spacing-6);\n background-color: var(--color-surface-1);\n color: var(--color-word-2);\n }\n\n .pk-tool-chat-file__cell {\n width: 1%;\n color: var(--color-word-2);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n }\n\n .pk-tool-chat-file__before {\n width: 50%;\n color: var(--color-word-3);\n }\n\n .pk-tool-chat-file__after {\n width: 50%;\n color: var(--color-word-1);\n }\n\n .pk-tool-chat-file__paragraphs {\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n .pk-tool-chat-file__paragraph {\n display: grid;\n grid-template-columns: minmax(4rem, max-content) 1fr;\n gap: var(--spacing-4) var(--spacing-md);\n padding: var(--spacing-8) var(--spacing-12);\n border-bottom: var(--border) solid var(--color-surface-2);\n\n &:last-child {\n border-bottom: 0;\n }\n }\n\n .pk-tool-chat-file__what {\n color: var(--color-word-3);\n white-space: nowrap;\n }\n\n .pk-tool-chat-file__text {\n min-width: 0;\n color: var(--color-word-2);\n overflow-wrap: anywhere;\n }\n\n // Marked as Word marks a revision, struck where words went and\n // underlined where they came, in the red and green of a comparison: the\n // change is what the row exists to report, the verdict exception of\n // DESIGN.md (principle 2). The readable text tokens hold the contrast in\n // both themes. The base styles take the line off `del`.\n .pk-tool-chat-file__removed {\n color: var(--u-danger-text);\n text-decoration: line-through;\n }\n\n .pk-tool-chat-file__added {\n color: var(--u-success-text);\n font-weight: var(--font-medium);\n text-decoration: underline;\n text-underline-offset: 0.2em;\n }\n\n .pk-tool-chat-file__removed + .pk-tool-chat-file__added {\n margin-inline-start: var(--spacing-4);\n }\n\n .pk-tool-chat-file__note {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-top: var(--border) solid var(--color-surface-2);\n color: var(--color-word-3);\n }\n\n .pk-tool-chat-file__more {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: var(--spacing-4);\n width: 100%;\n padding: var(--spacing-8) var(--spacing-12);\n border: 0;\n border-top: var(--border) solid var(--color-surface-2);\n background: none;\n color: var(--color-word-2);\n font: inherit;\n cursor: pointer;\n transition: background-color var(--duration-150) var(--ease-out);\n\n &:hover {\n background-color: var(--color-surface-1);\n }\n\n &:focus-visible {\n outline: var(--spacing-2) solid var(--input-focus-color);\n outline-offset: calc(var(--spacing-2) * -1);\n }\n }\n\n .pk-tool-chat-file__reminder {\n display: flex;\n align-items: flex-start;\n gap: var(--spacing-8);\n margin: 0;\n padding: var(--spacing-8) var(--spacing-12);\n border-top: var(--border) solid var(--color-surface-2);\n color: var(--color-word-2);\n }\n\n .pk-tool-chat-file__reminder-icon {\n flex-shrink: 0;\n margin-top: var(--spacing-2);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GAAAC,EAiBS,UAAA;;KAfL,MAAK;KACL,OAAM;KACL,iBAAe+D,EAAA;KACf,SAAK,AAAAwD,EAAA,QAAA,MAAE,EAAA,QAAO,CAAIxD,EAAA;I,IACnB9D,EAKyBiH,GAAA;KAJpB,MAA+BnD,EAAA,QAAO,uBAAA;KAGvC,OAAM;KACN,eAAY;I,uBAASvD,EAAA,MACzBJ,EACI2D,EAAA,QAAkC1D,EAAAyD,CAAA,CAAE,CAAA,iBAAA,IAA8CzD,EAAAyD,CAAA,CAAE,CAAA,mBAAA,EAAA,OAA6B+C,EAAA,MAAU,CAAA,CAAA,GAAA,CAAA,C;KAKnI9G,EAAA,EAAA,GAAAC,EASIM,GAAA,MAAAC,EARmBwF,EAAA,MAAK,YAAjB,OADXhG,EAAA,GAAAC,EASI,KAAA;KAPC,KAAKwH;KACN,OAAM;I,IACNvH,EAGyBiH,GAAA;KAFrB,MAAK;KACL,OAAM;KACN,eAAY;I,IAAS1G,EAAA,MACzBJ,EAAGoH,CAAQ,GAAA,CAAA,C;G,MAGLzB,EAAA,MAAK,WAAnBhG,EAAA,GAAAC,EAEI,KAFJwD,GAEIpD,EADG2F,EAAA,MAAK,OAAO,GAAA,CAAA,K"}
@@ -1,4 +1,4 @@
1
- import { r as e } from "./index.es-B9l77u9z.js";
1
+ import { r as e } from "./index.es-DHeth3Ja.js";
2
2
  import { L as t, S as n, Tt as r, f as i, g as a, h as o, k as s, kt as c, ot as l, v as u, w as d, wt as f, x as p, y as m, z as h } from "./vue.runtime.esm-bundler-DZgpK-ja.js";
3
3
  import { r as g } from "./vue-i18n-CDYWo9pX.js";
4
4
  import { S as _ } from "./Agent-nB9V45mr.js";
@@ -63,4 +63,4 @@ var v = { class: "flex items-center gap-6 text-12 text-word-3 border border-surf
63
63
  });
64
64
  export { y as default };
65
65
 
66
- //# sourceMappingURL=PkToolRequestGeolocation-D4pYnCW5.js.map
66
+ //# sourceMappingURL=PkToolRequestGeolocation-BeFZQQxz.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PkToolRequestGeolocation-D4pYnCW5.js","names":["$n","_openBlock","_createElementBlock","_Fragment","_createVNode","_createElementVNode","_toDisplayString","_unref","_createTextVNode","De","onMounted","createVNode","init_shared_esm_bundler","Fragment","createBaseVNode","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","isVoiceRenderAck","_hoisted_1","PkToolRequestGeolocation_default","__emit","props","__props","emit","$t","toolPart","state","isRenderAck","isOutputAvailable","successOutput","out","errorOutput","mapGeolocationError","code","position","city","latitude","longitude","error","_component_VvIcon","_ctx"],"sources":["../../../../packages/components/src/chat/PkToolRequestGeolocation.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, onMounted } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n\n import type { ReverseGeocodeFn } from 'utils/src/device-context'\n\n type GeolocationOutput =\n | {\n latitude: number\n longitude: number\n accuracy?: number\n city?: string\n }\n | { error: 'permission_denied' | 'position_unavailable' | 'timeout' }\n\n const props = defineProps<{\n part: unknown\n reverseGeocode?: ReverseGeocodeFn\n /**\n * Whether a voice call is on the line right now. A request drawn\n * during a call arrives already resolved with the render ack, and the\n * browser prompt must fire only while the caller who was asked is\n * still there: reopening the conversation later must not ask again.\n */\n callLive?: boolean\n }>()\n\n const emit = defineEmits<{\n result: [output: GeolocationOutput]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n input?: { reason?: string }\n /** The position, or the voice render ack (a string). */\n output?: GeolocationOutput | string\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n\n /**\n * The ack is not a position: it only says the card was drawn during a\n * call (see `isVoiceRenderAck`, same rule as the forms). Besides gating\n * the prompt below, it must be kept away from the output parsing: `in`\n * on a string throws, which broke this card on every spoken turn.\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n const isOutputAvailable = computed(\n () => state.value === 'output-available' && !isRenderAck.value,\n )\n\n const successOutput = computed(() => {\n const out = toolPart.value.output\n if (!out || typeof out === 'string' || 'error' in out) {\n return undefined\n }\n return out\n })\n\n const errorOutput = computed(() => {\n const out = toolPart.value.output\n if (!out || typeof out === 'string' || !('error' in out)) {\n return undefined\n }\n return out\n })\n\n /** Maps GeolocationPositionError.code to a typed string */\n function mapGeolocationError(\n code: number,\n ): 'permission_denied' | 'position_unavailable' | 'timeout' {\n if (code === 1) {\n return 'permission_denied'\n }\n if (code === 3) {\n return 'timeout'\n }\n return 'position_unavailable'\n }\n\n onMounted(() => {\n const isAwaitingPosition =\n state.value === 'input-available' ||\n (isRenderAck.value && props.callLive === true)\n if (!isAwaitingPosition) {\n return\n }\n\n if (!navigator.geolocation) {\n emit('result', { error: 'position_unavailable' })\n return\n }\n\n navigator.geolocation.getCurrentPosition(\n async (position) => {\n const { latitude, longitude, accuracy } = position.coords\n const city = props.reverseGeocode\n ? await props\n .reverseGeocode(latitude, longitude)\n .catch(() => undefined)\n : undefined\n emit('result', { latitude, longitude, accuracy, city })\n },\n (error) => {\n emit('result', { error: mapGeolocationError(error.code) })\n },\n { timeout: 15000 },\n )\n })\n</script>\n\n<template>\n <div\n class=\"flex items-center gap-6 text-12 text-word-3 border border-surface-3 rounded-xl px-sm py-10 bg-surface\">\n <!-- Loading state -->\n <template v-if=\"!isOutputAvailable\">\n <VvIcon name=\"loading-loop\" class=\"text-16\" />\n <span>{{ $t('messagePart.requestGeolocation') }}</span>\n </template>\n\n <!-- Success state -->\n <template v-else-if=\"successOutput\">\n <VvIcon name=\"ri:map-pin-line\" class=\"text-16\" />\n <span>\n {{\n $n(successOutput.latitude, {\n style: 'decimal',\n minimumFractionDigits: 5,\n maximumFractionDigits: 5,\n })\n }},\n {{\n $n(successOutput.longitude, {\n style: 'decimal',\n minimumFractionDigits: 5,\n maximumFractionDigits: 5,\n })\n }}\n <template v-if=\"successOutput.accuracy !== undefined\">\n (±{{\n $n(successOutput.accuracy, {\n style: 'unit',\n unit: 'meter',\n })\n }})\n </template>\n </span>\n </template>\n\n <!-- Error state -->\n <template v-else-if=\"errorOutput\">\n <VvIcon\n name=\"ri:error-warning-line\"\n class=\"w-16 h-16 shrink-0 text-danger\" />\n <span>\n {{\n errorOutput.error === 'permission_denied'\n ? $t('message.geolocationPermissionDenied')\n : $t('message.geolocationUnavailable')\n }}\n </span>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;EAgBI,IAAM8B,IAAQC,GAYRC,IAAOH,GAIP,EAAE,GAAGI,MAAOR,EAAQ,EAAE,UAAU,SAAS,CAAC,GAE1CS,IAAWnB,QACNe,EAAM,IAMhB,GAEKK,IAAQpB,QAAemB,EAAS,MAAM,SAAS,SAAS,GAQxDE,IAAcrB,QAAeW,EAAiBQ,EAAS,MAAM,MAAM,CAAC,GAEpEG,IAAoBtB,QAChBoB,EAAM,UAAU,sBAAsB,CAACC,EAAY,KAC7D,GAEME,IAAgBvB,QAAe;GACjC,IAAMwB,IAAML,EAAS,MAAM;GAC3B,IAAI,GAACK,KAAO,OAAOA,KAAQ,YAAY,WAAWA,IAGlD,OAAOA;EACX,CAAC,GAEKC,IAAczB,QAAe;GAC/B,IAAMwB,IAAML,EAAS,MAAM;GAC3B,IAAKK,KAAO,OAAOA,KAAQ,YAAc,WAAWA,GAGpD,OAAOA;EACX,CAAC;EAGD,SAASE,EACL,GACwD;GAOxD,OANIC,MAAS,IACF,sBAEPA,MAAS,IACF,YAEJ;EACX;E,OAEAhC,QAAgB;GAIZ,CAFIyB,EAAM,UAAU,qBACfC,EAAY,SAASN,EAAM,aAAa,QAKxC,UAAU,cAKf,UAAU,YAAY,mBAClB,OAAO,MAAa;IAChB,IAAM,EAAE,aAAU,cAAW,gBAAaa,EAAS,QAC7CC,IAAOd,EAAM,iBACb,MAAMA,EACD,eAAee,GAAUC,CAAS,CAAA,CAClC,YAAY,KAAA,C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AM;G,IAClC3C,EAAuD,QAAA,MAAAC,EAA9CC,EAAA0B,CAAA,CAAE,CAAA,gCAAA,CAAA,GAAA,CAAA,C"}
1
+ {"version":3,"file":"PkToolRequestGeolocation-BeFZQQxz.js","names":["$n","_openBlock","_createElementBlock","_Fragment","_createVNode","_createElementVNode","_toDisplayString","_unref","_createTextVNode","Te","onMounted","createVNode","init_shared_esm_bundler","Fragment","createBaseVNode","computed","init_runtime_core_esm_bundler","toDisplayString","init_reactivity_esm_bundler","createCommentVNode","defineComponent","unref","createTextVNode","createElementBlock","openBlock","useI18n","isVoiceRenderAck","_hoisted_1","PkToolRequestGeolocation_default","__emit","props","__props","emit","$t","toolPart","state","isRenderAck","isOutputAvailable","successOutput","out","errorOutput","mapGeolocationError","code","position","city","latitude","longitude","error","_component_VvIcon","_ctx"],"sources":["../../../../packages/components/src/chat/PkToolRequestGeolocation.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, onMounted } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { isVoiceRenderAck } from 'models'\n\n import type { ReverseGeocodeFn } from 'utils/src/device-context'\n\n type GeolocationOutput =\n | {\n latitude: number\n longitude: number\n accuracy?: number\n city?: string\n }\n | { error: 'permission_denied' | 'position_unavailable' | 'timeout' }\n\n const props = defineProps<{\n part: unknown\n reverseGeocode?: ReverseGeocodeFn\n /**\n * Whether a voice call is on the line right now. A request drawn\n * during a call arrives already resolved with the render ack, and the\n * browser prompt must fire only while the caller who was asked is\n * still there: reopening the conversation later must not ask again.\n */\n callLive?: boolean\n }>()\n\n const emit = defineEmits<{\n result: [output: GeolocationOutput]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n const toolPart = computed(() => {\n return props.part as {\n state?: string\n input?: { reason?: string }\n /** The position, or the voice render ack (a string). */\n output?: GeolocationOutput | string\n }\n })\n\n const state = computed(() => toolPart.value.state ?? 'unknown')\n\n /**\n * The ack is not a position: it only says the card was drawn during a\n * call (see `isVoiceRenderAck`, same rule as the forms). Besides gating\n * the prompt below, it must be kept away from the output parsing: `in`\n * on a string throws, which broke this card on every spoken turn.\n */\n const isRenderAck = computed(() => isVoiceRenderAck(toolPart.value.output))\n\n const isOutputAvailable = computed(\n () => state.value === 'output-available' && !isRenderAck.value,\n )\n\n const successOutput = computed(() => {\n const out = toolPart.value.output\n if (!out || typeof out === 'string' || 'error' in out) {\n return undefined\n }\n return out\n })\n\n const errorOutput = computed(() => {\n const out = toolPart.value.output\n if (!out || typeof out === 'string' || !('error' in out)) {\n return undefined\n }\n return out\n })\n\n /** Maps GeolocationPositionError.code to a typed string */\n function mapGeolocationError(\n code: number,\n ): 'permission_denied' | 'position_unavailable' | 'timeout' {\n if (code === 1) {\n return 'permission_denied'\n }\n if (code === 3) {\n return 'timeout'\n }\n return 'position_unavailable'\n }\n\n onMounted(() => {\n const isAwaitingPosition =\n state.value === 'input-available' ||\n (isRenderAck.value && props.callLive === true)\n if (!isAwaitingPosition) {\n return\n }\n\n if (!navigator.geolocation) {\n emit('result', { error: 'position_unavailable' })\n return\n }\n\n navigator.geolocation.getCurrentPosition(\n async (position) => {\n const { latitude, longitude, accuracy } = position.coords\n const city = props.reverseGeocode\n ? await props\n .reverseGeocode(latitude, longitude)\n .catch(() => undefined)\n : undefined\n emit('result', { latitude, longitude, accuracy, city })\n },\n (error) => {\n emit('result', { error: mapGeolocationError(error.code) })\n },\n { timeout: 15000 },\n )\n })\n</script>\n\n<template>\n <div\n class=\"flex items-center gap-6 text-12 text-word-3 border border-surface-3 rounded-xl px-sm py-10 bg-surface\">\n <!-- Loading state -->\n <template v-if=\"!isOutputAvailable\">\n <VvIcon name=\"loading-loop\" class=\"text-16\" />\n <span>{{ $t('messagePart.requestGeolocation') }}</span>\n </template>\n\n <!-- Success state -->\n <template v-else-if=\"successOutput\">\n <VvIcon name=\"ri:map-pin-line\" class=\"text-16\" />\n <span>\n {{\n $n(successOutput.latitude, {\n style: 'decimal',\n minimumFractionDigits: 5,\n maximumFractionDigits: 5,\n })\n }},\n {{\n $n(successOutput.longitude, {\n style: 'decimal',\n minimumFractionDigits: 5,\n maximumFractionDigits: 5,\n })\n }}\n <template v-if=\"successOutput.accuracy !== undefined\">\n (±{{\n $n(successOutput.accuracy, {\n style: 'unit',\n unit: 'meter',\n })\n }})\n </template>\n </span>\n </template>\n\n <!-- Error state -->\n <template v-else-if=\"errorOutput\">\n <VvIcon\n name=\"ri:error-warning-line\"\n class=\"w-16 h-16 shrink-0 text-danger\" />\n <span>\n {{\n errorOutput.error === 'permission_denied'\n ? $t('message.geolocationPermissionDenied')\n : $t('message.geolocationUnavailable')\n }}\n </span>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;EAgBI,IAAM8B,IAAQC,GAYRC,IAAOH,GAIP,EAAE,GAAGI,MAAOR,EAAQ,EAAE,UAAU,SAAS,CAAC,GAE1CS,IAAWnB,QACNe,EAAM,IAMhB,GAEKK,IAAQpB,QAAemB,EAAS,MAAM,SAAS,SAAS,GAQxDE,IAAcrB,QAAeW,EAAiBQ,EAAS,MAAM,MAAM,CAAC,GAEpEG,IAAoBtB,QAChBoB,EAAM,UAAU,sBAAsB,CAACC,EAAY,KAC7D,GAEME,IAAgBvB,QAAe;GACjC,IAAMwB,IAAML,EAAS,MAAM;GAC3B,IAAI,GAACK,KAAO,OAAOA,KAAQ,YAAY,WAAWA,IAGlD,OAAOA;EACX,CAAC,GAEKC,IAAczB,QAAe;GAC/B,IAAMwB,IAAML,EAAS,MAAM;GAC3B,IAAKK,KAAO,OAAOA,KAAQ,YAAc,WAAWA,GAGpD,OAAOA;EACX,CAAC;EAGD,SAASE,EACL,GACwD;GAOxD,OANIC,MAAS,IACF,sBAEPA,MAAS,IACF,YAEJ;EACX;E,OAEAhC,QAAgB;GAIZ,CAFIyB,EAAM,UAAU,qBACfC,EAAY,SAASN,EAAM,aAAa,QAKxC,UAAU,cAKf,UAAU,YAAY,mBAClB,OAAO,MAAa;IAChB,IAAM,EAAE,aAAU,cAAW,gB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,EAAA,GAAAC,EAGWC,GAAA,EAAA,KAAA,EAAA,GAAA,CAFPC,EAA8C4C,GAAA;IAAtC,MAAK;IAAe,OAAM;G,IAClC3C,EAAuD,QAAA,MAAAC,EAA9CC,EAAA0B,CAAA,CAAE,CAAA,gCAAA,CAAA,GAAA,CAAA,C"}
@@ -1,5 +1,5 @@
1
- import { t as e } from "./VvButtonLocalized-C3bg4fNl.js";
2
- import { r as t } from "./index.es-B9l77u9z.js";
1
+ import { t as e } from "./VvButtonLocalized-DfLLySHy.js";
2
+ import { r as t } from "./index.es-DHeth3Ja.js";
3
3
  import { L as n, R as r, S as i, Tt as a, _ as o, f as s, g as c, gt as l, h as u, k as d, kt as f, ot as p, v as m, w as h, wt as g, y as _, z as v } from "./vue.runtime.esm-bundler-DZgpK-ja.js";
4
4
  import { r as y } from "./vue-i18n-CDYWo9pX.js";
5
5
  import { i as b } from "./url-validation-CJV9pp4v.js";
@@ -119,4 +119,4 @@ var C = { class: "border border-surface-3 rounded-xl w-full overflow-hidden bg-s
119
119
  });
120
120
  export { P as default };
121
121
 
122
- //# sourceMappingURL=PkToolRequestOAuthConnection-DnnRY2rt.js.map
122
+ //# sourceMappingURL=PkToolRequestOAuthConnection-_01ct5du.js.map