/** * Picture-fill (``) registration for chart parts. * * Callers supply an image payload via `AddChartSeriesOptions.pictureFill.image`; * the builder stores it on the chart model's `spPr.fill.blip._pendingImage` * field. This module consumes those staged payloads at chart-registration * time, pushes the image into the workbook media collection, allocates a * fresh chart-part relationship, and rewrites the blip with the resolved * `r:embed` id. * * The worksheet path calls {@link resolvePendingChartImages} right after * `fillChartCaches` and before the chart entry is stored — at that point * we have both the built model and the owning workbook, so we can do the * binding without requiring callers to juggle rel ids manually. */ import type { ChartEntry } from "./chart.ts"; /** * Minimal workbook surface used by {@link resolvePendingChartImages}. The * concrete worksheet/workbook types pull in Cell/Row/Column machinery * this helper has no business touching, so we work against a structural * slice instead to keep the chart module import-light. */ export interface PictureFillHostWorkbook { addImage(image: WorkbookImagePayload): number; getImage(id: number | string): WorkbookMediaLike | undefined; } interface WorkbookMediaLike { extension?: string; buffer?: Uint8Array | undefined; base64?: string | undefined; filename?: string | undefined; } /** * Image payload accepted by `Workbook.addImage`. Named * `WorkbookImagePayload` — NOT `ImageData` — so we do not collide with * the browser's built-in `ImageData` DOM type (pixel buffer used by * Canvas) when this module is compiled for the browser bundle. */ interface WorkbookImagePayload { extension: "jpeg" | "png" | "gif"; base64?: string; filename?: string; buffer?: Uint8Array; } /** * Rel information that {@link resolvePendingChartImages} appends to the * chart entry so the writer can emit the `chart{N}.xml.rels` file and * the correct `r:embed` value inside the chart XML. * * The concrete shape matches the rel entry format used elsewhere * (xlsx-writer relationships XForm) — Id + Type + Target triple. We * hardcode the Type URI in the literal emitted at the call site so * callers don't need to import the workbook-level `RelType` enum. */ /** * Walk a chart model, resolve every `_pendingImage` blip into a real * workbook media entry + chart relationship, and mutate the model so * the blip references the allocated `rIdN`. * * Safe to call multiple times on the same entry: once a blip has a * `relationshipId` and no `_pendingImage`, it is skipped. * * @param entry The chart entry being registered. Its `rels` array is * populated (created if absent) with any freshly * allocated image relationships. * @param workbook Host workbook exposing `addImage`. Also consulted for * its internal `_chartRels[n]` bag — those rels are * loaded from disk during round-trip and carry canonical * rIds that must NOT collide with freshly allocated * image rels (the xlsx writer merges both lists and * silently drops any duplicate Id, which would otherwise * orphan the image relationship). * @param chartNumber 1-based chart index. Used to look up * `workbook._chartRels[chartNumber]` so pre-existing * rels seed the collision set. */ export declare function resolvePendingChartImages(entry: ChartEntry, workbook: PictureFillHostWorkbook, chartNumber: number): void; export {};