<script setup>
const config = useRuntimeConfig()
const attachmentPreview = useAttachmentPreview()
const attachmentParam = useAttachmentParam()

watch(attachmentPreview, () => {
  if(!attachmentPreview.value) {
    attachmentParam.value = {}
  }
})
</script>

<template>
  <AttachmentViewer v-model="attachmentPreview" :type="attachmentParam?.mime ?? ''" :source="(attachmentParam?.formats?.large?.url ?? attachmentParam?.url) ? config.public.strapi+'/files-api/'+(attachmentParam?.formats?.large?.url ?? attachmentParam?.url).replace('/uploads/', '') : ''" :title="attachmentParam?.name ?? ''" :width="attachmentParam?.width ?? 1366" :height="attachmentParam?.height ?? 768" />
</template>