import type { StoryState } from '../core/types/story'; import type { CapturePayload } from '../core/state/story.svelte'; import { IIIF_PRESENTATION_3_CONTEXT, MANGO_STORY_CONTEXT_URL, W3C_WEB_ANNOTATION_CONTEXT, type MangoViewerStateBody } from './storyAnnotationProfile'; export type SaveConfig = { endpoint?: string; method?: 'POST' | 'PUT'; headers?: Record; timeoutMs?: number; credentials?: RequestCredentials; enabled?: boolean; /** Host-owned persistence, for example IndexedDB or a native application store. */ handler?: StorySaveHandler; }; export type StorySelector = { type?: string; conformsTo?: string; value?: string; [key: string]: unknown; }; export type StoryTarget = { source?: string; type?: string; partOf?: { id: string; type: 'Manifest'; }; selector?: StorySelector | StorySelector[]; [key: string]: unknown; }; export type StoryAnnotation = { id: string; type: 'Annotation'; motivation: 'supplementing' | 'describing' | 'highlighting' | 'commenting'; label?: Record; summary?: Record; stylesheet?: Record | string | Array | string>; body?: Record | MangoViewerStateBody | Array | MangoViewerStateBody>; target: StoryTarget | string; }; export type StoryAnnotationPage = { '@context': [ typeof W3C_WEB_ANNOTATION_CONTEXT, typeof MANGO_STORY_CONTEXT_URL, typeof IIIF_PRESENTATION_3_CONTEXT ]; id: string; type: 'AnnotationPage'; /** * Absent on an untitled story. IIIF permits an AnnotationPage without a * label, and the page label is the story title by contract — so a stand-in * written here for display is a title the next load reads back as real. */ label?: Record; items: StoryAnnotation[]; }; export type SerializeStoryOptions = { /** Public HTTP(S) identifier for the exported AnnotationPage. */ id?: string; }; export type ExportEnvelope = StoryAnnotationPage; export type SaveResult = { ok: true; message?: string; } | { ok: false; message: string; code?: string; }; export type StorySaveHandler = (payload: ExportEnvelope) => SaveResult | void | Promise; export type SaveState = { status: 'idle'; message?: string; code?: string; } | { status: 'saving'; message?: string; code?: string; } | { status: 'success'; message?: string; } | { status: 'error'; message?: string; code?: string; }; export declare const serializeStoryToIiif: (raw: StoryState, options?: SerializeStoryOptions) => StoryAnnotationPage; export declare const buildExportEnvelope: (raw: StoryState) => ExportEnvelope; export declare const performFetchWithTimeout: (cfg: SaveConfig, payload: ExportEnvelope) => Promise; export declare const validateStoryForExport: (story: StoryState) => { ok: boolean; errors: string[]; }; export type StoryStoreWrapper = { loadStory: (next: StoryState) => void; addChapterFromCapture: (payload: { capture: CapturePayload; id?: string; }) => void; setNarrationTrack: (payload: { language: string; src: string; }) => void; setChapterTitle: (payload: { chapterId: string; language: string; value: string; }) => void; setChapterDescription: (payload: { chapterId: string; language: string; value: string; }) => void; setNarrationSegment: (payload: { chapterId: string; language: string; start: number; end: number; }) => void; setAnnotationText: (payload: { chapterId: string; language: string; text: string; }) => void; setAnnotationPlacement: (payload: { chapterId: string; language: string; placement: import('../core/types/story').AnnotationPlacement; }) => void; setAdvanceMode: (payload: { chapterId: string; mode: import('../core/types/story').ChapterAdvance['mode']; }) => void; setDelay: (payload: { chapterId: string; delayMs?: number; }) => void; }; export declare const loadStoryIntoStore: (storyToLoad: StoryState, storyStoreWrapper: StoryStoreWrapper) => void;