import { Graphics2DCapabilities, Graphics2DClient, Graphics2DElement, Graphics2DFont, Graphics2DSurfaceFinishItem, Graphics2DTarget } from './graphics2d'; export type Graphics2DEditorPhase = "idle" | "opening" | "ready" | "selecting-target" | "editing" | "switching-target" | "closing" | "error"; export type Graphics2DEditorOperation = "add-image" | "replace-image" | "add-text" | "update-text" | "remove-element" | "update-transform" | "apply-finish" | "rollback" | "commit"; export type Graphics2DEditorErrorStage = "capabilities" | "open" | "target" | "image" | "text" | "fonts" | "transform" | "finish" | "rollback" | "commit"; export interface Graphics2DTransformDraft { x?: number; y?: number; scale?: number; rotation?: number; opacity?: number; flipX?: boolean; flipY?: boolean; } export interface Graphics2DEditorOptions { transform?: { minScale?: number; maxScale?: number; positionStep?: number; scaleStep?: number; previewMode?: "auto" | "realtime" | "release"; }; text?: { /** Default content used only when addText() is called without content. */ defaultContent?: string; }; closeAction?: "rollback" | "commit"; } export interface Graphics2DEditorState { phase: Graphics2DEditorPhase; capabilities: Graphics2DCapabilities | null; targets: Graphics2DTarget[]; activeTargetId: string | null; elements: Graphics2DElement[]; selectedElementId: string | null; selectedElement: Graphics2DElement | null; finishes: Graphics2DSurfaceFinishItem[]; finishesLoaded: boolean; fonts: Graphics2DFont[]; fontsLoaded: boolean; busyOperation: Graphics2DEditorOperation | null; transformDraft: Graphics2DTransformDraft | null; warning: string | null; error: Graphics2DEditorError | null; } export declare class Graphics2DEditorError extends Error { readonly code: string; readonly stage: Graphics2DEditorErrorStage; readonly recoverable: boolean; constructor(code: string, message: string, stage: Graphics2DEditorErrorStage, recoverable: boolean, options?: { cause?: unknown; }); } type StateListener = (state: Readonly) => void; export declare class Graphics2DEditorController { private readonly client; private readonly eventTarget?; private currentState; private readonly listeners; private sessionId; private disposed; private operationTail; private pendingTransform; private transformDrainRunning; readonly transformOptions: Required>; readonly closeAction: "rollback" | "commit"; readonly defaultTextContent: string; constructor(client: Graphics2DClient, eventTarget?: EventTarget, options?: Graphics2DEditorOptions); get state(): Readonly; subscribe(listener: StateListener): () => void; refresh(): Promise; open(): Promise; selectTarget(targetId: string): Promise; selectElement(elementId: string): void; addImage(source: Blob | string, options?: { name?: string; x?: number; y?: number; }): Promise; replaceImage(source: Blob | string): Promise; loadFonts(): Promise; addText(content?: string, options?: { name?: string; x?: number; y?: number; fontSize?: number; fontFamily?: string; fontWeight?: string; color?: string; }): Promise; updateSelectedText(values: { content?: string; fontSize?: number; fontFamily?: string; fontWeight?: string; color?: string; }): Promise; removeSelectedElement(): Promise; updateTransform(values: Graphics2DTransformDraft, options?: { final?: boolean; }): Promise; rotate(degrees: -90 | 90): Promise; toggleFlip(axis: "x" | "y"): Promise; loadFinishes(): Promise; applyFinish(finishId: string | null): Promise; rollback(): Promise; /** Roll back and reopen the current target as one serialized editor operation. */ reset(): Promise; commit(): Promise; close(options?: { action?: "rollback" | "commit"; }): Promise; dispose(): void; private readonly handleTargetSelected; private readonly handleSessionEnded; private drainTransforms; private exclusive; private rollbackSession; private syncElements; private transformForElement; private normalizeTransform; private releaseOnlyPreview; private cancelPendingTransform; private patchState; private fail; private requireSession; private requireSelectedElement; private currentScaleBounds; private assertActive; } export {};