@templatical/editor 0.53.0 → 0.54.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/dist/{AiChatPanel-DdhtfsmO.js → AiChatPanel-C8SeEJRP.js} +8 -8
  2. package/dist/{AiPanels-HBx7xoJR.js → AiPanels-CR6zphjP.js} +1 -1
  3. package/dist/{AiRewriteMenu-DPzSekZt.js → AiRewriteMenu-arKoTjsQ.js} +6 -6
  4. package/dist/{BlockIssueBadge-eIXZJ9M3.js → BlockIssueBadge-DaPTq1RE.js} +2 -2
  5. package/dist/{BlockPreviewCanvas-DO-2TP_6.js → BlockPreviewCanvas-BTieuBmH.js} +3 -3
  6. package/dist/{CloudPanels-i2kZdrdP.js → CloudPanels-Hxdp0doU.js} +3 -3
  7. package/dist/{CollaborationNotices-DANsjl7c.js → CollaborationNotices-Cnx0XHzZ.js} +1 -1
  8. package/dist/{CollaboratorBar-CbbAA0m1.js → CollaboratorBar-BaBoNhwB.js} +1 -1
  9. package/dist/{CommentsPanel-CYW3LWis.js → CommentsPanel-Ck3QmqiC.js} +1 -1
  10. package/dist/{CommentsSidebar-CcF4ISMi.js → CommentsSidebar-CHknhOar.js} +10 -10
  11. package/dist/{CountdownToolbar-D3Lv74kU.js → CountdownToolbar-CM4XNEuO.js} +3 -3
  12. package/dist/{IssuesPanel-BMAG9042.js → IssuesPanel-1wGV0wiy.js} +8 -8
  13. package/dist/{LanguageMenu-FlP_Jbup.js → LanguageMenu-BpxbIJEx.js} +8 -8
  14. package/dist/{LocaleNotices-DAnVszWu.js → LocaleNotices-WzsYtBRs.js} +2 -2
  15. package/dist/{LogicTagInsertButton-BjYs-UQX.js → LogicTagInsertButton-DgTJ6Lvx.js} +3 -3
  16. package/dist/{MediaEditModal-LnG-cF_S.js → MediaEditModal-C3U9Mi31.js} +1 -1
  17. package/dist/{MediaPanels-C2r5fiFo.js → MediaPanels-CGmk9ufe.js} +1 -1
  18. package/dist/{MergeTagInput-BsnogCeY.js → MergeTagInput-B_51YcQO.js} +1 -1
  19. package/dist/{MergeTagModeToggle-DiufIQ-_.js → MergeTagModeToggle-D3Q2z317.js} +3 -3
  20. package/dist/{MergeTagTextarea-BweI-Xsi.js → MergeTagTextarea-DZz1L9DE.js} +2 -2
  21. package/dist/{ParagraphEditor-qgBp5yIB.js → ParagraphEditor-B38t4E2p.js} +16 -15
  22. package/dist/{RestoreVersionDialog-DdYUrFiK.js → RestoreVersionDialog-n7FSmWXB.js} +3 -3
  23. package/dist/{RichTextEditorContent-C5MAzx3E.js → RichTextEditorContent-Dstovi0m.js} +4 -4
  24. package/dist/{SaveBlockDialog-eK6fjtTy.js → SaveBlockDialog-B94NpmDV.js} +7 -7
  25. package/dist/{SavedBlocksBrowserModal-D2QHd2Yp.js → SavedBlocksBrowserModal-C1vSc8iM.js} +9 -9
  26. package/dist/{SavedBlocksPanels-Cl61f4Mf.js → SavedBlocksPanels-DLDmIYeL.js} +1 -1
  27. package/dist/{SavedBlocksPickBar-CXP2dkeB.js → SavedBlocksPickBar-ngf2sFEs.js} +2 -2
  28. package/dist/{TemplateSettings-BKJrdZcH.js → TemplateSettings-Baar78_s.js} +6 -6
  29. package/dist/{TestEmailModal-DQotJg6g.js → TestEmailModal-CB_9I1bl.js} +6 -6
  30. package/dist/{TestEmailPanel-CwiTzJsh.js → TestEmailPanel-BUq-dbXQ.js} +1 -1
  31. package/dist/{TitleEditor-CzSvsPAn.js → TitleEditor-BLP41rwy.js} +10 -9
  32. package/dist/{Toolbar-Cd75ci5W.js → Toolbar-bOZ_eq7X.js} +27 -27
  33. package/dist/{TplModal-ZoXu40T9.js → TplModal-DFKqmJQz.js} +1 -1
  34. package/dist/{VersionHistoryMenu-BvhN-Ofk.js → VersionHistoryMenu-BnP0EyLl.js} +5 -5
  35. package/dist/{VersionHistoryPanels-DPWMnYbd.js → VersionHistoryPanels-DPxj3mec.js} +1 -1
  36. package/dist/{VersionPreviewBanner-CuJnasxH.js → VersionPreviewBanner-BPP939cD.js} +1 -1
  37. package/dist/{WrapperBlock-D4fPwO0t.js → WrapperBlock-BdVIuGMR.js} +2 -2
  38. package/dist/{blockTypeIcons-BXMxu86H.js → blockTypeIcons-BUyPZ7Su.js} +3 -3
  39. package/dist/bundle-stats.json +5 -5
  40. package/dist/cdn/chunks/{AiAltTextPopover-ByZ0FEqI.js → AiAltTextPopover-Cnc_kUmb.js} +2 -2
  41. package/dist/cdn/chunks/{AiAltTextPopover-ByZ0FEqI.js.map → AiAltTextPopover-Cnc_kUmb.js.map} +1 -1
  42. package/dist/cdn/chunks/{AiAltTextReview-Dtm3A2cD.js → AiAltTextReview-DPeSY-7r.js} +2 -2
  43. package/dist/cdn/chunks/{AiAltTextReview-Dtm3A2cD.js.map → AiAltTextReview-DPeSY-7r.js.map} +1 -1
  44. package/dist/cdn/chunks/{AiChatPanel-DciEt27y.js → AiChatPanel-By8Uo1nH.js} +2 -2
  45. package/dist/cdn/chunks/{AiChatPanel-DciEt27y.js.map → AiChatPanel-By8Uo1nH.js.map} +1 -1
  46. package/dist/cdn/chunks/{AiPanels-BV5D1itk.js → AiPanels-BblCSkQy.js} +2 -2
  47. package/dist/cdn/chunks/{AiPanels-BV5D1itk.js.map → AiPanels-BblCSkQy.js.map} +1 -1
  48. package/dist/cdn/chunks/{AiRewriteMenu-D3jkh6Xb.js → AiRewriteMenu-YcVFv6RS.js} +6 -6
  49. package/dist/cdn/chunks/{AiRewriteMenu-D3jkh6Xb.js.map → AiRewriteMenu-YcVFv6RS.js.map} +1 -1
  50. package/dist/cdn/chunks/{BlockIssueBadge-DyEgBZtR.js → BlockIssueBadge-D3Plo_wt.js} +2 -2
  51. package/dist/cdn/chunks/{BlockIssueBadge-DyEgBZtR.js.map → BlockIssueBadge-D3Plo_wt.js.map} +1 -1
  52. package/dist/cdn/chunks/{BlockPreviewCanvas-RQFilqXC.js → BlockPreviewCanvas-6ck15xz9.js} +7 -7
  53. package/dist/cdn/chunks/{BlockPreviewCanvas-RQFilqXC.js.map → BlockPreviewCanvas-6ck15xz9.js.map} +1 -1
  54. package/dist/cdn/chunks/{CloudPanels-BSJ-Z5Hw.js → CloudPanels-BHHpNckC.js} +3 -3
  55. package/dist/cdn/chunks/{CloudPanels-BSJ-Z5Hw.js.map → CloudPanels-BHHpNckC.js.map} +1 -1
  56. package/dist/cdn/chunks/{CollaborationNotices-BS7xrlPE.js → CollaborationNotices-DraFUhyo.js} +2 -2
  57. package/dist/cdn/chunks/{CollaborationNotices-BS7xrlPE.js.map → CollaborationNotices-DraFUhyo.js.map} +1 -1
  58. package/dist/cdn/chunks/{CollaboratorBar-Bc9914Az.js → CollaboratorBar-0OEH3hrj.js} +2 -2
  59. package/dist/cdn/chunks/{CollaboratorBar-Bc9914Az.js.map → CollaboratorBar-0OEH3hrj.js.map} +1 -1
  60. package/dist/cdn/chunks/{CommentsPanel-DbR9phAk.js → CommentsPanel-tZZswofV.js} +2 -2
  61. package/dist/cdn/chunks/{CommentsPanel-DbR9phAk.js.map → CommentsPanel-tZZswofV.js.map} +1 -1
  62. package/dist/cdn/chunks/{CommentsSidebar-BD4--XP2.js → CommentsSidebar-7Hfl3Hdj.js} +2 -2
  63. package/dist/cdn/chunks/{CommentsSidebar-BD4--XP2.js.map → CommentsSidebar-7Hfl3Hdj.js.map} +1 -1
  64. package/dist/cdn/chunks/{CountdownToolbar-DxwYBw-d.js → CountdownToolbar-CNgsNL5-.js} +5 -5
  65. package/dist/cdn/chunks/{CountdownToolbar-DxwYBw-d.js.map → CountdownToolbar-CNgsNL5-.js.map} +1 -1
  66. package/dist/cdn/chunks/{IssuesPanel-CUmI4HMm.js → IssuesPanel-Duic0mIs.js} +4 -4
  67. package/dist/cdn/chunks/{IssuesPanel-CUmI4HMm.js.map → IssuesPanel-Duic0mIs.js.map} +1 -1
  68. package/dist/cdn/chunks/{LanguageMenu-3ydCozQJ.js → LanguageMenu-C6utRx_4.js} +11 -11
  69. package/dist/cdn/chunks/{LanguageMenu-3ydCozQJ.js.map → LanguageMenu-C6utRx_4.js.map} +1 -1
  70. package/dist/cdn/chunks/{LocaleNotices-BfoH6gST.js → LocaleNotices-8J2DRWeg.js} +2 -2
  71. package/dist/cdn/chunks/{LocaleNotices-BfoH6gST.js.map → LocaleNotices-8J2DRWeg.js.map} +1 -1
  72. package/dist/cdn/chunks/{LogicTagInsertButton-5Z3fFzjc.js → LogicTagInsertButton-Bhvi0nWz.js} +5 -5
  73. package/dist/cdn/chunks/{LogicTagInsertButton-5Z3fFzjc.js.map → LogicTagInsertButton-Bhvi0nWz.js.map} +1 -1
  74. package/dist/cdn/chunks/{MediaEditModal-DDCIwr9U.js → MediaEditModal-Dz972UFx.js} +2 -2
  75. package/dist/cdn/chunks/{MediaEditModal-DDCIwr9U.js.map → MediaEditModal-Dz972UFx.js.map} +1 -1
  76. package/dist/cdn/chunks/{MediaPanels-Dz79oy8P.js → MediaPanels-C6Hqtp1H.js} +2 -2
  77. package/dist/cdn/chunks/{MediaPanels-Dz79oy8P.js.map → MediaPanels-C6Hqtp1H.js.map} +1 -1
  78. package/dist/cdn/chunks/{MergeTagInput-CIWy-cXf.js → MergeTagInput-CrhZm-AW.js} +2 -2
  79. package/dist/cdn/chunks/{MergeTagInput-CIWy-cXf.js.map → MergeTagInput-CrhZm-AW.js.map} +1 -1
  80. package/dist/cdn/chunks/{MergeTagModeToggle-BrP5GR-x.js → MergeTagModeToggle-CWVtXLYa.js} +3 -3
  81. package/dist/cdn/chunks/{MergeTagModeToggle-BrP5GR-x.js.map → MergeTagModeToggle-CWVtXLYa.js.map} +1 -1
  82. package/dist/cdn/chunks/{MergeTagTextarea-D3nNDlhV.js → MergeTagTextarea-hTIBwX0F.js} +7 -7
  83. package/dist/cdn/chunks/{MergeTagTextarea-D3nNDlhV.js.map → MergeTagTextarea-hTIBwX0F.js.map} +1 -1
  84. package/dist/cdn/chunks/{ParagraphEditor-DDolH_Pf.js → ParagraphEditor-B3EQ0Ai6.js} +113 -112
  85. package/dist/cdn/chunks/ParagraphEditor-B3EQ0Ai6.js.map +1 -0
  86. package/dist/cdn/chunks/{RestoreVersionDialog-Crj1DBqC.js → RestoreVersionDialog-DfNrVi0R.js} +3 -3
  87. package/dist/cdn/chunks/{RestoreVersionDialog-Crj1DBqC.js.map → RestoreVersionDialog-DfNrVi0R.js.map} +1 -1
  88. package/dist/cdn/chunks/{RichTextEditorContent-rCCqFlwJ.js → RichTextEditorContent-up4AqL7D.js} +4 -4
  89. package/dist/cdn/chunks/{RichTextEditorContent-rCCqFlwJ.js.map → RichTextEditorContent-up4AqL7D.js.map} +1 -1
  90. package/dist/cdn/chunks/{SaveBlockDialog-C34RW1aM.js → SaveBlockDialog-BqglcKcN.js} +6 -6
  91. package/dist/cdn/chunks/{SaveBlockDialog-C34RW1aM.js.map → SaveBlockDialog-BqglcKcN.js.map} +1 -1
  92. package/dist/cdn/chunks/{SavedBlocksBrowserModal-CJnwWPT-.js → SavedBlocksBrowserModal-BewXGlrK.js} +6 -6
  93. package/dist/cdn/chunks/{SavedBlocksBrowserModal-CJnwWPT-.js.map → SavedBlocksBrowserModal-BewXGlrK.js.map} +1 -1
  94. package/dist/cdn/chunks/{SavedBlocksPanels-CA2PqXIH.js → SavedBlocksPanels-0ZpX-jXI.js} +2 -2
  95. package/dist/cdn/chunks/{SavedBlocksPanels-CA2PqXIH.js.map → SavedBlocksPanels-0ZpX-jXI.js.map} +1 -1
  96. package/dist/cdn/chunks/{SavedBlocksPickBar-Dj3ortee.js → SavedBlocksPickBar-DHah-Uf7.js} +3 -3
  97. package/dist/cdn/chunks/{SavedBlocksPickBar-Dj3ortee.js.map → SavedBlocksPickBar-DHah-Uf7.js.map} +1 -1
  98. package/dist/cdn/chunks/{TemplateSettings-sW0ZlDl1.js → TemplateSettings-CWUpUKJb.js} +6 -6
  99. package/dist/cdn/chunks/{TemplateSettings-sW0ZlDl1.js.map → TemplateSettings-CWUpUKJb.js.map} +1 -1
  100. package/dist/cdn/chunks/{TestEmailModal-BXeCtTjU.js → TestEmailModal-7pUDYLrk.js} +7 -7
  101. package/dist/cdn/chunks/{TestEmailModal-BXeCtTjU.js.map → TestEmailModal-7pUDYLrk.js.map} +1 -1
  102. package/dist/cdn/chunks/{TestEmailPanel-CpZcpB9D.js → TestEmailPanel-DBWwMsH1.js} +2 -2
  103. package/dist/cdn/chunks/{TestEmailPanel-CpZcpB9D.js.map → TestEmailPanel-DBWwMsH1.js.map} +1 -1
  104. package/dist/cdn/chunks/{TitleEditor-Bv3SmSO6.js → TitleEditor-VAanUjPQ.js} +9 -8
  105. package/dist/cdn/chunks/TitleEditor-VAanUjPQ.js.map +1 -0
  106. package/dist/cdn/chunks/{Toolbar-BJKpJ2Mg.js → Toolbar-BlWVQRcA.js} +571 -571
  107. package/dist/cdn/chunks/{Toolbar-BJKpJ2Mg.js.map → Toolbar-BlWVQRcA.js.map} +1 -1
  108. package/dist/cdn/chunks/{TplModal-DDDUDMYC.js → TplModal-DDlR7mk3.js} +2 -2
  109. package/dist/cdn/chunks/{TplModal-DDDUDMYC.js.map → TplModal-DDlR7mk3.js.map} +1 -1
  110. package/dist/cdn/chunks/{VersionHistoryMenu-DSElv3Sv.js → VersionHistoryMenu-CZury5gU.js} +4 -4
  111. package/dist/cdn/chunks/{VersionHistoryMenu-DSElv3Sv.js.map → VersionHistoryMenu-CZury5gU.js.map} +1 -1
  112. package/dist/cdn/chunks/{VersionHistoryPanels-H2nuik1l.js → VersionHistoryPanels-DJDeaf1B.js} +2 -2
  113. package/dist/cdn/chunks/{VersionHistoryPanels-H2nuik1l.js.map → VersionHistoryPanels-DJDeaf1B.js.map} +1 -1
  114. package/dist/cdn/chunks/{VersionPreviewBanner-Whwxh55w.js → VersionPreviewBanner-C4Ji8nu4.js} +2 -2
  115. package/dist/cdn/chunks/{VersionPreviewBanner-Whwxh55w.js.map → VersionPreviewBanner-C4Ji8nu4.js.map} +1 -1
  116. package/dist/cdn/chunks/{WrapperBlock-jTqsuLnS.js → WrapperBlock-DRJnrgy-.js} +4 -4
  117. package/dist/cdn/chunks/{WrapperBlock-jTqsuLnS.js.map → WrapperBlock-DRJnrgy-.js.map} +1 -1
  118. package/dist/cdn/chunks/{blockTypeIcons-DMgLcuI8.js → blockTypeIcons-Cc6RJ27V.js} +2 -2
  119. package/dist/cdn/chunks/{blockTypeIcons-DMgLcuI8.js.map → blockTypeIcons-Cc6RJ27V.js.map} +1 -1
  120. package/dist/cdn/chunks/{composables-D0UYam2P.js → composables-Jc3uZuLs.js} +117 -117
  121. package/dist/cdn/chunks/{composables-D0UYam2P.js.map → composables-Jc3uZuLs.js.map} +1 -1
  122. package/dist/cdn/chunks/{createCloudRuntime-BdsclY8_.js → createCloudRuntime-C2Zs5F1O.js} +3 -3
  123. package/dist/cdn/chunks/{createCloudRuntime-BdsclY8_.js.map → createCloudRuntime-C2Zs5F1O.js.map} +1 -1
  124. package/dist/cdn/chunks/{editor-modal-CPbgthOv.js → editor-modal-erQEOHZN.js} +90 -90
  125. package/dist/cdn/chunks/{editor-modal-CPbgthOv.js.map → editor-modal-erQEOHZN.js.map} +1 -1
  126. package/dist/cdn/chunks/en-B6tLGRHq.js +1 -0
  127. package/dist/cdn/chunks/{extensions-Uh9vuFfK.js → extensions-DcMKZpzh.js} +4 -4
  128. package/dist/cdn/chunks/{extensions-Uh9vuFfK.js.map → extensions-DcMKZpzh.js.map} +1 -1
  129. package/dist/cdn/chunks/{icons-CSSMtbGK.js → icons-Da9GKjPx.js} +42 -42
  130. package/dist/cdn/chunks/{icons-CSSMtbGK.js.map → icons-Da9GKjPx.js.map} +1 -1
  131. package/dist/cdn/chunks/{normalizeMergeTagMarkup-oGhwVscw.js → normalizeMergeTagMarkup-cC32Ox6A.js} +23 -23
  132. package/dist/cdn/chunks/{normalizeMergeTagMarkup-oGhwVscw.js.map → normalizeMergeTagMarkup-cC32Ox6A.js.map} +1 -1
  133. package/dist/cdn/chunks/{preRenderCustomBlocks-C8k7tw98.js → preRenderCustomBlocks-f7GEKdvw.js} +4 -4
  134. package/dist/cdn/chunks/{preRenderCustomBlocks-C8k7tw98.js.map → preRenderCustomBlocks-f7GEKdvw.js.map} +1 -1
  135. package/dist/cdn/chunks/{sanitizeHtml-DYklmvgX.js → sanitizeHtml-WTfz9lZd.js} +2 -2
  136. package/dist/cdn/chunks/{sanitizeHtml-DYklmvgX.js.map → sanitizeHtml-WTfz9lZd.js.map} +1 -1
  137. package/dist/cdn/chunks/{socialIcons-BAiuHyJs.js → socialIcons-DeCYorUT.js} +493 -493
  138. package/dist/cdn/chunks/{socialIcons-BAiuHyJs.js.map → socialIcons-DeCYorUT.js.map} +1 -1
  139. package/dist/cdn/chunks/{src-Ddpm4HsS.js → src-8bYYJPCt.js} +237 -179
  140. package/dist/cdn/chunks/src-8bYYJPCt.js.map +1 -0
  141. package/dist/cdn/chunks/{src-DheBmnvF.js → src-A_cKeTM_.js} +263 -263
  142. package/dist/cdn/chunks/{src-DheBmnvF.js.map → src-A_cKeTM_.js.map} +1 -1
  143. package/dist/cdn/chunks/{src-CACM3o--.js → src-BQUv2CYU.js} +152 -152
  144. package/dist/cdn/chunks/{src-CACM3o--.js.map → src-BQUv2CYU.js.map} +1 -1
  145. package/dist/cdn/chunks/useLocalizedDisplay-aGfnO90D.js +33 -0
  146. package/dist/cdn/chunks/{useLocalizedDisplay-yXbRKNrs.js.map → useLocalizedDisplay-aGfnO90D.js.map} +1 -1
  147. package/dist/cdn/chunks/{useLogicTag-B7RpqVFQ.js → useLogicTag-DtYe8HIq.js} +2 -2
  148. package/dist/cdn/chunks/{useLogicTag-B7RpqVFQ.js.map → useLogicTag-DtYe8HIq.js.map} +1 -1
  149. package/dist/cdn/chunks/{useMergeTag-C-32ETjj.js → useMergeTag-B8ULmsnp.js} +2 -2
  150. package/dist/cdn/chunks/{useMergeTag-C-32ETjj.js.map → useMergeTag-B8ULmsnp.js.map} +1 -1
  151. package/dist/cdn/chunks/{withCurrentFont-D33ZXoWp.js → withCurrentFont-MK8ga9q9.js} +2 -2
  152. package/dist/cdn/chunks/{withCurrentFont-D33ZXoWp.js.map → withCurrentFont-MK8ga9q9.js.map} +1 -1
  153. package/dist/cdn/editor.js +262 -262
  154. package/dist/cdn/editor.js.map +1 -1
  155. package/dist/{check-ChQ0l8EQ.js → check-XMnOOIEC.js} +1 -1
  156. package/dist/{chevron-down-Bh6cp6PI.js → chevron-down-DmamTEWQ.js} +1 -1
  157. package/dist/{chevron-right-LUgdqdoW.js → chevron-right-BEFXOH27.js} +1 -1
  158. package/dist/{chevron-up-XsDeJxQN.js → chevron-up-Dw7woXj8.js} +1 -1
  159. package/dist/{circle-alert-lODfDsrj.js → circle-alert-BTKC9vkq.js} +1 -1
  160. package/dist/{clock-DrqFEZkT.js → clock-BVT5u2uG.js} +1 -1
  161. package/dist/{composables-BOP3ERRP.js → composables-XjYKaKhY.js} +13 -13
  162. package/dist/{createLucideIcon-Dw5e5gVE.js → createLucideIcon-CgDE3xAR.js} +5 -5
  163. package/dist/{editor-modal-B_2EAOjN.js → editor-modal-BeX6otLk.js} +15 -15
  164. package/dist/en-Do0SU6tR.js +1 -0
  165. package/dist/{extensions-DOLZkLzV.js → extensions-BJ184osp.js} +1 -1
  166. package/dist/{eye-DChfk0gi.js → eye-ByMgHeA_.js} +1 -1
  167. package/dist/{image--Hj2by1G.js → image-Ch8tR35K.js} +1 -1
  168. package/dist/{info-BbXgy82f.js → info-DzSD-Wpk.js} +1 -1
  169. package/dist/{link-C2_8yJno.js → link-oDn9AR2w.js} +1 -1
  170. package/dist/{list-DLGs2n0V.js → list-C5t07dp8.js} +1 -1
  171. package/dist/{loader-circle-BbDItE_O.js → loader-circle-k6xvKgUB.js} +1 -1
  172. package/dist/{message-circle-NAModq0p.js → message-circle-C23R6OJR.js} +1 -1
  173. package/dist/{package-BuzsfRyH.js → package-C90eQ7NU.js} +1 -1
  174. package/dist/{pencil-BTUUECH4.js → pencil-BK7GrQuA.js} +1 -1
  175. package/dist/{plus-Dm7DN65T.js → plus-Cr0Mis63.js} +1 -1
  176. package/dist/{refresh-cw-xMURqGWi.js → refresh-cw-_ZLOIEvA.js} +1 -1
  177. package/dist/{rotate-ccw-DqVcEIn5.js → rotate-ccw-CB5wsHwv.js} +1 -1
  178. package/dist/{sanitizeHtml-mKgNUdME.js → sanitizeHtml-2rjV0r-6.js} +1 -1
  179. package/dist/{search-Cfr3W44N.js → search-BmrQNox8.js} +1 -1
  180. package/dist/{send-CH1SrvyB.js → send-blAsIBBg.js} +1 -1
  181. package/dist/{smartphone-pAkvzjdI.js → smartphone-BPpWYrwV.js} +1 -1
  182. package/dist/{socialIcons-Dqr4DJOz.js → socialIcons-TFiOkpoU.js} +3 -3
  183. package/dist/{sparkles-CRO0cCnp.js → sparkles-OqIxrNp-.js} +1 -1
  184. package/dist/{square-CaQWMntx.js → square-BP-V7iT-.js} +1 -1
  185. package/dist/templatical-editor.js +29 -29
  186. package/dist/{text-align-start-BQ39AaRK.js → text-align-start-4mwX2o-F.js} +13 -13
  187. package/dist/{trash-BL5gEFHN.js → trash-B99WixTA.js} +1 -1
  188. package/dist/{triangle-alert-BYbKu7zZ.js → triangle-alert-CHMiDkHa.js} +1 -1
  189. package/dist/{upload-BhmL4Vqx.js → upload-Cp8o-hrN.js} +1 -1
  190. package/dist/{useScrollToBlock-C0Kapxdh.js → useScrollToBlock-B35ObCGK.js} +1 -1
  191. package/dist/{x-B7NZYzhx.js → x-BIBStNMS.js} +1 -1
  192. package/package.json +8 -8
  193. package/dist/cdn/chunks/ParagraphEditor-DDolH_Pf.js.map +0 -1
  194. package/dist/cdn/chunks/TitleEditor-Bv3SmSO6.js.map +0 -1
  195. package/dist/cdn/chunks/en-IYVryJRl.js +0 -1
  196. package/dist/cdn/chunks/src-Ddpm4HsS.js.map +0 -1
  197. package/dist/cdn/chunks/useLocalizedDisplay-yXbRKNrs.js +0 -33
  198. package/dist/en-DTtwco2Q.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"AiChatPanel-DciEt27y.js","names":["_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_unref","_toDisplayString","_createCommentVNode","_renderSlot","_sfc_main","_openBlock","_createElementBlock","_createVNode","AiPanelShell","_unref","_withCtx","_createCommentVNode","_createElementVNode","_Fragment","_renderList","_createBlock","_toDisplayString","_normalizeClass","_withDirectives","_vModelText","_createTextVNode","LoadingTrack","_sfc_main","defineComponent","openBlock","withCtx","watch","withDirectives","renderList","inject","renderSlot","createElementBlock","createTextVNode","unref","normalizeClass","createCommentVNode","createBlock","nextTick","createBaseVNode","toDisplayString","vModelText","computed","ref","Fragment","_plugin_vue_export_helper_default","Sparkles","CircleAlert","Paperclip","Square","FileText","Image","LoaderCircle","Send","Undo2","X","MessageSquarePlus","Redo2","UI_LOCALE_KEY","EDITOR_KEY","useI18n","languageName","secondaryBtnCompactClass","useTimeoutFn","useIntervalFn","LoadingTrack_default","aiErrorMessage","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","_hoisted_4$1","_hoisted_5$1","_hoisted_6$1","_hoisted_7$1","_hoisted_8$1","_hoisted_9$1","AiPanelShell_default","__emit","emit","__props","createVNode","_ctx","_cache","TYPES","validateChatAttachments","accepted","existing","errors","total","sum","file","added","reason","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","\"color\"","_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","_hoisted_23","_hoisted_24","_hoisted_25","_hoisted_26","_hoisted_27","_hoisted_28","_hoisted_29","_hoisted_30","_hoisted_31","_hoisted_32","_hoisted_33","_hoisted_34","_hoisted_35","AiChatPanel_default","props","editor","uiLocale","promptInput","composer","fileInput","attachments","attachmentErrors","dragDepth","canAttach","attach","result","files","keys","format","t","error","picked","input","event","isBusy","removeAttachment","index","isFileDrag","dragEnter","dragLeave","dragOver","drop","messagesContainer","visibleStarterCount","starters","messages","failureText","failure","pauseReveal","resumeReveal","startReveal","count","scrollToBottom","prompt","send","appliedLabel","item","itemFailure","toggleUndo","chooseStarter","starter","onKeydown","$event","attachment"],"sources":["../../../src/components/ai/AiPanelShell.vue","../../../src/components/ai/AiPanelShell.vue","../../../src/utils/aiAttachments.ts","../../../src/components/ai/AiChatPanel.vue","../../../src/components/ai/AiChatPanel.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Sparkles, X } from \"@lucide/vue\";\n\ndefineProps<{\n title: string;\n subtitle?: string;\n /** `ai-panel-chat`. */\n testid: string;\n closeLabel: string;\n}>();\n\nconst emit = defineEmits<{ (e: \"close\"): void }>();\n</script>\n\n<template>\n <div\n role=\"complementary\"\n :aria-label=\"title\"\n :data-testid=\"testid\"\n class=\"tpl-ai-sidebar tpl:absolute tpl:top-14 tpl:right-0 tpl:bottom-0 tpl:flex tpl:w-[360px] tpl:flex-col tpl:border-l tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg-elevated)]\"\n >\n <!-- The header names the panel an AI feature (EU AI Act Art. 50). -->\n <div\n class=\"tpl:flex tpl:items-start tpl:justify-between tpl:gap-2 tpl:border-b tpl:border-[var(--tpl-border)] tpl:px-4 tpl:py-3\"\n >\n <div class=\"tpl:flex tpl:min-w-0 tpl:flex-col tpl:gap-0.5\">\n <div\n class=\"tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]\"\n >\n <Sparkles :size=\"13\" :stroke-width=\"2\" aria-hidden=\"true\" />\n <span data-testid=\"ai-panel-title\">{{ title }}</span>\n </div>\n <p\n v-if=\"subtitle\"\n data-testid=\"ai-panel-subtitle\"\n class=\"tpl:m-0 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ subtitle }}\n </p>\n </div>\n <div class=\"tpl:flex tpl:items-center tpl:gap-1\">\n <slot name=\"actions\" />\n <button\n type=\"button\"\n data-testid=\"ai-panel-close\"\n class=\"tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:text-[var(--tpl-text-muted)]\"\n :aria-label=\"closeLabel\"\n :title=\"closeLabel\"\n @click=\"emit('close')\"\n >\n <X :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n <div class=\"tpl:relative tpl:flex tpl:min-h-0 tpl:flex-1 tpl:flex-col\">\n <slot />\n </div>\n <slot name=\"footer\" />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { Sparkles, X } from \"@lucide/vue\";\n\ndefineProps<{\n title: string;\n subtitle?: string;\n /** `ai-panel-chat`. */\n testid: string;\n closeLabel: string;\n}>();\n\nconst emit = defineEmits<{ (e: \"close\"): void }>();\n</script>\n\n<template>\n <div\n role=\"complementary\"\n :aria-label=\"title\"\n :data-testid=\"testid\"\n class=\"tpl-ai-sidebar tpl:absolute tpl:top-14 tpl:right-0 tpl:bottom-0 tpl:flex tpl:w-[360px] tpl:flex-col tpl:border-l tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg-elevated)]\"\n >\n <!-- The header names the panel an AI feature (EU AI Act Art. 50). -->\n <div\n class=\"tpl:flex tpl:items-start tpl:justify-between tpl:gap-2 tpl:border-b tpl:border-[var(--tpl-border)] tpl:px-4 tpl:py-3\"\n >\n <div class=\"tpl:flex tpl:min-w-0 tpl:flex-col tpl:gap-0.5\">\n <div\n class=\"tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]\"\n >\n <Sparkles :size=\"13\" :stroke-width=\"2\" aria-hidden=\"true\" />\n <span data-testid=\"ai-panel-title\">{{ title }}</span>\n </div>\n <p\n v-if=\"subtitle\"\n data-testid=\"ai-panel-subtitle\"\n class=\"tpl:m-0 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ subtitle }}\n </p>\n </div>\n <div class=\"tpl:flex tpl:items-center tpl:gap-1\">\n <slot name=\"actions\" />\n <button\n type=\"button\"\n data-testid=\"ai-panel-close\"\n class=\"tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:text-[var(--tpl-text-muted)]\"\n :aria-label=\"closeLabel\"\n :title=\"closeLabel\"\n @click=\"emit('close')\"\n >\n <X :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n <div class=\"tpl:relative tpl:flex tpl:min-h-0 tpl:flex-1 tpl:flex-col\">\n <slot />\n </div>\n <slot name=\"footer\" />\n </div>\n</template>\n","/** Chat file limits, matching the AI wire. */\nexport const AI_ATTACHMENTS_MAX = 4;\nexport const AI_ATTACHMENT_MAX_BYTES = 5 * 1024 * 1024;\nexport const AI_ATTACHMENTS_TOTAL_MAX_BYTES = 10 * 1024 * 1024;\nconst TYPES = new Set([\n \"image/png\",\n \"image/jpeg\",\n \"image/webp\",\n \"image/gif\",\n \"application/pdf\",\n]);\nexport function validateChatAttachments(\n existing: File[],\n added: File[],\n): {\n accepted: File[];\n errors: {\n name: string;\n reason: \"tooMany\" | \"tooLarge\" | \"totalTooLarge\" | \"wrongType\";\n }[];\n} {\n const accepted = [...existing];\n const errors: ReturnType<typeof validateChatAttachments>[\"errors\"] = [];\n let total = existing.reduce((sum, file) => sum + file.size, 0);\n for (const file of added) {\n const reason =\n accepted.length >= AI_ATTACHMENTS_MAX\n ? \"tooMany\"\n : !TYPES.has(file.type)\n ? \"wrongType\"\n : file.size > AI_ATTACHMENT_MAX_BYTES\n ? \"tooLarge\"\n : total + file.size > AI_ATTACHMENTS_TOTAL_MAX_BYTES\n ? \"totalTooLarge\"\n : null;\n if (reason) errors.push({ name: file.name, reason });\n else {\n accepted.push(file);\n total += file.size;\n }\n }\n return { accepted, errors };\n}\n","<script setup lang=\"ts\">\nimport {\n CircleAlert,\n FileText,\n Image,\n Paperclip,\n X,\n LoaderCircle,\n MessageSquarePlus,\n Redo2,\n Send,\n Sparkles,\n Square,\n Undo2,\n} from \"@lucide/vue\";\nimport { computed, inject, nextTick, ref, watch } from \"vue\";\nimport { useIntervalFn, useTimeoutFn } from \"@vueuse/core\";\nimport LoadingTrack from \"../LoadingTrack.vue\";\nimport AiPanelShell from \"./AiPanelShell.vue\";\nimport type {\n AiChatItem,\n UseAiFeatureReturn,\n} from \"../../composables/useAiFeature\";\nimport { useI18n } from \"../../composables/useI18n\";\nimport { secondaryBtnCompactClass } from \"../../constants/styleConstants\";\nimport { EDITOR_KEY, UI_LOCALE_KEY } from \"../../keys\";\nimport { validateChatAttachments } from \"../../utils/aiAttachments\";\nimport { languageName } from \"../../utils/languageName\";\nimport { aiErrorMessage } from \"../../utils/aiErrors\";\n\nconst props = defineProps<{ feature: UseAiFeatureReturn }>();\nconst emit = defineEmits<{ (e: \"close\"): void }>();\n\nconst { t, format } = useI18n();\nconst editor = inject(EDITOR_KEY, null);\nconst uiLocale = inject(UI_LOCALE_KEY, undefined);\n\nconst promptInput = ref(\"\");\nconst composer = ref<HTMLTextAreaElement | null>(null);\nconst fileInput = ref<HTMLInputElement | null>(null);\nconst attachments = ref<File[]>([]);\nconst attachmentErrors = ref<string[]>([]);\nconst dragDepth = ref(0);\nwatch(\n () => props.feature.templateSession.value,\n () => {\n promptInput.value = \"\";\n attachments.value = [];\n attachmentErrors.value = [];\n dragDepth.value = 0;\n },\n { flush: \"sync\" },\n);\nconst canAttach = computed(() => props.feature.has(\"chatAttachments\"));\nfunction attach(files: File[]): void {\n const result = validateChatAttachments(attachments.value, files);\n attachments.value = result.accepted;\n const keys = {\n tooMany: \"attachTooMany\",\n tooLarge: \"attachTooLarge\",\n totalTooLarge: \"attachTotalTooLarge\",\n wrongType: \"attachWrongType\",\n } as const;\n attachmentErrors.value = result.errors.map((error) =>\n format(t.ai.chat[keys[error.reason]], { name: error.name }),\n );\n}\nfunction picked(event: Event): void {\n const input = event.target as HTMLInputElement;\n if (!isBusy.value && canAttach.value) attach(Array.from(input.files ?? []));\n input.value = \"\";\n}\nfunction removeAttachment(index: number): void {\n if (isBusy.value) return;\n attachments.value.splice(index, 1);\n attachmentErrors.value = [];\n}\nfunction isFileDrag(event: DragEvent): boolean {\n return Array.from(event.dataTransfer?.types ?? []).includes(\"Files\");\n}\nfunction dragEnter(event: DragEvent): void {\n if (!canAttach.value || isBusy.value || !isFileDrag(event)) return;\n event.preventDefault();\n dragDepth.value++;\n}\nfunction dragLeave(event: DragEvent): void {\n if (!isFileDrag(event)) return;\n dragDepth.value = Math.max(0, dragDepth.value - 1);\n}\nfunction dragOver(event: DragEvent): void {\n if (canAttach.value && isFileDrag(event)) event.preventDefault();\n}\nfunction drop(event: DragEvent): void {\n dragDepth.value = 0;\n if (!canAttach.value || !isFileDrag(event)) return;\n event.preventDefault();\n if (!isBusy.value) attach(Array.from(event.dataTransfer?.files ?? []));\n}\nwatch(\n () => props.feature.importQueue.value,\n (files) => {\n if (!canAttach.value || !files.length) return;\n attach(files);\n if (!promptInput.value.trim()) promptInput.value = t.ai.import.prompt;\n props.feature.importQueue.value = [];\n void nextTick(() => composer.value?.focus());\n },\n { immediate: true },\n);\nconst messagesContainer = ref<HTMLElement | null>(null);\nconst visibleStarterCount = ref(0);\n\nconst starters = computed(() =>\n props.feature.isTemplateEmpty.value\n ? [\n t.ai.starters.emptyWelcome,\n t.ai.starters.emptyLaunch,\n t.ai.starters.emptyNewsletter,\n ]\n : [\n t.ai.starters.filledShorten,\n t.ai.starters.filledFriendlier,\n t.ai.starters.filledDates,\n t.ai.starters.filledCta,\n ],\n);\nconst messages = computed(() => props.feature.messages.value);\nconst isBusy = computed(() => props.feature.isRunning.value);\nconst failureText = computed(() => {\n const failure = props.feature.failure.value;\n return failure\n ? aiErrorMessage(\n failure.error,\n t.ai.errors,\n format,\n uiLocale,\n failure.context,\n )\n : \"\";\n});\n\nconst { pause: pauseReveal, resume: resumeReveal } = useIntervalFn(\n () => {\n if (visibleStarterCount.value < starters.value.length) {\n visibleStarterCount.value++;\n } else {\n pauseReveal();\n }\n },\n 150,\n { immediate: false },\n);\nconst { start: startReveal } = useTimeoutFn(() => resumeReveal(), 100, {\n immediate: false,\n});\n\nwatch(\n () => starters.value.length,\n (count) => {\n pauseReveal();\n visibleStarterCount.value = 0;\n if (count > 0) startReveal();\n },\n { immediate: true },\n);\n\nfunction scrollToBottom(): void {\n void nextTick(() => {\n if (messagesContainer.value) {\n messagesContainer.value.scrollTop = messagesContainer.value.scrollHeight;\n }\n });\n}\n\nwatch(() => messages.value.length, scrollToBottom);\n\n// A failed turn gives its prompt back (D15).\nwatch(\n () =>\n [\n props.feature.failedPrompt.value,\n props.feature.failedAttachments.value,\n ] as const,\n ([prompt, files]) => {\n if (prompt) {\n promptInput.value = prompt;\n attachments.value = [...files];\n }\n },\n { immediate: true },\n);\n\nasync function send(): Promise<void> {\n const prompt = promptInput.value.trim();\n if (!prompt || isBusy.value) return;\n const files = [...attachments.value];\n promptInput.value = \"\";\n attachments.value = [];\n attachmentErrors.value = [];\n scrollToBottom();\n await props.feature.send(prompt, files);\n scrollToBottom();\n}\n\nfunction appliedLabel(item: AiChatItem): string {\n if (item.undone) return t.ai.chat.undone;\n return item.operationCount === 1\n ? t.ai.chat.appliedChange\n : format(t.ai.chat.appliedChanges, { count: item.operationCount });\n}\n\nfunction itemFailure(item: AiChatItem): string {\n return item.failure\n ? aiErrorMessage(\n item.failure.error,\n t.ai.errors,\n format,\n uiLocale,\n item.failure.context,\n )\n : \"\";\n}\n\nfunction toggleUndo(item: AiChatItem): void {\n if (item.undone) void props.feature.redoMessage(item.id);\n else void props.feature.undoMessage(item.id);\n}\n\nfunction chooseStarter(starter: string): void {\n pauseReveal();\n promptInput.value = starter;\n void send();\n}\n\nfunction onKeydown(event: KeyboardEvent): void {\n if (event.isComposing || event.keyCode === 229) return;\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n void send();\n }\n}\n</script>\n\n<template>\n <div\n class=\"tpl:contents\"\n data-testid=\"ai-chat-dropzone\"\n @dragenter=\"dragEnter\"\n @dragleave=\"dragLeave\"\n @dragover=\"dragOver\"\n @drop=\"drop\"\n >\n <AiPanelShell\n :title=\"t.ai.chat.title\"\n :subtitle=\"t.ai.chat.notice\"\n testid=\"ai-panel-chat\"\n :close-label=\"t.ai.chat.close\"\n @close=\"emit('close')\"\n >\n <template #actions>\n <button\n v-if=\"feature.canClear && messages.length > 0\"\n type=\"button\"\n data-testid=\"ai-chat-new\"\n class=\"tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:text-[var(--tpl-text-muted)] tpl:disabled:opacity-40\"\n :aria-label=\"t.ai.chat.newChat\"\n :title=\"t.ai.chat.newChat\"\n :disabled=\"isBusy\"\n @click=\"feature.newChat()\"\n >\n <MessageSquarePlus :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </template>\n\n <div\n v-if=\"canAttach && dragDepth > 0 && !isBusy\"\n data-testid=\"ai-chat-drop-hint\"\n class=\"tpl:absolute tpl:inset-0 tpl:z-20 tpl:flex tpl:items-center tpl:justify-center tpl:border-2 tpl:border-dashed tpl:border-[var(--tpl-primary)] tpl:bg-[var(--tpl-bg-elevated)] tpl:p-4 tpl:text-center tpl:text-sm tpl:text-[var(--tpl-primary)] tpl:pointer-events-none\"\n >\n {{ t.ai.chat.dropHint }}\n </div>\n <div\n ref=\"messagesContainer\"\n class=\"tpl:flex-1 tpl:overflow-y-auto tpl:p-4\"\n >\n <div\n v-if=\"feature.isLoadingHistory.value\"\n class=\"tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center\"\n >\n <LoaderCircle\n class=\"tpl-spinner tpl:text-[var(--tpl-text-muted)]\"\n :size=\"24\"\n :stroke-width=\"2\"\n aria-hidden=\"true\"\n />\n <p class=\"tpl:text-sm tpl:text-[var(--tpl-text-muted)]\">\n {{ t.ai.chat.loadingHistory }}\n </p>\n </div>\n\n <div\n v-else-if=\"messages.length === 0\"\n class=\"tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center\"\n >\n <Sparkles\n :size=\"32\"\n :stroke-width=\"1.5\"\n class=\"tpl:text-[var(--tpl-text-dim)]\"\n aria-hidden=\"true\"\n />\n <p\n class=\"tpl:max-w-[240px] tpl:text-sm tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ t.ai.chat.placeholder }}\n </p>\n </div>\n\n <!-- Text is interpolated, never `v-html`. -->\n <div v-else class=\"tpl:flex tpl:flex-col tpl:gap-4\">\n <div\n v-for=\"item in messages\"\n :key=\"item.id\"\n class=\"tpl:flex tpl:flex-col tpl:gap-2\"\n >\n <span\n v-if=\"typeof item.locale === 'string'\"\n data-testid=\"ai-chat-language\"\n class=\"tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ languageName(item.locale) }}\n </span>\n <div\n v-if=\"item.role === 'user'\"\n data-testid=\"ai-chat-prompt\"\n class=\"tpl:self-end tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3.5 tpl:py-2.5 tpl:text-sm tpl:whitespace-pre-wrap\"\n style=\"\n background-color: var(--tpl-primary-light);\n color: var(--tpl-text);\n max-width: 85%;\n box-shadow: var(--tpl-shadow);\n \"\n >\n {{ item.text }}\n <span\n v-for=\"(attachment, index) in item.attachments\"\n :key=\"index\"\n data-testid=\"ai-chat-history-attachment\"\n class=\"tpl:mt-1 tpl:flex tpl:items-center tpl:gap-1 tpl:rounded tpl:border tpl:border-[var(--tpl-border)] tpl:px-2 tpl:py-1 tpl:text-xs\"\n >\n <FileText\n v-if=\"attachment.kind === 'pdf'\"\n :size=\"12\"\n aria-hidden=\"true\"\n /><Image v-else :size=\"12\" aria-hidden=\"true\" />{{\n attachment.name\n }}\n </span>\n </div>\n\n <div v-else class=\"tpl:flex tpl:flex-col tpl:gap-2\">\n <LoadingTrack\n v-if=\"item.text === '' && item.status === 'streaming'\"\n />\n <div\n v-else-if=\"item.text !== ''\"\n data-testid=\"ai-chat-reply\"\n class=\"tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3.5 tpl:py-2.5 tpl:text-sm tpl:whitespace-pre-wrap\"\n style=\"\n max-width: 85%;\n background-color: var(--tpl-bg);\n color: var(--tpl-text);\n box-shadow: var(--tpl-shadow);\n \"\n >\n {{ item.text }}\n </div>\n <div\n v-if=\"item.operationCount > 0\"\n data-testid=\"ai-chat-applied\"\n class=\"tpl:flex tpl:items-center tpl:gap-2 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n <span>{{ appliedLabel(item) }}</span>\n <button\n v-if=\"item.undone ? item.canRedo : item.canUndo\"\n type=\"button\"\n data-testid=\"ai-chat-undo\"\n :class=\"secondaryBtnCompactClass\"\n :disabled=\"isBusy\"\n @click=\"toggleUndo(item)\"\n >\n <Redo2\n v-if=\"item.undone\"\n :size=\"12\"\n :stroke-width=\"2\"\n aria-hidden=\"true\"\n />\n <Undo2\n v-else\n :size=\"12\"\n :stroke-width=\"2\"\n aria-hidden=\"true\"\n />\n {{ item.undone ? t.ai.chat.redo : t.ai.chat.undo }}\n </button>\n </div>\n <p\n v-if=\"item.failure\"\n role=\"alert\"\n data-testid=\"ai-chat-item-error\"\n class=\"tpl:m-0 tpl:text-xs tpl:text-[var(--tpl-danger)]\"\n >\n {{ itemFailure(item) }}\n </p>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Starter prompts, over the empty state (D21). -->\n <div\n v-if=\"messages.length === 0 && starters.length > 0\"\n class=\"tpl:absolute tpl:right-0 tpl:bottom-0 tpl:left-0 tpl:z-10 tpl:px-3 tpl:pb-3\"\n style=\"\n background-color: color-mix(in srgb, var(--tpl-bg) 50%, transparent);\n backdrop-filter: blur(2px);\n \"\n >\n <div class=\"tpl:flex tpl:flex-col tpl:gap-1.5\">\n <button\n v-for=\"(starter, index) in starters\"\n :key=\"index\"\n type=\"button\"\n data-testid=\"ai-chat-starter\"\n class=\"tpl-starter-btn tpl:cursor-pointer tpl:rounded-[var(--tpl-radius-sm)] tpl:border tpl:px-3 tpl:py-2 tpl:text-left tpl:text-xs tpl:leading-snug tpl:transition-all tpl:duration-300 tpl:ease-out\"\n :class=\"\n starters.length - 1 - index < visibleStarterCount\n ? 'tpl:translate-y-0 tpl:opacity-100'\n : 'tpl:pointer-events-none tpl:-translate-y-2 tpl:opacity-0'\n \"\n style=\"\n border-color: var(--tpl-border);\n color: var(--tpl-primary);\n background-color: var(--tpl-bg);\n box-shadow: var(--tpl-shadow);\n \"\n @click=\"chooseStarter(starter)\"\n >\n {{ starter }}\n </button>\n </div>\n </div>\n\n <template #footer>\n <div class=\"tpl:border-t tpl:p-3 tpl:border-[var(--tpl-border)]\">\n <template v-if=\"canAttach\">\n <input\n ref=\"fileInput\"\n data-testid=\"ai-chat-files\"\n type=\"file\"\n multiple\n accept=\"image/png,image/jpeg,image/webp,image/gif,application/pdf\"\n hidden\n :disabled=\"isBusy\"\n @change=\"picked\"\n />\n <div\n v-if=\"attachments.length\"\n class=\"tpl:mb-2 tpl:flex tpl:flex-wrap tpl:gap-1\"\n >\n <span\n v-for=\"(file, index) in attachments\"\n :key=\"index\"\n data-testid=\"ai-chat-attachment\"\n class=\"tpl:flex tpl:max-w-full tpl:items-center tpl:gap-1 tpl:rounded tpl:border tpl:border-[var(--tpl-border)] tpl:px-2 tpl:py-1 tpl:text-xs tpl:text-[var(--tpl-text)]\"\n >\n <FileText\n v-if=\"file.type === 'application/pdf'\"\n :size=\"12\"\n aria-hidden=\"true\"\n /><Image v-else :size=\"12\" aria-hidden=\"true\" />\n <span class=\"tpl:truncate\">{{ file.name }}</span>\n <button\n type=\"button\"\n :aria-label=\"\n format(t.ai.chat.removeAttachment, { name: file.name })\n \"\n :disabled=\"isBusy\"\n class=\"tpl:shrink-0 tpl:rounded tpl:p-0.5 tpl:disabled:opacity-40\"\n @click=\"removeAttachment(index)\"\n >\n <X :size=\"12\" aria-hidden=\"true\" />\n </button>\n </span>\n </div>\n <p\n v-if=\"attachments.length\"\n class=\"tpl:mb-2 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ t.ai.import.placeholderNote }}\n </p>\n <div\n aria-live=\"polite\"\n class=\"tpl:text-xs tpl:text-[var(--tpl-danger)]\"\n >\n <p\n v-for=\"(error, index) in attachmentErrors\"\n :key=\"index\"\n class=\"tpl:mb-2\"\n >\n {{ error }}\n </p>\n </div>\n </template>\n <div\n v-if=\"feature.keptYourVersion.value\"\n role=\"status\"\n class=\"tpl:mb-2 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n <p>{{ t.ai.chat.keptYourVersion }}</p>\n <button\n type=\"button\"\n :disabled=\"isBusy\"\n :class=\"secondaryBtnCompactClass\"\n @click=\"feature.reloadTemplate()\"\n >\n {{ t.ai.chat.reload }}\n </button>\n </div>\n <div\n v-if=\"failureText\"\n role=\"alert\"\n data-testid=\"ai-chat-error\"\n class=\"tpl:mx-3 tpl:mb-2 tpl:flex tpl:items-start tpl:gap-2 tpl:rounded-lg tpl:px-3 tpl:py-2 tpl:text-xs\"\n style=\"\n background-color: var(--tpl-danger-light);\n color: var(--tpl-danger);\n \"\n >\n <CircleAlert\n :size=\"14\"\n :stroke-width=\"2\"\n class=\"tpl:mt-0.5 tpl:shrink-0\"\n aria-hidden=\"true\"\n />\n <span>{{ failureText }}</span>\n </div>\n <div\n class=\"tpl-ai-input-wrapper tpl-focus-ring-host tpl:flex tpl:flex-col tpl:gap-2 tpl:rounded-[var(--tpl-radius)] tpl:border tpl:px-3 tpl:py-2 tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)]\"\n >\n <p\n v-if=\"editor?.activeLocale?.value\"\n data-testid=\"ai-active-language\"\n class=\"tpl:text-xs tpl:text-[var(--tpl-chrome-text-dim)]\"\n >\n {{\n format(t.localization.aiActiveLanguage, {\n language: languageName(editor.activeLocale.value),\n })\n }}\n </p>\n <textarea\n ref=\"composer\"\n v-model=\"promptInput\"\n data-testid=\"ai-chat-input\"\n class=\"tpl:max-h-32 tpl:min-h-[44px] tpl:w-full tpl:resize-none tpl:border-none tpl:bg-transparent tpl:font-sans tpl:text-sm tpl:outline-none tpl:text-[var(--tpl-text)]\"\n :placeholder=\"t.ai.chat.inputPlaceholder\"\n :aria-label=\"t.ai.chat.inputPlaceholder\"\n :disabled=\"isBusy\"\n maxlength=\"4000\"\n rows=\"3\"\n @keydown=\"onKeydown\"\n />\n <div class=\"tpl:flex tpl:items-center tpl:justify-between\">\n <button\n v-if=\"canAttach\"\n type=\"button\"\n :aria-label=\"t.ai.chat.attach\"\n :title=\"t.ai.chat.attach\"\n :disabled=\"isBusy\"\n class=\"tpl:-ml-1.5 tpl:shrink-0 tpl:rounded-md tpl:p-1.5 tpl:text-[var(--tpl-text-muted)] tpl:disabled:opacity-40\"\n @click=\"fileInput?.click()\"\n >\n <Paperclip :size=\"16\" aria-hidden=\"true\" />\n </button>\n <button\n v-if=\"isBusy\"\n type=\"button\"\n data-testid=\"ai-chat-stop\"\n class=\"tpl-ai-send-btn tpl:ml-auto tpl:-mr-1.5 tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-center tpl:rounded-md tpl:p-1.5 tpl:transition-all tpl:text-[var(--tpl-primary)]\"\n :aria-label=\"t.ai.chat.stop\"\n :title=\"t.ai.chat.stop\"\n @click=\"feature.stop()\"\n >\n <Square :size=\"16\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n <button\n v-else\n type=\"button\"\n data-testid=\"ai-chat-send\"\n class=\"tpl-ai-send-btn tpl:ml-auto tpl:-mr-1.5 tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-center tpl:rounded-md tpl:p-1.5 tpl:transition-all tpl:disabled:opacity-40 tpl:text-[var(--tpl-primary)]\"\n :aria-label=\"t.ai.chat.send\"\n :title=\"t.ai.chat.send\"\n :disabled=\"!promptInput.trim()\"\n @click=\"send\"\n >\n <Send :size=\"16\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n <p\n class=\"tpl:m-0 tpl:px-1 tpl:pt-2 tpl:text-center tpl:text-[10px] tpl:text-[var(--tpl-text-dim)]\"\n >\n {{ t.ai.chat.disclaimer }}\n </p>\n </div>\n </template>\n </AiPanelShell>\n </div>\n</template>\n\n<style scoped>\n.tpl-ai-input-wrapper:focus-within {\n border-color: var(--tpl-primary);\n box-shadow: var(--tpl-ring);\n}\n\n.tpl-ai-send-btn:not(:disabled):hover {\n transform: scale(1.05);\n}\n\n.tpl-starter-btn:hover {\n border-color: var(--tpl-primary) !important;\n background-color: var(--tpl-primary-light) !important;\n}\n</style>\n","<script setup lang=\"ts\">\nimport {\n CircleAlert,\n FileText,\n Image,\n Paperclip,\n X,\n LoaderCircle,\n MessageSquarePlus,\n Redo2,\n Send,\n Sparkles,\n Square,\n Undo2,\n} from \"@lucide/vue\";\nimport { computed, inject, nextTick, ref, watch } from \"vue\";\nimport { useIntervalFn, useTimeoutFn } from \"@vueuse/core\";\nimport LoadingTrack from \"../LoadingTrack.vue\";\nimport AiPanelShell from \"./AiPanelShell.vue\";\nimport type {\n AiChatItem,\n UseAiFeatureReturn,\n} from \"../../composables/useAiFeature\";\nimport { useI18n } from \"../../composables/useI18n\";\nimport { secondaryBtnCompactClass } from \"../../constants/styleConstants\";\nimport { EDITOR_KEY, UI_LOCALE_KEY } from \"../../keys\";\nimport { validateChatAttachments } from \"../../utils/aiAttachments\";\nimport { languageName } from \"../../utils/languageName\";\nimport { aiErrorMessage } from \"../../utils/aiErrors\";\n\nconst props = defineProps<{ feature: UseAiFeatureReturn }>();\nconst emit = defineEmits<{ (e: \"close\"): void }>();\n\nconst { t, format } = useI18n();\nconst editor = inject(EDITOR_KEY, null);\nconst uiLocale = inject(UI_LOCALE_KEY, undefined);\n\nconst promptInput = ref(\"\");\nconst composer = ref<HTMLTextAreaElement | null>(null);\nconst fileInput = ref<HTMLInputElement | null>(null);\nconst attachments = ref<File[]>([]);\nconst attachmentErrors = ref<string[]>([]);\nconst dragDepth = ref(0);\nwatch(\n () => props.feature.templateSession.value,\n () => {\n promptInput.value = \"\";\n attachments.value = [];\n attachmentErrors.value = [];\n dragDepth.value = 0;\n },\n { flush: \"sync\" },\n);\nconst canAttach = computed(() => props.feature.has(\"chatAttachments\"));\nfunction attach(files: File[]): void {\n const result = validateChatAttachments(attachments.value, files);\n attachments.value = result.accepted;\n const keys = {\n tooMany: \"attachTooMany\",\n tooLarge: \"attachTooLarge\",\n totalTooLarge: \"attachTotalTooLarge\",\n wrongType: \"attachWrongType\",\n } as const;\n attachmentErrors.value = result.errors.map((error) =>\n format(t.ai.chat[keys[error.reason]], { name: error.name }),\n );\n}\nfunction picked(event: Event): void {\n const input = event.target as HTMLInputElement;\n if (!isBusy.value && canAttach.value) attach(Array.from(input.files ?? []));\n input.value = \"\";\n}\nfunction removeAttachment(index: number): void {\n if (isBusy.value) return;\n attachments.value.splice(index, 1);\n attachmentErrors.value = [];\n}\nfunction isFileDrag(event: DragEvent): boolean {\n return Array.from(event.dataTransfer?.types ?? []).includes(\"Files\");\n}\nfunction dragEnter(event: DragEvent): void {\n if (!canAttach.value || isBusy.value || !isFileDrag(event)) return;\n event.preventDefault();\n dragDepth.value++;\n}\nfunction dragLeave(event: DragEvent): void {\n if (!isFileDrag(event)) return;\n dragDepth.value = Math.max(0, dragDepth.value - 1);\n}\nfunction dragOver(event: DragEvent): void {\n if (canAttach.value && isFileDrag(event)) event.preventDefault();\n}\nfunction drop(event: DragEvent): void {\n dragDepth.value = 0;\n if (!canAttach.value || !isFileDrag(event)) return;\n event.preventDefault();\n if (!isBusy.value) attach(Array.from(event.dataTransfer?.files ?? []));\n}\nwatch(\n () => props.feature.importQueue.value,\n (files) => {\n if (!canAttach.value || !files.length) return;\n attach(files);\n if (!promptInput.value.trim()) promptInput.value = t.ai.import.prompt;\n props.feature.importQueue.value = [];\n void nextTick(() => composer.value?.focus());\n },\n { immediate: true },\n);\nconst messagesContainer = ref<HTMLElement | null>(null);\nconst visibleStarterCount = ref(0);\n\nconst starters = computed(() =>\n props.feature.isTemplateEmpty.value\n ? [\n t.ai.starters.emptyWelcome,\n t.ai.starters.emptyLaunch,\n t.ai.starters.emptyNewsletter,\n ]\n : [\n t.ai.starters.filledShorten,\n t.ai.starters.filledFriendlier,\n t.ai.starters.filledDates,\n t.ai.starters.filledCta,\n ],\n);\nconst messages = computed(() => props.feature.messages.value);\nconst isBusy = computed(() => props.feature.isRunning.value);\nconst failureText = computed(() => {\n const failure = props.feature.failure.value;\n return failure\n ? aiErrorMessage(\n failure.error,\n t.ai.errors,\n format,\n uiLocale,\n failure.context,\n )\n : \"\";\n});\n\nconst { pause: pauseReveal, resume: resumeReveal } = useIntervalFn(\n () => {\n if (visibleStarterCount.value < starters.value.length) {\n visibleStarterCount.value++;\n } else {\n pauseReveal();\n }\n },\n 150,\n { immediate: false },\n);\nconst { start: startReveal } = useTimeoutFn(() => resumeReveal(), 100, {\n immediate: false,\n});\n\nwatch(\n () => starters.value.length,\n (count) => {\n pauseReveal();\n visibleStarterCount.value = 0;\n if (count > 0) startReveal();\n },\n { immediate: true },\n);\n\nfunction scrollToBottom(): void {\n void nextTick(() => {\n if (messagesContainer.value) {\n messagesContainer.value.scrollTop = messagesContainer.value.scrollHeight;\n }\n });\n}\n\nwatch(() => messages.value.length, scrollToBottom);\n\n// A failed turn gives its prompt back (D15).\nwatch(\n () =>\n [\n props.feature.failedPrompt.value,\n props.feature.failedAttachments.value,\n ] as const,\n ([prompt, files]) => {\n if (prompt) {\n promptInput.value = prompt;\n attachments.value = [...files];\n }\n },\n { immediate: true },\n);\n\nasync function send(): Promise<void> {\n const prompt = promptInput.value.trim();\n if (!prompt || isBusy.value) return;\n const files = [...attachments.value];\n promptInput.value = \"\";\n attachments.value = [];\n attachmentErrors.value = [];\n scrollToBottom();\n await props.feature.send(prompt, files);\n scrollToBottom();\n}\n\nfunction appliedLabel(item: AiChatItem): string {\n if (item.undone) return t.ai.chat.undone;\n return item.operationCount === 1\n ? t.ai.chat.appliedChange\n : format(t.ai.chat.appliedChanges, { count: item.operationCount });\n}\n\nfunction itemFailure(item: AiChatItem): string {\n return item.failure\n ? aiErrorMessage(\n item.failure.error,\n t.ai.errors,\n format,\n uiLocale,\n item.failure.context,\n )\n : \"\";\n}\n\nfunction toggleUndo(item: AiChatItem): void {\n if (item.undone) void props.feature.redoMessage(item.id);\n else void props.feature.undoMessage(item.id);\n}\n\nfunction chooseStarter(starter: string): void {\n pauseReveal();\n promptInput.value = starter;\n void send();\n}\n\nfunction onKeydown(event: KeyboardEvent): void {\n if (event.isComposing || event.keyCode === 229) return;\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n void send();\n }\n}\n</script>\n\n<template>\n <div\n class=\"tpl:contents\"\n data-testid=\"ai-chat-dropzone\"\n @dragenter=\"dragEnter\"\n @dragleave=\"dragLeave\"\n @dragover=\"dragOver\"\n @drop=\"drop\"\n >\n <AiPanelShell\n :title=\"t.ai.chat.title\"\n :subtitle=\"t.ai.chat.notice\"\n testid=\"ai-panel-chat\"\n :close-label=\"t.ai.chat.close\"\n @close=\"emit('close')\"\n >\n <template #actions>\n <button\n v-if=\"feature.canClear && messages.length > 0\"\n type=\"button\"\n data-testid=\"ai-chat-new\"\n class=\"tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:text-[var(--tpl-text-muted)] tpl:disabled:opacity-40\"\n :aria-label=\"t.ai.chat.newChat\"\n :title=\"t.ai.chat.newChat\"\n :disabled=\"isBusy\"\n @click=\"feature.newChat()\"\n >\n <MessageSquarePlus :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </template>\n\n <div\n v-if=\"canAttach && dragDepth > 0 && !isBusy\"\n data-testid=\"ai-chat-drop-hint\"\n class=\"tpl:absolute tpl:inset-0 tpl:z-20 tpl:flex tpl:items-center tpl:justify-center tpl:border-2 tpl:border-dashed tpl:border-[var(--tpl-primary)] tpl:bg-[var(--tpl-bg-elevated)] tpl:p-4 tpl:text-center tpl:text-sm tpl:text-[var(--tpl-primary)] tpl:pointer-events-none\"\n >\n {{ t.ai.chat.dropHint }}\n </div>\n <div\n ref=\"messagesContainer\"\n class=\"tpl:flex-1 tpl:overflow-y-auto tpl:p-4\"\n >\n <div\n v-if=\"feature.isLoadingHistory.value\"\n class=\"tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center\"\n >\n <LoaderCircle\n class=\"tpl-spinner tpl:text-[var(--tpl-text-muted)]\"\n :size=\"24\"\n :stroke-width=\"2\"\n aria-hidden=\"true\"\n />\n <p class=\"tpl:text-sm tpl:text-[var(--tpl-text-muted)]\">\n {{ t.ai.chat.loadingHistory }}\n </p>\n </div>\n\n <div\n v-else-if=\"messages.length === 0\"\n class=\"tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center\"\n >\n <Sparkles\n :size=\"32\"\n :stroke-width=\"1.5\"\n class=\"tpl:text-[var(--tpl-text-dim)]\"\n aria-hidden=\"true\"\n />\n <p\n class=\"tpl:max-w-[240px] tpl:text-sm tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ t.ai.chat.placeholder }}\n </p>\n </div>\n\n <!-- Text is interpolated, never `v-html`. -->\n <div v-else class=\"tpl:flex tpl:flex-col tpl:gap-4\">\n <div\n v-for=\"item in messages\"\n :key=\"item.id\"\n class=\"tpl:flex tpl:flex-col tpl:gap-2\"\n >\n <span\n v-if=\"typeof item.locale === 'string'\"\n data-testid=\"ai-chat-language\"\n class=\"tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ languageName(item.locale) }}\n </span>\n <div\n v-if=\"item.role === 'user'\"\n data-testid=\"ai-chat-prompt\"\n class=\"tpl:self-end tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3.5 tpl:py-2.5 tpl:text-sm tpl:whitespace-pre-wrap\"\n style=\"\n background-color: var(--tpl-primary-light);\n color: var(--tpl-text);\n max-width: 85%;\n box-shadow: var(--tpl-shadow);\n \"\n >\n {{ item.text }}\n <span\n v-for=\"(attachment, index) in item.attachments\"\n :key=\"index\"\n data-testid=\"ai-chat-history-attachment\"\n class=\"tpl:mt-1 tpl:flex tpl:items-center tpl:gap-1 tpl:rounded tpl:border tpl:border-[var(--tpl-border)] tpl:px-2 tpl:py-1 tpl:text-xs\"\n >\n <FileText\n v-if=\"attachment.kind === 'pdf'\"\n :size=\"12\"\n aria-hidden=\"true\"\n /><Image v-else :size=\"12\" aria-hidden=\"true\" />{{\n attachment.name\n }}\n </span>\n </div>\n\n <div v-else class=\"tpl:flex tpl:flex-col tpl:gap-2\">\n <LoadingTrack\n v-if=\"item.text === '' && item.status === 'streaming'\"\n />\n <div\n v-else-if=\"item.text !== ''\"\n data-testid=\"ai-chat-reply\"\n class=\"tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3.5 tpl:py-2.5 tpl:text-sm tpl:whitespace-pre-wrap\"\n style=\"\n max-width: 85%;\n background-color: var(--tpl-bg);\n color: var(--tpl-text);\n box-shadow: var(--tpl-shadow);\n \"\n >\n {{ item.text }}\n </div>\n <div\n v-if=\"item.operationCount > 0\"\n data-testid=\"ai-chat-applied\"\n class=\"tpl:flex tpl:items-center tpl:gap-2 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n <span>{{ appliedLabel(item) }}</span>\n <button\n v-if=\"item.undone ? item.canRedo : item.canUndo\"\n type=\"button\"\n data-testid=\"ai-chat-undo\"\n :class=\"secondaryBtnCompactClass\"\n :disabled=\"isBusy\"\n @click=\"toggleUndo(item)\"\n >\n <Redo2\n v-if=\"item.undone\"\n :size=\"12\"\n :stroke-width=\"2\"\n aria-hidden=\"true\"\n />\n <Undo2\n v-else\n :size=\"12\"\n :stroke-width=\"2\"\n aria-hidden=\"true\"\n />\n {{ item.undone ? t.ai.chat.redo : t.ai.chat.undo }}\n </button>\n </div>\n <p\n v-if=\"item.failure\"\n role=\"alert\"\n data-testid=\"ai-chat-item-error\"\n class=\"tpl:m-0 tpl:text-xs tpl:text-[var(--tpl-danger)]\"\n >\n {{ itemFailure(item) }}\n </p>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Starter prompts, over the empty state (D21). -->\n <div\n v-if=\"messages.length === 0 && starters.length > 0\"\n class=\"tpl:absolute tpl:right-0 tpl:bottom-0 tpl:left-0 tpl:z-10 tpl:px-3 tpl:pb-3\"\n style=\"\n background-color: color-mix(in srgb, var(--tpl-bg) 50%, transparent);\n backdrop-filter: blur(2px);\n \"\n >\n <div class=\"tpl:flex tpl:flex-col tpl:gap-1.5\">\n <button\n v-for=\"(starter, index) in starters\"\n :key=\"index\"\n type=\"button\"\n data-testid=\"ai-chat-starter\"\n class=\"tpl-starter-btn tpl:cursor-pointer tpl:rounded-[var(--tpl-radius-sm)] tpl:border tpl:px-3 tpl:py-2 tpl:text-left tpl:text-xs tpl:leading-snug tpl:transition-all tpl:duration-300 tpl:ease-out\"\n :class=\"\n starters.length - 1 - index < visibleStarterCount\n ? 'tpl:translate-y-0 tpl:opacity-100'\n : 'tpl:pointer-events-none tpl:-translate-y-2 tpl:opacity-0'\n \"\n style=\"\n border-color: var(--tpl-border);\n color: var(--tpl-primary);\n background-color: var(--tpl-bg);\n box-shadow: var(--tpl-shadow);\n \"\n @click=\"chooseStarter(starter)\"\n >\n {{ starter }}\n </button>\n </div>\n </div>\n\n <template #footer>\n <div class=\"tpl:border-t tpl:p-3 tpl:border-[var(--tpl-border)]\">\n <template v-if=\"canAttach\">\n <input\n ref=\"fileInput\"\n data-testid=\"ai-chat-files\"\n type=\"file\"\n multiple\n accept=\"image/png,image/jpeg,image/webp,image/gif,application/pdf\"\n hidden\n :disabled=\"isBusy\"\n @change=\"picked\"\n />\n <div\n v-if=\"attachments.length\"\n class=\"tpl:mb-2 tpl:flex tpl:flex-wrap tpl:gap-1\"\n >\n <span\n v-for=\"(file, index) in attachments\"\n :key=\"index\"\n data-testid=\"ai-chat-attachment\"\n class=\"tpl:flex tpl:max-w-full tpl:items-center tpl:gap-1 tpl:rounded tpl:border tpl:border-[var(--tpl-border)] tpl:px-2 tpl:py-1 tpl:text-xs tpl:text-[var(--tpl-text)]\"\n >\n <FileText\n v-if=\"file.type === 'application/pdf'\"\n :size=\"12\"\n aria-hidden=\"true\"\n /><Image v-else :size=\"12\" aria-hidden=\"true\" />\n <span class=\"tpl:truncate\">{{ file.name }}</span>\n <button\n type=\"button\"\n :aria-label=\"\n format(t.ai.chat.removeAttachment, { name: file.name })\n \"\n :disabled=\"isBusy\"\n class=\"tpl:shrink-0 tpl:rounded tpl:p-0.5 tpl:disabled:opacity-40\"\n @click=\"removeAttachment(index)\"\n >\n <X :size=\"12\" aria-hidden=\"true\" />\n </button>\n </span>\n </div>\n <p\n v-if=\"attachments.length\"\n class=\"tpl:mb-2 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ t.ai.import.placeholderNote }}\n </p>\n <div\n aria-live=\"polite\"\n class=\"tpl:text-xs tpl:text-[var(--tpl-danger)]\"\n >\n <p\n v-for=\"(error, index) in attachmentErrors\"\n :key=\"index\"\n class=\"tpl:mb-2\"\n >\n {{ error }}\n </p>\n </div>\n </template>\n <div\n v-if=\"feature.keptYourVersion.value\"\n role=\"status\"\n class=\"tpl:mb-2 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n <p>{{ t.ai.chat.keptYourVersion }}</p>\n <button\n type=\"button\"\n :disabled=\"isBusy\"\n :class=\"secondaryBtnCompactClass\"\n @click=\"feature.reloadTemplate()\"\n >\n {{ t.ai.chat.reload }}\n </button>\n </div>\n <div\n v-if=\"failureText\"\n role=\"alert\"\n data-testid=\"ai-chat-error\"\n class=\"tpl:mx-3 tpl:mb-2 tpl:flex tpl:items-start tpl:gap-2 tpl:rounded-lg tpl:px-3 tpl:py-2 tpl:text-xs\"\n style=\"\n background-color: var(--tpl-danger-light);\n color: var(--tpl-danger);\n \"\n >\n <CircleAlert\n :size=\"14\"\n :stroke-width=\"2\"\n class=\"tpl:mt-0.5 tpl:shrink-0\"\n aria-hidden=\"true\"\n />\n <span>{{ failureText }}</span>\n </div>\n <div\n class=\"tpl-ai-input-wrapper tpl-focus-ring-host tpl:flex tpl:flex-col tpl:gap-2 tpl:rounded-[var(--tpl-radius)] tpl:border tpl:px-3 tpl:py-2 tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)]\"\n >\n <p\n v-if=\"editor?.activeLocale?.value\"\n data-testid=\"ai-active-language\"\n class=\"tpl:text-xs tpl:text-[var(--tpl-chrome-text-dim)]\"\n >\n {{\n format(t.localization.aiActiveLanguage, {\n language: languageName(editor.activeLocale.value),\n })\n }}\n </p>\n <textarea\n ref=\"composer\"\n v-model=\"promptInput\"\n data-testid=\"ai-chat-input\"\n class=\"tpl:max-h-32 tpl:min-h-[44px] tpl:w-full tpl:resize-none tpl:border-none tpl:bg-transparent tpl:font-sans tpl:text-sm tpl:outline-none tpl:text-[var(--tpl-text)]\"\n :placeholder=\"t.ai.chat.inputPlaceholder\"\n :aria-label=\"t.ai.chat.inputPlaceholder\"\n :disabled=\"isBusy\"\n maxlength=\"4000\"\n rows=\"3\"\n @keydown=\"onKeydown\"\n />\n <div class=\"tpl:flex tpl:items-center tpl:justify-between\">\n <button\n v-if=\"canAttach\"\n type=\"button\"\n :aria-label=\"t.ai.chat.attach\"\n :title=\"t.ai.chat.attach\"\n :disabled=\"isBusy\"\n class=\"tpl:-ml-1.5 tpl:shrink-0 tpl:rounded-md tpl:p-1.5 tpl:text-[var(--tpl-text-muted)] tpl:disabled:opacity-40\"\n @click=\"fileInput?.click()\"\n >\n <Paperclip :size=\"16\" aria-hidden=\"true\" />\n </button>\n <button\n v-if=\"isBusy\"\n type=\"button\"\n data-testid=\"ai-chat-stop\"\n class=\"tpl-ai-send-btn tpl:ml-auto tpl:-mr-1.5 tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-center tpl:rounded-md tpl:p-1.5 tpl:transition-all tpl:text-[var(--tpl-primary)]\"\n :aria-label=\"t.ai.chat.stop\"\n :title=\"t.ai.chat.stop\"\n @click=\"feature.stop()\"\n >\n <Square :size=\"16\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n <button\n v-else\n type=\"button\"\n data-testid=\"ai-chat-send\"\n class=\"tpl-ai-send-btn tpl:ml-auto tpl:-mr-1.5 tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-center tpl:rounded-md tpl:p-1.5 tpl:transition-all tpl:disabled:opacity-40 tpl:text-[var(--tpl-primary)]\"\n :aria-label=\"t.ai.chat.send\"\n :title=\"t.ai.chat.send\"\n :disabled=\"!promptInput.trim()\"\n @click=\"send\"\n >\n <Send :size=\"16\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n <p\n class=\"tpl:m-0 tpl:px-1 tpl:pt-2 tpl:text-center tpl:text-[10px] tpl:text-[var(--tpl-text-dim)]\"\n >\n {{ t.ai.chat.disclaimer }}\n </p>\n </div>\n </template>\n </AiPanelShell>\n </div>\n</template>\n\n<style scoped>\n.tpl-ai-input-wrapper:focus-within {\n border-color: var(--tpl-primary);\n box-shadow: var(--tpl-ring);\n}\n\n.tpl-ai-send-btn:not(:disabled):hover {\n transform: scale(1.05);\n}\n\n.tpl-starter-btn:hover {\n border-color: var(--tpl-primary) !important;\n background-color: var(--tpl-primary-light) !important;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAWA,IAAM0F,IAAOD;E,kBAIXhF,EAAA,GAAAC,EA2CM,OAAA;GA1CJ,MAAK;GACJ,cAAYiF,EAAA;GACZ,eAAaA,EAAA;GACd,OAAM;;GAGNhF,EA+BM,OA/BNV,GA+BM,CA5BJU,EAcM,OAdNT,GAcM,CAbJS,EAKM,OALNR,GAKM,CAFJS,EAA4DC,EAAA6C,CAAA,GAAA;IAAjD,MAAM;IAAK,gBAAc;IAAG,eAAY;G,IACnD/C,EAAqD,QAArDP,GAAqDU,EAAf6E,EAAA,KAAK,GAAA,CAAA,C,IAGrCA,EAAA,YADRlF,EAAA,GAAAC,EAMI,KANJL,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AAG2J,EAAK,SAASlK,EAAAuI,CAAA,CAAC,CAAC,GAAG,KAAK,OAAOvI,EAAAuI,CAAA,CAAC,CAAC,GAAG,KAAK,IAAI,GAAA,CAAA,C;KAI5C2B,EAAK,WADbtK,EAAA,GAAAC,EAOI,KAPJoG,IAOI1F,EADC4J,GAAYD,CAAI,CAAA,GAAA,CAAA,K;;IASrBX,EAAA,MAAS,WAAM,KAAUD,EAAA,MAAS,SAAM,KADhD1J,EAAA,GAAAC,EA+BM,OA/BNqG,IA+BM,CAvBJ/F,EAsBM,OAtBNgG,IAsBM,EArBJvG,EAAA,EAAA,GAAAC,EAoBSO,GAAA,MAAAC,EAnBoBiJ,EAAA,QAAnB,GAAS,OADnB1J,EAAA,GAAAC,EAoBS,UAAA;KAlBN,KAAKiJ;KACN,MAAK;KACL,eAAY;KACZ,OAAKtI,EAAA,CAAC,kMACiB8I,EAAA,MAAS,SAAM,IAAOR,IAAQO,EAAA,Q;KAKrD,OAAA;MAAA,gBAAA;MAAAzD,OAAA;MAAA,oBAAA;MAAA,cAAA;KAAA;KAMC,UAAK,MAAEyE,GAAcC,CAAO;IAE1B,GAAA/J,EAAA+J,CAAO,GAAA,IAAAlE,EAAA,E"}
1
+ {"version":3,"file":"AiChatPanel-By8Uo1nH.js","names":["_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_openBlock","_createElementBlock","_createElementVNode","_createVNode","_unref","_toDisplayString","_createCommentVNode","_renderSlot","_sfc_main","_openBlock","_createElementBlock","_createVNode","AiPanelShell","_unref","_withCtx","_createCommentVNode","_createElementVNode","_Fragment","_renderList","_createBlock","_toDisplayString","_normalizeClass","_withDirectives","_vModelText","_createTextVNode","LoadingTrack","_sfc_main","defineComponent","openBlock","withCtx","watch","withDirectives","renderList","inject","renderSlot","createElementBlock","createTextVNode","unref","normalizeClass","createCommentVNode","createBlock","nextTick","createBaseVNode","toDisplayString","vModelText","computed","ref","Fragment","_plugin_vue_export_helper_default","Sparkles","CircleAlert","Paperclip","Square","FileText","Image","LoaderCircle","Send","Undo2","X","MessageSquarePlus","Redo2","UI_LOCALE_KEY","EDITOR_KEY","useI18n","languageName","secondaryBtnCompactClass","useTimeoutFn","useIntervalFn","LoadingTrack_default","aiErrorMessage","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","_hoisted_4$1","_hoisted_5$1","_hoisted_6$1","_hoisted_7$1","_hoisted_8$1","_hoisted_9$1","AiPanelShell_default","__emit","emit","__props","createVNode","_ctx","_cache","TYPES","validateChatAttachments","accepted","existing","errors","total","sum","file","added","reason","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","\"color\"","_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","_hoisted_23","_hoisted_24","_hoisted_25","_hoisted_26","_hoisted_27","_hoisted_28","_hoisted_29","_hoisted_30","_hoisted_31","_hoisted_32","_hoisted_33","_hoisted_34","_hoisted_35","AiChatPanel_default","props","editor","uiLocale","promptInput","composer","fileInput","attachments","attachmentErrors","dragDepth","canAttach","attach","result","files","keys","format","t","error","picked","input","event","isBusy","removeAttachment","index","isFileDrag","dragEnter","dragLeave","dragOver","drop","messagesContainer","visibleStarterCount","starters","messages","failureText","failure","pauseReveal","resumeReveal","startReveal","count","scrollToBottom","prompt","send","appliedLabel","item","itemFailure","toggleUndo","chooseStarter","starter","onKeydown","$event","attachment"],"sources":["../../../src/components/ai/AiPanelShell.vue","../../../src/components/ai/AiPanelShell.vue","../../../src/utils/aiAttachments.ts","../../../src/components/ai/AiChatPanel.vue","../../../src/components/ai/AiChatPanel.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Sparkles, X } from \"@lucide/vue\";\n\ndefineProps<{\n title: string;\n subtitle?: string;\n /** `ai-panel-chat`. */\n testid: string;\n closeLabel: string;\n}>();\n\nconst emit = defineEmits<{ (e: \"close\"): void }>();\n</script>\n\n<template>\n <div\n role=\"complementary\"\n :aria-label=\"title\"\n :data-testid=\"testid\"\n class=\"tpl-ai-sidebar tpl:absolute tpl:top-14 tpl:right-0 tpl:bottom-0 tpl:flex tpl:w-[360px] tpl:flex-col tpl:border-l tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg-elevated)]\"\n >\n <!-- The header names the panel an AI feature (EU AI Act Art. 50). -->\n <div\n class=\"tpl:flex tpl:items-start tpl:justify-between tpl:gap-2 tpl:border-b tpl:border-[var(--tpl-border)] tpl:px-4 tpl:py-3\"\n >\n <div class=\"tpl:flex tpl:min-w-0 tpl:flex-col tpl:gap-0.5\">\n <div\n class=\"tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]\"\n >\n <Sparkles :size=\"13\" :stroke-width=\"2\" aria-hidden=\"true\" />\n <span data-testid=\"ai-panel-title\">{{ title }}</span>\n </div>\n <p\n v-if=\"subtitle\"\n data-testid=\"ai-panel-subtitle\"\n class=\"tpl:m-0 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ subtitle }}\n </p>\n </div>\n <div class=\"tpl:flex tpl:items-center tpl:gap-1\">\n <slot name=\"actions\" />\n <button\n type=\"button\"\n data-testid=\"ai-panel-close\"\n class=\"tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:text-[var(--tpl-text-muted)]\"\n :aria-label=\"closeLabel\"\n :title=\"closeLabel\"\n @click=\"emit('close')\"\n >\n <X :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n <div class=\"tpl:relative tpl:flex tpl:min-h-0 tpl:flex-1 tpl:flex-col\">\n <slot />\n </div>\n <slot name=\"footer\" />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { Sparkles, X } from \"@lucide/vue\";\n\ndefineProps<{\n title: string;\n subtitle?: string;\n /** `ai-panel-chat`. */\n testid: string;\n closeLabel: string;\n}>();\n\nconst emit = defineEmits<{ (e: \"close\"): void }>();\n</script>\n\n<template>\n <div\n role=\"complementary\"\n :aria-label=\"title\"\n :data-testid=\"testid\"\n class=\"tpl-ai-sidebar tpl:absolute tpl:top-14 tpl:right-0 tpl:bottom-0 tpl:flex tpl:w-[360px] tpl:flex-col tpl:border-l tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg-elevated)]\"\n >\n <!-- The header names the panel an AI feature (EU AI Act Art. 50). -->\n <div\n class=\"tpl:flex tpl:items-start tpl:justify-between tpl:gap-2 tpl:border-b tpl:border-[var(--tpl-border)] tpl:px-4 tpl:py-3\"\n >\n <div class=\"tpl:flex tpl:min-w-0 tpl:flex-col tpl:gap-0.5\">\n <div\n class=\"tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]\"\n >\n <Sparkles :size=\"13\" :stroke-width=\"2\" aria-hidden=\"true\" />\n <span data-testid=\"ai-panel-title\">{{ title }}</span>\n </div>\n <p\n v-if=\"subtitle\"\n data-testid=\"ai-panel-subtitle\"\n class=\"tpl:m-0 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ subtitle }}\n </p>\n </div>\n <div class=\"tpl:flex tpl:items-center tpl:gap-1\">\n <slot name=\"actions\" />\n <button\n type=\"button\"\n data-testid=\"ai-panel-close\"\n class=\"tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:text-[var(--tpl-text-muted)]\"\n :aria-label=\"closeLabel\"\n :title=\"closeLabel\"\n @click=\"emit('close')\"\n >\n <X :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n <div class=\"tpl:relative tpl:flex tpl:min-h-0 tpl:flex-1 tpl:flex-col\">\n <slot />\n </div>\n <slot name=\"footer\" />\n </div>\n</template>\n","/** Chat file limits, matching the AI wire. */\nexport const AI_ATTACHMENTS_MAX = 4;\nexport const AI_ATTACHMENT_MAX_BYTES = 5 * 1024 * 1024;\nexport const AI_ATTACHMENTS_TOTAL_MAX_BYTES = 10 * 1024 * 1024;\nconst TYPES = new Set([\n \"image/png\",\n \"image/jpeg\",\n \"image/webp\",\n \"image/gif\",\n \"application/pdf\",\n]);\nexport function validateChatAttachments(\n existing: File[],\n added: File[],\n): {\n accepted: File[];\n errors: {\n name: string;\n reason: \"tooMany\" | \"tooLarge\" | \"totalTooLarge\" | \"wrongType\";\n }[];\n} {\n const accepted = [...existing];\n const errors: ReturnType<typeof validateChatAttachments>[\"errors\"] = [];\n let total = existing.reduce((sum, file) => sum + file.size, 0);\n for (const file of added) {\n const reason =\n accepted.length >= AI_ATTACHMENTS_MAX\n ? \"tooMany\"\n : !TYPES.has(file.type)\n ? \"wrongType\"\n : file.size > AI_ATTACHMENT_MAX_BYTES\n ? \"tooLarge\"\n : total + file.size > AI_ATTACHMENTS_TOTAL_MAX_BYTES\n ? \"totalTooLarge\"\n : null;\n if (reason) errors.push({ name: file.name, reason });\n else {\n accepted.push(file);\n total += file.size;\n }\n }\n return { accepted, errors };\n}\n","<script setup lang=\"ts\">\nimport {\n CircleAlert,\n FileText,\n Image,\n Paperclip,\n X,\n LoaderCircle,\n MessageSquarePlus,\n Redo2,\n Send,\n Sparkles,\n Square,\n Undo2,\n} from \"@lucide/vue\";\nimport { computed, inject, nextTick, ref, watch } from \"vue\";\nimport { useIntervalFn, useTimeoutFn } from \"@vueuse/core\";\nimport LoadingTrack from \"../LoadingTrack.vue\";\nimport AiPanelShell from \"./AiPanelShell.vue\";\nimport type {\n AiChatItem,\n UseAiFeatureReturn,\n} from \"../../composables/useAiFeature\";\nimport { useI18n } from \"../../composables/useI18n\";\nimport { secondaryBtnCompactClass } from \"../../constants/styleConstants\";\nimport { EDITOR_KEY, UI_LOCALE_KEY } from \"../../keys\";\nimport { validateChatAttachments } from \"../../utils/aiAttachments\";\nimport { languageName } from \"../../utils/languageName\";\nimport { aiErrorMessage } from \"../../utils/aiErrors\";\n\nconst props = defineProps<{ feature: UseAiFeatureReturn }>();\nconst emit = defineEmits<{ (e: \"close\"): void }>();\n\nconst { t, format } = useI18n();\nconst editor = inject(EDITOR_KEY, null);\nconst uiLocale = inject(UI_LOCALE_KEY, undefined);\n\nconst promptInput = ref(\"\");\nconst composer = ref<HTMLTextAreaElement | null>(null);\nconst fileInput = ref<HTMLInputElement | null>(null);\nconst attachments = ref<File[]>([]);\nconst attachmentErrors = ref<string[]>([]);\nconst dragDepth = ref(0);\nwatch(\n () => props.feature.templateSession.value,\n () => {\n promptInput.value = \"\";\n attachments.value = [];\n attachmentErrors.value = [];\n dragDepth.value = 0;\n },\n { flush: \"sync\" },\n);\nconst canAttach = computed(() => props.feature.has(\"chatAttachments\"));\nfunction attach(files: File[]): void {\n const result = validateChatAttachments(attachments.value, files);\n attachments.value = result.accepted;\n const keys = {\n tooMany: \"attachTooMany\",\n tooLarge: \"attachTooLarge\",\n totalTooLarge: \"attachTotalTooLarge\",\n wrongType: \"attachWrongType\",\n } as const;\n attachmentErrors.value = result.errors.map((error) =>\n format(t.ai.chat[keys[error.reason]], { name: error.name }),\n );\n}\nfunction picked(event: Event): void {\n const input = event.target as HTMLInputElement;\n if (!isBusy.value && canAttach.value) attach(Array.from(input.files ?? []));\n input.value = \"\";\n}\nfunction removeAttachment(index: number): void {\n if (isBusy.value) return;\n attachments.value.splice(index, 1);\n attachmentErrors.value = [];\n}\nfunction isFileDrag(event: DragEvent): boolean {\n return Array.from(event.dataTransfer?.types ?? []).includes(\"Files\");\n}\nfunction dragEnter(event: DragEvent): void {\n if (!canAttach.value || isBusy.value || !isFileDrag(event)) return;\n event.preventDefault();\n dragDepth.value++;\n}\nfunction dragLeave(event: DragEvent): void {\n if (!isFileDrag(event)) return;\n dragDepth.value = Math.max(0, dragDepth.value - 1);\n}\nfunction dragOver(event: DragEvent): void {\n if (canAttach.value && isFileDrag(event)) event.preventDefault();\n}\nfunction drop(event: DragEvent): void {\n dragDepth.value = 0;\n if (!canAttach.value || !isFileDrag(event)) return;\n event.preventDefault();\n if (!isBusy.value) attach(Array.from(event.dataTransfer?.files ?? []));\n}\nwatch(\n () => props.feature.importQueue.value,\n (files) => {\n if (!canAttach.value || !files.length) return;\n attach(files);\n if (!promptInput.value.trim()) promptInput.value = t.ai.import.prompt;\n props.feature.importQueue.value = [];\n void nextTick(() => composer.value?.focus());\n },\n { immediate: true },\n);\nconst messagesContainer = ref<HTMLElement | null>(null);\nconst visibleStarterCount = ref(0);\n\nconst starters = computed(() =>\n props.feature.isTemplateEmpty.value\n ? [\n t.ai.starters.emptyWelcome,\n t.ai.starters.emptyLaunch,\n t.ai.starters.emptyNewsletter,\n ]\n : [\n t.ai.starters.filledShorten,\n t.ai.starters.filledFriendlier,\n t.ai.starters.filledDates,\n t.ai.starters.filledCta,\n ],\n);\nconst messages = computed(() => props.feature.messages.value);\nconst isBusy = computed(() => props.feature.isRunning.value);\nconst failureText = computed(() => {\n const failure = props.feature.failure.value;\n return failure\n ? aiErrorMessage(\n failure.error,\n t.ai.errors,\n format,\n uiLocale,\n failure.context,\n )\n : \"\";\n});\n\nconst { pause: pauseReveal, resume: resumeReveal } = useIntervalFn(\n () => {\n if (visibleStarterCount.value < starters.value.length) {\n visibleStarterCount.value++;\n } else {\n pauseReveal();\n }\n },\n 150,\n { immediate: false },\n);\nconst { start: startReveal } = useTimeoutFn(() => resumeReveal(), 100, {\n immediate: false,\n});\n\nwatch(\n () => starters.value.length,\n (count) => {\n pauseReveal();\n visibleStarterCount.value = 0;\n if (count > 0) startReveal();\n },\n { immediate: true },\n);\n\nfunction scrollToBottom(): void {\n void nextTick(() => {\n if (messagesContainer.value) {\n messagesContainer.value.scrollTop = messagesContainer.value.scrollHeight;\n }\n });\n}\n\nwatch(() => messages.value.length, scrollToBottom);\n\n// A failed turn gives its prompt back (D15).\nwatch(\n () =>\n [\n props.feature.failedPrompt.value,\n props.feature.failedAttachments.value,\n ] as const,\n ([prompt, files]) => {\n if (prompt) {\n promptInput.value = prompt;\n attachments.value = [...files];\n }\n },\n { immediate: true },\n);\n\nasync function send(): Promise<void> {\n const prompt = promptInput.value.trim();\n if (!prompt || isBusy.value) return;\n const files = [...attachments.value];\n promptInput.value = \"\";\n attachments.value = [];\n attachmentErrors.value = [];\n scrollToBottom();\n await props.feature.send(prompt, files);\n scrollToBottom();\n}\n\nfunction appliedLabel(item: AiChatItem): string {\n if (item.undone) return t.ai.chat.undone;\n return item.operationCount === 1\n ? t.ai.chat.appliedChange\n : format(t.ai.chat.appliedChanges, { count: item.operationCount });\n}\n\nfunction itemFailure(item: AiChatItem): string {\n return item.failure\n ? aiErrorMessage(\n item.failure.error,\n t.ai.errors,\n format,\n uiLocale,\n item.failure.context,\n )\n : \"\";\n}\n\nfunction toggleUndo(item: AiChatItem): void {\n if (item.undone) void props.feature.redoMessage(item.id);\n else void props.feature.undoMessage(item.id);\n}\n\nfunction chooseStarter(starter: string): void {\n pauseReveal();\n promptInput.value = starter;\n void send();\n}\n\nfunction onKeydown(event: KeyboardEvent): void {\n if (event.isComposing || event.keyCode === 229) return;\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n void send();\n }\n}\n</script>\n\n<template>\n <div\n class=\"tpl:contents\"\n data-testid=\"ai-chat-dropzone\"\n @dragenter=\"dragEnter\"\n @dragleave=\"dragLeave\"\n @dragover=\"dragOver\"\n @drop=\"drop\"\n >\n <AiPanelShell\n :title=\"t.ai.chat.title\"\n :subtitle=\"t.ai.chat.notice\"\n testid=\"ai-panel-chat\"\n :close-label=\"t.ai.chat.close\"\n @close=\"emit('close')\"\n >\n <template #actions>\n <button\n v-if=\"feature.canClear && messages.length > 0\"\n type=\"button\"\n data-testid=\"ai-chat-new\"\n class=\"tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:text-[var(--tpl-text-muted)] tpl:disabled:opacity-40\"\n :aria-label=\"t.ai.chat.newChat\"\n :title=\"t.ai.chat.newChat\"\n :disabled=\"isBusy\"\n @click=\"feature.newChat()\"\n >\n <MessageSquarePlus :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </template>\n\n <div\n v-if=\"canAttach && dragDepth > 0 && !isBusy\"\n data-testid=\"ai-chat-drop-hint\"\n class=\"tpl:absolute tpl:inset-0 tpl:z-20 tpl:flex tpl:items-center tpl:justify-center tpl:border-2 tpl:border-dashed tpl:border-[var(--tpl-primary)] tpl:bg-[var(--tpl-bg-elevated)] tpl:p-4 tpl:text-center tpl:text-sm tpl:text-[var(--tpl-primary)] tpl:pointer-events-none\"\n >\n {{ t.ai.chat.dropHint }}\n </div>\n <div\n ref=\"messagesContainer\"\n class=\"tpl:flex-1 tpl:overflow-y-auto tpl:p-4\"\n >\n <div\n v-if=\"feature.isLoadingHistory.value\"\n class=\"tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center\"\n >\n <LoaderCircle\n class=\"tpl-spinner tpl:text-[var(--tpl-text-muted)]\"\n :size=\"24\"\n :stroke-width=\"2\"\n aria-hidden=\"true\"\n />\n <p class=\"tpl:text-sm tpl:text-[var(--tpl-text-muted)]\">\n {{ t.ai.chat.loadingHistory }}\n </p>\n </div>\n\n <div\n v-else-if=\"messages.length === 0\"\n class=\"tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center\"\n >\n <Sparkles\n :size=\"32\"\n :stroke-width=\"1.5\"\n class=\"tpl:text-[var(--tpl-text-dim)]\"\n aria-hidden=\"true\"\n />\n <p\n class=\"tpl:max-w-[240px] tpl:text-sm tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ t.ai.chat.placeholder }}\n </p>\n </div>\n\n <!-- Text is interpolated, never `v-html`. -->\n <div v-else class=\"tpl:flex tpl:flex-col tpl:gap-4\">\n <div\n v-for=\"item in messages\"\n :key=\"item.id\"\n class=\"tpl:flex tpl:flex-col tpl:gap-2\"\n >\n <span\n v-if=\"typeof item.locale === 'string'\"\n data-testid=\"ai-chat-language\"\n class=\"tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ languageName(item.locale) }}\n </span>\n <div\n v-if=\"item.role === 'user'\"\n data-testid=\"ai-chat-prompt\"\n class=\"tpl:self-end tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3.5 tpl:py-2.5 tpl:text-sm tpl:whitespace-pre-wrap\"\n style=\"\n background-color: var(--tpl-primary-light);\n color: var(--tpl-text);\n max-width: 85%;\n box-shadow: var(--tpl-shadow);\n \"\n >\n {{ item.text }}\n <span\n v-for=\"(attachment, index) in item.attachments\"\n :key=\"index\"\n data-testid=\"ai-chat-history-attachment\"\n class=\"tpl:mt-1 tpl:flex tpl:items-center tpl:gap-1 tpl:rounded tpl:border tpl:border-[var(--tpl-border)] tpl:px-2 tpl:py-1 tpl:text-xs\"\n >\n <FileText\n v-if=\"attachment.kind === 'pdf'\"\n :size=\"12\"\n aria-hidden=\"true\"\n /><Image v-else :size=\"12\" aria-hidden=\"true\" />{{\n attachment.name\n }}\n </span>\n </div>\n\n <div v-else class=\"tpl:flex tpl:flex-col tpl:gap-2\">\n <LoadingTrack\n v-if=\"item.text === '' && item.status === 'streaming'\"\n />\n <div\n v-else-if=\"item.text !== ''\"\n data-testid=\"ai-chat-reply\"\n class=\"tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3.5 tpl:py-2.5 tpl:text-sm tpl:whitespace-pre-wrap\"\n style=\"\n max-width: 85%;\n background-color: var(--tpl-bg);\n color: var(--tpl-text);\n box-shadow: var(--tpl-shadow);\n \"\n >\n {{ item.text }}\n </div>\n <div\n v-if=\"item.operationCount > 0\"\n data-testid=\"ai-chat-applied\"\n class=\"tpl:flex tpl:items-center tpl:gap-2 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n <span>{{ appliedLabel(item) }}</span>\n <button\n v-if=\"item.undone ? item.canRedo : item.canUndo\"\n type=\"button\"\n data-testid=\"ai-chat-undo\"\n :class=\"secondaryBtnCompactClass\"\n :disabled=\"isBusy\"\n @click=\"toggleUndo(item)\"\n >\n <Redo2\n v-if=\"item.undone\"\n :size=\"12\"\n :stroke-width=\"2\"\n aria-hidden=\"true\"\n />\n <Undo2\n v-else\n :size=\"12\"\n :stroke-width=\"2\"\n aria-hidden=\"true\"\n />\n {{ item.undone ? t.ai.chat.redo : t.ai.chat.undo }}\n </button>\n </div>\n <p\n v-if=\"item.failure\"\n role=\"alert\"\n data-testid=\"ai-chat-item-error\"\n class=\"tpl:m-0 tpl:text-xs tpl:text-[var(--tpl-danger)]\"\n >\n {{ itemFailure(item) }}\n </p>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Starter prompts, over the empty state (D21). -->\n <div\n v-if=\"messages.length === 0 && starters.length > 0\"\n class=\"tpl:absolute tpl:right-0 tpl:bottom-0 tpl:left-0 tpl:z-10 tpl:px-3 tpl:pb-3\"\n style=\"\n background-color: color-mix(in srgb, var(--tpl-bg) 50%, transparent);\n backdrop-filter: blur(2px);\n \"\n >\n <div class=\"tpl:flex tpl:flex-col tpl:gap-1.5\">\n <button\n v-for=\"(starter, index) in starters\"\n :key=\"index\"\n type=\"button\"\n data-testid=\"ai-chat-starter\"\n class=\"tpl-starter-btn tpl:cursor-pointer tpl:rounded-[var(--tpl-radius-sm)] tpl:border tpl:px-3 tpl:py-2 tpl:text-left tpl:text-xs tpl:leading-snug tpl:transition-all tpl:duration-300 tpl:ease-out\"\n :class=\"\n starters.length - 1 - index < visibleStarterCount\n ? 'tpl:translate-y-0 tpl:opacity-100'\n : 'tpl:pointer-events-none tpl:-translate-y-2 tpl:opacity-0'\n \"\n style=\"\n border-color: var(--tpl-border);\n color: var(--tpl-primary);\n background-color: var(--tpl-bg);\n box-shadow: var(--tpl-shadow);\n \"\n @click=\"chooseStarter(starter)\"\n >\n {{ starter }}\n </button>\n </div>\n </div>\n\n <template #footer>\n <div class=\"tpl:border-t tpl:p-3 tpl:border-[var(--tpl-border)]\">\n <template v-if=\"canAttach\">\n <input\n ref=\"fileInput\"\n data-testid=\"ai-chat-files\"\n type=\"file\"\n multiple\n accept=\"image/png,image/jpeg,image/webp,image/gif,application/pdf\"\n hidden\n :disabled=\"isBusy\"\n @change=\"picked\"\n />\n <div\n v-if=\"attachments.length\"\n class=\"tpl:mb-2 tpl:flex tpl:flex-wrap tpl:gap-1\"\n >\n <span\n v-for=\"(file, index) in attachments\"\n :key=\"index\"\n data-testid=\"ai-chat-attachment\"\n class=\"tpl:flex tpl:max-w-full tpl:items-center tpl:gap-1 tpl:rounded tpl:border tpl:border-[var(--tpl-border)] tpl:px-2 tpl:py-1 tpl:text-xs tpl:text-[var(--tpl-text)]\"\n >\n <FileText\n v-if=\"file.type === 'application/pdf'\"\n :size=\"12\"\n aria-hidden=\"true\"\n /><Image v-else :size=\"12\" aria-hidden=\"true\" />\n <span class=\"tpl:truncate\">{{ file.name }}</span>\n <button\n type=\"button\"\n :aria-label=\"\n format(t.ai.chat.removeAttachment, { name: file.name })\n \"\n :disabled=\"isBusy\"\n class=\"tpl:shrink-0 tpl:rounded tpl:p-0.5 tpl:disabled:opacity-40\"\n @click=\"removeAttachment(index)\"\n >\n <X :size=\"12\" aria-hidden=\"true\" />\n </button>\n </span>\n </div>\n <p\n v-if=\"attachments.length\"\n class=\"tpl:mb-2 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ t.ai.import.placeholderNote }}\n </p>\n <div\n aria-live=\"polite\"\n class=\"tpl:text-xs tpl:text-[var(--tpl-danger)]\"\n >\n <p\n v-for=\"(error, index) in attachmentErrors\"\n :key=\"index\"\n class=\"tpl:mb-2\"\n >\n {{ error }}\n </p>\n </div>\n </template>\n <div\n v-if=\"feature.keptYourVersion.value\"\n role=\"status\"\n class=\"tpl:mb-2 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n <p>{{ t.ai.chat.keptYourVersion }}</p>\n <button\n type=\"button\"\n :disabled=\"isBusy\"\n :class=\"secondaryBtnCompactClass\"\n @click=\"feature.reloadTemplate()\"\n >\n {{ t.ai.chat.reload }}\n </button>\n </div>\n <div\n v-if=\"failureText\"\n role=\"alert\"\n data-testid=\"ai-chat-error\"\n class=\"tpl:mx-3 tpl:mb-2 tpl:flex tpl:items-start tpl:gap-2 tpl:rounded-lg tpl:px-3 tpl:py-2 tpl:text-xs\"\n style=\"\n background-color: var(--tpl-danger-light);\n color: var(--tpl-danger);\n \"\n >\n <CircleAlert\n :size=\"14\"\n :stroke-width=\"2\"\n class=\"tpl:mt-0.5 tpl:shrink-0\"\n aria-hidden=\"true\"\n />\n <span>{{ failureText }}</span>\n </div>\n <div\n class=\"tpl-ai-input-wrapper tpl-focus-ring-host tpl:flex tpl:flex-col tpl:gap-2 tpl:rounded-[var(--tpl-radius)] tpl:border tpl:px-3 tpl:py-2 tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)]\"\n >\n <p\n v-if=\"editor?.activeLocale?.value\"\n data-testid=\"ai-active-language\"\n class=\"tpl:text-xs tpl:text-[var(--tpl-chrome-text-dim)]\"\n >\n {{\n format(t.localization.aiActiveLanguage, {\n language: languageName(editor.activeLocale.value),\n })\n }}\n </p>\n <textarea\n ref=\"composer\"\n v-model=\"promptInput\"\n data-testid=\"ai-chat-input\"\n class=\"tpl:max-h-32 tpl:min-h-[44px] tpl:w-full tpl:resize-none tpl:border-none tpl:bg-transparent tpl:font-sans tpl:text-sm tpl:outline-none tpl:text-[var(--tpl-text)]\"\n :placeholder=\"t.ai.chat.inputPlaceholder\"\n :aria-label=\"t.ai.chat.inputPlaceholder\"\n :disabled=\"isBusy\"\n maxlength=\"4000\"\n rows=\"3\"\n @keydown=\"onKeydown\"\n />\n <div class=\"tpl:flex tpl:items-center tpl:justify-between\">\n <button\n v-if=\"canAttach\"\n type=\"button\"\n :aria-label=\"t.ai.chat.attach\"\n :title=\"t.ai.chat.attach\"\n :disabled=\"isBusy\"\n class=\"tpl:-ml-1.5 tpl:shrink-0 tpl:rounded-md tpl:p-1.5 tpl:text-[var(--tpl-text-muted)] tpl:disabled:opacity-40\"\n @click=\"fileInput?.click()\"\n >\n <Paperclip :size=\"16\" aria-hidden=\"true\" />\n </button>\n <button\n v-if=\"isBusy\"\n type=\"button\"\n data-testid=\"ai-chat-stop\"\n class=\"tpl-ai-send-btn tpl:ml-auto tpl:-mr-1.5 tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-center tpl:rounded-md tpl:p-1.5 tpl:transition-all tpl:text-[var(--tpl-primary)]\"\n :aria-label=\"t.ai.chat.stop\"\n :title=\"t.ai.chat.stop\"\n @click=\"feature.stop()\"\n >\n <Square :size=\"16\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n <button\n v-else\n type=\"button\"\n data-testid=\"ai-chat-send\"\n class=\"tpl-ai-send-btn tpl:ml-auto tpl:-mr-1.5 tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-center tpl:rounded-md tpl:p-1.5 tpl:transition-all tpl:disabled:opacity-40 tpl:text-[var(--tpl-primary)]\"\n :aria-label=\"t.ai.chat.send\"\n :title=\"t.ai.chat.send\"\n :disabled=\"!promptInput.trim()\"\n @click=\"send\"\n >\n <Send :size=\"16\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n <p\n class=\"tpl:m-0 tpl:px-1 tpl:pt-2 tpl:text-center tpl:text-[10px] tpl:text-[var(--tpl-text-dim)]\"\n >\n {{ t.ai.chat.disclaimer }}\n </p>\n </div>\n </template>\n </AiPanelShell>\n </div>\n</template>\n\n<style scoped>\n.tpl-ai-input-wrapper:focus-within {\n border-color: var(--tpl-primary);\n box-shadow: var(--tpl-ring);\n}\n\n.tpl-ai-send-btn:not(:disabled):hover {\n transform: scale(1.05);\n}\n\n.tpl-starter-btn:hover {\n border-color: var(--tpl-primary) !important;\n background-color: var(--tpl-primary-light) !important;\n}\n</style>\n","<script setup lang=\"ts\">\nimport {\n CircleAlert,\n FileText,\n Image,\n Paperclip,\n X,\n LoaderCircle,\n MessageSquarePlus,\n Redo2,\n Send,\n Sparkles,\n Square,\n Undo2,\n} from \"@lucide/vue\";\nimport { computed, inject, nextTick, ref, watch } from \"vue\";\nimport { useIntervalFn, useTimeoutFn } from \"@vueuse/core\";\nimport LoadingTrack from \"../LoadingTrack.vue\";\nimport AiPanelShell from \"./AiPanelShell.vue\";\nimport type {\n AiChatItem,\n UseAiFeatureReturn,\n} from \"../../composables/useAiFeature\";\nimport { useI18n } from \"../../composables/useI18n\";\nimport { secondaryBtnCompactClass } from \"../../constants/styleConstants\";\nimport { EDITOR_KEY, UI_LOCALE_KEY } from \"../../keys\";\nimport { validateChatAttachments } from \"../../utils/aiAttachments\";\nimport { languageName } from \"../../utils/languageName\";\nimport { aiErrorMessage } from \"../../utils/aiErrors\";\n\nconst props = defineProps<{ feature: UseAiFeatureReturn }>();\nconst emit = defineEmits<{ (e: \"close\"): void }>();\n\nconst { t, format } = useI18n();\nconst editor = inject(EDITOR_KEY, null);\nconst uiLocale = inject(UI_LOCALE_KEY, undefined);\n\nconst promptInput = ref(\"\");\nconst composer = ref<HTMLTextAreaElement | null>(null);\nconst fileInput = ref<HTMLInputElement | null>(null);\nconst attachments = ref<File[]>([]);\nconst attachmentErrors = ref<string[]>([]);\nconst dragDepth = ref(0);\nwatch(\n () => props.feature.templateSession.value,\n () => {\n promptInput.value = \"\";\n attachments.value = [];\n attachmentErrors.value = [];\n dragDepth.value = 0;\n },\n { flush: \"sync\" },\n);\nconst canAttach = computed(() => props.feature.has(\"chatAttachments\"));\nfunction attach(files: File[]): void {\n const result = validateChatAttachments(attachments.value, files);\n attachments.value = result.accepted;\n const keys = {\n tooMany: \"attachTooMany\",\n tooLarge: \"attachTooLarge\",\n totalTooLarge: \"attachTotalTooLarge\",\n wrongType: \"attachWrongType\",\n } as const;\n attachmentErrors.value = result.errors.map((error) =>\n format(t.ai.chat[keys[error.reason]], { name: error.name }),\n );\n}\nfunction picked(event: Event): void {\n const input = event.target as HTMLInputElement;\n if (!isBusy.value && canAttach.value) attach(Array.from(input.files ?? []));\n input.value = \"\";\n}\nfunction removeAttachment(index: number): void {\n if (isBusy.value) return;\n attachments.value.splice(index, 1);\n attachmentErrors.value = [];\n}\nfunction isFileDrag(event: DragEvent): boolean {\n return Array.from(event.dataTransfer?.types ?? []).includes(\"Files\");\n}\nfunction dragEnter(event: DragEvent): void {\n if (!canAttach.value || isBusy.value || !isFileDrag(event)) return;\n event.preventDefault();\n dragDepth.value++;\n}\nfunction dragLeave(event: DragEvent): void {\n if (!isFileDrag(event)) return;\n dragDepth.value = Math.max(0, dragDepth.value - 1);\n}\nfunction dragOver(event: DragEvent): void {\n if (canAttach.value && isFileDrag(event)) event.preventDefault();\n}\nfunction drop(event: DragEvent): void {\n dragDepth.value = 0;\n if (!canAttach.value || !isFileDrag(event)) return;\n event.preventDefault();\n if (!isBusy.value) attach(Array.from(event.dataTransfer?.files ?? []));\n}\nwatch(\n () => props.feature.importQueue.value,\n (files) => {\n if (!canAttach.value || !files.length) return;\n attach(files);\n if (!promptInput.value.trim()) promptInput.value = t.ai.import.prompt;\n props.feature.importQueue.value = [];\n void nextTick(() => composer.value?.focus());\n },\n { immediate: true },\n);\nconst messagesContainer = ref<HTMLElement | null>(null);\nconst visibleStarterCount = ref(0);\n\nconst starters = computed(() =>\n props.feature.isTemplateEmpty.value\n ? [\n t.ai.starters.emptyWelcome,\n t.ai.starters.emptyLaunch,\n t.ai.starters.emptyNewsletter,\n ]\n : [\n t.ai.starters.filledShorten,\n t.ai.starters.filledFriendlier,\n t.ai.starters.filledDates,\n t.ai.starters.filledCta,\n ],\n);\nconst messages = computed(() => props.feature.messages.value);\nconst isBusy = computed(() => props.feature.isRunning.value);\nconst failureText = computed(() => {\n const failure = props.feature.failure.value;\n return failure\n ? aiErrorMessage(\n failure.error,\n t.ai.errors,\n format,\n uiLocale,\n failure.context,\n )\n : \"\";\n});\n\nconst { pause: pauseReveal, resume: resumeReveal } = useIntervalFn(\n () => {\n if (visibleStarterCount.value < starters.value.length) {\n visibleStarterCount.value++;\n } else {\n pauseReveal();\n }\n },\n 150,\n { immediate: false },\n);\nconst { start: startReveal } = useTimeoutFn(() => resumeReveal(), 100, {\n immediate: false,\n});\n\nwatch(\n () => starters.value.length,\n (count) => {\n pauseReveal();\n visibleStarterCount.value = 0;\n if (count > 0) startReveal();\n },\n { immediate: true },\n);\n\nfunction scrollToBottom(): void {\n void nextTick(() => {\n if (messagesContainer.value) {\n messagesContainer.value.scrollTop = messagesContainer.value.scrollHeight;\n }\n });\n}\n\nwatch(() => messages.value.length, scrollToBottom);\n\n// A failed turn gives its prompt back (D15).\nwatch(\n () =>\n [\n props.feature.failedPrompt.value,\n props.feature.failedAttachments.value,\n ] as const,\n ([prompt, files]) => {\n if (prompt) {\n promptInput.value = prompt;\n attachments.value = [...files];\n }\n },\n { immediate: true },\n);\n\nasync function send(): Promise<void> {\n const prompt = promptInput.value.trim();\n if (!prompt || isBusy.value) return;\n const files = [...attachments.value];\n promptInput.value = \"\";\n attachments.value = [];\n attachmentErrors.value = [];\n scrollToBottom();\n await props.feature.send(prompt, files);\n scrollToBottom();\n}\n\nfunction appliedLabel(item: AiChatItem): string {\n if (item.undone) return t.ai.chat.undone;\n return item.operationCount === 1\n ? t.ai.chat.appliedChange\n : format(t.ai.chat.appliedChanges, { count: item.operationCount });\n}\n\nfunction itemFailure(item: AiChatItem): string {\n return item.failure\n ? aiErrorMessage(\n item.failure.error,\n t.ai.errors,\n format,\n uiLocale,\n item.failure.context,\n )\n : \"\";\n}\n\nfunction toggleUndo(item: AiChatItem): void {\n if (item.undone) void props.feature.redoMessage(item.id);\n else void props.feature.undoMessage(item.id);\n}\n\nfunction chooseStarter(starter: string): void {\n pauseReveal();\n promptInput.value = starter;\n void send();\n}\n\nfunction onKeydown(event: KeyboardEvent): void {\n if (event.isComposing || event.keyCode === 229) return;\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n void send();\n }\n}\n</script>\n\n<template>\n <div\n class=\"tpl:contents\"\n data-testid=\"ai-chat-dropzone\"\n @dragenter=\"dragEnter\"\n @dragleave=\"dragLeave\"\n @dragover=\"dragOver\"\n @drop=\"drop\"\n >\n <AiPanelShell\n :title=\"t.ai.chat.title\"\n :subtitle=\"t.ai.chat.notice\"\n testid=\"ai-panel-chat\"\n :close-label=\"t.ai.chat.close\"\n @close=\"emit('close')\"\n >\n <template #actions>\n <button\n v-if=\"feature.canClear && messages.length > 0\"\n type=\"button\"\n data-testid=\"ai-chat-new\"\n class=\"tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:text-[var(--tpl-text-muted)] tpl:disabled:opacity-40\"\n :aria-label=\"t.ai.chat.newChat\"\n :title=\"t.ai.chat.newChat\"\n :disabled=\"isBusy\"\n @click=\"feature.newChat()\"\n >\n <MessageSquarePlus :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </template>\n\n <div\n v-if=\"canAttach && dragDepth > 0 && !isBusy\"\n data-testid=\"ai-chat-drop-hint\"\n class=\"tpl:absolute tpl:inset-0 tpl:z-20 tpl:flex tpl:items-center tpl:justify-center tpl:border-2 tpl:border-dashed tpl:border-[var(--tpl-primary)] tpl:bg-[var(--tpl-bg-elevated)] tpl:p-4 tpl:text-center tpl:text-sm tpl:text-[var(--tpl-primary)] tpl:pointer-events-none\"\n >\n {{ t.ai.chat.dropHint }}\n </div>\n <div\n ref=\"messagesContainer\"\n class=\"tpl:flex-1 tpl:overflow-y-auto tpl:p-4\"\n >\n <div\n v-if=\"feature.isLoadingHistory.value\"\n class=\"tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center\"\n >\n <LoaderCircle\n class=\"tpl-spinner tpl:text-[var(--tpl-text-muted)]\"\n :size=\"24\"\n :stroke-width=\"2\"\n aria-hidden=\"true\"\n />\n <p class=\"tpl:text-sm tpl:text-[var(--tpl-text-muted)]\">\n {{ t.ai.chat.loadingHistory }}\n </p>\n </div>\n\n <div\n v-else-if=\"messages.length === 0\"\n class=\"tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center\"\n >\n <Sparkles\n :size=\"32\"\n :stroke-width=\"1.5\"\n class=\"tpl:text-[var(--tpl-text-dim)]\"\n aria-hidden=\"true\"\n />\n <p\n class=\"tpl:max-w-[240px] tpl:text-sm tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ t.ai.chat.placeholder }}\n </p>\n </div>\n\n <!-- Text is interpolated, never `v-html`. -->\n <div v-else class=\"tpl:flex tpl:flex-col tpl:gap-4\">\n <div\n v-for=\"item in messages\"\n :key=\"item.id\"\n class=\"tpl:flex tpl:flex-col tpl:gap-2\"\n >\n <span\n v-if=\"typeof item.locale === 'string'\"\n data-testid=\"ai-chat-language\"\n class=\"tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ languageName(item.locale) }}\n </span>\n <div\n v-if=\"item.role === 'user'\"\n data-testid=\"ai-chat-prompt\"\n class=\"tpl:self-end tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3.5 tpl:py-2.5 tpl:text-sm tpl:whitespace-pre-wrap\"\n style=\"\n background-color: var(--tpl-primary-light);\n color: var(--tpl-text);\n max-width: 85%;\n box-shadow: var(--tpl-shadow);\n \"\n >\n {{ item.text }}\n <span\n v-for=\"(attachment, index) in item.attachments\"\n :key=\"index\"\n data-testid=\"ai-chat-history-attachment\"\n class=\"tpl:mt-1 tpl:flex tpl:items-center tpl:gap-1 tpl:rounded tpl:border tpl:border-[var(--tpl-border)] tpl:px-2 tpl:py-1 tpl:text-xs\"\n >\n <FileText\n v-if=\"attachment.kind === 'pdf'\"\n :size=\"12\"\n aria-hidden=\"true\"\n /><Image v-else :size=\"12\" aria-hidden=\"true\" />{{\n attachment.name\n }}\n </span>\n </div>\n\n <div v-else class=\"tpl:flex tpl:flex-col tpl:gap-2\">\n <LoadingTrack\n v-if=\"item.text === '' && item.status === 'streaming'\"\n />\n <div\n v-else-if=\"item.text !== ''\"\n data-testid=\"ai-chat-reply\"\n class=\"tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3.5 tpl:py-2.5 tpl:text-sm tpl:whitespace-pre-wrap\"\n style=\"\n max-width: 85%;\n background-color: var(--tpl-bg);\n color: var(--tpl-text);\n box-shadow: var(--tpl-shadow);\n \"\n >\n {{ item.text }}\n </div>\n <div\n v-if=\"item.operationCount > 0\"\n data-testid=\"ai-chat-applied\"\n class=\"tpl:flex tpl:items-center tpl:gap-2 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n <span>{{ appliedLabel(item) }}</span>\n <button\n v-if=\"item.undone ? item.canRedo : item.canUndo\"\n type=\"button\"\n data-testid=\"ai-chat-undo\"\n :class=\"secondaryBtnCompactClass\"\n :disabled=\"isBusy\"\n @click=\"toggleUndo(item)\"\n >\n <Redo2\n v-if=\"item.undone\"\n :size=\"12\"\n :stroke-width=\"2\"\n aria-hidden=\"true\"\n />\n <Undo2\n v-else\n :size=\"12\"\n :stroke-width=\"2\"\n aria-hidden=\"true\"\n />\n {{ item.undone ? t.ai.chat.redo : t.ai.chat.undo }}\n </button>\n </div>\n <p\n v-if=\"item.failure\"\n role=\"alert\"\n data-testid=\"ai-chat-item-error\"\n class=\"tpl:m-0 tpl:text-xs tpl:text-[var(--tpl-danger)]\"\n >\n {{ itemFailure(item) }}\n </p>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Starter prompts, over the empty state (D21). -->\n <div\n v-if=\"messages.length === 0 && starters.length > 0\"\n class=\"tpl:absolute tpl:right-0 tpl:bottom-0 tpl:left-0 tpl:z-10 tpl:px-3 tpl:pb-3\"\n style=\"\n background-color: color-mix(in srgb, var(--tpl-bg) 50%, transparent);\n backdrop-filter: blur(2px);\n \"\n >\n <div class=\"tpl:flex tpl:flex-col tpl:gap-1.5\">\n <button\n v-for=\"(starter, index) in starters\"\n :key=\"index\"\n type=\"button\"\n data-testid=\"ai-chat-starter\"\n class=\"tpl-starter-btn tpl:cursor-pointer tpl:rounded-[var(--tpl-radius-sm)] tpl:border tpl:px-3 tpl:py-2 tpl:text-left tpl:text-xs tpl:leading-snug tpl:transition-all tpl:duration-300 tpl:ease-out\"\n :class=\"\n starters.length - 1 - index < visibleStarterCount\n ? 'tpl:translate-y-0 tpl:opacity-100'\n : 'tpl:pointer-events-none tpl:-translate-y-2 tpl:opacity-0'\n \"\n style=\"\n border-color: var(--tpl-border);\n color: var(--tpl-primary);\n background-color: var(--tpl-bg);\n box-shadow: var(--tpl-shadow);\n \"\n @click=\"chooseStarter(starter)\"\n >\n {{ starter }}\n </button>\n </div>\n </div>\n\n <template #footer>\n <div class=\"tpl:border-t tpl:p-3 tpl:border-[var(--tpl-border)]\">\n <template v-if=\"canAttach\">\n <input\n ref=\"fileInput\"\n data-testid=\"ai-chat-files\"\n type=\"file\"\n multiple\n accept=\"image/png,image/jpeg,image/webp,image/gif,application/pdf\"\n hidden\n :disabled=\"isBusy\"\n @change=\"picked\"\n />\n <div\n v-if=\"attachments.length\"\n class=\"tpl:mb-2 tpl:flex tpl:flex-wrap tpl:gap-1\"\n >\n <span\n v-for=\"(file, index) in attachments\"\n :key=\"index\"\n data-testid=\"ai-chat-attachment\"\n class=\"tpl:flex tpl:max-w-full tpl:items-center tpl:gap-1 tpl:rounded tpl:border tpl:border-[var(--tpl-border)] tpl:px-2 tpl:py-1 tpl:text-xs tpl:text-[var(--tpl-text)]\"\n >\n <FileText\n v-if=\"file.type === 'application/pdf'\"\n :size=\"12\"\n aria-hidden=\"true\"\n /><Image v-else :size=\"12\" aria-hidden=\"true\" />\n <span class=\"tpl:truncate\">{{ file.name }}</span>\n <button\n type=\"button\"\n :aria-label=\"\n format(t.ai.chat.removeAttachment, { name: file.name })\n \"\n :disabled=\"isBusy\"\n class=\"tpl:shrink-0 tpl:rounded tpl:p-0.5 tpl:disabled:opacity-40\"\n @click=\"removeAttachment(index)\"\n >\n <X :size=\"12\" aria-hidden=\"true\" />\n </button>\n </span>\n </div>\n <p\n v-if=\"attachments.length\"\n class=\"tpl:mb-2 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ t.ai.import.placeholderNote }}\n </p>\n <div\n aria-live=\"polite\"\n class=\"tpl:text-xs tpl:text-[var(--tpl-danger)]\"\n >\n <p\n v-for=\"(error, index) in attachmentErrors\"\n :key=\"index\"\n class=\"tpl:mb-2\"\n >\n {{ error }}\n </p>\n </div>\n </template>\n <div\n v-if=\"feature.keptYourVersion.value\"\n role=\"status\"\n class=\"tpl:mb-2 tpl:text-xs tpl:text-[var(--tpl-text-muted)]\"\n >\n <p>{{ t.ai.chat.keptYourVersion }}</p>\n <button\n type=\"button\"\n :disabled=\"isBusy\"\n :class=\"secondaryBtnCompactClass\"\n @click=\"feature.reloadTemplate()\"\n >\n {{ t.ai.chat.reload }}\n </button>\n </div>\n <div\n v-if=\"failureText\"\n role=\"alert\"\n data-testid=\"ai-chat-error\"\n class=\"tpl:mx-3 tpl:mb-2 tpl:flex tpl:items-start tpl:gap-2 tpl:rounded-lg tpl:px-3 tpl:py-2 tpl:text-xs\"\n style=\"\n background-color: var(--tpl-danger-light);\n color: var(--tpl-danger);\n \"\n >\n <CircleAlert\n :size=\"14\"\n :stroke-width=\"2\"\n class=\"tpl:mt-0.5 tpl:shrink-0\"\n aria-hidden=\"true\"\n />\n <span>{{ failureText }}</span>\n </div>\n <div\n class=\"tpl-ai-input-wrapper tpl-focus-ring-host tpl:flex tpl:flex-col tpl:gap-2 tpl:rounded-[var(--tpl-radius)] tpl:border tpl:px-3 tpl:py-2 tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)]\"\n >\n <p\n v-if=\"editor?.activeLocale?.value\"\n data-testid=\"ai-active-language\"\n class=\"tpl:text-xs tpl:text-[var(--tpl-chrome-text-dim)]\"\n >\n {{\n format(t.localization.aiActiveLanguage, {\n language: languageName(editor.activeLocale.value),\n })\n }}\n </p>\n <textarea\n ref=\"composer\"\n v-model=\"promptInput\"\n data-testid=\"ai-chat-input\"\n class=\"tpl:max-h-32 tpl:min-h-[44px] tpl:w-full tpl:resize-none tpl:border-none tpl:bg-transparent tpl:font-sans tpl:text-sm tpl:outline-none tpl:text-[var(--tpl-text)]\"\n :placeholder=\"t.ai.chat.inputPlaceholder\"\n :aria-label=\"t.ai.chat.inputPlaceholder\"\n :disabled=\"isBusy\"\n maxlength=\"4000\"\n rows=\"3\"\n @keydown=\"onKeydown\"\n />\n <div class=\"tpl:flex tpl:items-center tpl:justify-between\">\n <button\n v-if=\"canAttach\"\n type=\"button\"\n :aria-label=\"t.ai.chat.attach\"\n :title=\"t.ai.chat.attach\"\n :disabled=\"isBusy\"\n class=\"tpl:-ml-1.5 tpl:shrink-0 tpl:rounded-md tpl:p-1.5 tpl:text-[var(--tpl-text-muted)] tpl:disabled:opacity-40\"\n @click=\"fileInput?.click()\"\n >\n <Paperclip :size=\"16\" aria-hidden=\"true\" />\n </button>\n <button\n v-if=\"isBusy\"\n type=\"button\"\n data-testid=\"ai-chat-stop\"\n class=\"tpl-ai-send-btn tpl:ml-auto tpl:-mr-1.5 tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-center tpl:rounded-md tpl:p-1.5 tpl:transition-all tpl:text-[var(--tpl-primary)]\"\n :aria-label=\"t.ai.chat.stop\"\n :title=\"t.ai.chat.stop\"\n @click=\"feature.stop()\"\n >\n <Square :size=\"16\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n <button\n v-else\n type=\"button\"\n data-testid=\"ai-chat-send\"\n class=\"tpl-ai-send-btn tpl:ml-auto tpl:-mr-1.5 tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-center tpl:rounded-md tpl:p-1.5 tpl:transition-all tpl:disabled:opacity-40 tpl:text-[var(--tpl-primary)]\"\n :aria-label=\"t.ai.chat.send\"\n :title=\"t.ai.chat.send\"\n :disabled=\"!promptInput.trim()\"\n @click=\"send\"\n >\n <Send :size=\"16\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n <p\n class=\"tpl:m-0 tpl:px-1 tpl:pt-2 tpl:text-center tpl:text-[10px] tpl:text-[var(--tpl-text-dim)]\"\n >\n {{ t.ai.chat.disclaimer }}\n </p>\n </div>\n </template>\n </AiPanelShell>\n </div>\n</template>\n\n<style scoped>\n.tpl-ai-input-wrapper:focus-within {\n border-color: var(--tpl-primary);\n box-shadow: var(--tpl-ring);\n}\n\n.tpl-ai-send-btn:not(:disabled):hover {\n transform: scale(1.05);\n}\n\n.tpl-starter-btn:hover {\n border-color: var(--tpl-primary) !important;\n background-color: var(--tpl-primary-light) !important;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAWA,IAAM0F,IAAOD;E,kBAIXhF,EAAA,GAAAC,EA2CM,OAAA;GA1CJ,MAAK;GACJ,cAAYiF,EAAA;GACZ,eAAaA,EAAA;GACd,OAAM;;GAGNhF,EA+BM,OA/BNV,GA+BM,CA5BJU,EAcM,OAdNT,GAcM,CAbJS,EAKM,OALNR,GAKM,CAFJS,EAA4DC,EAAA6C,CAAA,GAAA;IAAjD,MAAM;IAAK,gBAAc;IAAG,eAAY;G,IACnD/C,EAAqD,QAArDP,GAAqDU,EAAf6E,EAAA,KAAK,GAAA,CAAA,C,IAGrCA,EAAA,YADRlF,EAAA,GAAAC,EAMI,KANJL,GAMIS,EADC6E,EAAA,QAAQ,GAAA,CAAA,K,aAGfhF,EAYM,OAZNL,GAYM,CAXJU,EAAuB6E,EAAA,QAAA,SAAA,GACvBlF,EASS,UAAA;IARP,MAAK;IACL,eAAY;IACZ,OAAM;IACL,cAAYgF,EAAA;IACZ,OAAOA,EAAA;IACP,SAAK,AAAAG,EAAA,QAAA,MAAEJ,EAAI,OAAA;G,IAEZ9E,EAAqDC,EAAAsD,CAAA,GAAA;IAAjD,MAAM;IAAK,gBAAc;IAAG,eAAY;;GAIlDxD,EAEM,OAFNH,GAEM,CADJQ,EAAQ6E,EAAA,QAAA,SAAA,C;GAEV7E,EAAsB6E,EAA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iJ,EAAA,QAAnB,GAAS,OADnB1J,EAAA,GAAAC,EAoBS,UAAA;KAlBN,KAAKiJ;KACN,MAAK;KACL,eAAY;KACZ,OAAKtI,EAAA,CAAC,kMACiB8I,EAAA,MAAS,SAAM,IAAOR,IAAQO,EAAA,Q;KAKrD,OAAA;MAAA,gBAAA;MAAAzD,OAAA;MAAA,oBAAA;MAAA,cAAA;KAAA;KAMC,UAAK,MAAEyE,GAAcC,CAAO;IAE1B,GAAA/J,EAAA+J,CAAO,GAAA,IAAAlE,EAAA,E"}
@@ -5,7 +5,7 @@ var d = /*#__PURE__*/ u(/* @__PURE__ */ t({
5
5
  __name: "AiPanels",
6
6
  props: { feature: {} },
7
7
  setup(t) {
8
- let u = i(() => import("./AiChatPanel-DciEt27y.js")), d = t, f = { chat: u }, p = l(() => {
8
+ let u = i(() => import("./AiChatPanel-By8Uo1nH.js")), d = t, f = { chat: u }, p = l(() => {
9
9
  let e = d.feature.panel.value;
10
10
  return e !== null && e in f ? f[e] : null;
11
11
  });
@@ -29,4 +29,4 @@ var d = /*#__PURE__*/ u(/* @__PURE__ */ t({
29
29
  }), [["__scopeId", "data-v-3d8e197c"]]);
30
30
  export { d as default };
31
31
 
32
- //# sourceMappingURL=AiPanels-BV5D1itk.js.map
32
+ //# sourceMappingURL=AiPanels-BblCSkQy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AiPanels-BV5D1itk.js","names":["_openBlock","_createBlock","_Transition","_withCtx","_KeepAlive","_resolveDynamicComponent","_createCommentVNode","_sfc_main","resolveDynamicComponent","defineComponent","openBlock","withCtx","defineAsyncComponent","KeepAlive","createCommentVNode","createBlock","Transition","computed","_plugin_vue_export_helper_default","AiPanels_default","AiChatPanel","props","__props","PANELS","current","panel","_cache"],"sources":["../../../src/components/ai/AiPanels.vue","../../../src/components/ai/AiPanels.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, defineAsyncComponent } from \"vue\";\nimport type { UseAiFeatureReturn } from \"../../composables/useAiFeature\";\n\nconst AiChatPanel = defineAsyncComponent(() => import(\"./AiChatPanel.vue\"));\n\nconst props = defineProps<{ feature: UseAiFeatureReturn }>();\n\nconst PANELS = {\n chat: AiChatPanel,\n} as const;\n\nconst current = computed(() => {\n const panel = props.feature.panel.value;\n return panel !== null && panel in PANELS\n ? PANELS[panel as keyof typeof PANELS]\n : null;\n});\n</script>\n\n<template>\n <Transition\n enter-active-class=\"tpl-ai-slide-enter-active\"\n enter-from-class=\"tpl:translate-x-full\"\n enter-to-class=\"tpl:translate-x-0\"\n leave-active-class=\"tpl-ai-slide-leave-active\"\n leave-from-class=\"tpl:translate-x-0\"\n leave-to-class=\"tpl:translate-x-full\"\n mode=\"out-in\"\n >\n <!-- Keep chat state when the panel closes. -->\n <KeepAlive>\n <component\n :is=\"current\"\n v-if=\"current\"\n :key=\"feature.panel.value ?? 'none'\"\n :feature=\"feature\"\n @close=\"feature.close()\"\n />\n </KeepAlive>\n </Transition>\n</template>\n\n<style scoped>\n.tpl-ai-slide-enter-active {\n transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n\n.tpl-ai-slide-leave-active {\n transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tpl-ai-slide-enter-active,\n .tpl-ai-slide-leave-active {\n transition: none;\n }\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, defineAsyncComponent } from \"vue\";\nimport type { UseAiFeatureReturn } from \"../../composables/useAiFeature\";\n\nconst AiChatPanel = defineAsyncComponent(() => import(\"./AiChatPanel.vue\"));\n\nconst props = defineProps<{ feature: UseAiFeatureReturn }>();\n\nconst PANELS = {\n chat: AiChatPanel,\n} as const;\n\nconst current = computed(() => {\n const panel = props.feature.panel.value;\n return panel !== null && panel in PANELS\n ? PANELS[panel as keyof typeof PANELS]\n : null;\n});\n</script>\n\n<template>\n <Transition\n enter-active-class=\"tpl-ai-slide-enter-active\"\n enter-from-class=\"tpl:translate-x-full\"\n enter-to-class=\"tpl:translate-x-0\"\n leave-active-class=\"tpl-ai-slide-leave-active\"\n leave-from-class=\"tpl:translate-x-0\"\n leave-to-class=\"tpl:translate-x-full\"\n mode=\"out-in\"\n >\n <!-- Keep chat state when the panel closes. -->\n <KeepAlive>\n <component\n :is=\"current\"\n v-if=\"current\"\n :key=\"feature.panel.value ?? 'none'\"\n :feature=\"feature\"\n @close=\"feature.close()\"\n />\n </KeepAlive>\n </Transition>\n</template>\n\n<style scoped>\n.tpl-ai-slide-enter-active {\n transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n\n.tpl-ai-slide-leave-active {\n transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tpl-ai-slide-enter-active,\n .tpl-ai-slide-leave-active {\n transition: none;\n }\n}\n</style>\n"],"mappings":";;;;;;;EAIA,IAAMoB,IAAcR,QAA2B,OAAO,4BAAoB,GAEpES,IAAQC,GAERC,IAAS,EACb,MAAMH,EACR,GAEMI,IAAUP,QAAe;GAC7B,IAAMQ,IAAQJ,EAAM,QAAQ,MAAM;GAClC,OAAOI,MAAU,QAAQA,KAASF,IAC9BA,EAAOE,KACP;EACN,CAAC;E,kBAICzB,EAAA,GAAAC,EAmBaC,GAAA;GAlBX,sBAAmB;GACnB,oBAAiB;GACjB,kBAAe;GACf,sBAAmB;GACnB,oBAAiB;GACjB,kBAAe;GACf,MAAK;;GAGL,SAAAC,QAQY,EARZH,EAAA,GAAAC,EAQYG,GAAA,MAAA,CALFoB,EAAA,SAFRxB,EAAA,GAAAC,EAMEI,EALKmB,EAAA,KAAO,GAAA;IAEX,KAAKF,EAAA,QAAQ,MAAM,SAAK;IACxB,SAASA,EAAA;IACT,SAAK,AAAAI,EAAA,QAAA,MAAEJ,EAAA,QAAQ,MAAK"}
1
+ {"version":3,"file":"AiPanels-BblCSkQy.js","names":["_openBlock","_createBlock","_Transition","_withCtx","_KeepAlive","_resolveDynamicComponent","_createCommentVNode","_sfc_main","resolveDynamicComponent","defineComponent","openBlock","withCtx","defineAsyncComponent","KeepAlive","createCommentVNode","createBlock","Transition","computed","_plugin_vue_export_helper_default","AiPanels_default","AiChatPanel","props","__props","PANELS","current","panel","_cache"],"sources":["../../../src/components/ai/AiPanels.vue","../../../src/components/ai/AiPanels.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, defineAsyncComponent } from \"vue\";\nimport type { UseAiFeatureReturn } from \"../../composables/useAiFeature\";\n\nconst AiChatPanel = defineAsyncComponent(() => import(\"./AiChatPanel.vue\"));\n\nconst props = defineProps<{ feature: UseAiFeatureReturn }>();\n\nconst PANELS = {\n chat: AiChatPanel,\n} as const;\n\nconst current = computed(() => {\n const panel = props.feature.panel.value;\n return panel !== null && panel in PANELS\n ? PANELS[panel as keyof typeof PANELS]\n : null;\n});\n</script>\n\n<template>\n <Transition\n enter-active-class=\"tpl-ai-slide-enter-active\"\n enter-from-class=\"tpl:translate-x-full\"\n enter-to-class=\"tpl:translate-x-0\"\n leave-active-class=\"tpl-ai-slide-leave-active\"\n leave-from-class=\"tpl:translate-x-0\"\n leave-to-class=\"tpl:translate-x-full\"\n mode=\"out-in\"\n >\n <!-- Keep chat state when the panel closes. -->\n <KeepAlive>\n <component\n :is=\"current\"\n v-if=\"current\"\n :key=\"feature.panel.value ?? 'none'\"\n :feature=\"feature\"\n @close=\"feature.close()\"\n />\n </KeepAlive>\n </Transition>\n</template>\n\n<style scoped>\n.tpl-ai-slide-enter-active {\n transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n\n.tpl-ai-slide-leave-active {\n transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tpl-ai-slide-enter-active,\n .tpl-ai-slide-leave-active {\n transition: none;\n }\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, defineAsyncComponent } from \"vue\";\nimport type { UseAiFeatureReturn } from \"../../composables/useAiFeature\";\n\nconst AiChatPanel = defineAsyncComponent(() => import(\"./AiChatPanel.vue\"));\n\nconst props = defineProps<{ feature: UseAiFeatureReturn }>();\n\nconst PANELS = {\n chat: AiChatPanel,\n} as const;\n\nconst current = computed(() => {\n const panel = props.feature.panel.value;\n return panel !== null && panel in PANELS\n ? PANELS[panel as keyof typeof PANELS]\n : null;\n});\n</script>\n\n<template>\n <Transition\n enter-active-class=\"tpl-ai-slide-enter-active\"\n enter-from-class=\"tpl:translate-x-full\"\n enter-to-class=\"tpl:translate-x-0\"\n leave-active-class=\"tpl-ai-slide-leave-active\"\n leave-from-class=\"tpl:translate-x-0\"\n leave-to-class=\"tpl:translate-x-full\"\n mode=\"out-in\"\n >\n <!-- Keep chat state when the panel closes. -->\n <KeepAlive>\n <component\n :is=\"current\"\n v-if=\"current\"\n :key=\"feature.panel.value ?? 'none'\"\n :feature=\"feature\"\n @close=\"feature.close()\"\n />\n </KeepAlive>\n </Transition>\n</template>\n\n<style scoped>\n.tpl-ai-slide-enter-active {\n transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n\n.tpl-ai-slide-leave-active {\n transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tpl-ai-slide-enter-active,\n .tpl-ai-slide-leave-active {\n transition: none;\n }\n}\n</style>\n"],"mappings":";;;;;;;EAIA,IAAMoB,IAAcR,QAA2B,OAAO,4BAAoB,GAEpES,IAAQC,GAERC,IAAS,EACb,MAAMH,EACR,GAEMI,IAAUP,QAAe;GAC7B,IAAMQ,IAAQJ,EAAM,QAAQ,MAAM;GAClC,OAAOI,MAAU,QAAQA,KAASF,IAC9BA,EAAOE,KACP;EACN,CAAC;E,kBAICzB,EAAA,GAAAC,EAmBaC,GAAA;GAlBX,sBAAmB;GACnB,oBAAiB;GACjB,kBAAe;GACf,sBAAmB;GACnB,oBAAiB;GACjB,kBAAe;GACf,MAAK;;GAGL,SAAAC,QAQY,EARZH,EAAA,GAAAC,EAQYG,GAAA,MAAA,CALFoB,EAAA,SAFRxB,EAAA,GAAAC,EAMEI,EALKmB,EAAA,KAAO,GAAA;IAEX,KAAKF,EAAA,QAAQ,MAAM,SAAK;IACxB,SAASA,EAAA;IACT,SAAK,AAAAI,EAAA,QAAA,MAAEJ,EAAA,QAAQ,MAAK"}
@@ -1,14 +1,14 @@
1
1
  import { C as e, F as t, H as n, K as r, L as i, M as a, O as o, _ as s, b as c, ct as l, dt as u, g as d, m as f, mt as p, o as ee, p as m, tt as h, u as g, x as _ } from "./draggable-DepKdldn.js";
2
- import { Zt as te, n as ne } from "./src-CACM3o--.js";
3
- import { D as re, T as ie, a as ae, mt as oe, t as se } from "./icons-CSSMtbGK.js";
2
+ import { Qt as te, n as ne } from "./src-BQUv2CYU.js";
3
+ import { D as re, T as ie, a as ae, mt as oe, t as se } from "./icons-Da9GKjPx.js";
4
4
  import { B as ce, P as le, V as ue, n as de, ot as fe, rt as pe, v as me } from "./keys-CoQtCqNv.js";
5
5
  import { t as he } from "./useI18n-BnJYydPv.js";
6
6
  import { w as v, x as y } from "./styleConstants-CgiNKdnc.js";
7
- import { t as ge } from "./sanitizeHtml-DYklmvgX.js";
8
- import { r as _e } from "./normalizeMergeTagMarkup-oGhwVscw.js";
7
+ import { t as ge } from "./sanitizeHtml-WTfz9lZd.js";
8
+ import { r as _e } from "./normalizeMergeTagMarkup-cC32Ox6A.js";
9
9
  import { n as ve } from "./aiErrors-C3QEMB0x.js";
10
10
  import { n as ye, t as be } from "./aiRewritePreview-DlMyx6Si.js";
11
- import { n as xe } from "./ParagraphEditor-DDolH_Pf.js";
11
+ import { n as xe } from "./ParagraphEditor-B3EQ0Ai6.js";
12
12
  // src/components/ai/AiRewriteMenu.vue?vue&type=script&setup=true&lang.ts
13
13
  var b = { class: "tpl:relative tpl:flex tpl:items-center" }, x = [
14
14
  "aria-label",
@@ -204,4 +204,4 @@ var b = { class: "tpl:relative tpl:flex tpl:items-center" }, x = [
204
204
  });
205
205
  export { P as default };
206
206
 
207
- //# sourceMappingURL=AiRewriteMenu-D3jkh6Xb.js.map
207
+ //# sourceMappingURL=AiRewriteMenu-YcVFv6RS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AiRewriteMenu-D3jkh6Xb.js","names":["_openBlock","_createElementBlock","_createElementVNode","_unref","_createVNode","_createTextVNode","_toDisplayString","_Fragment","_normalizeClass","_renderList","ToolbarSelect","_withDirectives","_vModelText","_createCommentVNode","_sfc_main","defineComponent","openBlock","watch","withDirectives","renderList","onBeforeUnmount","inject","createElementBlock","createTextVNode","unref","normalizeClass","createCommentVNode","createBaseVNode","toDisplayString","vModelText","computed","ref","Fragment","createVNode","SdkError","SYNTAX_PRESETS","Sparkles","Square","WandSparkles","Languages","X","MERGE_TAG_SYNTAX_KEY","MERGE_TAGS_KEY","NO_MERGE_TAGS","AI_FEATURE_KEY","requireInject","UI_LOCALE_KEY","EDITOR_KEY","useI18n","secondaryBtnCompactClass","primaryBtnCompactClass","sanitizeHtml","normalizeMergeTagsInHtml","aiErrorMessage","rewriteLanguageOptions","htmlToPlainText","ToolbarSelect_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","AiRewriteMenu_default","props","__props","feature","mergeTags","syntax","uiLocale","templateEditor","PRESETS","languages","isOpen","language","instruction","isRewriting","streamed","raw","failure","controller","generation","result","streamingPreview","errorText","t","format","stop","activeController","reset","close","toggle","run","text","preset","html","requestController","token","answer","chunk","error","replace","_cache","$event"],"sources":["../../../src/components/ai/AiRewriteMenu.vue","../../../src/components/ai/AiRewriteMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Editor } from \"@tiptap/core\";\nimport {\n SdkError,\n SYNTAX_PRESETS,\n type AiRewritePreset,\n} from \"@templatical/types\";\nimport { Languages, Sparkles, Square, WandSparkles, X } from \"@lucide/vue\";\nimport { computed, inject, onBeforeUnmount, ref, watch } from \"vue\";\nimport ToolbarSelect from \"../toolbar/ToolbarSelect.vue\";\nimport { useI18n } from \"../../composables/useI18n\";\nimport {\n primaryBtnCompactClass,\n secondaryBtnCompactClass,\n} from \"../../constants/styleConstants\";\nimport {\n AI_FEATURE_KEY,\n EDITOR_KEY,\n MERGE_TAGS_KEY,\n MERGE_TAG_SYNTAX_KEY,\n NO_MERGE_TAGS,\n UI_LOCALE_KEY,\n requireInject,\n} from \"../../keys\";\nimport { aiErrorMessage } from \"../../utils/aiErrors\";\nimport {\n htmlToPlainText,\n rewriteLanguageOptions,\n} from \"../../utils/aiRewritePreview\";\nimport { normalizeMergeTagsInHtml } from \"../../utils/normalizeMergeTagMarkup\";\nimport { sanitizeHtml } from \"../../utils/sanitizeHtml\";\n\n/**\n * Rewrite with AI, in the paragraph text toolbar: a preset or the user's own\n * instruction, streamed into a preview labelled as an AI suggestion. Replace\n * puts it into the paragraph through TipTap, so it is the user's own edit\n * (an ordinary change, on the normal undo stack, a normal batch with\n * collaboration). Rendered inside `.tpl-text-toolbar` and never teleported:\n * the paragraph leaves edit mode on a mousedown outside the toolbar.\n */\nconst props = defineProps<{ editor: Editor }>();\n\nconst { t, format } = useI18n();\nconst feature = requireInject(AI_FEATURE_KEY, \"AiRewriteMenu\");\nconst mergeTags = inject(MERGE_TAGS_KEY, NO_MERGE_TAGS);\nconst syntax = inject(MERGE_TAG_SYNTAX_KEY, SYNTAX_PRESETS.liquid);\nconst uiLocale = inject(UI_LOCALE_KEY, undefined);\nconst templateEditor = inject(EDITOR_KEY, null);\n\nconst PRESETS: Exclude<AiRewritePreset, \"translate\">[] = [\n \"shorten\",\n \"expand\",\n \"friendlier\",\n \"formal\",\n \"fixGrammar\",\n];\nconst languages = rewriteLanguageOptions(uiLocale);\n\nconst isOpen = ref(false);\nconst language = ref(languages[0].value);\nconst instruction = ref(\"\");\nconst isRewriting = ref(false);\nconst streamed = ref(\"\");\nconst raw = ref<string | null>(null);\nconst failure = ref<unknown>(null);\nlet controller: AbortController | null = null;\nlet generation = 0;\n\n/** The finished rewrite as the editor will hold it: tags, then sanitized (D22). */\nconst result = computed(() =>\n raw.value === null\n ? null\n : sanitizeHtml(\n normalizeMergeTagsInHtml(raw.value, mergeTags.value, syntax),\n ),\n);\nconst streamingPreview = computed(() => htmlToPlainText(streamed.value));\nconst errorText = computed(() =>\n failure.value\n ? aiErrorMessage(failure.value, t.ai.errors, format, uiLocale)\n : \"\",\n);\n\nfunction stop(): void {\n generation++;\n const activeController = controller;\n controller = null;\n isRewriting.value = false;\n activeController?.abort();\n}\n\nfunction reset(): void {\n stop();\n streamed.value = \"\";\n raw.value = null;\n failure.value = null;\n}\n\nfunction close(): void {\n reset();\n isOpen.value = false;\n}\n\nfunction toggle(): void {\n if (isOpen.value) close();\n else isOpen.value = true;\n}\n\nasync function run(preset: AiRewritePreset | null): Promise<void> {\n const text = instruction.value.trim();\n if (\n isRewriting.value ||\n (preset === null && text === \"\") ||\n (preset === \"translate\" && language.value === \"\")\n )\n return;\n reset();\n const html = props.editor.getHTML();\n if (Array.from(html).length > 20_000) {\n failure.value = new SdkError(t.ai.rewrite.tooLarge, 413);\n return;\n }\n const requestController = new AbortController();\n const token = ++generation;\n controller = requestController;\n isRewriting.value = true;\n try {\n const answer = await feature.rewrite(\n {\n html,\n preset,\n language: preset === \"translate\" ? language.value : null,\n instruction: text === \"\" ? null : text,\n },\n (chunk) => {\n if (token !== generation) return;\n streamed.value += chunk;\n },\n requestController.signal,\n );\n if (token !== generation) return;\n raw.value = answer.html;\n } catch (error) {\n if (\n token === generation &&\n !(error instanceof Error && error.name === \"AbortError\")\n )\n failure.value = error;\n } finally {\n if (token === generation) {\n isRewriting.value = false;\n controller = null;\n }\n }\n}\n\nfunction replace(): void {\n if (result.value === null) return;\n props.editor\n .chain()\n .focus()\n .setContent(result.value, { emitUpdate: true })\n .run();\n close();\n}\n\nif (templateEditor?.activeLocale)\n watch(templateEditor.activeLocale, close, { flush: \"sync\" });\nonBeforeUnmount(stop);\n</script>\n\n<template>\n <div class=\"tpl:relative tpl:flex tpl:items-center\">\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-trigger\"\n class=\"tpl:flex tpl:h-8 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:gap-1.5 tpl:rounded tpl:border-none tpl:bg-transparent tpl:px-2.5 tpl:text-xs tpl:font-medium tpl:text-[var(--tpl-primary)] tpl:transition-all tpl:hover:bg-[var(--tpl-bg-active)]\"\n :aria-label=\"t.ai.rewrite.title\"\n :title=\"t.ai.rewrite.title\"\n aria-haspopup=\"dialog\"\n :aria-expanded=\"isOpen\"\n @click=\"toggle\"\n >\n <Sparkles :size=\"16\" :stroke-width=\"2\" aria-hidden=\"true\" />\n {{ t.ai.menu.button }}\n </button>\n\n <div\n v-if=\"isOpen\"\n role=\"dialog\"\n :aria-label=\"t.ai.rewrite.title\"\n data-testid=\"ai-rewrite-panel\"\n class=\"tpl-ai-rewrite-panel tpl:absolute tpl:top-full tpl:right-0 tpl:z-50 tpl:mt-2 tpl:flex tpl:w-80 tpl:flex-col tpl:gap-3 tpl:rounded-[var(--tpl-radius)] tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:p-3 tpl:shadow-[var(--tpl-shadow-lg)]\"\n >\n <div class=\"tpl:flex tpl:items-center tpl:justify-between\">\n <span\n class=\"tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]\"\n >\n <WandSparkles :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n {{ t.ai.rewrite.title }}\n </span>\n <button\n type=\"button\"\n class=\"tpl:rounded-md tpl:p-0.5 tpl:text-[var(--tpl-text-muted)]\"\n :aria-label=\"t.ai.rewrite.close\"\n :title=\"t.ai.rewrite.close\"\n @click=\"close\"\n >\n <X :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </div>\n\n <!-- The finished rewrite: normalized and sanitized, labelled (Art. 50). -->\n <template v-if=\"result !== null\">\n <span\n data-testid=\"ai-rewrite-label\"\n class=\"tpl:self-start tpl:rounded tpl:px-1.5 tpl:py-px tpl:text-[10px] tpl:font-medium tpl:bg-[var(--tpl-secondary-light)] tpl:text-[var(--tpl-text)]\"\n >\n {{ t.ai.rewrite.suggestionLabel }}\n </span>\n <div\n data-testid=\"ai-rewrite-preview\"\n class=\"tpl:max-h-48 tpl:overflow-y-auto tpl:text-sm tpl:text-[var(--tpl-text)]\"\n v-html=\"result\"\n />\n <div class=\"tpl:flex tpl:justify-end tpl:gap-2\">\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-discard\"\n :class=\"secondaryBtnCompactClass\"\n @click=\"reset\"\n >\n {{ t.ai.rewrite.discard }}\n </button>\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-replace\"\n :class=\"primaryBtnCompactClass\"\n @click=\"replace\"\n >\n {{ t.ai.rewrite.replaceAction }}\n </button>\n </div>\n </template>\n\n <!-- Streaming: plain text only. -->\n <template v-else-if=\"isRewriting\">\n <span\n data-testid=\"ai-rewrite-label\"\n class=\"tpl:self-start tpl:rounded tpl:px-1.5 tpl:py-px tpl:text-[10px] tpl:font-medium tpl:bg-[var(--tpl-secondary-light)] tpl:text-[var(--tpl-text)]\"\n >\n {{ t.ai.rewrite.suggestionLabel }}\n </span>\n <p\n data-testid=\"ai-rewrite-preview\"\n class=\"tpl:m-0 tpl:max-h-48 tpl:overflow-y-auto tpl:whitespace-pre-wrap tpl:text-sm tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ streamingPreview || t.ai.rewrite.rewriting }}\n </p>\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-stop\"\n :class=\"[secondaryBtnCompactClass, 'tpl:self-end']\"\n @click=\"stop\"\n >\n <Square :size=\"12\" :stroke-width=\"2\" aria-hidden=\"true\" />\n {{ t.ai.rewrite.stop }}\n </button>\n </template>\n\n <template v-else>\n <div class=\"tpl:flex tpl:flex-wrap tpl:gap-1.5\">\n <button\n v-for=\"preset in PRESETS\"\n :key=\"preset\"\n type=\"button\"\n :data-testid=\"`ai-rewrite-preset-${preset}`\"\n :class=\"secondaryBtnCompactClass\"\n @click=\"run(preset)\"\n >\n {{ t.ai.rewrite.presets[preset] }}\n </button>\n </div>\n <div class=\"tpl:flex tpl:items-center tpl:gap-2\">\n <Languages\n :size=\"14\"\n :stroke-width=\"2\"\n class=\"tpl:shrink-0 tpl:text-[var(--tpl-text-muted)]\"\n aria-hidden=\"true\"\n />\n <ToolbarSelect\n v-model=\"language\"\n :options=\"languages\"\n :label=\"t.ai.rewrite.language\"\n width-class=\"tpl:flex-1\"\n />\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-preset-translate\"\n :class=\"secondaryBtnCompactClass\"\n :disabled=\"language === ''\"\n @click=\"run('translate')\"\n >\n {{ t.ai.rewrite.presets.translate }}\n </button>\n </div>\n <div class=\"tpl:flex tpl:items-end tpl:gap-2\">\n <textarea\n v-model=\"instruction\"\n data-testid=\"ai-rewrite-instruction\"\n maxlength=\"500\"\n rows=\"2\"\n class=\"tpl:flex-1 tpl:resize-none tpl:rounded-[var(--tpl-radius-sm)] tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:px-2 tpl:py-1.5 tpl:font-sans tpl:text-sm tpl:text-[var(--tpl-text)]\"\n :aria-label=\"t.ai.rewrite.instructionLabel\"\n :placeholder=\"t.ai.rewrite.instructionPlaceholder\"\n />\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-run\"\n :class=\"primaryBtnCompactClass\"\n :disabled=\"instruction.trim() === ''\"\n @click=\"run(null)\"\n >\n {{ t.ai.rewrite.run }}\n </button>\n </div>\n <p\n v-if=\"errorText\"\n role=\"alert\"\n data-testid=\"ai-rewrite-error\"\n class=\"tpl:m-0 tpl:text-xs tpl:text-[var(--tpl-danger)]\"\n >\n {{ errorText }}\n </p>\n <p class=\"tpl:m-0 tpl:text-[10px] tpl:text-[var(--tpl-text-dim)]\">\n {{ t.ai.chat.disclaimer }}\n </p>\n </template>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { Editor } from \"@tiptap/core\";\nimport {\n SdkError,\n SYNTAX_PRESETS,\n type AiRewritePreset,\n} from \"@templatical/types\";\nimport { Languages, Sparkles, Square, WandSparkles, X } from \"@lucide/vue\";\nimport { computed, inject, onBeforeUnmount, ref, watch } from \"vue\";\nimport ToolbarSelect from \"../toolbar/ToolbarSelect.vue\";\nimport { useI18n } from \"../../composables/useI18n\";\nimport {\n primaryBtnCompactClass,\n secondaryBtnCompactClass,\n} from \"../../constants/styleConstants\";\nimport {\n AI_FEATURE_KEY,\n EDITOR_KEY,\n MERGE_TAGS_KEY,\n MERGE_TAG_SYNTAX_KEY,\n NO_MERGE_TAGS,\n UI_LOCALE_KEY,\n requireInject,\n} from \"../../keys\";\nimport { aiErrorMessage } from \"../../utils/aiErrors\";\nimport {\n htmlToPlainText,\n rewriteLanguageOptions,\n} from \"../../utils/aiRewritePreview\";\nimport { normalizeMergeTagsInHtml } from \"../../utils/normalizeMergeTagMarkup\";\nimport { sanitizeHtml } from \"../../utils/sanitizeHtml\";\n\n/**\n * Rewrite with AI, in the paragraph text toolbar: a preset or the user's own\n * instruction, streamed into a preview labelled as an AI suggestion. Replace\n * puts it into the paragraph through TipTap, so it is the user's own edit\n * (an ordinary change, on the normal undo stack, a normal batch with\n * collaboration). Rendered inside `.tpl-text-toolbar` and never teleported:\n * the paragraph leaves edit mode on a mousedown outside the toolbar.\n */\nconst props = defineProps<{ editor: Editor }>();\n\nconst { t, format } = useI18n();\nconst feature = requireInject(AI_FEATURE_KEY, \"AiRewriteMenu\");\nconst mergeTags = inject(MERGE_TAGS_KEY, NO_MERGE_TAGS);\nconst syntax = inject(MERGE_TAG_SYNTAX_KEY, SYNTAX_PRESETS.liquid);\nconst uiLocale = inject(UI_LOCALE_KEY, undefined);\nconst templateEditor = inject(EDITOR_KEY, null);\n\nconst PRESETS: Exclude<AiRewritePreset, \"translate\">[] = [\n \"shorten\",\n \"expand\",\n \"friendlier\",\n \"formal\",\n \"fixGrammar\",\n];\nconst languages = rewriteLanguageOptions(uiLocale);\n\nconst isOpen = ref(false);\nconst language = ref(languages[0].value);\nconst instruction = ref(\"\");\nconst isRewriting = ref(false);\nconst streamed = ref(\"\");\nconst raw = ref<string | null>(null);\nconst failure = ref<unknown>(null);\nlet controller: AbortController | null = null;\nlet generation = 0;\n\n/** The finished rewrite as the editor will hold it: tags, then sanitized (D22). */\nconst result = computed(() =>\n raw.value === null\n ? null\n : sanitizeHtml(\n normalizeMergeTagsInHtml(raw.value, mergeTags.value, syntax),\n ),\n);\nconst streamingPreview = computed(() => htmlToPlainText(streamed.value));\nconst errorText = computed(() =>\n failure.value\n ? aiErrorMessage(failure.value, t.ai.errors, format, uiLocale)\n : \"\",\n);\n\nfunction stop(): void {\n generation++;\n const activeController = controller;\n controller = null;\n isRewriting.value = false;\n activeController?.abort();\n}\n\nfunction reset(): void {\n stop();\n streamed.value = \"\";\n raw.value = null;\n failure.value = null;\n}\n\nfunction close(): void {\n reset();\n isOpen.value = false;\n}\n\nfunction toggle(): void {\n if (isOpen.value) close();\n else isOpen.value = true;\n}\n\nasync function run(preset: AiRewritePreset | null): Promise<void> {\n const text = instruction.value.trim();\n if (\n isRewriting.value ||\n (preset === null && text === \"\") ||\n (preset === \"translate\" && language.value === \"\")\n )\n return;\n reset();\n const html = props.editor.getHTML();\n if (Array.from(html).length > 20_000) {\n failure.value = new SdkError(t.ai.rewrite.tooLarge, 413);\n return;\n }\n const requestController = new AbortController();\n const token = ++generation;\n controller = requestController;\n isRewriting.value = true;\n try {\n const answer = await feature.rewrite(\n {\n html,\n preset,\n language: preset === \"translate\" ? language.value : null,\n instruction: text === \"\" ? null : text,\n },\n (chunk) => {\n if (token !== generation) return;\n streamed.value += chunk;\n },\n requestController.signal,\n );\n if (token !== generation) return;\n raw.value = answer.html;\n } catch (error) {\n if (\n token === generation &&\n !(error instanceof Error && error.name === \"AbortError\")\n )\n failure.value = error;\n } finally {\n if (token === generation) {\n isRewriting.value = false;\n controller = null;\n }\n }\n}\n\nfunction replace(): void {\n if (result.value === null) return;\n props.editor\n .chain()\n .focus()\n .setContent(result.value, { emitUpdate: true })\n .run();\n close();\n}\n\nif (templateEditor?.activeLocale)\n watch(templateEditor.activeLocale, close, { flush: \"sync\" });\nonBeforeUnmount(stop);\n</script>\n\n<template>\n <div class=\"tpl:relative tpl:flex tpl:items-center\">\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-trigger\"\n class=\"tpl:flex tpl:h-8 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:gap-1.5 tpl:rounded tpl:border-none tpl:bg-transparent tpl:px-2.5 tpl:text-xs tpl:font-medium tpl:text-[var(--tpl-primary)] tpl:transition-all tpl:hover:bg-[var(--tpl-bg-active)]\"\n :aria-label=\"t.ai.rewrite.title\"\n :title=\"t.ai.rewrite.title\"\n aria-haspopup=\"dialog\"\n :aria-expanded=\"isOpen\"\n @click=\"toggle\"\n >\n <Sparkles :size=\"16\" :stroke-width=\"2\" aria-hidden=\"true\" />\n {{ t.ai.menu.button }}\n </button>\n\n <div\n v-if=\"isOpen\"\n role=\"dialog\"\n :aria-label=\"t.ai.rewrite.title\"\n data-testid=\"ai-rewrite-panel\"\n class=\"tpl-ai-rewrite-panel tpl:absolute tpl:top-full tpl:right-0 tpl:z-50 tpl:mt-2 tpl:flex tpl:w-80 tpl:flex-col tpl:gap-3 tpl:rounded-[var(--tpl-radius)] tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:p-3 tpl:shadow-[var(--tpl-shadow-lg)]\"\n >\n <div class=\"tpl:flex tpl:items-center tpl:justify-between\">\n <span\n class=\"tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]\"\n >\n <WandSparkles :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n {{ t.ai.rewrite.title }}\n </span>\n <button\n type=\"button\"\n class=\"tpl:rounded-md tpl:p-0.5 tpl:text-[var(--tpl-text-muted)]\"\n :aria-label=\"t.ai.rewrite.close\"\n :title=\"t.ai.rewrite.close\"\n @click=\"close\"\n >\n <X :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </div>\n\n <!-- The finished rewrite: normalized and sanitized, labelled (Art. 50). -->\n <template v-if=\"result !== null\">\n <span\n data-testid=\"ai-rewrite-label\"\n class=\"tpl:self-start tpl:rounded tpl:px-1.5 tpl:py-px tpl:text-[10px] tpl:font-medium tpl:bg-[var(--tpl-secondary-light)] tpl:text-[var(--tpl-text)]\"\n >\n {{ t.ai.rewrite.suggestionLabel }}\n </span>\n <div\n data-testid=\"ai-rewrite-preview\"\n class=\"tpl:max-h-48 tpl:overflow-y-auto tpl:text-sm tpl:text-[var(--tpl-text)]\"\n v-html=\"result\"\n />\n <div class=\"tpl:flex tpl:justify-end tpl:gap-2\">\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-discard\"\n :class=\"secondaryBtnCompactClass\"\n @click=\"reset\"\n >\n {{ t.ai.rewrite.discard }}\n </button>\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-replace\"\n :class=\"primaryBtnCompactClass\"\n @click=\"replace\"\n >\n {{ t.ai.rewrite.replaceAction }}\n </button>\n </div>\n </template>\n\n <!-- Streaming: plain text only. -->\n <template v-else-if=\"isRewriting\">\n <span\n data-testid=\"ai-rewrite-label\"\n class=\"tpl:self-start tpl:rounded tpl:px-1.5 tpl:py-px tpl:text-[10px] tpl:font-medium tpl:bg-[var(--tpl-secondary-light)] tpl:text-[var(--tpl-text)]\"\n >\n {{ t.ai.rewrite.suggestionLabel }}\n </span>\n <p\n data-testid=\"ai-rewrite-preview\"\n class=\"tpl:m-0 tpl:max-h-48 tpl:overflow-y-auto tpl:whitespace-pre-wrap tpl:text-sm tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ streamingPreview || t.ai.rewrite.rewriting }}\n </p>\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-stop\"\n :class=\"[secondaryBtnCompactClass, 'tpl:self-end']\"\n @click=\"stop\"\n >\n <Square :size=\"12\" :stroke-width=\"2\" aria-hidden=\"true\" />\n {{ t.ai.rewrite.stop }}\n </button>\n </template>\n\n <template v-else>\n <div class=\"tpl:flex tpl:flex-wrap tpl:gap-1.5\">\n <button\n v-for=\"preset in PRESETS\"\n :key=\"preset\"\n type=\"button\"\n :data-testid=\"`ai-rewrite-preset-${preset}`\"\n :class=\"secondaryBtnCompactClass\"\n @click=\"run(preset)\"\n >\n {{ t.ai.rewrite.presets[preset] }}\n </button>\n </div>\n <div class=\"tpl:flex tpl:items-center tpl:gap-2\">\n <Languages\n :size=\"14\"\n :stroke-width=\"2\"\n class=\"tpl:shrink-0 tpl:text-[var(--tpl-text-muted)]\"\n aria-hidden=\"true\"\n />\n <ToolbarSelect\n v-model=\"language\"\n :options=\"languages\"\n :label=\"t.ai.rewrite.language\"\n width-class=\"tpl:flex-1\"\n />\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-preset-translate\"\n :class=\"secondaryBtnCompactClass\"\n :disabled=\"language === ''\"\n @click=\"run('translate')\"\n >\n {{ t.ai.rewrite.presets.translate }}\n </button>\n </div>\n <div class=\"tpl:flex tpl:items-end tpl:gap-2\">\n <textarea\n v-model=\"instruction\"\n data-testid=\"ai-rewrite-instruction\"\n maxlength=\"500\"\n rows=\"2\"\n class=\"tpl:flex-1 tpl:resize-none tpl:rounded-[var(--tpl-radius-sm)] tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:px-2 tpl:py-1.5 tpl:font-sans tpl:text-sm tpl:text-[var(--tpl-text)]\"\n :aria-label=\"t.ai.rewrite.instructionLabel\"\n :placeholder=\"t.ai.rewrite.instructionPlaceholder\"\n />\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-run\"\n :class=\"primaryBtnCompactClass\"\n :disabled=\"instruction.trim() === ''\"\n @click=\"run(null)\"\n >\n {{ t.ai.rewrite.run }}\n </button>\n </div>\n <p\n v-if=\"errorText\"\n role=\"alert\"\n data-testid=\"ai-rewrite-error\"\n class=\"tpl:m-0 tpl:text-xs tpl:text-[var(--tpl-danger)]\"\n >\n {{ errorText }}\n </p>\n <p class=\"tpl:m-0 tpl:text-[10px] tpl:text-[var(--tpl-text-dim)]\">\n {{ t.ai.chat.disclaimer }}\n </p>\n </template>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwCA,IAAM8E,IAAQC,GAER,EAAE,MAAG,eAAW/B,GAAQ,GACxBgC,KAAUnC,GAAcD,IAAgB,eAAe,GACvDqC,KAAY5D,EAAOqB,IAAgBC,EAAa,GAChDuC,KAAS7D,EAAOoB,IAAsBN,GAAe,MAAM,GAC3DgD,IAAW9D,EAAOyB,IAAe,KAAA,CAAS,GAC1CsC,IAAiB/D,EAAO0B,IAAY,IAAI,GAExCsC,KAAmD;GACvD;GACA;GACA;GACA;GACA;EACF,GACMC,IAAYhC,GAAuB6B,CAAQ,GAE3CI,IAASxD,EAAI,EAAK,GAClByD,IAAWzD,EAAIuD,EAAU,EAAE,CAAC,KAAK,GACjCG,IAAc1D,EAAI,EAAE,GACpB2D,IAAc3D,EAAI,EAAK,GACvB4D,IAAW5D,EAAI,EAAE,GACjB6D,IAAM7D,EAAmB,IAAI,GAC7B8D,IAAU9D,EAAa,IAAI,GAC7B+D,IAAqC,MACrCC,IAAa,GAGXC,IAASlE,QACb8D,EAAI,UAAU,OACV,OACAzC,GACEC,GAAyBwC,EAAI,OAAOX,GAAU,OAAOC,EAAM,CAC7D,CACN,GACMe,KAAmBnE,QAAeyB,GAAgBoC,EAAS,KAAK,CAAC,GACjEO,IAAYpE,QAChB+D,EAAQ,QACJxC,GAAewC,EAAQ,OAAOM,E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EA8BWM,GAAA,EAAA,KAAA,EAAA,GAAA;GA7BTL,EAKO,QALP6D,GAKOzD,EADFH,EAAAgG,CAAA,CAAC,CAAC,GAAG,QAAQ,eAAe,GAAA,CAAA;GAEjCjG,EAIE,OAAA;IAHA,eAAY;IACZ,OAAM;IACN,WAAQ8F,EAAA;;GAEV9F,EAiBM,OAjBN+D,GAiBM,CAhBJ/D,EAOS,UAAA;IANP,MAAK;IACL,eAAY;IACX,OAAKM,EAAEL,EAAA8C,CAAA,CAAwB;IAC/B,SAAOsD;GAEL,GAAAjG,EAAAH,EAAAgG,CAAA,CAAC,CAAC,GAAG,QAAQ,OAAO,GAAA,CAAA,GAEzBjG,EAOS,UAAA;IANP,MAAK;IACL,eAAY;IACX,OAAKM,EAAEL,EAAA+C,CAAA,CAAsB;IAC7B,SAAOiE;GAEL,GAAA7G,EAAAH,EAAAgG,CAAA,CAAC,CAAC,GAAG,QAAQ,aAAa,GAAA,CAAA,C"}
1
+ {"version":3,"file":"AiRewriteMenu-YcVFv6RS.js","names":["_openBlock","_createElementBlock","_createElementVNode","_unref","_createVNode","_createTextVNode","_toDisplayString","_Fragment","_normalizeClass","_renderList","ToolbarSelect","_withDirectives","_vModelText","_createCommentVNode","_sfc_main","defineComponent","openBlock","watch","withDirectives","renderList","onBeforeUnmount","inject","createElementBlock","createTextVNode","unref","normalizeClass","createCommentVNode","createBaseVNode","toDisplayString","vModelText","computed","ref","Fragment","createVNode","SdkError","SYNTAX_PRESETS","Sparkles","Square","WandSparkles","Languages","X","MERGE_TAG_SYNTAX_KEY","MERGE_TAGS_KEY","NO_MERGE_TAGS","AI_FEATURE_KEY","requireInject","UI_LOCALE_KEY","EDITOR_KEY","useI18n","secondaryBtnCompactClass","primaryBtnCompactClass","sanitizeHtml","normalizeMergeTagsInHtml","aiErrorMessage","rewriteLanguageOptions","htmlToPlainText","ToolbarSelect_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","AiRewriteMenu_default","props","__props","feature","mergeTags","syntax","uiLocale","templateEditor","PRESETS","languages","isOpen","language","instruction","isRewriting","streamed","raw","failure","controller","generation","result","streamingPreview","errorText","t","format","stop","activeController","reset","close","toggle","run","text","preset","html","requestController","token","answer","chunk","error","replace","_cache","$event"],"sources":["../../../src/components/ai/AiRewriteMenu.vue","../../../src/components/ai/AiRewriteMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Editor } from \"@tiptap/core\";\nimport {\n SdkError,\n SYNTAX_PRESETS,\n type AiRewritePreset,\n} from \"@templatical/types\";\nimport { Languages, Sparkles, Square, WandSparkles, X } from \"@lucide/vue\";\nimport { computed, inject, onBeforeUnmount, ref, watch } from \"vue\";\nimport ToolbarSelect from \"../toolbar/ToolbarSelect.vue\";\nimport { useI18n } from \"../../composables/useI18n\";\nimport {\n primaryBtnCompactClass,\n secondaryBtnCompactClass,\n} from \"../../constants/styleConstants\";\nimport {\n AI_FEATURE_KEY,\n EDITOR_KEY,\n MERGE_TAGS_KEY,\n MERGE_TAG_SYNTAX_KEY,\n NO_MERGE_TAGS,\n UI_LOCALE_KEY,\n requireInject,\n} from \"../../keys\";\nimport { aiErrorMessage } from \"../../utils/aiErrors\";\nimport {\n htmlToPlainText,\n rewriteLanguageOptions,\n} from \"../../utils/aiRewritePreview\";\nimport { normalizeMergeTagsInHtml } from \"../../utils/normalizeMergeTagMarkup\";\nimport { sanitizeHtml } from \"../../utils/sanitizeHtml\";\n\n/**\n * Rewrite with AI, in the paragraph text toolbar: a preset or the user's own\n * instruction, streamed into a preview labelled as an AI suggestion. Replace\n * puts it into the paragraph through TipTap, so it is the user's own edit\n * (an ordinary change, on the normal undo stack, a normal batch with\n * collaboration). Rendered inside `.tpl-text-toolbar` and never teleported:\n * the paragraph leaves edit mode on a mousedown outside the toolbar.\n */\nconst props = defineProps<{ editor: Editor }>();\n\nconst { t, format } = useI18n();\nconst feature = requireInject(AI_FEATURE_KEY, \"AiRewriteMenu\");\nconst mergeTags = inject(MERGE_TAGS_KEY, NO_MERGE_TAGS);\nconst syntax = inject(MERGE_TAG_SYNTAX_KEY, SYNTAX_PRESETS.liquid);\nconst uiLocale = inject(UI_LOCALE_KEY, undefined);\nconst templateEditor = inject(EDITOR_KEY, null);\n\nconst PRESETS: Exclude<AiRewritePreset, \"translate\">[] = [\n \"shorten\",\n \"expand\",\n \"friendlier\",\n \"formal\",\n \"fixGrammar\",\n];\nconst languages = rewriteLanguageOptions(uiLocale);\n\nconst isOpen = ref(false);\nconst language = ref(languages[0].value);\nconst instruction = ref(\"\");\nconst isRewriting = ref(false);\nconst streamed = ref(\"\");\nconst raw = ref<string | null>(null);\nconst failure = ref<unknown>(null);\nlet controller: AbortController | null = null;\nlet generation = 0;\n\n/** The finished rewrite as the editor will hold it: tags, then sanitized (D22). */\nconst result = computed(() =>\n raw.value === null\n ? null\n : sanitizeHtml(\n normalizeMergeTagsInHtml(raw.value, mergeTags.value, syntax),\n ),\n);\nconst streamingPreview = computed(() => htmlToPlainText(streamed.value));\nconst errorText = computed(() =>\n failure.value\n ? aiErrorMessage(failure.value, t.ai.errors, format, uiLocale)\n : \"\",\n);\n\nfunction stop(): void {\n generation++;\n const activeController = controller;\n controller = null;\n isRewriting.value = false;\n activeController?.abort();\n}\n\nfunction reset(): void {\n stop();\n streamed.value = \"\";\n raw.value = null;\n failure.value = null;\n}\n\nfunction close(): void {\n reset();\n isOpen.value = false;\n}\n\nfunction toggle(): void {\n if (isOpen.value) close();\n else isOpen.value = true;\n}\n\nasync function run(preset: AiRewritePreset | null): Promise<void> {\n const text = instruction.value.trim();\n if (\n isRewriting.value ||\n (preset === null && text === \"\") ||\n (preset === \"translate\" && language.value === \"\")\n )\n return;\n reset();\n const html = props.editor.getHTML();\n if (Array.from(html).length > 20_000) {\n failure.value = new SdkError(t.ai.rewrite.tooLarge, 413);\n return;\n }\n const requestController = new AbortController();\n const token = ++generation;\n controller = requestController;\n isRewriting.value = true;\n try {\n const answer = await feature.rewrite(\n {\n html,\n preset,\n language: preset === \"translate\" ? language.value : null,\n instruction: text === \"\" ? null : text,\n },\n (chunk) => {\n if (token !== generation) return;\n streamed.value += chunk;\n },\n requestController.signal,\n );\n if (token !== generation) return;\n raw.value = answer.html;\n } catch (error) {\n if (\n token === generation &&\n !(error instanceof Error && error.name === \"AbortError\")\n )\n failure.value = error;\n } finally {\n if (token === generation) {\n isRewriting.value = false;\n controller = null;\n }\n }\n}\n\nfunction replace(): void {\n if (result.value === null) return;\n props.editor\n .chain()\n .focus()\n .setContent(result.value, { emitUpdate: true })\n .run();\n close();\n}\n\nif (templateEditor?.activeLocale)\n watch(templateEditor.activeLocale, close, { flush: \"sync\" });\nonBeforeUnmount(stop);\n</script>\n\n<template>\n <div class=\"tpl:relative tpl:flex tpl:items-center\">\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-trigger\"\n class=\"tpl:flex tpl:h-8 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:gap-1.5 tpl:rounded tpl:border-none tpl:bg-transparent tpl:px-2.5 tpl:text-xs tpl:font-medium tpl:text-[var(--tpl-primary)] tpl:transition-all tpl:hover:bg-[var(--tpl-bg-active)]\"\n :aria-label=\"t.ai.rewrite.title\"\n :title=\"t.ai.rewrite.title\"\n aria-haspopup=\"dialog\"\n :aria-expanded=\"isOpen\"\n @click=\"toggle\"\n >\n <Sparkles :size=\"16\" :stroke-width=\"2\" aria-hidden=\"true\" />\n {{ t.ai.menu.button }}\n </button>\n\n <div\n v-if=\"isOpen\"\n role=\"dialog\"\n :aria-label=\"t.ai.rewrite.title\"\n data-testid=\"ai-rewrite-panel\"\n class=\"tpl-ai-rewrite-panel tpl:absolute tpl:top-full tpl:right-0 tpl:z-50 tpl:mt-2 tpl:flex tpl:w-80 tpl:flex-col tpl:gap-3 tpl:rounded-[var(--tpl-radius)] tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:p-3 tpl:shadow-[var(--tpl-shadow-lg)]\"\n >\n <div class=\"tpl:flex tpl:items-center tpl:justify-between\">\n <span\n class=\"tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]\"\n >\n <WandSparkles :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n {{ t.ai.rewrite.title }}\n </span>\n <button\n type=\"button\"\n class=\"tpl:rounded-md tpl:p-0.5 tpl:text-[var(--tpl-text-muted)]\"\n :aria-label=\"t.ai.rewrite.close\"\n :title=\"t.ai.rewrite.close\"\n @click=\"close\"\n >\n <X :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </div>\n\n <!-- The finished rewrite: normalized and sanitized, labelled (Art. 50). -->\n <template v-if=\"result !== null\">\n <span\n data-testid=\"ai-rewrite-label\"\n class=\"tpl:self-start tpl:rounded tpl:px-1.5 tpl:py-px tpl:text-[10px] tpl:font-medium tpl:bg-[var(--tpl-secondary-light)] tpl:text-[var(--tpl-text)]\"\n >\n {{ t.ai.rewrite.suggestionLabel }}\n </span>\n <div\n data-testid=\"ai-rewrite-preview\"\n class=\"tpl:max-h-48 tpl:overflow-y-auto tpl:text-sm tpl:text-[var(--tpl-text)]\"\n v-html=\"result\"\n />\n <div class=\"tpl:flex tpl:justify-end tpl:gap-2\">\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-discard\"\n :class=\"secondaryBtnCompactClass\"\n @click=\"reset\"\n >\n {{ t.ai.rewrite.discard }}\n </button>\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-replace\"\n :class=\"primaryBtnCompactClass\"\n @click=\"replace\"\n >\n {{ t.ai.rewrite.replaceAction }}\n </button>\n </div>\n </template>\n\n <!-- Streaming: plain text only. -->\n <template v-else-if=\"isRewriting\">\n <span\n data-testid=\"ai-rewrite-label\"\n class=\"tpl:self-start tpl:rounded tpl:px-1.5 tpl:py-px tpl:text-[10px] tpl:font-medium tpl:bg-[var(--tpl-secondary-light)] tpl:text-[var(--tpl-text)]\"\n >\n {{ t.ai.rewrite.suggestionLabel }}\n </span>\n <p\n data-testid=\"ai-rewrite-preview\"\n class=\"tpl:m-0 tpl:max-h-48 tpl:overflow-y-auto tpl:whitespace-pre-wrap tpl:text-sm tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ streamingPreview || t.ai.rewrite.rewriting }}\n </p>\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-stop\"\n :class=\"[secondaryBtnCompactClass, 'tpl:self-end']\"\n @click=\"stop\"\n >\n <Square :size=\"12\" :stroke-width=\"2\" aria-hidden=\"true\" />\n {{ t.ai.rewrite.stop }}\n </button>\n </template>\n\n <template v-else>\n <div class=\"tpl:flex tpl:flex-wrap tpl:gap-1.5\">\n <button\n v-for=\"preset in PRESETS\"\n :key=\"preset\"\n type=\"button\"\n :data-testid=\"`ai-rewrite-preset-${preset}`\"\n :class=\"secondaryBtnCompactClass\"\n @click=\"run(preset)\"\n >\n {{ t.ai.rewrite.presets[preset] }}\n </button>\n </div>\n <div class=\"tpl:flex tpl:items-center tpl:gap-2\">\n <Languages\n :size=\"14\"\n :stroke-width=\"2\"\n class=\"tpl:shrink-0 tpl:text-[var(--tpl-text-muted)]\"\n aria-hidden=\"true\"\n />\n <ToolbarSelect\n v-model=\"language\"\n :options=\"languages\"\n :label=\"t.ai.rewrite.language\"\n width-class=\"tpl:flex-1\"\n />\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-preset-translate\"\n :class=\"secondaryBtnCompactClass\"\n :disabled=\"language === ''\"\n @click=\"run('translate')\"\n >\n {{ t.ai.rewrite.presets.translate }}\n </button>\n </div>\n <div class=\"tpl:flex tpl:items-end tpl:gap-2\">\n <textarea\n v-model=\"instruction\"\n data-testid=\"ai-rewrite-instruction\"\n maxlength=\"500\"\n rows=\"2\"\n class=\"tpl:flex-1 tpl:resize-none tpl:rounded-[var(--tpl-radius-sm)] tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:px-2 tpl:py-1.5 tpl:font-sans tpl:text-sm tpl:text-[var(--tpl-text)]\"\n :aria-label=\"t.ai.rewrite.instructionLabel\"\n :placeholder=\"t.ai.rewrite.instructionPlaceholder\"\n />\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-run\"\n :class=\"primaryBtnCompactClass\"\n :disabled=\"instruction.trim() === ''\"\n @click=\"run(null)\"\n >\n {{ t.ai.rewrite.run }}\n </button>\n </div>\n <p\n v-if=\"errorText\"\n role=\"alert\"\n data-testid=\"ai-rewrite-error\"\n class=\"tpl:m-0 tpl:text-xs tpl:text-[var(--tpl-danger)]\"\n >\n {{ errorText }}\n </p>\n <p class=\"tpl:m-0 tpl:text-[10px] tpl:text-[var(--tpl-text-dim)]\">\n {{ t.ai.chat.disclaimer }}\n </p>\n </template>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { Editor } from \"@tiptap/core\";\nimport {\n SdkError,\n SYNTAX_PRESETS,\n type AiRewritePreset,\n} from \"@templatical/types\";\nimport { Languages, Sparkles, Square, WandSparkles, X } from \"@lucide/vue\";\nimport { computed, inject, onBeforeUnmount, ref, watch } from \"vue\";\nimport ToolbarSelect from \"../toolbar/ToolbarSelect.vue\";\nimport { useI18n } from \"../../composables/useI18n\";\nimport {\n primaryBtnCompactClass,\n secondaryBtnCompactClass,\n} from \"../../constants/styleConstants\";\nimport {\n AI_FEATURE_KEY,\n EDITOR_KEY,\n MERGE_TAGS_KEY,\n MERGE_TAG_SYNTAX_KEY,\n NO_MERGE_TAGS,\n UI_LOCALE_KEY,\n requireInject,\n} from \"../../keys\";\nimport { aiErrorMessage } from \"../../utils/aiErrors\";\nimport {\n htmlToPlainText,\n rewriteLanguageOptions,\n} from \"../../utils/aiRewritePreview\";\nimport { normalizeMergeTagsInHtml } from \"../../utils/normalizeMergeTagMarkup\";\nimport { sanitizeHtml } from \"../../utils/sanitizeHtml\";\n\n/**\n * Rewrite with AI, in the paragraph text toolbar: a preset or the user's own\n * instruction, streamed into a preview labelled as an AI suggestion. Replace\n * puts it into the paragraph through TipTap, so it is the user's own edit\n * (an ordinary change, on the normal undo stack, a normal batch with\n * collaboration). Rendered inside `.tpl-text-toolbar` and never teleported:\n * the paragraph leaves edit mode on a mousedown outside the toolbar.\n */\nconst props = defineProps<{ editor: Editor }>();\n\nconst { t, format } = useI18n();\nconst feature = requireInject(AI_FEATURE_KEY, \"AiRewriteMenu\");\nconst mergeTags = inject(MERGE_TAGS_KEY, NO_MERGE_TAGS);\nconst syntax = inject(MERGE_TAG_SYNTAX_KEY, SYNTAX_PRESETS.liquid);\nconst uiLocale = inject(UI_LOCALE_KEY, undefined);\nconst templateEditor = inject(EDITOR_KEY, null);\n\nconst PRESETS: Exclude<AiRewritePreset, \"translate\">[] = [\n \"shorten\",\n \"expand\",\n \"friendlier\",\n \"formal\",\n \"fixGrammar\",\n];\nconst languages = rewriteLanguageOptions(uiLocale);\n\nconst isOpen = ref(false);\nconst language = ref(languages[0].value);\nconst instruction = ref(\"\");\nconst isRewriting = ref(false);\nconst streamed = ref(\"\");\nconst raw = ref<string | null>(null);\nconst failure = ref<unknown>(null);\nlet controller: AbortController | null = null;\nlet generation = 0;\n\n/** The finished rewrite as the editor will hold it: tags, then sanitized (D22). */\nconst result = computed(() =>\n raw.value === null\n ? null\n : sanitizeHtml(\n normalizeMergeTagsInHtml(raw.value, mergeTags.value, syntax),\n ),\n);\nconst streamingPreview = computed(() => htmlToPlainText(streamed.value));\nconst errorText = computed(() =>\n failure.value\n ? aiErrorMessage(failure.value, t.ai.errors, format, uiLocale)\n : \"\",\n);\n\nfunction stop(): void {\n generation++;\n const activeController = controller;\n controller = null;\n isRewriting.value = false;\n activeController?.abort();\n}\n\nfunction reset(): void {\n stop();\n streamed.value = \"\";\n raw.value = null;\n failure.value = null;\n}\n\nfunction close(): void {\n reset();\n isOpen.value = false;\n}\n\nfunction toggle(): void {\n if (isOpen.value) close();\n else isOpen.value = true;\n}\n\nasync function run(preset: AiRewritePreset | null): Promise<void> {\n const text = instruction.value.trim();\n if (\n isRewriting.value ||\n (preset === null && text === \"\") ||\n (preset === \"translate\" && language.value === \"\")\n )\n return;\n reset();\n const html = props.editor.getHTML();\n if (Array.from(html).length > 20_000) {\n failure.value = new SdkError(t.ai.rewrite.tooLarge, 413);\n return;\n }\n const requestController = new AbortController();\n const token = ++generation;\n controller = requestController;\n isRewriting.value = true;\n try {\n const answer = await feature.rewrite(\n {\n html,\n preset,\n language: preset === \"translate\" ? language.value : null,\n instruction: text === \"\" ? null : text,\n },\n (chunk) => {\n if (token !== generation) return;\n streamed.value += chunk;\n },\n requestController.signal,\n );\n if (token !== generation) return;\n raw.value = answer.html;\n } catch (error) {\n if (\n token === generation &&\n !(error instanceof Error && error.name === \"AbortError\")\n )\n failure.value = error;\n } finally {\n if (token === generation) {\n isRewriting.value = false;\n controller = null;\n }\n }\n}\n\nfunction replace(): void {\n if (result.value === null) return;\n props.editor\n .chain()\n .focus()\n .setContent(result.value, { emitUpdate: true })\n .run();\n close();\n}\n\nif (templateEditor?.activeLocale)\n watch(templateEditor.activeLocale, close, { flush: \"sync\" });\nonBeforeUnmount(stop);\n</script>\n\n<template>\n <div class=\"tpl:relative tpl:flex tpl:items-center\">\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-trigger\"\n class=\"tpl:flex tpl:h-8 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:gap-1.5 tpl:rounded tpl:border-none tpl:bg-transparent tpl:px-2.5 tpl:text-xs tpl:font-medium tpl:text-[var(--tpl-primary)] tpl:transition-all tpl:hover:bg-[var(--tpl-bg-active)]\"\n :aria-label=\"t.ai.rewrite.title\"\n :title=\"t.ai.rewrite.title\"\n aria-haspopup=\"dialog\"\n :aria-expanded=\"isOpen\"\n @click=\"toggle\"\n >\n <Sparkles :size=\"16\" :stroke-width=\"2\" aria-hidden=\"true\" />\n {{ t.ai.menu.button }}\n </button>\n\n <div\n v-if=\"isOpen\"\n role=\"dialog\"\n :aria-label=\"t.ai.rewrite.title\"\n data-testid=\"ai-rewrite-panel\"\n class=\"tpl-ai-rewrite-panel tpl:absolute tpl:top-full tpl:right-0 tpl:z-50 tpl:mt-2 tpl:flex tpl:w-80 tpl:flex-col tpl:gap-3 tpl:rounded-[var(--tpl-radius)] tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:p-3 tpl:shadow-[var(--tpl-shadow-lg)]\"\n >\n <div class=\"tpl:flex tpl:items-center tpl:justify-between\">\n <span\n class=\"tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]\"\n >\n <WandSparkles :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n {{ t.ai.rewrite.title }}\n </span>\n <button\n type=\"button\"\n class=\"tpl:rounded-md tpl:p-0.5 tpl:text-[var(--tpl-text-muted)]\"\n :aria-label=\"t.ai.rewrite.close\"\n :title=\"t.ai.rewrite.close\"\n @click=\"close\"\n >\n <X :size=\"14\" :stroke-width=\"2\" aria-hidden=\"true\" />\n </button>\n </div>\n\n <!-- The finished rewrite: normalized and sanitized, labelled (Art. 50). -->\n <template v-if=\"result !== null\">\n <span\n data-testid=\"ai-rewrite-label\"\n class=\"tpl:self-start tpl:rounded tpl:px-1.5 tpl:py-px tpl:text-[10px] tpl:font-medium tpl:bg-[var(--tpl-secondary-light)] tpl:text-[var(--tpl-text)]\"\n >\n {{ t.ai.rewrite.suggestionLabel }}\n </span>\n <div\n data-testid=\"ai-rewrite-preview\"\n class=\"tpl:max-h-48 tpl:overflow-y-auto tpl:text-sm tpl:text-[var(--tpl-text)]\"\n v-html=\"result\"\n />\n <div class=\"tpl:flex tpl:justify-end tpl:gap-2\">\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-discard\"\n :class=\"secondaryBtnCompactClass\"\n @click=\"reset\"\n >\n {{ t.ai.rewrite.discard }}\n </button>\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-replace\"\n :class=\"primaryBtnCompactClass\"\n @click=\"replace\"\n >\n {{ t.ai.rewrite.replaceAction }}\n </button>\n </div>\n </template>\n\n <!-- Streaming: plain text only. -->\n <template v-else-if=\"isRewriting\">\n <span\n data-testid=\"ai-rewrite-label\"\n class=\"tpl:self-start tpl:rounded tpl:px-1.5 tpl:py-px tpl:text-[10px] tpl:font-medium tpl:bg-[var(--tpl-secondary-light)] tpl:text-[var(--tpl-text)]\"\n >\n {{ t.ai.rewrite.suggestionLabel }}\n </span>\n <p\n data-testid=\"ai-rewrite-preview\"\n class=\"tpl:m-0 tpl:max-h-48 tpl:overflow-y-auto tpl:whitespace-pre-wrap tpl:text-sm tpl:text-[var(--tpl-text-muted)]\"\n >\n {{ streamingPreview || t.ai.rewrite.rewriting }}\n </p>\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-stop\"\n :class=\"[secondaryBtnCompactClass, 'tpl:self-end']\"\n @click=\"stop\"\n >\n <Square :size=\"12\" :stroke-width=\"2\" aria-hidden=\"true\" />\n {{ t.ai.rewrite.stop }}\n </button>\n </template>\n\n <template v-else>\n <div class=\"tpl:flex tpl:flex-wrap tpl:gap-1.5\">\n <button\n v-for=\"preset in PRESETS\"\n :key=\"preset\"\n type=\"button\"\n :data-testid=\"`ai-rewrite-preset-${preset}`\"\n :class=\"secondaryBtnCompactClass\"\n @click=\"run(preset)\"\n >\n {{ t.ai.rewrite.presets[preset] }}\n </button>\n </div>\n <div class=\"tpl:flex tpl:items-center tpl:gap-2\">\n <Languages\n :size=\"14\"\n :stroke-width=\"2\"\n class=\"tpl:shrink-0 tpl:text-[var(--tpl-text-muted)]\"\n aria-hidden=\"true\"\n />\n <ToolbarSelect\n v-model=\"language\"\n :options=\"languages\"\n :label=\"t.ai.rewrite.language\"\n width-class=\"tpl:flex-1\"\n />\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-preset-translate\"\n :class=\"secondaryBtnCompactClass\"\n :disabled=\"language === ''\"\n @click=\"run('translate')\"\n >\n {{ t.ai.rewrite.presets.translate }}\n </button>\n </div>\n <div class=\"tpl:flex tpl:items-end tpl:gap-2\">\n <textarea\n v-model=\"instruction\"\n data-testid=\"ai-rewrite-instruction\"\n maxlength=\"500\"\n rows=\"2\"\n class=\"tpl:flex-1 tpl:resize-none tpl:rounded-[var(--tpl-radius-sm)] tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:px-2 tpl:py-1.5 tpl:font-sans tpl:text-sm tpl:text-[var(--tpl-text)]\"\n :aria-label=\"t.ai.rewrite.instructionLabel\"\n :placeholder=\"t.ai.rewrite.instructionPlaceholder\"\n />\n <button\n type=\"button\"\n data-testid=\"ai-rewrite-run\"\n :class=\"primaryBtnCompactClass\"\n :disabled=\"instruction.trim() === ''\"\n @click=\"run(null)\"\n >\n {{ t.ai.rewrite.run }}\n </button>\n </div>\n <p\n v-if=\"errorText\"\n role=\"alert\"\n data-testid=\"ai-rewrite-error\"\n class=\"tpl:m-0 tpl:text-xs tpl:text-[var(--tpl-danger)]\"\n >\n {{ errorText }}\n </p>\n <p class=\"tpl:m-0 tpl:text-[10px] tpl:text-[var(--tpl-text-dim)]\">\n {{ t.ai.chat.disclaimer }}\n </p>\n </template>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwCA,IAAM8E,IAAQC,GAER,EAAE,MAAG,eAAW/B,GAAQ,GACxBgC,KAAUnC,GAAcD,IAAgB,eAAe,GACvDqC,KAAY5D,EAAOqB,IAAgBC,EAAa,GAChDuC,KAAS7D,EAAOoB,IAAsBN,GAAe,MAAM,GAC3DgD,IAAW9D,EAAOyB,IAAe,KAAA,CAAS,GAC1CsC,IAAiB/D,EAAO0B,IAAY,IAAI,GAExCsC,KAAmD;GACvD;GACA;GACA;GACA;GACA;EACF,GACMC,IAAYhC,GAAuB6B,CAAQ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