import { buildSheetSnapshot, ENVELOPE_FORMAT, ENVELOPE_VERSION, REPORT_VERSION, type Branding, type Observation, type Report, type ReportArchiveEnvelope, } from '@faunosteo/domain' import { defaultPdfLabels } from '@faunosteo/pdf' import { loadSheetIndex } from '@/sheets/useSheet' import type { SheetIndex } from '@/services/sheetIndex' /** The bundled reference draft (vitest runs the sheet-bundle plugin in draft mode). */ export async function loadTestSheet(): Promise { const index = await loadSheetIndex('equine') if (!index) throw new Error('bundled sheet missing: run pnpm import:equine') return index } export function emptyObservation(id = 'obs-1'): Observation { return { id, zones: [], findings: [], freeTextFindings: [], comment: '' } } export function minimalReport( sheet: SheetIndex, patch: Partial = {}, ): Report { return { version: REPORT_VERSION, id: 'r1', createdAt: '2026-10-10T10:00:00Z', date: '2026-10-10', practitioner: { name: 'Dr. Dupont' }, animal: { speciesId: 'equine', name: 'Mistral' }, owner: { name: 'Jean Martin' }, sheet: sheet.sheet.ref, observations: [], conclusion: '', recommendations: '', localAnnotations: [], ...patch, } } /** The branding the app loads when every logo fetch fails (credits keep their text). */ export function nologosBranding(): Branding { return { siteUrl: 'https://faunosteo.com', headerLogo: null, footerLogo: null, poweredBy: { logo: null, url: 'https://zenquality.fr', fallbackText: 'zenquality.fr', }, partner: { logo: null, url: 'https://www.instagram.com/paws.iin.harmony', fallbackText: '@paws.iin.harmony', }, } } /** A valid Step 6 envelope for `report`, snapshotted on `sheet` (no logos). */ export function archiveEnvelope( sheet: SheetIndex, report: Report, ): ReportArchiveEnvelope { return { format: ENVELOPE_FORMAT, envelopeVersion: ENVELOPE_VERSION, exportedAt: '2026-10-11T12:00:00.000Z', locale: 'fr', report, sheetSnapshot: buildSheetSnapshot(sheet.sheet, report), branding: nologosBranding(), labels: defaultPdfLabels, } }