@8wave/ai-elements 0.125.0-beta.31 → 0.125.0-beta.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{PkImageEditorDialog-Cq8y_PtC.js → PkImageEditorDialog-BMCnqiqI.js} +2 -2
- package/dist/_chunks/PkImageEditorDialog-BMCnqiqI.js.map +1 -0
- package/dist/ai-elements.es.js +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotInput.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/_chunks/{PkChatbot-DLgPqMWd.js → PkChatbot-g-mj6Luo.js} +2 -2
- package/dist-vue/_chunks/{PkChatbot-DLgPqMWd.js.map → PkChatbot-g-mj6Luo.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotInput-TamSYiA7.js → PkChatbotInput-OBoyFkZ-.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotInput-TamSYiA7.js.map → PkChatbotInput-OBoyFkZ-.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-y60IA9aQ.js → PkChatbotViewChat-C28g7dz-.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewChat-y60IA9aQ.js.map → PkChatbotViewChat-C28g7dz-.js.map} +1 -1
- package/dist-vue/_chunks/{PkFilePreview-CPSYaOV7.js → PkFilePreview-BgyJngDt.js} +2 -2
- package/dist-vue/_chunks/{PkFilePreview-CPSYaOV7.js.map → PkFilePreview-BgyJngDt.js.map} +1 -1
- package/dist-vue/_chunks/{PkFilePreviewDialog-D6zFO_H_.js → PkFilePreviewDialog-B3-oF1_R.js} +2 -2
- package/dist-vue/_chunks/{PkFilePreviewDialog-D6zFO_H_.js.map → PkFilePreviewDialog-B3-oF1_R.js.map} +1 -1
- package/dist-vue/_chunks/{PkImageEditorDialog-BLUyILVi.js → PkImageEditorDialog-3L4URgPw.js} +2 -2
- package/dist-vue/_chunks/PkImageEditorDialog-3L4URgPw.js.map +1 -0
- package/dist-vue/index.js +4 -4
- package/package.json +1 -1
- package/dist/_chunks/PkImageEditorDialog-Cq8y_PtC.js.map +0 -1
- package/dist-vue/_chunks/PkImageEditorDialog-BLUyILVi.js.map +0 -1
package/dist-vue/_chunks/{PkFilePreviewDialog-D6zFO_H_.js → PkFilePreviewDialog-B3-oF1_R.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-CGnMp29N.js";
|
|
2
|
-
import { t } from "./PkFilePreview-
|
|
2
|
+
import { t } from "./PkFilePreview-BgyJngDt.js";
|
|
3
3
|
import { VvDialog as n } from "@volverjs/ui-vue/components";
|
|
4
4
|
import { createBlock as r, createVNode as i, defineComponent as a, mergeModels as o, openBlock as s, useModel as c, withCtx as l } from "vue";
|
|
5
5
|
// ../../packages/components/src/chat/PkFilePreviewDialog.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -108,4 +108,4 @@ var u = /*@__PURE__*/ a({
|
|
|
108
108
|
}), d = /* @__PURE__ */ e({ default: () => f }), f = u;
|
|
109
109
|
export { d as n, f as t };
|
|
110
110
|
|
|
111
|
-
//# sourceMappingURL=PkFilePreviewDialog-
|
|
111
|
+
//# sourceMappingURL=PkFilePreviewDialog-B3-oF1_R.js.map
|
package/dist-vue/_chunks/{PkFilePreviewDialog-D6zFO_H_.js.map → PkFilePreviewDialog-B3-oF1_R.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkFilePreviewDialog-D6zFO_H_.js","names":["_useModel","__unplugin_components_0","_openBlock","_createBlock","_withCtx","_createVNode","PkFilePreview","_sfc_main","__exportAll","PkFilePreviewDialog_vue_vue_type_script_setup_true_lang_default","\"mode\"","\"modeModifiers\"","\"sheet\"","\"sheetModifiers\"","\"zoom\"","\"zoomModifiers\"","\"fit\"","\"fitModifiers\"","__emit","emit","mode","useModel","__props","sheet","zoom","fit","_component_VvDialog","VvDialog","openBlock","createBlock","_cache","$event","withCtx","createVNode","PkFilePreview_default","text","pointer","action","PkFilePreviewDialog_exports","PkFilePreviewDialog_default"],"sources":["../../../../packages/components/src/chat/PkFilePreviewDialog.vue","../../../../packages/components/src/chat/PkFilePreviewDialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewChanges } from './previewChanges'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n /** What the version changed from the one shown before, for a moment. */\n changes?: ChatFilePreviewChanges\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :changes\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewChanges } from './previewChanges'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n /** What the version changed from the one shown before, for a moment. */\n changes?: ChatFilePreviewChanges\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :changes\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCI,IAAMmB,IAAOD,GAaPE,IAAOpB,EAA4BsB,GAAC,MAAM,GAC1CC,IAAQvB,EAAmBsB,GAAC,OAAO,GACnCE,IAAOxB,EAAmBsB,GAAC,MAAM,GAGjCG,IAAMzB,EAAoBsB,GAAC,KAAwB;;;GAIzD,OAAApB,EAAA,GAAAC,EAiCWuB,GAAA;IAhCN,eAAa;IACb,cAAYJ,EAAA,OAAO;IACnB,WAAWA,EAAA,aAAU,eAAkB,KAAA;IACxC,OAAM;IACL,uBAAkB,AAAAQ,EAAA,QAAA,MAAA,CAAGC,KAAUZ,EAAI,OAAA;;IACpC,SAAAf,QA0B6B,CA1B7BC,EA0B6BC,GAAA;KAzBjB,MAAMc,EAAA;KAAA,iBAAA,AAAAU,EAAA,QAAA,MAAA,EAAI,QAAAC;KACV,OAAOR,EAAA;KAAA,kBAAA,AAAAO,EAAA,QAAA,MAAA,EAAK,QAAAC;KACZ,MAAMP,EAAA;KAAA,iBAAA,AAAAM,EAAA,QAAA,MAAA,EAAI,QAAAC;KACV,KAAKN,EAAA;KAAA,gBAAA,AAAAK,EAAA,QAAA,MAAA,EAAG,QAAAC;KACf,MAAMT,EAAA,OAAO;KACb,UAAUA,EAAA,OAAO;KACjB,SAASA,EAAA,OAAO;KAChB,UAAAA,EAAA;KACA,gBAAAA,EAAA;KACA,SAAAA,EAAA;KACA,SAAAA,EAAA;KACA,SAAAA,EAAA;KACA,OAAAA,EAAA;KACA,YAAAA,EAAA;KACA,QAAAA,EAAA;KACA,WAASA,EAAA,OAAO;KAChB,oBAAkBA,EAAA,OAAO;KACzB,qBAAAA,EAAA;KACA,WAAO,AAAAQ,EAAA,QAAA,MAAEX,EAAI,WAAYY,CAAM;KAC/B,WAAO,AAAAD,EAAA,QAAA,MAAEX,EAAI,SAAA;KACb,UAAM,AAAAW,EAAA,QAAA,MAAEX,EAAI,QAAA;KACZ,iBAAc,AAAAW,EAAA,QAAoB,GAAM,GAAS,MAA+BX,EAAI,iBAAkBgB,GAAMC,GAASC,CAAM;KAI3H,SAAK,AAAAP,EAAA,QAAA,MAAEX,EAAI,OAAA"}
|
|
1
|
+
{"version":3,"file":"PkFilePreviewDialog-B3-oF1_R.js","names":["_useModel","__unplugin_components_0","_openBlock","_createBlock","_withCtx","_createVNode","PkFilePreview","_sfc_main","__exportAll","PkFilePreviewDialog_vue_vue_type_script_setup_true_lang_default","\"mode\"","\"modeModifiers\"","\"sheet\"","\"sheetModifiers\"","\"zoom\"","\"zoomModifiers\"","\"fit\"","\"fitModifiers\"","__emit","emit","mode","useModel","__props","sheet","zoom","fit","_component_VvDialog","VvDialog","openBlock","createBlock","_cache","$event","withCtx","createVNode","PkFilePreview_default","text","pointer","action","PkFilePreviewDialog_exports","PkFilePreviewDialog_default"],"sources":["../../../../packages/components/src/chat/PkFilePreviewDialog.vue","../../../../packages/components/src/chat/PkFilePreviewDialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewChanges } from './previewChanges'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n /** What the version changed from the one shown before, for a moment. */\n changes?: ChatFilePreviewChanges\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :changes\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import type {\n ChatFilePreview,\n FilePointer,\n SelectionGroupCapability,\n } from 'models'\n import PkFilePreview from './PkFilePreview.vue'\n import type { ChatFilePreviewChanges } from './previewChanges'\n import type { ChatFilePreviewTarget, WordPreviewMode } from './utils'\n\n /**\n * The viewer of a file stored in a chat in a dialog over the page: the\n * chat's when it has no room for the panel beside it or the reader\n * expands it, the chat log's always. Open while it is mounted: `close`\n * asks the host to drop it. The viewer draws its own head, with the file\n * and the close button, so the dialog has no title and takes its name.\n */\n defineProps<{\n target: ChatFilePreviewTarget\n /** The authenticated download URL of the same version. */\n downloadUrl: string\n preview?: ChatFilePreview\n /** What the version changed from the one shown before, for a moment. */\n changes?: ChatFilePreviewChanges\n loading?: boolean\n error?: boolean\n /** Covers the screen, for a phone. */\n fullscreen?: boolean\n /** The versions of the file in the conversation, from 1. */\n versions?: number[]\n /** The shown version can be written again as the newest one. */\n restorable?: boolean\n /** Offers to go back to the panel beside the chat. */\n resize?: 'shrink'\n /** The selection bar's actions for this format: absent in the chat logs. */\n selectionActions?: SelectionGroupCapability\n }>()\n\n const emit = defineEmits<{\n close: []\n version: [version: number]\n restore: []\n resize: []\n selectionSend: [\n text: string,\n pointer: FilePointer,\n action: { id: string; size: number },\n ]\n }>()\n\n // How the file is shown, kept by the host across panel and dialog\n const mode = defineModel<WordPreviewMode>('mode')\n const sheet = defineModel<number>('sheet')\n const zoom = defineModel<number>('zoom')\n // A boolean prop left out is false, not the viewer's default: the chat\n // logs keep no zoom, and their pages opened at 100% instead of fitted\n const fit = defineModel<boolean>('fit', { default: true })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :aria-label=\"target.filename\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n class=\"pk-file-preview-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <PkFilePreview\n v-model:mode=\"mode\"\n v-model:sheet=\"sheet\"\n v-model:zoom=\"zoom\"\n v-model:fit=\"fit\"\n :kind=\"target.kind\"\n :filename=\"target.filename\"\n :version=\"target.version\"\n :versions\n :download-url\n :preview\n :changes\n :loading\n :error\n :restorable\n :resize\n :file-id=\"target.fileId\"\n :stored-file-name=\"target.storedFileName\"\n :selection-actions\n @version=\"emit('version', $event)\"\n @restore=\"emit('restore')\"\n @resize=\"emit('resize')\"\n @selection-send=\"\n (text, pointer, action) =>\n emit('selectionSend', text, pointer, action)\n \"\n @close=\"emit('close')\" />\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Almost the whole window, room for a page of Word and a grid of Excel;\n // the viewer scrolls in its own box, so the content does not pad it.\n .pk-file-preview-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(90rem, 94dvw);\n height: 92dvh;\n }\n\n // The library writes `max-height: auto`, which is no value: the\n // wrapper kept its 90dvh and the phone saw the chat around it\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n }\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCI,IAAMmB,IAAOD,GAaPE,IAAOpB,EAA4BsB,GAAC,MAAM,GAC1CC,IAAQvB,EAAmBsB,GAAC,OAAO,GACnCE,IAAOxB,EAAmBsB,GAAC,MAAM,GAGjCG,IAAMzB,EAAoBsB,GAAC,KAAwB;;;GAIzD,OAAApB,EAAA,GAAAC,EAiCWuB,GAAA;IAhCN,eAAa;IACb,cAAYJ,EAAA,OAAO;IACnB,WAAWA,EAAA,aAAU,eAAkB,KAAA;IACxC,OAAM;IACL,uBAAkB,AAAAQ,EAAA,QAAA,MAAA,CAAGC,KAAUZ,EAAI,OAAA;;IACpC,SAAAf,QA0B6B,CA1B7BC,EA0B6BC,GAAA;KAzBjB,MAAMc,EAAA;KAAA,iBAAA,AAAAU,EAAA,QAAA,MAAA,EAAI,QAAAC;KACV,OAAOR,EAAA;KAAA,kBAAA,AAAAO,EAAA,QAAA,MAAA,EAAK,QAAAC;KACZ,MAAMP,EAAA;KAAA,iBAAA,AAAAM,EAAA,QAAA,MAAA,EAAI,QAAAC;KACV,KAAKN,EAAA;KAAA,gBAAA,AAAAK,EAAA,QAAA,MAAA,EAAG,QAAAC;KACf,MAAMT,EAAA,OAAO;KACb,UAAUA,EAAA,OAAO;KACjB,SAASA,EAAA,OAAO;KAChB,UAAAA,EAAA;KACA,gBAAAA,EAAA;KACA,SAAAA,EAAA;KACA,SAAAA,EAAA;KACA,SAAAA,EAAA;KACA,OAAAA,EAAA;KACA,YAAAA,EAAA;KACA,QAAAA,EAAA;KACA,WAASA,EAAA,OAAO;KAChB,oBAAkBA,EAAA,OAAO;KACzB,qBAAAA,EAAA;KACA,WAAO,AAAAQ,EAAA,QAAA,MAAEX,EAAI,WAAYY,CAAM;KAC/B,WAAO,AAAAD,EAAA,QAAA,MAAEX,EAAI,SAAA;KACb,UAAM,AAAAW,EAAA,QAAA,MAAEX,EAAI,QAAA;KACZ,iBAAc,AAAAW,EAAA,QAAoB,GAAM,GAAS,MAA+BX,EAAI,iBAAkBgB,GAAMC,GAASC,CAAM;KAI3H,SAAK,AAAAP,EAAA,QAAA,MAAEX,EAAI,OAAA"}
|
package/dist-vue/_chunks/{PkImageEditorDialog-BLUyILVi.js → PkImageEditorDialog-3L4URgPw.js}
RENAMED
|
@@ -128,7 +128,7 @@ function W(e, t) {
|
|
|
128
128
|
width: e.height,
|
|
129
129
|
height: e.width
|
|
130
130
|
}), r = U(n);
|
|
131
|
-
return r.translate(n.width / 2, n.height / 2), r.rotate(t * Math.PI / 2), r.drawImage(e, -e.width / 2, -e.height / 2), n;
|
|
131
|
+
return r.save(), r.translate(n.width / 2, n.height / 2), r.rotate(t * Math.PI / 2), r.drawImage(e, -e.width / 2, -e.height / 2), r.restore(), n;
|
|
132
132
|
}
|
|
133
133
|
function G(e, t) {
|
|
134
134
|
let n = H(t);
|
|
@@ -547,4 +547,4 @@ var se = { class: "pk-image-editor" }, ce = { class: "pk-image-editor__toolbar"
|
|
|
547
547
|
});
|
|
548
548
|
export { X as default };
|
|
549
549
|
|
|
550
|
-
//# sourceMappingURL=PkImageEditorDialog-
|
|
550
|
+
//# sourceMappingURL=PkImageEditorDialog-3L4URgPw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PkImageEditorDialog-3L4URgPw.js","names":["_hoisted_1","_hoisted_2","_useModel","__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","_openBlock","_createElementBlock","_createElementVNode","_createVNode","PkEditorRadioButtons","_unref","_withCtx","_createTextVNode","_toDisplayString","_Fragment","_normalizeStyle","_normalizeClass","_createCommentVNode","_sfc_main","__unplugin_components_0","__unplugin_components_1","__unplugin_components_2","__unplugin_components_3","__unplugin_components_4","_openBlock","_createBlock","_unref","_withCtx","_createVNode","_createCommentVNode","PkImageEditor","_createElementBlock","_toDisplayString","_sfc_main","PkEditorRadioButtons_default","MAX_CANVAS_AREA","EXPORT_QUALITY","MIN_PIXEL_BLOCK","PIXEL_BLOCK_DIVISOR","EXTENSIONS","fitToArea","area","size","maxArea","scale","sizeAfterEdits","edit","edits","width","height","pixelBlock","dragRect","ax","clamp","from","bounds","ay","dx","to","dy","roomX","roomY","aspect","lead","x","y","pixelateData","blockEnd","start","block","by","bottom","bx","right","r","g","b","a","i","alpha","data","count","color","editedFileName","extension","writtenType","originalType","name","dot","loadEditableImage","bitmap","file","original","image","createCanvas","context","renderEdits","canvas","next","rotate","crop","releaseCanvas","exportCanvas","blob","resolve","reject","type","source","turn","rect","cover","style","pixels","max","min","value","_hoisted_1$1","_hoisted_2$1","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","MIN_DRAG","PkImageEditor_default","defineComponent","\"edits\"","\"editsModifiers\"","__expose","__emit","props","__props","emit","useModel","$t","useI18n","ASPECTS","tool","ref","coverStyle","toolOptions","computed","aspectOptions","coverOptions","aspectLabelId","useId","redoStack","push","undo","last","redo","stageEl","useTemplateRef","shown","draw","onMounted","watch","onBeforeUnmount","areaEl","room","entry","frameStyle","frameEl","selection","dragFrom","pointOf","box","event","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","pendingCrop","applyCrop","selectionStyle","_component_VvIcon","VvIcon","_component_VvButton","VvButtonLocalized","_component_VvButtonGroup","VvButtonGroup","openBlock","createElementBlock","createElementVNode","createVNode","_cache","$event","unref","withCtx","createTextVNode","toDisplayString","option","Fragment","normalizeStyle","normalizeClass","createCommentVNode","_hoisted_1","_hoisted_2","PkImageEditorDialog_default","fullscreen","useMediaQuery","loaded","shallowRef","failed","exporting","editorEl","scaledDown","changed","useImage","editor","nextTick","failedLabel","_component_VvAlert","VvAlert","_component_VvDialog","VvDialog","createBlock"],"sources":["../../../../packages/components/src/chat/imageEdits.ts","../../../../packages/components/src/chat/PkImageEditor.vue","../../../../packages/components/src/chat/PkImageEditor.vue","../../../../packages/components/src/chat/PkImageEditorDialog.vue","../../../../packages/components/src/chat/PkImageEditorDialog.vue"],"sourcesContent":["/**\n * The model of the image editor (spec `chat-image-editor.md`): a list of\n * edits applied in order to the original, so every draw starts again from\n * the original and undo drops the last edit. The geometry is pure; the\n * drawing needs a canvas, which only a browser has.\n */\n\n/** A point in the pixels of the image an edit applies to. */\nexport interface ImagePoint {\n x: number\n y: number\n}\n\nexport interface ImageSize {\n width: number\n height: number\n}\n\n/** A rectangle in the pixels of the image an edit applies to. */\nexport interface ImageRect extends ImagePoint, ImageSize {}\n\n/**\n * How a covered area is drawn: a black box, the only cover a text cannot be\n * read back through, or large blocks of its average color, for a face.\n */\nexport type CoverStyle = 'solid' | 'pixelate'\n\n/**\n * One change, in the coordinates of the image the edits before it left: a\n * crop changes the size, a quarter turn swaps the sides.\n */\nexport type ImageEdit =\n /** A quarter turn, `1` clockwise and `-1` counterclockwise. */\n | { kind: 'rotate'; turn: 1 | -1 }\n | { kind: 'crop'; rect: ImageRect }\n | { kind: 'cover'; rect: ImageRect; style: CoverStyle }\n\n/**\n * Safari on iOS refuses a canvas larger than this area: a larger image is\n * scaled down to fit before it is edited.\n */\nexport const MAX_CANVAS_AREA = 4096 * 4096\n\n/** The quality of a JPEG or WebP written back. */\nexport const EXPORT_QUALITY = 0.92\n\n/**\n * The side of a block of a pixelated cover: never under 12 pixels, nor under\n * 1/32 of the short side, so a pixelated cover never turns into a light blur\n * that a face or a word can be guessed through.\n */\nconst MIN_PIXEL_BLOCK = 12\nconst PIXEL_BLOCK_DIVISOR = 32\n\nconst EXTENSIONS: Record<string, string> = {\n 'image/jpeg': 'jpg',\n 'image/png': 'png',\n 'image/webp': 'webp',\n}\n\n/**\n * The size an image is edited at: its own, or the largest with the same\n * proportions whose area fits `maxArea`.\n */\nexport function fitToArea(\n size: ImageSize,\n maxArea = MAX_CANVAS_AREA,\n): ImageSize {\n const area = size.width * size.height\n if (area <= maxArea) {\n return { width: size.width, height: size.height }\n }\n const scale = Math.sqrt(maxArea / area)\n return {\n width: Math.max(1, Math.floor(size.width * scale)),\n height: Math.max(1, Math.floor(size.height * scale)),\n }\n}\n\n/** The size of the image once `edits` are applied to one of `size`. */\nexport function sizeAfterEdits(\n size: ImageSize,\n edits: readonly ImageEdit[],\n): ImageSize {\n let { width, height } = size\n for (const edit of edits) {\n if (edit.kind === 'rotate') {\n ;[width, height] = [height, width]\n } else if (edit.kind === 'crop') {\n ;({ width, height } = edit.rect)\n }\n }\n return { width, height }\n}\n\n/** The side of a block of a pixelated cover on an image of `size`. */\nexport function pixelBlock(size: ImageSize): number {\n return Math.max(\n MIN_PIXEL_BLOCK,\n Math.round(Math.min(size.width, size.height) / PIXEL_BLOCK_DIVISOR),\n )\n}\n\n/**\n * The rectangle a drag from `from` to `to` draws, in any direction, inside\n * `bounds`. With an `aspect` (width over height) the longer side of the drag\n * leads, and both sides shrink together to stay inside the image.\n */\nexport function dragRect(\n from: ImagePoint,\n to: ImagePoint,\n bounds: ImageSize,\n aspect?: number,\n): ImageRect {\n const ax = clamp(from.x, 0, bounds.width)\n const ay = clamp(from.y, 0, bounds.height)\n const dx = to.x - ax\n const dy = to.y - ay\n // The room from the anchor to the edges the drag goes toward\n const roomX = dx < 0 ? ax : bounds.width - ax\n const roomY = dy < 0 ? ay : bounds.height - ay\n let width = Math.min(Math.abs(dx), roomX)\n let height = Math.min(Math.abs(dy), roomY)\n if (aspect) {\n const lead = Math.max(Math.abs(dx), Math.abs(dy) * aspect)\n width = Math.min(lead, roomX, roomY * aspect)\n height = width / aspect\n }\n const x = Math.round(dx < 0 ? ax - width : ax)\n const y = Math.round(dy < 0 ? ay - height : ay)\n return {\n x,\n y,\n width: Math.min(Math.round(width), bounds.width - x),\n height: Math.min(Math.round(height), bounds.height - y),\n }\n}\n\n/**\n * Pixelates RGBA pixels in place: each `block` square takes the average\n * color of the pixels it covers, weighted by their opacity, so the\n * transparent pixels of a PNG do not darken it. The blocks start at the top\n * left corner. What is left on the right and bottom edges, less than a\n * block, joins the last block: a strip of a few pixels would keep a detail\n * finer than the block promises.\n */\nexport function pixelateData(\n data: Uint8ClampedArray,\n width: number,\n height: number,\n block: number,\n): void {\n const blockEnd = (start: number, size: number) =>\n start + 2 * block > size ? size : start + block\n for (let by = 0; by < height; by = blockEnd(by, height)) {\n const bottom = blockEnd(by, height)\n for (let bx = 0; bx < width; bx = blockEnd(bx, width)) {\n const right = blockEnd(bx, width)\n let r = 0\n let g = 0\n let b = 0\n let a = 0\n for (let y = by; y < bottom; y++) {\n for (let x = bx; x < right; x++) {\n const i = (y * width + x) * 4\n const alpha = data[i + 3]\n r += data[i] * alpha\n g += data[i + 1] * alpha\n b += data[i + 2] * alpha\n a += alpha\n }\n }\n const count = (bottom - by) * (right - bx)\n const color =\n a > 0 ? [r / a, g / a, b / a, a / count] : [0, 0, 0, 0]\n for (let y = by; y < bottom; y++) {\n for (let x = bx; x < right; x++) {\n data.set(color, (y * width + x) * 4)\n }\n }\n }\n }\n}\n\n/**\n * The name of the edited file: the original one, with the extension of the\n * type written when the browser could not write the original type (Safari\n * writes no WebP and gives a PNG instead).\n */\nexport function editedFileName(\n name: string,\n originalType: string,\n writtenType: string,\n): string {\n const extension = EXTENSIONS[writtenType]\n if (writtenType === originalType || !extension) {\n return name\n }\n const dot = name.lastIndexOf('.')\n return `${dot > 0 ? name.slice(0, dot) : name}.${extension}`\n}\n\n// --- Canvas ---\n\nexport interface LoadedImage {\n /** The image as it is edited, at most `MAX_CANVAS_AREA` pixels. */\n image: HTMLCanvasElement\n /** The size of the file, larger than `image` when it was scaled down. */\n original: ImageSize\n}\n\n/**\n * Decodes an image file into the canvas the edits start from, upright as\n * the photo's orientation says and scaled down if it is too large for a\n * canvas.\n */\nexport async function loadEditableImage(file: Blob): Promise<LoadedImage> {\n const bitmap = await createImageBitmap(file, {\n imageOrientation: 'from-image',\n })\n try {\n const original = { width: bitmap.width, height: bitmap.height }\n const image = createCanvas(fitToArea(original))\n const g = context(image)\n g.imageSmoothingQuality = 'high'\n g.drawImage(bitmap, 0, 0, image.width, image.height)\n return { image, original }\n } finally {\n bitmap.close()\n }\n}\n\n/**\n * Draws `edits` over a copy of `image`, which stays untouched. The canvas\n * returned is new: the caller releases it with `releaseCanvas` when it\n * draws the next one.\n */\nexport function renderEdits(\n image: HTMLCanvasElement,\n edits: readonly ImageEdit[],\n): HTMLCanvasElement {\n let canvas = createCanvas(image)\n context(canvas).drawImage(image, 0, 0)\n for (const edit of edits) {\n if (edit.kind === 'cover') {\n cover(canvas, edit.rect, edit.style)\n continue\n }\n const next =\n edit.kind === 'rotate'\n ? rotate(canvas, edit.turn)\n : crop(canvas, edit.rect)\n releaseCanvas(canvas)\n canvas = next\n }\n return canvas\n}\n\n/**\n * Writes the canvas as a file of `type`, or as a PNG where the browser\n * cannot write that type. A canvas writes no metadata: the EXIF of a photo,\n * its position included, does not survive.\n */\nexport function exportCanvas(\n canvas: HTMLCanvasElement,\n type: string,\n): Promise<Blob> {\n return new Promise((resolve, reject) => {\n canvas.toBlob(\n (blob) =>\n blob\n ? resolve(blob)\n : reject(new Error('The image could not be written')),\n type,\n EXPORT_QUALITY,\n )\n })\n}\n\n/**\n * Frees the memory of a canvas no longer shown: Safari counts every canvas\n * until it is collected, and refuses new ones past its total.\n */\nexport function releaseCanvas(canvas: HTMLCanvasElement): void {\n canvas.width = 0\n canvas.height = 0\n}\n\nfunction createCanvas(size: ImageSize): HTMLCanvasElement {\n const canvas = document.createElement('canvas')\n canvas.width = size.width\n canvas.height = size.height\n return canvas\n}\n\nfunction context(canvas: HTMLCanvasElement): CanvasRenderingContext2D {\n const g = canvas.getContext('2d')\n if (!g) {\n throw new Error('No 2D canvas in this browser')\n }\n return g\n}\n\nfunction rotate(source: HTMLCanvasElement, turn: 1 | -1): HTMLCanvasElement {\n const canvas = createCanvas({\n width: source.height,\n height: source.width,\n })\n const g = context(canvas)\n // The context stays the canvas's: the edits after a turn draw through\n // it, and a turn left on it put a solid cover beside what it covers\n g.save()\n g.translate(canvas.width / 2, canvas.height / 2)\n g.rotate((turn * Math.PI) / 2)\n g.drawImage(source, -source.width / 2, -source.height / 2)\n g.restore()\n return canvas\n}\n\nfunction crop(source: HTMLCanvasElement, rect: ImageRect): HTMLCanvasElement {\n const canvas = createCanvas(rect)\n context(canvas).drawImage(\n source,\n rect.x,\n rect.y,\n rect.width,\n rect.height,\n 0,\n 0,\n rect.width,\n rect.height,\n )\n return canvas\n}\n\nfunction cover(\n canvas: HTMLCanvasElement,\n rect: ImageRect,\n style: CoverStyle,\n): void {\n const g = context(canvas)\n if (style === 'solid') {\n g.fillStyle = '#000000'\n g.fillRect(rect.x, rect.y, rect.width, rect.height)\n return\n }\n const pixels = g.getImageData(rect.x, rect.y, rect.width, rect.height)\n pixelateData(pixels.data, rect.width, rect.height, pixelBlock(canvas))\n g.putImageData(pixels, rect.x, rect.y)\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value))\n}\n","<script setup lang=\"ts\">\n import {\n computed,\n onBeforeUnmount,\n onMounted,\n ref,\n useId,\n useTemplateRef,\n watch,\n } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useResizeObserver } from '@vueuse/core'\n import PkEditorRadioButtons from '../PkEditorRadioButtons.vue'\n import {\n dragRect,\n releaseCanvas,\n renderEdits,\n sizeAfterEdits,\n type CoverStyle,\n type ImageEdit,\n type ImagePoint,\n type ImageRect,\n } from './imageEdits'\n\n /**\n * The tools of the image editor over the image they change (spec\n * `chat-image-editor.md`, F1): crop and cover by dragging on the image,\n * quarter turns, undo and redo. The edits are the model, the image stays\n * as it was loaded. Dragging needs a mouse, a pen or a finger; the rest\n * works from the keyboard.\n */\n const props = defineProps<{\n /** The image the edits start from. */\n image: HTMLCanvasElement\n }>()\n\n const emit = defineEmits<{\n /** The browser could not draw the image, out of canvas memory. */\n error: []\n }>()\n\n const edits = defineModel<ImageEdit[]>('edits', { required: true })\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n // --- Tools ---\n\n type Tool = 'crop' | 'cover'\n type Aspect = 'free' | '1:1' | '4:3' | '16:9'\n\n const ASPECTS: Record<Aspect, number | undefined> = {\n free: undefined,\n '1:1': 1,\n '4:3': 4 / 3,\n '16:9': 16 / 9,\n }\n\n const tool = ref<Tool>('crop')\n const aspect = ref<Aspect>('free')\n // Every opening starts on the solid box, the only cover safe on a text:\n // the pixels picked for a face yesterday do not cover an IBAN today\n const coverStyle = ref<CoverStyle>('solid')\n\n const toolOptions = computed(() => [\n { value: 'crop', label: $t('imageEditor.crop') },\n { value: 'cover', label: $t('imageEditor.cover') },\n ])\n const aspectOptions = computed(() => [\n { value: 'free', label: $t('imageEditor.aspectFree') },\n { value: '1:1', label: '1:1' },\n { value: '4:3', label: '4:3' },\n { value: '16:9', label: '16:9' },\n ])\n const coverOptions = computed(() => [\n { value: 'solid', label: $t('imageEditor.coverSolid') },\n { value: 'pixelate', label: $t('imageEditor.coverPixelate') },\n ])\n const aspectLabelId = useId()\n\n // --- History ---\n\n const redoStack = ref<ImageEdit[]>([])\n\n function push(edit: ImageEdit) {\n edits.value = [...edits.value, edit]\n redoStack.value = []\n }\n\n function undo() {\n selection.value = undefined\n const last = edits.value[edits.value.length - 1]\n if (!last) {\n return\n }\n edits.value = edits.value.slice(0, -1)\n redoStack.value = [...redoStack.value, last]\n }\n\n function redo() {\n selection.value = undefined\n const next = redoStack.value[redoStack.value.length - 1]\n if (!next) {\n return\n }\n edits.value = [...edits.value, next]\n redoStack.value = redoStack.value.slice(0, -1)\n }\n\n function rotate(turn: 1 | -1) {\n selection.value = undefined\n push({ kind: 'rotate', turn })\n }\n\n // --- Drawing ---\n\n const size = computed(() => sizeAfterEdits(props.image, edits.value))\n const stageEl = useTemplateRef<HTMLDivElement>('stageEl')\n // The canvas on screen, outside Vue: a new one replaces it on each edit\n let shown: HTMLCanvasElement | undefined\n\n function draw() {\n if (!stageEl.value) {\n return\n }\n let canvas: HTMLCanvasElement\n try {\n canvas = renderEdits(props.image, edits.value)\n } catch {\n emit('error')\n return\n }\n canvas.setAttribute('role', 'img')\n canvas.setAttribute('aria-label', $t('imageEditor.canvasLabel'))\n stageEl.value.replaceChildren(canvas)\n if (shown) {\n releaseCanvas(shown)\n }\n shown = canvas\n }\n\n onMounted(draw)\n watch([() => props.image, edits], draw, { flush: 'post' })\n onBeforeUnmount(() => {\n if (shown) {\n releaseCanvas(shown)\n }\n })\n\n // The image fits the room it has, never drawn larger than its pixels\n const areaEl = useTemplateRef<HTMLDivElement>('areaEl')\n const room = ref({ width: 0, height: 0 })\n useResizeObserver(areaEl, ([entry]) => {\n if (entry) {\n room.value = {\n width: entry.contentRect.width,\n height: entry.contentRect.height,\n }\n }\n })\n const scale = computed(() =>\n Math.min(\n 1,\n room.value.width / size.value.width,\n room.value.height / size.value.height,\n ),\n )\n const frameStyle = computed(() => ({\n width: `${Math.max(1, Math.floor(size.value.width * scale.value))}px`,\n height: `${Math.max(1, Math.floor(size.value.height * scale.value))}px`,\n }))\n\n // --- Dragging a rectangle ---\n\n /** A rectangle thinner than this on screen is a click, not a drag. */\n const MIN_DRAG = 6\n\n const frameEl = useTemplateRef<HTMLDivElement>('frameEl')\n const selection = ref<ImageRect>()\n const dragFrom = ref<ImagePoint>()\n\n function pointOf(event: PointerEvent): ImagePoint {\n const box = frameEl.value?.getBoundingClientRect()\n if (!box?.width || !box.height) {\n return { x: 0, y: 0 }\n }\n return {\n x: ((event.clientX - box.left) / box.width) * size.value.width,\n y: ((event.clientY - box.top) / box.height) * size.value.height,\n }\n }\n\n function onPointerDown(event: PointerEvent) {\n if (event.button !== 0) {\n return\n }\n frameEl.value?.setPointerCapture(event.pointerId)\n dragFrom.value = pointOf(event)\n selection.value = undefined\n }\n\n function onPointerMove(event: PointerEvent) {\n if (!dragFrom.value) {\n return\n }\n selection.value = dragRect(\n dragFrom.value,\n pointOf(event),\n size.value,\n tool.value === 'crop' ? ASPECTS[aspect.value] : undefined,\n )\n }\n\n function onPointerUp() {\n if (!dragFrom.value) {\n return\n }\n dragFrom.value = undefined\n const rect = selection.value\n if (\n !rect ||\n rect.width * scale.value < MIN_DRAG ||\n rect.height * scale.value < MIN_DRAG\n ) {\n selection.value = undefined\n return\n }\n // A cover is written as soon as it is drawn; a crop waits for Apply\n if (tool.value === 'cover') {\n selection.value = undefined\n push({ kind: 'cover', rect, style: coverStyle.value })\n }\n }\n\n function onPointerCancel() {\n dragFrom.value = undefined\n selection.value = undefined\n }\n\n const pendingCrop = computed(\n () => tool.value === 'crop' && !dragFrom.value && !!selection.value,\n )\n\n function applyCrop() {\n const rect = selection.value\n if (!pendingCrop.value || !rect) {\n return\n }\n selection.value = undefined\n if (\n rect.width === size.value.width &&\n rect.height === size.value.height\n ) {\n return\n }\n push({ kind: 'crop', rect })\n }\n\n watch(tool, () => {\n selection.value = undefined\n })\n\n // A crop drawn and then given proportions keeps its corner and takes them\n watch(aspect, (value) => {\n const rect = selection.value\n if (rect && tool.value === 'crop') {\n selection.value = dragRect(\n rect,\n { x: rect.x + rect.width, y: rect.y + rect.height },\n size.value,\n ASPECTS[value],\n )\n }\n })\n\n const selectionStyle = computed(() => {\n const rect = selection.value\n if (!rect) {\n return undefined\n }\n return {\n left: `${(rect.x / size.value.width) * 100}%`,\n top: `${(rect.y / size.value.height) * 100}%`,\n width: `${(rect.width / size.value.width) * 100}%`,\n height: `${(rect.height / size.value.height) * 100}%`,\n }\n })\n\n defineExpose({\n /** A crop is drawn and not applied yet. */\n pendingCrop,\n /** Applies the crop drawn, as Apply does: \"Use the image\" calls it first. */\n applyCrop,\n /**\n * The canvas on screen, every edit drawn, which the host writes as\n * the file: it stays the editor's, released when the editor goes.\n */\n shownCanvas: () => shown,\n })\n</script>\n\n<template>\n <div class=\"pk-image-editor\">\n <div class=\"pk-image-editor__toolbar\">\n <PkEditorRadioButtons\n v-model=\"tool\"\n name=\"pk-image-editor-tool\"\n segmented\n class=\"mb-0\"\n :aria-label=\"$t('imageEditor.tool')\"\n :options=\"toolOptions\">\n <template #crop=\"{ option }\">\n <VvIcon name=\"ri:crop-line\" class=\"w-16 h-16\" />\n {{ option.label }}\n </template>\n <template #cover=\"{ option }\">\n <VvIcon name=\"ri:eye-off-line\" class=\"w-16 h-16\" />\n {{ option.label }}\n </template>\n </PkEditorRadioButtons>\n <VvButtonGroup modifiers=\"compact\">\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:anticlockwise-line\"\n :title=\"$t('imageEditor.rotateLeft')\"\n :aria-label=\"$t('imageEditor.rotateLeft')\"\n @click=\"rotate(-1)\" />\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:clockwise-line\"\n :title=\"$t('imageEditor.rotateRight')\"\n :aria-label=\"$t('imageEditor.rotateRight')\"\n @click=\"rotate(1)\" />\n </VvButtonGroup>\n <!-- \"Annulla\" is already the dialog's button: two \"Annulla\"\n doing different things in one window read as one -->\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto\">\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:arrow-go-back-line\"\n :title=\"$t('imageEditor.undo')\"\n :aria-label=\"$t('imageEditor.undo')\"\n :disabled=\"!edits.length\"\n @click=\"undo\" />\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:arrow-go-forward-line\"\n :title=\"$t('imageEditor.redo')\"\n :aria-label=\"$t('imageEditor.redo')\"\n :disabled=\"!redoStack.length\"\n @click=\"redo\" />\n </VvButtonGroup>\n </div>\n <div class=\"pk-image-editor__options\">\n <template v-if=\"tool === 'crop'\">\n <span :id=\"aspectLabelId\" class=\"pk-image-editor__label\">\n {{ $t('imageEditor.aspect') }}\n </span>\n <PkEditorRadioButtons\n v-model=\"aspect\"\n name=\"pk-image-editor-aspect\"\n segmented\n class=\"mb-0\"\n :aria-labelledby=\"aspectLabelId\"\n :options=\"aspectOptions\" />\n <span class=\"pk-image-editor__hint\">\n {{ $t('imageEditor.cropHint') }}\n </span>\n <VvButton\n class=\"ml-auto\"\n modifiers=\"secondary\"\n :label=\"$t('action.apply')\"\n :disabled=\"!pendingCrop\"\n @click=\"applyCrop\" />\n </template>\n <template v-else>\n <PkEditorRadioButtons\n v-model=\"coverStyle\"\n name=\"pk-image-editor-cover\"\n segmented\n class=\"mb-0\"\n :aria-label=\"$t('imageEditor.coverStyle')\"\n :options=\"coverOptions\" />\n <span class=\"pk-image-editor__hint\">\n {{ $t('imageEditor.coverHint') }}\n </span>\n </template>\n </div>\n <div ref=\"areaEl\" class=\"pk-image-editor__area\">\n <div\n ref=\"frameEl\"\n class=\"pk-image-editor__frame\"\n :style=\"frameStyle\"\n @pointerdown=\"onPointerDown\"\n @pointermove=\"onPointerMove\"\n @pointerup=\"onPointerUp\"\n @pointercancel=\"onPointerCancel\">\n <div ref=\"stageEl\" class=\"pk-image-editor__stage\" />\n <div\n v-if=\"selection\"\n class=\"pk-image-editor__selection\"\n :class=\"`pk-image-editor__selection--${tool}`\"\n :style=\"selectionStyle\" />\n </div>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-image-editor {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n\n &__toolbar,\n &__options {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--spacing-8);\n padding: var(--spacing-8) var(--spacing-md);\n border-bottom: 1px solid var(--color-surface-3);\n }\n\n &__toolbar {\n background-color: var(--color-surface-1);\n }\n\n // A segmented control is as wide as its options, each as wide as its\n // words: with the library's equal segments the longer one was cut\n // (\"Riquadro pien\") and its icon shrank. A row too narrow sends the\n // control to a line of its own.\n &__toolbar > .vv-radio-group,\n &__options > .vv-radio-group {\n flex: none;\n width: auto;\n\n .vv-radio {\n flex: none;\n }\n }\n\n &__label {\n color: var(--color-word-2);\n font-size: var(--text-14);\n }\n\n &__hint {\n color: var(--color-word-3);\n font-size: var(--text-12);\n }\n\n // A checkerboard, as in the lightbox: a transparent PNG shows where\n // it is transparent\n &__area {\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n min-height: 12rem;\n padding: var(--spacing-md);\n overflow: hidden;\n background: repeating-conic-gradient(\n var(--color-surface-2) 0% 25%,\n var(--color-surface) 0% 50%\n )\n 50% / 16px 16px;\n }\n\n &__frame {\n position: relative;\n flex-shrink: 0;\n overflow: hidden;\n box-shadow: var(--shadow-sm);\n cursor: crosshair;\n\n // The drag is the gesture: no scroll or zoom of the page under it\n touch-action: none;\n user-select: none;\n }\n\n &__stage,\n &__stage > canvas {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n // Drawn over a photo, so the same in both themes: white with a dark\n // edge reads on any image\n &__selection {\n position: absolute;\n pointer-events: none;\n border: 2px solid var(--color-white);\n outline: 1px solid\n color-mix(in srgb, var(--color-black) 50%, transparent);\n\n // What a crop leaves out goes dark\n &--crop {\n box-shadow: 0 0 0 100vmax\n color-mix(in srgb, var(--color-black) 55%, transparent);\n }\n\n &--cover {\n border-style: dashed;\n background-color: color-mix(\n in srgb,\n var(--color-black) 30%,\n transparent\n );\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import {\n computed,\n onBeforeUnmount,\n onMounted,\n ref,\n useId,\n useTemplateRef,\n watch,\n } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useResizeObserver } from '@vueuse/core'\n import PkEditorRadioButtons from '../PkEditorRadioButtons.vue'\n import {\n dragRect,\n releaseCanvas,\n renderEdits,\n sizeAfterEdits,\n type CoverStyle,\n type ImageEdit,\n type ImagePoint,\n type ImageRect,\n } from './imageEdits'\n\n /**\n * The tools of the image editor over the image they change (spec\n * `chat-image-editor.md`, F1): crop and cover by dragging on the image,\n * quarter turns, undo and redo. The edits are the model, the image stays\n * as it was loaded. Dragging needs a mouse, a pen or a finger; the rest\n * works from the keyboard.\n */\n const props = defineProps<{\n /** The image the edits start from. */\n image: HTMLCanvasElement\n }>()\n\n const emit = defineEmits<{\n /** The browser could not draw the image, out of canvas memory. */\n error: []\n }>()\n\n const edits = defineModel<ImageEdit[]>('edits', { required: true })\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n // --- Tools ---\n\n type Tool = 'crop' | 'cover'\n type Aspect = 'free' | '1:1' | '4:3' | '16:9'\n\n const ASPECTS: Record<Aspect, number | undefined> = {\n free: undefined,\n '1:1': 1,\n '4:3': 4 / 3,\n '16:9': 16 / 9,\n }\n\n const tool = ref<Tool>('crop')\n const aspect = ref<Aspect>('free')\n // Every opening starts on the solid box, the only cover safe on a text:\n // the pixels picked for a face yesterday do not cover an IBAN today\n const coverStyle = ref<CoverStyle>('solid')\n\n const toolOptions = computed(() => [\n { value: 'crop', label: $t('imageEditor.crop') },\n { value: 'cover', label: $t('imageEditor.cover') },\n ])\n const aspectOptions = computed(() => [\n { value: 'free', label: $t('imageEditor.aspectFree') },\n { value: '1:1', label: '1:1' },\n { value: '4:3', label: '4:3' },\n { value: '16:9', label: '16:9' },\n ])\n const coverOptions = computed(() => [\n { value: 'solid', label: $t('imageEditor.coverSolid') },\n { value: 'pixelate', label: $t('imageEditor.coverPixelate') },\n ])\n const aspectLabelId = useId()\n\n // --- History ---\n\n const redoStack = ref<ImageEdit[]>([])\n\n function push(edit: ImageEdit) {\n edits.value = [...edits.value, edit]\n redoStack.value = []\n }\n\n function undo() {\n selection.value = undefined\n const last = edits.value[edits.value.length - 1]\n if (!last) {\n return\n }\n edits.value = edits.value.slice(0, -1)\n redoStack.value = [...redoStack.value, last]\n }\n\n function redo() {\n selection.value = undefined\n const next = redoStack.value[redoStack.value.length - 1]\n if (!next) {\n return\n }\n edits.value = [...edits.value, next]\n redoStack.value = redoStack.value.slice(0, -1)\n }\n\n function rotate(turn: 1 | -1) {\n selection.value = undefined\n push({ kind: 'rotate', turn })\n }\n\n // --- Drawing ---\n\n const size = computed(() => sizeAfterEdits(props.image, edits.value))\n const stageEl = useTemplateRef<HTMLDivElement>('stageEl')\n // The canvas on screen, outside Vue: a new one replaces it on each edit\n let shown: HTMLCanvasElement | undefined\n\n function draw() {\n if (!stageEl.value) {\n return\n }\n let canvas: HTMLCanvasElement\n try {\n canvas = renderEdits(props.image, edits.value)\n } catch {\n emit('error')\n return\n }\n canvas.setAttribute('role', 'img')\n canvas.setAttribute('aria-label', $t('imageEditor.canvasLabel'))\n stageEl.value.replaceChildren(canvas)\n if (shown) {\n releaseCanvas(shown)\n }\n shown = canvas\n }\n\n onMounted(draw)\n watch([() => props.image, edits], draw, { flush: 'post' })\n onBeforeUnmount(() => {\n if (shown) {\n releaseCanvas(shown)\n }\n })\n\n // The image fits the room it has, never drawn larger than its pixels\n const areaEl = useTemplateRef<HTMLDivElement>('areaEl')\n const room = ref({ width: 0, height: 0 })\n useResizeObserver(areaEl, ([entry]) => {\n if (entry) {\n room.value = {\n width: entry.contentRect.width,\n height: entry.contentRect.height,\n }\n }\n })\n const scale = computed(() =>\n Math.min(\n 1,\n room.value.width / size.value.width,\n room.value.height / size.value.height,\n ),\n )\n const frameStyle = computed(() => ({\n width: `${Math.max(1, Math.floor(size.value.width * scale.value))}px`,\n height: `${Math.max(1, Math.floor(size.value.height * scale.value))}px`,\n }))\n\n // --- Dragging a rectangle ---\n\n /** A rectangle thinner than this on screen is a click, not a drag. */\n const MIN_DRAG = 6\n\n const frameEl = useTemplateRef<HTMLDivElement>('frameEl')\n const selection = ref<ImageRect>()\n const dragFrom = ref<ImagePoint>()\n\n function pointOf(event: PointerEvent): ImagePoint {\n const box = frameEl.value?.getBoundingClientRect()\n if (!box?.width || !box.height) {\n return { x: 0, y: 0 }\n }\n return {\n x: ((event.clientX - box.left) / box.width) * size.value.width,\n y: ((event.clientY - box.top) / box.height) * size.value.height,\n }\n }\n\n function onPointerDown(event: PointerEvent) {\n if (event.button !== 0) {\n return\n }\n frameEl.value?.setPointerCapture(event.pointerId)\n dragFrom.value = pointOf(event)\n selection.value = undefined\n }\n\n function onPointerMove(event: PointerEvent) {\n if (!dragFrom.value) {\n return\n }\n selection.value = dragRect(\n dragFrom.value,\n pointOf(event),\n size.value,\n tool.value === 'crop' ? ASPECTS[aspect.value] : undefined,\n )\n }\n\n function onPointerUp() {\n if (!dragFrom.value) {\n return\n }\n dragFrom.value = undefined\n const rect = selection.value\n if (\n !rect ||\n rect.width * scale.value < MIN_DRAG ||\n rect.height * scale.value < MIN_DRAG\n ) {\n selection.value = undefined\n return\n }\n // A cover is written as soon as it is drawn; a crop waits for Apply\n if (tool.value === 'cover') {\n selection.value = undefined\n push({ kind: 'cover', rect, style: coverStyle.value })\n }\n }\n\n function onPointerCancel() {\n dragFrom.value = undefined\n selection.value = undefined\n }\n\n const pendingCrop = computed(\n () => tool.value === 'crop' && !dragFrom.value && !!selection.value,\n )\n\n function applyCrop() {\n const rect = selection.value\n if (!pendingCrop.value || !rect) {\n return\n }\n selection.value = undefined\n if (\n rect.width === size.value.width &&\n rect.height === size.value.height\n ) {\n return\n }\n push({ kind: 'crop', rect })\n }\n\n watch(tool, () => {\n selection.value = undefined\n })\n\n // A crop drawn and then given proportions keeps its corner and takes them\n watch(aspect, (value) => {\n const rect = selection.value\n if (rect && tool.value === 'crop') {\n selection.value = dragRect(\n rect,\n { x: rect.x + rect.width, y: rect.y + rect.height },\n size.value,\n ASPECTS[value],\n )\n }\n })\n\n const selectionStyle = computed(() => {\n const rect = selection.value\n if (!rect) {\n return undefined\n }\n return {\n left: `${(rect.x / size.value.width) * 100}%`,\n top: `${(rect.y / size.value.height) * 100}%`,\n width: `${(rect.width / size.value.width) * 100}%`,\n height: `${(rect.height / size.value.height) * 100}%`,\n }\n })\n\n defineExpose({\n /** A crop is drawn and not applied yet. */\n pendingCrop,\n /** Applies the crop drawn, as Apply does: \"Use the image\" calls it first. */\n applyCrop,\n /**\n * The canvas on screen, every edit drawn, which the host writes as\n * the file: it stays the editor's, released when the editor goes.\n */\n shownCanvas: () => shown,\n })\n</script>\n\n<template>\n <div class=\"pk-image-editor\">\n <div class=\"pk-image-editor__toolbar\">\n <PkEditorRadioButtons\n v-model=\"tool\"\n name=\"pk-image-editor-tool\"\n segmented\n class=\"mb-0\"\n :aria-label=\"$t('imageEditor.tool')\"\n :options=\"toolOptions\">\n <template #crop=\"{ option }\">\n <VvIcon name=\"ri:crop-line\" class=\"w-16 h-16\" />\n {{ option.label }}\n </template>\n <template #cover=\"{ option }\">\n <VvIcon name=\"ri:eye-off-line\" class=\"w-16 h-16\" />\n {{ option.label }}\n </template>\n </PkEditorRadioButtons>\n <VvButtonGroup modifiers=\"compact\">\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:anticlockwise-line\"\n :title=\"$t('imageEditor.rotateLeft')\"\n :aria-label=\"$t('imageEditor.rotateLeft')\"\n @click=\"rotate(-1)\" />\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:clockwise-line\"\n :title=\"$t('imageEditor.rotateRight')\"\n :aria-label=\"$t('imageEditor.rotateRight')\"\n @click=\"rotate(1)\" />\n </VvButtonGroup>\n <!-- \"Annulla\" is already the dialog's button: two \"Annulla\"\n doing different things in one window read as one -->\n <VvButtonGroup modifiers=\"compact\" class=\"ml-auto\">\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:arrow-go-back-line\"\n :title=\"$t('imageEditor.undo')\"\n :aria-label=\"$t('imageEditor.undo')\"\n :disabled=\"!edits.length\"\n @click=\"undo\" />\n <VvButton\n modifiers=\"action-quiet\"\n icon=\"ri:arrow-go-forward-line\"\n :title=\"$t('imageEditor.redo')\"\n :aria-label=\"$t('imageEditor.redo')\"\n :disabled=\"!redoStack.length\"\n @click=\"redo\" />\n </VvButtonGroup>\n </div>\n <div class=\"pk-image-editor__options\">\n <template v-if=\"tool === 'crop'\">\n <span :id=\"aspectLabelId\" class=\"pk-image-editor__label\">\n {{ $t('imageEditor.aspect') }}\n </span>\n <PkEditorRadioButtons\n v-model=\"aspect\"\n name=\"pk-image-editor-aspect\"\n segmented\n class=\"mb-0\"\n :aria-labelledby=\"aspectLabelId\"\n :options=\"aspectOptions\" />\n <span class=\"pk-image-editor__hint\">\n {{ $t('imageEditor.cropHint') }}\n </span>\n <VvButton\n class=\"ml-auto\"\n modifiers=\"secondary\"\n :label=\"$t('action.apply')\"\n :disabled=\"!pendingCrop\"\n @click=\"applyCrop\" />\n </template>\n <template v-else>\n <PkEditorRadioButtons\n v-model=\"coverStyle\"\n name=\"pk-image-editor-cover\"\n segmented\n class=\"mb-0\"\n :aria-label=\"$t('imageEditor.coverStyle')\"\n :options=\"coverOptions\" />\n <span class=\"pk-image-editor__hint\">\n {{ $t('imageEditor.coverHint') }}\n </span>\n </template>\n </div>\n <div ref=\"areaEl\" class=\"pk-image-editor__area\">\n <div\n ref=\"frameEl\"\n class=\"pk-image-editor__frame\"\n :style=\"frameStyle\"\n @pointerdown=\"onPointerDown\"\n @pointermove=\"onPointerMove\"\n @pointerup=\"onPointerUp\"\n @pointercancel=\"onPointerCancel\">\n <div ref=\"stageEl\" class=\"pk-image-editor__stage\" />\n <div\n v-if=\"selection\"\n class=\"pk-image-editor__selection\"\n :class=\"`pk-image-editor__selection--${tool}`\"\n :style=\"selectionStyle\" />\n </div>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n .pk-image-editor {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n\n &__toolbar,\n &__options {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--spacing-8);\n padding: var(--spacing-8) var(--spacing-md);\n border-bottom: 1px solid var(--color-surface-3);\n }\n\n &__toolbar {\n background-color: var(--color-surface-1);\n }\n\n // A segmented control is as wide as its options, each as wide as its\n // words: with the library's equal segments the longer one was cut\n // (\"Riquadro pien\") and its icon shrank. A row too narrow sends the\n // control to a line of its own.\n &__toolbar > .vv-radio-group,\n &__options > .vv-radio-group {\n flex: none;\n width: auto;\n\n .vv-radio {\n flex: none;\n }\n }\n\n &__label {\n color: var(--color-word-2);\n font-size: var(--text-14);\n }\n\n &__hint {\n color: var(--color-word-3);\n font-size: var(--text-12);\n }\n\n // A checkerboard, as in the lightbox: a transparent PNG shows where\n // it is transparent\n &__area {\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n min-height: 12rem;\n padding: var(--spacing-md);\n overflow: hidden;\n background: repeating-conic-gradient(\n var(--color-surface-2) 0% 25%,\n var(--color-surface) 0% 50%\n )\n 50% / 16px 16px;\n }\n\n &__frame {\n position: relative;\n flex-shrink: 0;\n overflow: hidden;\n box-shadow: var(--shadow-sm);\n cursor: crosshair;\n\n // The drag is the gesture: no scroll or zoom of the page under it\n touch-action: none;\n user-select: none;\n }\n\n &__stage,\n &__stage > canvas {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n // Drawn over a photo, so the same in both themes: white with a dark\n // edge reads on any image\n &__selection {\n position: absolute;\n pointer-events: none;\n border: 2px solid var(--color-white);\n outline: 1px solid\n color-mix(in srgb, var(--color-black) 50%, transparent);\n\n // What a crop leaves out goes dark\n &--crop {\n box-shadow: 0 0 0 100vmax\n color-mix(in srgb, var(--color-black) 55%, transparent);\n }\n\n &--cover {\n border-style: dashed;\n background-color: color-mix(\n in srgb,\n var(--color-black) 30%,\n transparent\n );\n }\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n shallowRef,\n useTemplateRef,\n } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useMediaQuery } from '@vueuse/core'\n import PkImageEditor from './PkImageEditor.vue'\n import {\n editedFileName,\n exportCanvas,\n loadEditableImage,\n releaseCanvas,\n sizeAfterEdits,\n type ImageEdit,\n type LoadedImage,\n } from './imageEdits'\n\n /**\n * The image editor in a dialog (spec `chat-image-editor.md`, F1): opens\n * on an image file and gives back the edited copy, same name and type.\n * Open while it is mounted: `close` asks the host to drop it. It keeps\n * open on a click outside and on `Esc`, which would throw the edits away.\n */\n const props = defineProps<{\n file: File\n }>()\n\n const emit = defineEmits<{\n close: []\n /** The edited copy, to take the place of `file`. */\n apply: [file: File]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n // The phone breakpoint of the design system: the dialog covers the screen\n const fullscreen = useMediaQuery('(max-width: 575.98px)')\n\n // A canvas is no state to make deeply reactive\n const loaded = shallowRef<LoadedImage>()\n const failed = ref<'load' | 'draw' | 'export'>()\n const edits = ref<ImageEdit[]>([])\n const exporting = ref(false)\n const editorEl =\n useTemplateRef<InstanceType<typeof PkImageEditor>>('editorEl')\n\n onMounted(async () => {\n try {\n loaded.value = await loadEditableImage(props.file)\n } catch {\n failed.value = 'load'\n }\n })\n\n onBeforeUnmount(() => {\n if (loaded.value) {\n releaseCanvas(loaded.value.image)\n }\n })\n\n const size = computed(\n () => loaded.value && sizeAfterEdits(loaded.value.image, edits.value),\n )\n const scaledDown = computed(\n () =>\n !!loaded.value &&\n loaded.value.image.width < loaded.value.original.width,\n )\n const changed = computed(\n () => edits.value.length > 0 || !!editorEl.value?.pendingCrop,\n )\n\n async function useImage() {\n const editor = editorEl.value\n if (!editor) {\n return\n }\n // A crop drawn and not applied is what the user sees: it goes too\n editor.applyCrop()\n // A crop of the whole image changes nothing\n if (!edits.value.length) {\n emit('close')\n return\n }\n failed.value = undefined\n exporting.value = true\n try {\n // The editor draws the crop above in its next update; the file is\n // written from that canvas, not from a second one of full size\n await nextTick()\n const canvas = editor.shownCanvas()\n if (failed.value === 'draw') {\n return\n }\n if (!canvas) {\n throw new Error('No image drawn')\n }\n const blob = await exportCanvas(canvas, props.file.type)\n emit(\n 'apply',\n new File(\n [blob],\n editedFileName(props.file.name, props.file.type, blob.type),\n { type: blob.type, lastModified: Date.now() },\n ),\n )\n } catch {\n failed.value = 'export'\n } finally {\n exporting.value = false\n }\n }\n\n const failedLabel = computed(() => {\n switch (failed.value) {\n case 'export':\n return $t('imageEditor.exportFailed')\n case 'draw':\n return $t('imageEditor.drawFailed')\n default:\n return $t('imageEditor.loadFailed')\n }\n })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :title=\"$t('imageEditor.title')\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n keep-open\n class=\"pk-image-editor-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <VvAlert\n v-if=\"failed\"\n modifiers=\"danger\"\n class=\"m-md\"\n :content=\"failedLabel\" />\n <PkImageEditor\n v-if=\"loaded && failed !== 'draw'\"\n ref=\"editorEl\"\n v-model:edits=\"edits\"\n :image=\"loaded.image\"\n @error=\"failed = 'draw'\" />\n <div\n v-else-if=\"!failed\"\n class=\"pk-image-editor-dialog__loading\"\n role=\"status\"\n :aria-label=\"$t('imageEditor.loading')\">\n <VvIcon name=\"loading-loop\" />\n </div>\n <p v-if=\"size\" class=\"pk-image-editor-dialog__size\">\n {{\n scaledDown\n ? $t('imageEditor.sizeScaledDown', {\n width: size.width,\n height: size.height,\n })\n : $t('imageEditor.size', {\n width: size.width,\n height: size.height,\n })\n }}\n </p>\n <template #footer>\n <VvButtonGroup>\n <VvButton\n modifiers=\"secondary\"\n :label=\"$t('action.cancel')\"\n @click=\"emit('close')\" />\n <VvButton\n :label=\"$t('imageEditor.use')\"\n :loading=\"exporting\"\n :disabled=\"exporting || !changed || failed === 'draw'\"\n @click=\"useImage\" />\n </VvButtonGroup>\n </template>\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Most of the window, as the file viewer: room for a photo and the tools\n .pk-image-editor-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(64rem, 94dvw);\n height: min(48rem, 92dvh);\n }\n\n // The library writes `max-height: auto`, which is no value (see\n // PkFilePreviewDialog)\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n\n &__loading {\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n color: var(--color-word-3);\n font-size: var(--text-24);\n }\n\n &__size {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-md);\n border-top: 1px solid var(--color-surface-3);\n color: var(--color-word-3);\n font-size: var(--text-12);\n font-variant-numeric: tabular-nums;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n shallowRef,\n useTemplateRef,\n } from 'vue'\n import { useI18n } from 'vue-i18n'\n import { useMediaQuery } from '@vueuse/core'\n import PkImageEditor from './PkImageEditor.vue'\n import {\n editedFileName,\n exportCanvas,\n loadEditableImage,\n releaseCanvas,\n sizeAfterEdits,\n type ImageEdit,\n type LoadedImage,\n } from './imageEdits'\n\n /**\n * The image editor in a dialog (spec `chat-image-editor.md`, F1): opens\n * on an image file and gives back the edited copy, same name and type.\n * Open while it is mounted: `close` asks the host to drop it. It keeps\n * open on a click outside and on `Esc`, which would throw the edits away.\n */\n const props = defineProps<{\n file: File\n }>()\n\n const emit = defineEmits<{\n close: []\n /** The edited copy, to take the place of `file`. */\n apply: [file: File]\n }>()\n\n const { t: $t } = useI18n({ useScope: 'global' })\n\n // The phone breakpoint of the design system: the dialog covers the screen\n const fullscreen = useMediaQuery('(max-width: 575.98px)')\n\n // A canvas is no state to make deeply reactive\n const loaded = shallowRef<LoadedImage>()\n const failed = ref<'load' | 'draw' | 'export'>()\n const edits = ref<ImageEdit[]>([])\n const exporting = ref(false)\n const editorEl =\n useTemplateRef<InstanceType<typeof PkImageEditor>>('editorEl')\n\n onMounted(async () => {\n try {\n loaded.value = await loadEditableImage(props.file)\n } catch {\n failed.value = 'load'\n }\n })\n\n onBeforeUnmount(() => {\n if (loaded.value) {\n releaseCanvas(loaded.value.image)\n }\n })\n\n const size = computed(\n () => loaded.value && sizeAfterEdits(loaded.value.image, edits.value),\n )\n const scaledDown = computed(\n () =>\n !!loaded.value &&\n loaded.value.image.width < loaded.value.original.width,\n )\n const changed = computed(\n () => edits.value.length > 0 || !!editorEl.value?.pendingCrop,\n )\n\n async function useImage() {\n const editor = editorEl.value\n if (!editor) {\n return\n }\n // A crop drawn and not applied is what the user sees: it goes too\n editor.applyCrop()\n // A crop of the whole image changes nothing\n if (!edits.value.length) {\n emit('close')\n return\n }\n failed.value = undefined\n exporting.value = true\n try {\n // The editor draws the crop above in its next update; the file is\n // written from that canvas, not from a second one of full size\n await nextTick()\n const canvas = editor.shownCanvas()\n if (failed.value === 'draw') {\n return\n }\n if (!canvas) {\n throw new Error('No image drawn')\n }\n const blob = await exportCanvas(canvas, props.file.type)\n emit(\n 'apply',\n new File(\n [blob],\n editedFileName(props.file.name, props.file.type, blob.type),\n { type: blob.type, lastModified: Date.now() },\n ),\n )\n } catch {\n failed.value = 'export'\n } finally {\n exporting.value = false\n }\n }\n\n const failedLabel = computed(() => {\n switch (failed.value) {\n case 'export':\n return $t('imageEditor.exportFailed')\n case 'draw':\n return $t('imageEditor.drawFailed')\n default:\n return $t('imageEditor.loadFailed')\n }\n })\n</script>\n\n<template>\n <VvDialog\n :model-value=\"true\"\n :title=\"$t('imageEditor.title')\"\n :modifiers=\"fullscreen ? 'fullscreen' : undefined\"\n keep-open\n class=\"pk-image-editor-dialog\"\n @update:model-value=\"!$event && emit('close')\">\n <VvAlert\n v-if=\"failed\"\n modifiers=\"danger\"\n class=\"m-md\"\n :content=\"failedLabel\" />\n <PkImageEditor\n v-if=\"loaded && failed !== 'draw'\"\n ref=\"editorEl\"\n v-model:edits=\"edits\"\n :image=\"loaded.image\"\n @error=\"failed = 'draw'\" />\n <div\n v-else-if=\"!failed\"\n class=\"pk-image-editor-dialog__loading\"\n role=\"status\"\n :aria-label=\"$t('imageEditor.loading')\">\n <VvIcon name=\"loading-loop\" />\n </div>\n <p v-if=\"size\" class=\"pk-image-editor-dialog__size\">\n {{\n scaledDown\n ? $t('imageEditor.sizeScaledDown', {\n width: size.width,\n height: size.height,\n })\n : $t('imageEditor.size', {\n width: size.width,\n height: size.height,\n })\n }}\n </p>\n <template #footer>\n <VvButtonGroup>\n <VvButton\n modifiers=\"secondary\"\n :label=\"$t('action.cancel')\"\n @click=\"emit('close')\" />\n <VvButton\n :label=\"$t('imageEditor.use')\"\n :loading=\"exporting\"\n :disabled=\"exporting || !changed || failed === 'draw'\"\n @click=\"useImage\" />\n </VvButtonGroup>\n </template>\n </VvDialog>\n</template>\n\n<style lang=\"scss\">\n // Most of the window, as the file viewer: room for a photo and the tools\n .pk-image-editor-dialog {\n &:not(.vv-dialog--fullscreen) > article {\n width: min(64rem, 94dvw);\n height: min(48rem, 92dvh);\n }\n\n // The library writes `max-height: auto`, which is no value (see\n // PkFilePreviewDialog)\n &.vv-dialog--fullscreen > article {\n max-height: none;\n }\n\n .vv-dialog__content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n padding: 0;\n }\n\n &__loading {\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n color: var(--color-word-3);\n font-size: var(--text-24);\n }\n\n &__size {\n margin: 0;\n padding: var(--spacing-8) var(--spacing-md);\n border-top: 1px solid var(--color-surface-3);\n color: var(--color-word-3);\n font-size: var(--text-12);\n font-variant-numeric: tabular-nums;\n }\n }\n</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AA;;MAJF,OAAM;MACN,MAAK;MACJ,cAAYL,EAAA2G,CAAA,CAAE,CAAA,qBAAA;K,IACfzG,EAA8BkJ,GAAA,EAAtB,MAAK,eAAc,CAAA,C;KAEtBpI,EAAA,SAATlB,EAAA,GAAAO,EAYI,KAZJqK,IAYIpK,EAVI6K,EAAA,QAAiCnL,EAAA2G,CAAA,CAAE,CAAA,8BAAA;MAAkE,OAAA3F,EAAA,MAAK;MAAyC,QAAAA,EAAA,MAAK;K,KAAuDhB,EAAA2G,CAAA,CAAE,CAAA,oBAAA;MAAwD,OAAA3F,EAAA,MAAK;MAAyC,QAAAA,EAAA,MAAK"}
|
package/dist-vue/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { A as lt, E as ut, I as dt, N as ft, Q as pt, R as mt, V as ht, X as gt,
|
|
|
17
17
|
import { t as St } from "./_chunks/useSafeLocalStorage-Bn4SsL8C.js";
|
|
18
18
|
import { t as Ct } from "./_chunks/useDialogConfirm-fn7iV-iE.js";
|
|
19
19
|
import { i as wt, n as Tt, r as Et, t as Dt } from "./_chunks/PkChatbotViewConversations-BPnPsRhJ.js";
|
|
20
|
-
import { a as Ot, i as kt, n as At, o as jt, s as Mt, t as Nt } from "./_chunks/PkChatbotViewChat-
|
|
20
|
+
import { a as Ot, i as kt, n as At, o as jt, s as Mt, t as Nt } from "./_chunks/PkChatbotViewChat-C28g7dz-.js";
|
|
21
21
|
import { t as Pt } from "./_chunks/PkChatbotError-BS84xuiu.js";
|
|
22
22
|
import { t as Ft } from "./_chunks/useImageFallback-HUe4GHah.js";
|
|
23
23
|
import { t as It } from "./_chunks/useLocalizedString-Dmn92nix.js";
|
|
@@ -36,10 +36,10 @@ import { t as ir } from "./_chunks/PkChatbotFilePreview-j_8sDZUE.js";
|
|
|
36
36
|
import { n as ar, t as or } from "./_chunks/PkChatbotSteps-pibgqxus.js";
|
|
37
37
|
import { t as sr } from "./_chunks/PkChatbotStepPayload-DfLVMQrN.js";
|
|
38
38
|
import { t as cr } from "./_chunks/PkChatbotStepToolDetail-mwByeqKJ.js";
|
|
39
|
-
import { n as lr, t as ur } from "./_chunks/PkChatbotInput-
|
|
39
|
+
import { n as lr, t as ur } from "./_chunks/PkChatbotInput-OBoyFkZ-.js";
|
|
40
40
|
import { t as dr } from "./_chunks/PkChatbotEmptyState-DMPEj1Qa.js";
|
|
41
41
|
import { t as fr } from "./_chunks/PkChatbotViewProfile-PnHDQuuK.js";
|
|
42
|
-
import { t as pr } from "./_chunks/PkChatbot-
|
|
42
|
+
import { t as pr } from "./_chunks/PkChatbot-g-mj6Luo.js";
|
|
43
43
|
import { i as mr, r as hr, t as gr } from "./_chunks/PkToolShowSources-DApWmwvk.js";
|
|
44
44
|
import { t as _r } from "./_chunks/mcpOAuthReport-D-MtFYwN.js";
|
|
45
45
|
import { t as vr } from "./_chunks/PkToolShowEmail-BehvoNsz.js";
|
|
@@ -55,7 +55,7 @@ import { t as Dr } from "./_chunks/PkToolShowImageGallery-B-lVY0xH.js";
|
|
|
55
55
|
import { t as Or } from "./_chunks/PkToolShowSuggestedReply-CXGpPEl-.js";
|
|
56
56
|
import { t as kr } from "./_chunks/PkToolShareDocument-cMUqik6v.js";
|
|
57
57
|
import { t as Ar } from "./_chunks/PkToolChatFile-PXpiJLZ6.js";
|
|
58
|
-
import { t as jr } from "./_chunks/PkFilePreviewDialog-
|
|
58
|
+
import { t as jr } from "./_chunks/PkFilePreviewDialog-B3-oF1_R.js";
|
|
59
59
|
import { t as Mr } from "./_chunks/PkToolRequestGeolocation-Bx2Vtb-5.js";
|
|
60
60
|
import { VvAccordion as Nr, VvAccordionGroup as Pr, VvAlert as Fr, VvAlertGroup as Ir, VvBadge as Lr, VvButtonGroup as Rr, VvCheckbox as zr, VvCombobox as Br, VvDialog as Vr, VvDropdown as Hr, VvDropdownAction as Ur, VvIcon as Wr, VvInputFile as Gr, VvInputRange as Kr, VvInputText as qr, VvTab as Jr, VvTextarea as Yr } from "@volverjs/ui-vue/components";
|
|
61
61
|
import { Fragment as k, Teleport as Xr, Transition as Zr, TransitionGroup as Qr, cloneVNode as $r, computed as A, createApp as ei, createBlock as j, createCommentVNode as M, createElementBlock as N, createElementVNode as P, createSlots as ti, createStaticVNode as ni, createTextVNode as F, createVNode as I, defineComponent as L, guardReactiveProps as ri, h as ii, inject as R, isRef as ai, isVNode as oi, mergeModels as si, mergeProps as ci, nextTick as li, normalizeClass as ui, normalizeProps as di, normalizeStyle as fi, onBeforeUnmount as pi, onMounted as mi, onUnmounted as hi, openBlock as z, provide as gi, reactive as _i, readonly as vi, ref as B, renderList as yi, renderSlot as bi, resolveComponent as xi, resolveDynamicComponent as Si, shallowRef as Ci, toDisplayString as V, toRef as wi, toRefs as Ti, unref as H, useId as Ei, useModel as U, useSlots as Di, useTemplateRef as Oi, vModelSelect as ki, vModelText as Ai, watch as W, withCtx as G, withDirectives as ji, withKeys as Mi, withModifiers as Ni } from "vue";
|