@hussmartinez/image-sdk 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/assets/image/job.worker.js +1 -1
- package/dist/assets/image/render.worker.js +1 -1
- package/dist/element.js +2 -2
- package/dist/index.d.ts +10 -1
- package/dist/index.js +1 -1
- package/dist/lazy/{inline-job-worker-BFybekkp.js → inline-job-worker-CIW_4y1q.js} +2 -2
- package/dist/lazy/{inline-job-worker-BFybekkp.js.map → inline-job-worker-CIW_4y1q.js.map} +1 -1
- package/dist/lazy/{inline-worker-CMzixw3b.js → inline-worker-B7Zgl5CJ.js} +2 -2
- package/dist/lazy/{inline-worker-CMzixw3b.js.map → inline-worker-B7Zgl5CJ.js.map} +1 -1
- package/dist/react.d.ts +10 -1
- package/dist/react.js +1 -1
- package/dist/shared/{core-CCE45OTe.js → core-VTHSqv-f.js} +4 -4
- package/dist/shared/{core-CCE45OTe.js.map → core-VTHSqv-f.js.map} +1 -1
- package/dist/shared/{editor-CJEZNOqH.js → editor-CXmyuWHq.js} +26 -7
- package/dist/shared/editor-CXmyuWHq.js.map +1 -0
- package/package.json +1 -1
- package/dist/shared/editor-CJEZNOqH.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-CXmyuWHq.js","names":["clamp","turned","clamp","keysOf","clamp","HANDLES","ARROWS","ARROWS","_Fragment","FIELDS","KINDS","_Fragment","_Fragment","_Fragment"],"sources":["../../src/features/editor-state.ts","../../src/features/tool-types.ts","../../src/features/crop/crop-tools.ts","../../src/features/layers/new-layer.ts","../../src/features/draw/draw-tool.ts","../../src/features/export/export-tool.ts","../../src/features/frames/frames-tool.ts","../../src/features/history/history-tools.ts","../../src/features/layers/add-layer-tools.ts","../../src/features/layers/layers-tool.ts","../../src/features/open/open-tool.ts","../../src/features/orientation/orientation-tools.ts","../../src/features/playback/playback.ts","../../src/features/playback/play-tool.ts","../../src/features/redact/redact-tool.ts","../../src/features/zoom/zoom-tools.ts","../../src/features/tools.ts","../../src/react/context.ts","../../src/react/hooks.ts","../../src/react/crop/use-crop.ts","../../src/react/crop/CropPanel.tsx","../../src/react/gesture.ts","../../src/react/redact/use-redact.ts","../../src/react/layers/use-layers.ts","../../src/react/layers/LayerFields.tsx","../../src/react/draw/use-draw.ts","../../src/react/draw/DrawPanel.tsx","../../src/react/EngineBoundary.tsx","../../src/react/crop/CropFrame.tsx","../../src/react/draw/DrawOverlay.tsx","../../src/react/key-run.ts","../../src/react/layers/frame-geometry.ts","../../src/react/layers/LayersOverlay.tsx","../../src/react/redact/RedactOverlay.tsx","../../src/react/stage/StageNotices.tsx","../../src/react/stage/ImageStage.tsx","../../src/react/export/export-listener.ts","../../src/react/export/ExportDialog.tsx","../../src/messages/editor-en.ts","../../src/react/editor-messages.ts","../../src/react/view-store.ts","../../src/react/ImageEditorProvider.tsx","../../src/react/frames/FrameThumbnail.tsx","../../src/react/frames/use-frames.ts","../../src/react/frames/FramesPanel.tsx","../../src/react/layers/LayersPanel.tsx","../../src/react/redact/RedactPanel.tsx","../../src/react/panels/use-slider-gesture.ts","../../src/react/panels/AdjustPanel.tsx","../../src/react/panels/FilterPanel.tsx","../../src/react/panels/InfoPanel.tsx","../../src/react/panels/Inspector.tsx","../../src/react/timeline/AnimationBar.tsx","../../src/react/toolbar/ImageToolbar.tsx","../../src/react/toolbar/icons.tsx","../../src/react/editor/ImageEditor.tsx"],"sourcesContent":["import { createStore, type Store } from \"@hussmartinez/sdk-core\";\nimport type { ImageError } from \"../core/errors/image-error.js\";\nimport type { ImageAspect } from \"../core/model/crop.js\";\nimport type { ImageCrop, ImagePlan, ImageRedactionMode } from \"../core/model/plan.js\";\n\n/**\n * The editor's own state, outside the session and its history\n * (docs/adr/0007): the active tool, a crop in progress, the redaction or\n * the layer that's selected, what's drawn with, and a gesture's transient plan, which the\n * stage renders instead of the session's.\n *\n * @public\n */\nexport interface ImageEditorState {\n /**\n * The tool that takes over the stage, such as `crop`, or `null`. With\n * `frames`, the inspector lists an animation's frames (docs/adr/0011);\n * the one selected is the one shown, `playback.frame`.\n */\n readonly tool: \"crop\" | \"redact\" | \"layers\" | \"draw\" | \"frames\" | null;\n /** The crop being made, in whole pixels of the oriented source, and its aspect. */\n readonly crop: { readonly pending: ImageCrop; readonly aspect: ImageAspect } | null;\n /**\n * While redacting: the key of the selected redaction, if any, and the mode\n * and colour a new one takes (docs/adr/0010).\n */\n readonly redact: {\n readonly selected: string | null;\n readonly mode: ImageRedactionMode;\n readonly colour: string;\n } | null;\n /**\n * While the layers are shown: the key of the selected layer, if any\n * (docs/adr/0013). Selection is view state, outside the plan and its\n * history.\n */\n readonly layers: {\n readonly selected: string | null;\n /**\n * Where the panel moves focus, once, before it clears this: to the\n * selected layer in the `list`, when the layers tool starts; or to the\n * `text` field of a text layer just added. Unset, focus stays where it\n * is, as when a shape or an image is added.\n */\n readonly focus?: \"list\" | \"text\";\n } | null;\n /**\n * While drawing (docs/adr/0015): what the next stroke is drawn with, and\n * the key of the drawing layer it joins, if there is one.\n */\n readonly draw: {\n /** A pen draws opaque strokes; a highlighter wide ones in a see-through drawing. */\n readonly mode: \"pen\" | \"highlighter\";\n readonly colour: string;\n /** In scene pixels. */\n readonly width: number;\n /** The drawing the next stroke joins, or `null` to start a new one. */\n readonly target: string | null;\n } | null;\n /**\n * What an editor's own action failed with, such as adding a layer over\n * the limit or an image that can't be read. The stage shows its text\n * until the next such action succeeds, or another image opens.\n */\n readonly error: ImageError | null;\n /**\n * A gesture's plan while it runs: the session's plan with the gesture's\n * change, which isn't an edit until the gesture ends.\n */\n readonly preview: ImagePlan | null;\n /** The dialog the editor shows over the stage, such as `export`, or `null`. */\n readonly dialog: \"export\" | null;\n /**\n * An animation's frame being shown, as an index into the plan's\n * `animation.frames`, and whether it's playing (docs/adr/0011). View\n * state, like the zoom: outside the plan and its history. No tool resets\n * it; another image opening does.\n */\n readonly playback: { readonly frame: number; readonly playing: boolean };\n}\n\n/** The first frame, paused: nothing plays on its own (docs/adr/0011). */\nexport const PAUSED = Object.freeze({ frame: 0, playing: false });\n\n/**\n * No tool on the stage: what a tool spreads before it sets its own state, so\n * one tool has the stage at a time, and what ends them all.\n */\nexport const NO_TOOL = Object.freeze({\n tool: null,\n crop: null,\n redact: null,\n layers: null,\n draw: null,\n} satisfies Partial<ImageEditorState>);\n\nexport const IDLE: ImageEditorState = Object.freeze({\n ...NO_TOOL,\n error: null,\n preview: null,\n dialog: null,\n playback: PAUSED,\n});\n\n/** A store of the editor's state. */\nexport function createEditorStore(): Store<ImageEditorState> {\n return createStore<ImageEditorState>(IDLE);\n}\n","import type { Store, Tool } from \"@hussmartinez/sdk-core\";\nimport type { ImageSession, ImageSessionSnapshot } from \"../core/session/session.js\";\nimport type { ImageEditorState } from \"./editor-state.js\";\n\n/**\n * What a tool reads to decide whether it's available, enabled or active.\n *\n * @public\n */\nexport interface ImageToolState {\n readonly snapshot: ImageSessionSnapshot;\n readonly editor: ImageEditorState;\n}\n\n/**\n * What a tool runs against.\n *\n * @public\n */\nexport interface ImageToolContext {\n readonly session: ImageSession;\n readonly view: Store<{\n readonly zoom: number;\n readonly pan: { readonly x: number; readonly y: number };\n }>;\n /** The editor's own state, which tools such as crop take over. */\n readonly editor: Store<ImageEditorState>;\n /** Asks the user for an image, as the open tool does. */\n readonly chooseFile: () => void;\n /** Asks the user for an image to add as a layer (docs/adr/0013). */\n readonly chooseLayerImage: () => void;\n}\n\n/**\n * One of the editor's tools (docs/adr/0007, sdk-core ADR 0009).\n *\n * @public\n */\nexport type ImageTool = Tool<ImageToolState, ImageToolContext, undefined> & {\n /**\n * Why the tool can't run right now, as a key of the editor's messages,\n * when there's something the user can do about it. The toolbar keeps a\n * button with a reason in the keyboard's order and describes it with the\n * text, so \"why is this greyed out\" has an answer.\n */\n readonly unavailable?: (state: ImageToolState) => string | undefined;\n};\n\n/** Whether a document is open. */\nexport const hasDocument = ({ snapshot }: ImageToolState): boolean => snapshot.plan !== null;\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport { wholeCrop } from \"../../core/model/crop.js\";\nimport type { ImageOrientation } from \"../../core/model/plan.js\";\nimport { NO_TOOL } from \"../editor-state.js\";\nimport { hasDocument, type ImageTool, type ImageToolContext } from \"../tool-types.js\";\n\n/** Starts cropping: the stage shows the whole image, with the current crop as the frame. */\nfunction startCrop({ session, editor }: ImageToolContext): void {\n const { plan, source } = session.getSnapshot();\n if (!plan || !source) return;\n editor.set((state) => ({\n ...state,\n // One tool has the stage at a time.\n ...NO_TOOL,\n tool: \"crop\",\n crop: { pending: plan.base.crop ?? wholeCrop(source), aspect: \"free\" },\n preview: null,\n }));\n}\n\n/** Shows the crop frame, which the editor then focuses (docs/adr/0007). */\nexport const cropTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.crop\",\n label: \"tools.crop\",\n icon: \"crop\",\n group: \"crop\",\n isEnabled: hasDocument,\n isActive: ({ editor }) => editor.tool === \"crop\",\n run: (context) => {\n if (context.editor.getSnapshot().tool === \"crop\") return;\n startCrop(context);\n },\n shortcuts: [\"C\"],\n});\n\nfunction flip({ session }: ImageToolContext, axis: \"flipX\" | \"flipY\"): void {\n const plan = session.getSnapshot().plan;\n if (!plan) return;\n const orientation: ImageOrientation = {\n ...plan.base.orientation,\n [axis]: !plan.base.orientation[axis],\n };\n session.execute({ type: \"image.setOrientation\", orientation });\n}\n\n/** Mirrors what's on screen left to right: the plan's flips come after its rotation. */\nexport const flipHorizontalTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.flip-horizontal\",\n label: \"tools.flip-horizontal\",\n icon: \"flip-horizontal\",\n group: \"orientation\",\n isEnabled: hasDocument,\n run: (context) => flip(context, \"flipX\"),\n});\n\n/** Mirrors what's on screen top to bottom. */\nexport const flipVerticalTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.flip-vertical\",\n label: \"tools.flip-vertical\",\n icon: \"flip-vertical\",\n group: \"orientation\",\n isEnabled: hasDocument,\n run: (context) => flip(context, \"flipY\"),\n});\n","import { compositionSize, compositionToSource, cropRect } from \"../../core/model/geometry.js\";\nimport { createImageKey } from \"../../core/model/keys.js\";\nimport { newLayerBox } from \"../../core/model/layer-placement.js\";\nimport {\n type ImageArrowLayer,\n type ImageLayer,\n type ImagePlan,\n type ImageShapeLayer,\n type ImageTextLayer,\n MAX_STROKE_WIDTH,\n} from \"../../core/model/plan.js\";\nimport type { ImageSize } from \"../../core/model/source.js\";\n\n/** The colour a new text layer and a new shape's outline take. */\nexport const DEFAULT_TEXT_COLOUR = \"#000000\";\nexport const DEFAULT_SHAPE_COLOUR = \"#e02020\";\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\n\n/** A key no layer or redaction of the plan has. */\nexport function newLayerKey(plan: ImagePlan): string {\n return createImageKey(new Set([...plan.layers, ...plan.redactions].map((item) => item.key)));\n}\n\nconst common = (plan: ImagePlan) => ({\n key: newLayerKey(plan),\n name: \"\",\n visible: true,\n opacity: 100,\n});\n\n/**\n * A new text layer, with no text yet: half the image wide and a fifth of it\n * tall, as it's shown. Text is drawn as large as fits its box.\n */\nexport function newTextLayer(plan: ImagePlan, source: ImageSize): ImageTextLayer {\n const { width, height } = compositionSize(plan, source);\n return {\n ...common(plan),\n kind: \"text\",\n text: \"\",\n font: \"sans-serif\",\n bold: false,\n colour: DEFAULT_TEXT_COLOUR,\n align: \"center\",\n ...newLayerBox(plan, source, { width: width / 2, height: height / 5 }),\n };\n}\n\n/** The outline a shape takes when it's given one: a hundredth of the image's shorter side, at least 2 pixels. */\nexport function defaultStrokeWidth(plan: ImagePlan, source: ImageSize): number {\n const { width, height } = compositionSize(plan, source);\n return clamp(Math.round(Math.min(width, height) / 100), 2, MAX_STROKE_WIDTH);\n}\n\n/**\n * A new shape: an outline with no fill, a quarter of the image each way, to\n * put around something.\n */\nexport function newShapeLayer(\n plan: ImagePlan,\n source: ImageSize,\n shape: ImageShapeLayer[\"shape\"],\n): ImageShapeLayer {\n const { width, height } = compositionSize(plan, source);\n const box = newLayerBox(plan, source, { width: width / 4, height: height / 4 });\n return {\n ...common(plan),\n kind: \"shape\",\n shape,\n fill: null,\n // Inside the box, so never wider than half of its shorter side.\n stroke: {\n colour: DEFAULT_SHAPE_COLOUR,\n width: Math.max(\n 1,\n Math.min(defaultStrokeWidth(plan, source), Math.floor(Math.min(box.width, box.height) / 2)),\n ),\n },\n ...box,\n };\n}\n\n/**\n * A new arrow (docs/adr/0014): across the middle quarter of the image as\n * it's shown, pointing right on screen whatever the plan's rotation and\n * flips, in a shape's red, as wide as a new shape's outline.\n */\nexport function newArrowLayer(plan: ImagePlan, source: ImageSize): ImageArrowLayer {\n const composition = compositionSize(plan, source);\n const crop = cropRect(plan.base.crop, source);\n const { orientation } = plan.base;\n const scene = (x: number, y: number) => {\n const point = compositionToSource({ x, y }, crop, orientation);\n return { x: Math.round(point.x) || 0, y: Math.round(point.y) || 0 };\n };\n const middle = composition.height / 2;\n const from = scene((composition.width * 3) / 8, middle);\n let to = scene((composition.width * 5) / 8, middle);\n // On an image a pixel or two wide the ends round to one point: an arrow has two.\n if (to.x === from.x && to.y === from.y) {\n const beside = scene((composition.width * 3) / 8 + 1, middle);\n to = beside.x === from.x && beside.y === from.y ? { x: from.x + 1, y: from.y } : beside;\n }\n return {\n ...common(plan),\n kind: \"arrow\",\n from,\n to,\n colour: DEFAULT_SHAPE_COLOUR,\n width: defaultStrokeWidth(plan, source),\n };\n}\n\n/** The command that puts a new layer over every other. */\nexport const insertOnTop = (plan: ImagePlan, layer: ImageLayer) =>\n ({ type: \"image.insertLayers\", at: plan.layers.length, layers: [layer] }) as const;\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport { MAX_STROKE_WIDTH } from \"../../core/model/plan.js\";\nimport { NO_TOOL } from \"../editor-state.js\";\nimport { DEFAULT_SHAPE_COLOUR, defaultStrokeWidth } from \"../layers/new-layer.js\";\nimport { hasDocument, type ImageTool, type ImageToolContext } from \"../tool-types.js\";\n\n/** What draws: a pen's strokes are opaque, a highlighter's wide in a see-through drawing. */\nexport type ImageDrawMode = \"pen\" | \"highlighter\";\n\n/**\n * The opacity of the drawing layer each mode draws into (docs/adr/0014): a\n * highlighter is a wide stroke in a drawing with a low opacity, composited\n * as one, so its strokes don't darken where they cross.\n */\nexport const DRAW_OPACITY: Readonly<Record<ImageDrawMode, number>> = { pen: 100, highlighter: 40 };\n\n/** The colour each mode starts with: a pen's red, a highlighter's yellow. */\nexport const DRAW_COLOUR: Readonly<Record<ImageDrawMode, string>> = {\n pen: DEFAULT_SHAPE_COLOUR,\n highlighter: \"#f0c020\",\n};\n\n/** How many times a pen's width a highlighter's is. */\nconst HIGHLIGHTER_WIDTH = 6;\n\n/**\n * The width each mode starts with, in scene pixels: a pen's is a new\n * shape's outline, a hundredth of the image's shorter side and at least 2;\n * a highlighter's is six of those.\n */\nexport function drawWidth({ session }: Pick<ImageToolContext, \"session\">, mode: ImageDrawMode) {\n const { plan, source } = session.getSnapshot();\n const pen = plan && source ? defaultStrokeWidth(plan, source) : 2;\n return mode === \"pen\" ? pen : Math.min(pen * HIGHLIGHTER_WIDTH, MAX_STROKE_WIDTH);\n}\n\n/**\n * Starts and ends drawing (docs/adr/0015): while it's on, a drag across the\n * image draws a stroke, and the inspector shows what it's drawn with. It\n * starts with the pen. If the layers were showing a drawing a pen can add\n * to, the strokes join it; otherwise the first stroke starts a new drawing.\n */\nexport const drawTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.draw\",\n label: \"tools.draw\",\n icon: \"pen\",\n group: \"draw\",\n isEnabled: hasDocument,\n isActive: ({ editor }) => editor.tool === \"draw\",\n run: (context) => {\n const { editor, session } = context;\n const selected = editor.getSnapshot().layers?.selected ?? null;\n const layer = session.getSnapshot().plan?.layers.find((item) => item.key === selected);\n const target =\n layer?.kind === \"drawing\" && layer.opacity === DRAW_OPACITY.pen ? layer.key : null;\n editor.set((state) =>\n state.tool === \"draw\"\n ? { ...state, ...NO_TOOL, preview: null }\n : {\n ...state,\n // One tool has the stage at a time.\n ...NO_TOOL,\n tool: \"draw\",\n preview: null,\n draw: {\n mode: \"pen\",\n colour: DRAW_COLOUR.pen,\n width: drawWidth(context, \"pen\"),\n target,\n },\n },\n );\n },\n shortcuts: [\"D\"],\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport { NO_TOOL } from \"../editor-state.js\";\nimport type { ImageTool, ImageToolContext, ImageToolState } from \"../tool-types.js\";\n\n/**\n * Opens the export dialog, which shows a summary before anything is written\n * (docs/adr/0007). No shortcut: export is irreversible, so it's a click.\n *\n * - **While redacting or arranging layers,** it ends the tool first. Nothing\n * there is unconfirmed: a gesture still running, such as text being typed,\n * becomes its step as the tool's panel closes, so what's exported is what's\n * shown.\n * - **While cropping,** it waits, and says why. A crop isn't an edit until\n * it's applied, and exporting would have to guess between applying and\n * cancelling it.\n */\nexport const exportTool: ImageTool = {\n .../* @__PURE__ */ defineTool<ImageToolState, ImageToolContext, undefined>({\n id: \"image.export\",\n label: \"tools.export\",\n icon: \"export\",\n group: \"export\",\n isEnabled: ({ snapshot, editor }) => snapshot.plan !== null && editor.tool !== \"crop\",\n run: ({ editor }) =>\n editor.set((state) =>\n state.tool === \"crop\"\n ? state\n : {\n ...state,\n ...NO_TOOL,\n dialog: \"export\",\n // The frame shown is the one exported: playing stops on it (docs/adr/0011).\n playback: { ...state.playback, playing: false },\n },\n ),\n }),\n unavailable: ({ snapshot, editor }) =>\n snapshot.plan !== null && editor.tool === \"crop\" ? \"tools.exportWhileCropping\" : undefined,\n};\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport { NO_TOOL } from \"../editor-state.js\";\nimport type { ImageTool, ImageToolState } from \"../tool-types.js\";\n\n/** Whether the open document is an animation. */\nconst animated = ({ snapshot }: ImageToolState): boolean => snapshot.plan?.animation != null;\n\n/**\n * Shows and hides an animation's frames (docs/adr/0011): while it's on,\n * the inspector lists them in the order they play, with each frame's delay,\n * and edits them: moves, copies, deletes and reverses them, and sets their\n * delays and how many times the animation repeats. It's on the toolbar only\n * for an animation. Starting it pauses playing, so the frame selected stays\n * the frame shown.\n */\nexport const framesTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.frames\",\n label: \"tools.frames\",\n icon: \"frames\",\n group: \"frames\",\n isAvailable: animated,\n isEnabled: animated,\n isActive: ({ editor }) => editor.tool === \"frames\",\n run: ({ editor }) => {\n editor.set((state) =>\n state.tool === \"frames\"\n ? { ...state, ...NO_TOOL, preview: null }\n : {\n ...state,\n // One tool has the stage at a time.\n ...NO_TOOL,\n tool: \"frames\",\n preview: null,\n playback: { ...state.playback, playing: false },\n },\n );\n },\n shortcuts: [\"F\"],\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport type { ImageTool } from \"../tool-types.js\";\n\n/** Undoes the last step (docs/adr/0007). */\nexport const undoTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.undo\",\n label: \"tools.undo\",\n icon: \"undo\",\n group: \"history\",\n isEnabled: ({ snapshot }) => snapshot.canUndo,\n run: ({ session }) => {\n session.undo();\n },\n shortcuts: \"undo\",\n});\n\n/** Redoes the last undone step. */\nexport const redoTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.redo\",\n label: \"tools.redo\",\n icon: \"redo\",\n group: \"history\",\n isEnabled: ({ snapshot }) => snapshot.canRedo,\n run: ({ session }) => {\n session.redo();\n },\n shortcuts: \"redo\",\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport { asImageError } from \"../../core/errors/error-helpers.js\";\nimport { isImageError } from \"../../core/errors/image-error.js\";\nimport type { ImageLayer, ImagePlan } from \"../../core/model/plan.js\";\nimport type { ImageSize } from \"../../core/model/source.js\";\nimport { NO_TOOL } from \"../editor-state.js\";\nimport { hasDocument, type ImageTool, type ImageToolContext } from \"../tool-types.js\";\nimport { insertOnTop, newArrowLayer, newShapeLayer, newTextLayer } from \"./new-layer.js\";\n\n/**\n * Adds a layer over every other, as one step, and shows the layers with it\n * selected (docs/adr/0013). What the session refuses, such as a layer over\n * the limit, goes to the editor's state, which the stage shows.\n */\nfunction add(\n { session, editor }: ImageToolContext,\n create: (plan: ImagePlan, source: ImageSize) => ImageLayer,\n edit = false,\n): void {\n const { plan, source } = session.getSnapshot();\n if (!plan || !source) return;\n const layer = create(plan, source);\n try {\n session.execute(insertOnTop(plan, layer));\n } catch (reason) {\n const error = isImageError(reason) ? reason : asImageError(reason);\n editor.set((state) => ({ ...state, error }));\n return;\n }\n editor.set((state) => ({\n ...state,\n // One tool has the stage at a time.\n ...NO_TOOL,\n tool: \"layers\",\n preview: null,\n error: null,\n layers: edit ? { selected: layer.key, focus: \"text\" } : { selected: layer.key },\n }));\n}\n\n/**\n * Adds a text layer in the middle of the image, with no text yet, and moves\n * focus to its text field.\n */\nexport const addTextTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.add-text\",\n label: \"tools.add-text\",\n icon: \"text\",\n group: \"add\",\n isEnabled: hasDocument,\n run: (context) => add(context, newTextLayer, true),\n shortcuts: [\"T\"],\n});\n\n/** Adds an outlined rectangle in the middle of the image. */\nexport const addRectangleTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.add-rectangle\",\n label: \"tools.add-rectangle\",\n icon: \"rectangle\",\n group: \"add\",\n isEnabled: hasDocument,\n run: (context) => add(context, (plan, source) => newShapeLayer(plan, source, \"rectangle\")),\n});\n\n/** Adds an outlined ellipse in the middle of the image. */\nexport const addEllipseTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.add-ellipse\",\n label: \"tools.add-ellipse\",\n icon: \"ellipse\",\n group: \"add\",\n isEnabled: hasDocument,\n run: (context) => add(context, (plan, source) => newShapeLayer(plan, source, \"ellipse\")),\n});\n\n/**\n * Adds an arrow across the middle of the image, pointing right: the\n * keyboard's way to point at something, since freehand drawing needs a\n * pointer (docs/adr/0014). Its ends are then moved from its frame or the\n * panel's fields.\n */\nexport const addArrowTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.add-arrow\",\n label: \"tools.add-arrow\",\n icon: \"arrow\",\n group: \"add\",\n isEnabled: hasDocument,\n run: (context) => add(context, newArrowLayer),\n});\n\n/**\n * Asks for an image and adds it as a layer in the middle of the image\n * (`session.insertImage`). Off while another is being added.\n */\nexport const addImageTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.add-image\",\n label: \"tools.add-image\",\n icon: \"add-image\",\n group: \"add\",\n isEnabled: (state) => hasDocument(state) && !state.snapshot.inserting,\n run: ({ chooseLayerImage }) => chooseLayerImage(),\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport { NO_TOOL } from \"../editor-state.js\";\nimport { hasDocument, type ImageTool } from \"../tool-types.js\";\n\n/**\n * Shows and hides the layers (docs/adr/0013): while it's on, the inspector\n * lists them, and the stage shows each as a frame that selects, moves and\n * resizes it. It starts with the top layer selected, when there is one, and\n * asks the panel to take focus there.\n */\nexport const layersTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.layers\",\n label: \"tools.layers\",\n icon: \"layers\",\n group: \"layers\",\n isEnabled: hasDocument,\n isActive: ({ editor }) => editor.tool === \"layers\",\n run: ({ editor, session }) => {\n const top = session.getSnapshot().plan?.layers.at(-1)?.key ?? null;\n editor.set((state) =>\n state.tool === \"layers\"\n ? { ...state, ...NO_TOOL, preview: null }\n : {\n ...state,\n // One tool has the stage at a time.\n ...NO_TOOL,\n tool: \"layers\",\n preview: null,\n layers: { selected: top, focus: \"list\" },\n },\n );\n },\n shortcuts: [\"L\"],\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport type { ImageTool } from \"../tool-types.js\";\n\n/** Asks for an image and opens it. No shortcut: `Mod+O` is the browser's own. */\nexport const openTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.open\",\n label: \"tools.open\",\n icon: \"open\",\n group: \"file\",\n run: ({ chooseFile }) => chooseFile(),\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport type { ImageOrientation, ImageRotation } from \"../../core/model/plan.js\";\nimport { hasDocument, type ImageTool, type ImageToolContext } from \"../tool-types.js\";\n\n/**\n * The orientation after a quarter turn of what's on screen. The plan's flips\n * come after its rotation, so with exactly one flip, turning the result\n * left is turning the rotation right.\n */\nexport function turned(\n orientation: ImageOrientation,\n direction: \"left\" | \"right\",\n): ImageOrientation {\n const mirrored = orientation.flipX !== orientation.flipY;\n const clockwise = (direction === \"right\") !== mirrored;\n const rotate = ((orientation.rotate + (clockwise ? 90 : 270)) % 360) as ImageRotation;\n return { ...orientation, rotate };\n}\n\nfunction turn({ session }: ImageToolContext, direction: \"left\" | \"right\"): void {\n const plan = session.getSnapshot().plan;\n if (!plan) return;\n session.execute({\n type: \"image.setOrientation\",\n orientation: turned(plan.base.orientation, direction),\n });\n}\n\n/** Turns the image a quarter turn anticlockwise. */\nexport const rotateLeftTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.rotate-left\",\n label: \"tools.rotate-left\",\n icon: \"rotate-left\",\n group: \"orientation\",\n isEnabled: hasDocument,\n run: (context) => turn(context, \"left\"),\n shortcuts: [\"[\"],\n});\n\n/** Turns the image a quarter turn clockwise. */\nexport const rotateRightTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.rotate-right\",\n label: \"tools.rotate-right\",\n icon: \"rotate-right\",\n group: \"orientation\",\n isEnabled: hasDocument,\n run: (context) => turn(context, \"right\"),\n shortcuts: [\"]\"],\n});\n","import type { ImageAnimation, ImagePlan } from \"../../core/model/plan.js\";\nimport type { ImageEditorState } from \"../editor-state.js\";\n\n/**\n * How long a frame is shown while playing, in milliseconds (docs/adr/0011):\n * its delay, except that a delay under 2 hundredths of a second is shown as\n * 10, as browsers show it. The plan and the export keep the delay as it is.\n */\nexport function shownDelay(delay: number): number {\n return (delay < 2 ? 10 : delay) * 10;\n}\n\n/**\n * What comes after a frame while playing: the next frame, the first again\n * while the loop count allows, or `null` to stop on the last.\n *\n * @param played - How many times the animation has reached its end so far.\n */\nexport function nextFrame(\n animation: ImageAnimation,\n frame: number,\n played: number,\n): { readonly frame: number; readonly played: number } | null {\n if (frame + 1 < animation.frames.length) return { frame: frame + 1, played };\n // `null` plays once; 0 for ever; n repeats n times after the first play.\n if (animation.loop === null) return null;\n if (animation.loop !== 0 && played + 1 > animation.loop) return null;\n return { frame: 0, played: played + 1 };\n}\n\n/**\n * The editor's state with playing turned on or off (docs/adr/0011). Turned\n * on at the last frame, it starts again from the first. A plan without an\n * animation, or with one frame, has nothing to play.\n */\nexport function withPlaying(\n state: ImageEditorState,\n plan: ImagePlan | null,\n playing: boolean,\n): ImageEditorState {\n const count = plan?.animation?.frames.length ?? 0;\n if (count < 2)\n return state.playback.playing\n ? { ...state, playback: { ...state.playback, playing: false } }\n : state;\n const at = Math.min(Math.max(0, state.playback.frame), count - 1);\n return { ...state, playback: { frame: playing && at === count - 1 ? 0 : at, playing } };\n}\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport type { ImageTool } from \"../tool-types.js\";\nimport { withPlaying } from \"./playback.js\";\n\n/**\n * Plays and pauses an animation (docs/adr/0011), with the family's\n * play-pause shortcut, `Space` (sdk-core ADR 0030): from anywhere in the\n * editor, never on a field or a control, which keep Space as their own. It\n * isn't on the toolbar: the animation's bar has Play.\n */\nexport const playTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.play\",\n label: \"tools.play\",\n icon: \"play\",\n group: \"playback\",\n isEnabled: ({ snapshot }) => (snapshot.plan?.animation?.frames.length ?? 0) > 1,\n run: ({ session, editor }) => {\n editor.set((state) => withPlaying(state, session.getSnapshot().plan, !state.playback.playing));\n },\n shortcuts: \"play-pause\",\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport { NO_TOOL } from \"../editor-state.js\";\nimport { hasDocument, type ImageTool } from \"../tool-types.js\";\n\n/** The fill a new solid redaction takes until another is chosen (docs/adr/0010). */\nexport const DEFAULT_REDACTION_COLOUR = \"#000000\";\n\n/**\n * Starts and ends redacting (docs/adr/0010): while it's on, the stage shows\n * each redaction as a frame, and the inspector shows the redact panel. It\n * starts with solid, the mode that destroys what it covers.\n */\nexport const redactTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.redact\",\n label: \"tools.redact\",\n icon: \"redact\",\n group: \"redact\",\n isEnabled: hasDocument,\n isActive: ({ editor }) => editor.tool === \"redact\",\n run: ({ editor }) => {\n editor.set((state) =>\n state.tool === \"redact\"\n ? { ...state, ...NO_TOOL, preview: null }\n : {\n ...state,\n ...NO_TOOL,\n tool: \"redact\",\n preview: null,\n redact: { selected: null, mode: \"solid\", colour: DEFAULT_REDACTION_COLOUR },\n },\n );\n },\n shortcuts: [\"R\"],\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport { hasDocument, type ImageTool } from \"../tool-types.js\";\n\nconst STEP = 1.25;\nconst clamp = (zoom: number) => Math.min(16, Math.max(0.1, zoom));\n\n/** Zooms the stage in, by the family's keys. */\nexport const zoomInTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.zoom-in\",\n label: \"tools.zoom-in\",\n icon: \"zoom-in\",\n group: \"zoom\",\n isEnabled: hasDocument,\n run: ({ view }) => view.set((v) => ({ ...v, zoom: clamp(v.zoom * STEP) })),\n shortcuts: \"zoom-in\",\n});\n\n/** Zooms the stage out. */\nexport const zoomOutTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.zoom-out\",\n label: \"tools.zoom-out\",\n icon: \"zoom-out\",\n group: \"zoom\",\n isEnabled: hasDocument,\n run: ({ view }) => view.set((v) => ({ ...v, zoom: clamp(v.zoom / STEP) })),\n shortcuts: \"zoom-out\",\n});\n\n/** Fits the image to the stage, with no pan, as the family's `zoom-reset` keys do. */\nexport const zoomFitTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.zoom-fit\",\n label: \"tools.zoom-fit\",\n icon: \"fit\",\n group: \"zoom\",\n isEnabled: hasDocument,\n run: ({ view }) => view.set({ zoom: 1, pan: { x: 0, y: 0 } }),\n shortcuts: \"zoom-reset\",\n});\n","import { cropTool, flipHorizontalTool, flipVerticalTool } from \"./crop/crop-tools.js\";\nimport { drawTool } from \"./draw/draw-tool.js\";\nimport { exportTool } from \"./export/export-tool.js\";\nimport { framesTool } from \"./frames/frames-tool.js\";\nimport { redoTool, undoTool } from \"./history/history-tools.js\";\nimport {\n addArrowTool,\n addEllipseTool,\n addImageTool,\n addRectangleTool,\n addTextTool,\n} from \"./layers/add-layer-tools.js\";\nimport { layersTool } from \"./layers/layers-tool.js\";\nimport { openTool } from \"./open/open-tool.js\";\nimport { rotateLeftTool, rotateRightTool } from \"./orientation/orientation-tools.js\";\nimport { playTool } from \"./playback/play-tool.js\";\nimport { redactTool } from \"./redact/redact-tool.js\";\nimport type { ImageTool } from \"./tool-types.js\";\nimport { zoomFitTool, zoomInTool, zoomOutTool } from \"./zoom/zoom-tools.js\";\n\n/**\n * Every tool the editor knows, in their default order (docs/adr/0007).\n *\n * @public\n */\nexport const imageTools: readonly ImageTool[] = [\n openTool,\n undoTool,\n redoTool,\n rotateLeftTool,\n rotateRightTool,\n flipHorizontalTool,\n flipVerticalTool,\n cropTool,\n redactTool,\n addTextTool,\n addRectangleTool,\n addEllipseTool,\n addArrowTool,\n addImageTool,\n drawTool,\n layersTool,\n framesTool,\n zoomInTool,\n zoomOutTool,\n zoomFitTool,\n exportTool,\n playTool,\n];\n\n/** The toolbar's default groups (docs/adr/0007). */\nexport const DEFAULT_TOOLBAR: readonly (readonly string[])[] = [\n [\"image.open\"],\n [\"image.undo\", \"image.redo\"],\n [\"image.rotate-left\", \"image.rotate-right\", \"image.flip-horizontal\", \"image.flip-vertical\"],\n [\"image.crop\"],\n [\"image.redact\"],\n [\n \"image.add-text\",\n \"image.add-rectangle\",\n \"image.add-ellipse\",\n \"image.add-arrow\",\n \"image.add-image\",\n ],\n [\"image.draw\"],\n [\"image.layers\"],\n [\"image.frames\"],\n [\"image.zoom-in\", \"image.zoom-out\", \"image.zoom-fit\"],\n [\"image.export\"],\n];\n","import type { Messages, Store } from \"@hussmartinez/sdk-core\";\nimport { createContext } from \"react\";\nimport { asImageError } from \"../core/errors/error-helpers.js\";\nimport { isImageError } from \"../core/errors/image-error.js\";\nimport type { ImageEngine } from \"../core/ports/image-engine.js\";\nimport type { ImageSession, ImageSessionEvent } from \"../core/session/session.js\";\nimport { type ImageEditorState, NO_TOOL } from \"../features/editor-state.js\";\nimport type { ImageEditorMessageCatalogue } from \"./editor-messages.js\";\nimport type { ImageViewState } from \"./view-store.js\";\n\n/** What the provider shares with every image component below it. */\nexport interface ImageContextValue {\n readonly session: ImageSession;\n /** The engine the session decodes with, which the stage's renderer shares. */\n readonly engine: ImageEngine;\n readonly messages: Messages<ImageEditorMessageCatalogue>;\n readonly view: Store<ImageViewState>;\n readonly editor: Store<ImageEditorState>;\n readonly opener: ImageOpener;\n readonly inserter: ImageInserter;\n /**\n * Sends the editor's own usage events, such as `download`, to the\n * provider's `onEvent`, where the session's go too (docs/adr/0007).\n */\n readonly emit: (event: ImageSessionEvent) => void;\n}\n\n/**\n * Adds images as layers for the editor's controls (docs/adr/0013): one at a\n * time, placed by the session in the middle of the image as it's shown, then\n * selected with the layers showing. A failure goes to the editor's state, which the stage\n * shows; a cancellation shows nothing.\n */\nexport interface ImageInserter {\n insert(file: Blob): Promise<void>;\n cancel(): void;\n}\n\n/** Creates an {@link ImageInserter} for a session and an editor's state. */\nexport function createInserter(\n session: ImageSession,\n editor: Store<ImageEditorState>,\n): ImageInserter {\n let controller: AbortController | undefined;\n return {\n async insert(file) {\n controller?.abort();\n const current = new AbortController();\n controller = current;\n try {\n // The session places it: in the middle, fitted, and neither turned\n // nor mirrored as it's seen.\n const image = await session.insertImage(file, { signal: current.signal });\n const layers = session.getSnapshot().plan?.layers ?? [];\n const added = [...layers]\n .reverse()\n .find((layer) => layer.kind === \"image\" && layer.source === image.id);\n const selected = added?.key ?? null;\n editor.set((state) => ({\n ...state,\n ...NO_TOOL,\n tool: \"layers\",\n preview: null,\n error: null,\n layers: { selected },\n }));\n } catch (reason) {\n const error = isImageError(reason) ? reason : asImageError(reason);\n // Cancelled, or another image was opened meanwhile: nothing to say.\n if (error.code !== \"ABORTED\") editor.set((state) => ({ ...state, error }));\n } finally {\n if (controller === current) controller = undefined;\n }\n },\n cancel() {\n controller?.abort();\n controller = undefined;\n },\n };\n}\n\n/**\n * Opens images for the editor's controls, cancelling one still opening when\n * another starts, or when the user cancels. A failure is in the session's\n * snapshot, which the stage shows.\n */\nexport interface ImageOpener {\n open(file: Blob): Promise<void>;\n cancel(): void;\n}\n\n/** Creates an {@link ImageOpener} for a session. */\nexport function createOpener(session: ImageSession): ImageOpener {\n let controller: AbortController | undefined;\n return {\n async open(file) {\n controller?.abort();\n const current = new AbortController();\n controller = current;\n try {\n await session.open(file, { signal: current.signal });\n } catch {\n // In the snapshot: the stage shows it.\n } finally {\n if (controller === current) controller = undefined;\n }\n },\n cancel() {\n controller?.abort();\n controller = undefined;\n },\n };\n}\n\nexport const ImageContext = /* @__PURE__ */ createContext<ImageContextValue | undefined>(undefined);\n","import type { Messages, Store } from \"@hussmartinez/sdk-core\";\nimport { useContext, useSyncExternalStore } from \"react\";\nimport type { ImageSession, ImageSessionSnapshot } from \"../core/session/session.js\";\nimport type { ImageEditorState } from \"../features/editor-state.js\";\nimport { ImageContext, type ImageContextValue } from \"./context.js\";\nimport type { ImageEditorMessageCatalogue } from \"./editor-messages.js\";\nimport type { ImageViewState } from \"./view-store.js\";\n\nfunction useImageContext(hook: string): ImageContextValue {\n const value = useContext(ImageContext);\n if (!value) throw new Error(`${hook}() must be used inside an ImageEditorProvider.`);\n return value;\n}\n\n/**\n * The session of the nearest `ImageEditorProvider`, to open images, run\n * commands, undo and export.\n *\n * @public\n */\nexport function useImageSession(): ImageSession {\n return useImageContext(\"useImageSession\").session;\n}\n\n/**\n * The session's snapshot, re-rendering whenever it changes, through\n * `useSyncExternalStore`, so it's safe with concurrent and server rendering.\n *\n * @public\n */\nexport function useImageDocument(): ImageSessionSnapshot {\n const { session } = useImageContext(\"useImageDocument\");\n return useSyncExternalStore(session.subscribe, session.getSnapshot, session.getSnapshot);\n}\n\n/**\n * The stage's zoom and pan, and the store to change them (docs/adr/0007).\n *\n * @public\n */\nexport function useImageView(): readonly [ImageViewState, Store<ImageViewState>] {\n const { view } = useImageContext(\"useImageView\");\n const state = useSyncExternalStore(view.subscribe, view.getSnapshot, view.getSnapshot);\n return [state, view] as const;\n}\n\n/**\n * The editor's own state: the active tool, a crop in progress, and a\n * gesture's transient plan (docs/adr/0007).\n *\n * @public\n */\nexport function useImageEditorState(): readonly [ImageEditorState, Store<ImageEditorState>] {\n const { editor } = useImageContext(\"useImageEditorState\");\n const state = useSyncExternalStore(editor.subscribe, editor.getSnapshot, editor.getSnapshot);\n return [state, editor] as const;\n}\n\n/**\n * The SDK's text for the provider's locale and overrides (ADR 0019).\n *\n * @public\n */\nexport function useImageMessages(): Messages<ImageEditorMessageCatalogue> {\n return useImageContext(\"useImageMessages\").messages;\n}\n\n/** The provider's whole context, for the SDK's own components. */\nexport function useImageInternals(): ImageContextValue {\n return useImageContext(\"useImageInternals\");\n}\n","import { useAnnounce } from \"@hussmartinez/ui/react\";\nimport { useMemo } from \"react\";\nimport { aspectRatio, fitAspect, type ImageAspect, wholeCrop } from \"../../core/model/crop.js\";\nimport type { ImageCrop } from \"../../core/model/plan.js\";\nimport { useImageInternals } from \"../hooks.js\";\n\n/** What the crop frame and panel do to a crop in progress (docs/adr/0007). */\nexport interface CropActions {\n /** Replaces the pending crop: a frame drag, a key or a field. */\n update(crop: ImageCrop): void;\n /** Chooses an aspect, and fits the pending crop to it. */\n setAspect(aspect: ImageAspect): void;\n /** Applies the pending crop as one undoable step, and ends cropping. */\n apply(): void;\n /** Ends cropping, changing nothing. */\n cancel(): void;\n}\n\nexport function useCropActions(): CropActions {\n const { session, editor, messages } = useImageInternals();\n const announce = useAnnounce();\n return useMemo(() => {\n const pendingCrop = () => editor.getSnapshot().crop;\n return {\n update(crop) {\n const current = pendingCrop();\n if (!current) return;\n editor.set((state) => ({ ...state, crop: { ...current, pending: crop } }));\n },\n setAspect(aspect) {\n const current = pendingCrop();\n const source = session.getSnapshot().source;\n if (!current || !source) return;\n const pending = fitAspect(current.pending, aspectRatio(aspect, source));\n editor.set((state) => ({ ...state, crop: { aspect, pending } }));\n },\n apply() {\n const current = pendingCrop();\n const { plan, source } = session.getSnapshot();\n editor.set((state) => ({ ...state, tool: null, crop: null }));\n if (!current || !plan || !source) return;\n const whole = wholeCrop(source);\n const isWhole =\n current.pending.x === 0 &&\n current.pending.y === 0 &&\n current.pending.width === whole.width &&\n current.pending.height === whole.height;\n const crop = isWhole ? null : current.pending;\n // One crop session is one step, and only if it changed anything.\n if (JSON.stringify(crop) !== JSON.stringify(plan.base.crop)) {\n session.execute({ type: \"image.setCrop\", crop });\n }\n announce(\n messages.t(\"crop.applied\", {\n width: current.pending.width,\n height: current.pending.height,\n }),\n );\n },\n cancel() {\n editor.set((state) => ({ ...state, tool: null, crop: null }));\n },\n };\n }, [announce, editor, messages, session]);\n}\n","import { Button, Field, NumberField, SegmentedControl } from \"@hussmartinez/ui/react\";\nimport type { ReactNode } from \"react\";\nimport { ASPECT_PRESETS, type ImageAspect, moveCrop, wholeCrop } from \"../../core/model/crop.js\";\nimport { useImageDocument, useImageEditorState, useImageMessages } from \"../hooks.js\";\nimport { useCropActions } from \"./use-crop.js\";\n\nconst aspectKey = (aspect: ImageAspect) =>\n typeof aspect === \"string\" ? aspect : `${aspect[0]}:${aspect[1]}`;\n\n/**\n * Props of {@link ImageCropPanel}.\n *\n * @public\n */\nexport interface ImageCropPanelProps {\n readonly className?: string;\n}\n\n/**\n * The crop panel (docs/adr/0007): the crop's position and size in source\n * pixels as number fields, the aspect presets, and Apply, Cancel and Whole\n * image. It's the alternative to dragging the frame (WCAG 2.5.7), shown while\n * cropping.\n *\n * @public\n */\nexport function ImageCropPanel(props: ImageCropPanelProps): ReactNode {\n const [state] = useImageEditorState();\n const { source } = useImageDocument();\n const messages = useImageMessages();\n const actions = useCropActions();\n const crop = state.crop;\n if (state.tool !== \"crop\" || !crop || !source) return null;\n const { pending } = crop;\n const field = (name: \"x\" | \"y\" | \"width\" | \"height\") => {\n const max =\n name === \"x\"\n ? source.width - pending.width\n : name === \"y\"\n ? source.height - pending.height\n : name === \"width\"\n ? source.width - pending.x\n : source.height - pending.y;\n return (\n <Field key={name} label={messages.t(`crop.${name}`)}>\n <NumberField\n value={pending[name]}\n min={name === \"width\" || name === \"height\" ? 1 : 0}\n max={max}\n step={1}\n largeStep={10}\n onValueChange={(value) => {\n const next = { ...pending, [name]: Math.round(value) };\n actions.update(name === \"x\" || name === \"y\" ? moveCrop(next, 0, 0, source) : next);\n }}\n />\n </Field>\n );\n };\n const options = ASPECT_PRESETS.map((aspect) => ({\n value: aspectKey(aspect),\n label:\n typeof aspect === \"string\"\n ? messages.t(`crop.aspects.${aspect}`)\n : messages.t(\"crop.aspects.ratio\", { width: aspect[0], height: aspect[1] }),\n }));\n return (\n <section\n className={[\"hm-image-crop-panel\", props.className].filter(Boolean).join(\" \")}\n aria-label={messages.t(\"crop.panel\")}\n >\n <div className=\"hm-image-crop-fields\">\n {([\"x\", \"y\", \"width\", \"height\"] as const).map(field)}\n </div>\n <SegmentedControl\n label={messages.t(\"crop.aspect\")}\n value={aspectKey(crop.aspect)}\n options={options}\n size=\"small\"\n onValueChange={(value) => {\n const aspect = ASPECT_PRESETS.find((a) => aspectKey(a) === value);\n if (aspect) actions.setAspect(aspect);\n }}\n />\n <div className=\"hm-image-crop-actions\">\n <Button variant=\"secondary\" onClick={() => actions.update(wholeCrop(source))}>\n {messages.t(\"crop.reset\")}\n </Button>\n <Button variant=\"secondary\" onClick={() => actions.cancel()}>\n {messages.t(\"crop.cancel\")}\n </Button>\n <Button variant=\"primary\" onClick={() => actions.apply()}>\n {messages.t(\"crop.apply\")}\n </Button>\n </div>\n </section>\n );\n}\n","import { applyCommands, type Store } from \"@hussmartinez/sdk-core\";\nimport { useEffect, useMemo } from \"react\";\nimport { createImageReducer, type ImageCommand } from \"../core/operations/commands.js\";\nimport type { ImageSession } from \"../core/session/session.js\";\nimport type { ImageEditorState } from \"../features/editor-state.js\";\nimport { useImageInternals } from \"./hooks.js\";\n\n/** How long after the last keystroke typing in a text layer becomes one step (docs/adr/0007). Arrow keys on a frame make a step per press, not after a delay. */\nexport const KEYBOARD_COMMIT_DELAY = 500;\n\n/**\n * One gesture of a continuous control, such as a slider (docs/adr/0007):\n * while it runs, the stage renders a transient plan, the session's plan with\n * the gesture's commands applied by the same reducer, and the session, its\n * history and the host's `onChange` don't see it. When it ends, its commands\n * execute as one undoable step.\n */\nexport interface Gesture {\n /** Shows these commands on the stage, replacing the gesture's earlier ones. */\n preview(commands: readonly ImageCommand[]): void;\n /** Ends the gesture now: its commands execute as one step, if it has any. */\n commit(): void;\n /** Ends the gesture after the typing delay, unless it continues before then: typing in a text layer. */\n commitSoon(): void;\n /** Ends the gesture with no step, and the stage shows the session's plan again. */\n cancel(): void;\n /** Whether a gesture is running. */\n readonly active: () => boolean;\n}\n\n/** A gesture over a session and an editor's state. */\nfunction createGesture(session: ImageSession, editor: Store<ImageEditorState>): Gesture {\n let pending: readonly ImageCommand[] | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n // The base's source and every image layer's, as the session's own reducer has them.\n const reducer = createImageReducer((id) =>\n session.getSnapshot().sources.find((source) => source.id === id),\n );\n const clearTimer = () => {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n };\n const end = () => {\n clearTimer();\n pending = undefined;\n editor.set((state) => (state.preview === null ? state : { ...state, preview: null }));\n };\n const value: Gesture = {\n preview(commands) {\n const plan = session.getSnapshot().plan;\n if (!plan) return;\n // Checked by the reducer, as executing them will be: a value it\n // refuses never reaches the stage.\n const preview = applyCommands(reducer, plan, commands).state;\n pending = commands;\n editor.set((state) => ({ ...state, preview }));\n },\n commit() {\n const commands = pending;\n end();\n if (commands && commands.length > 0) session.execute(commands);\n },\n commitSoon() {\n clearTimer();\n timer = setTimeout(() => value.commit(), KEYBOARD_COMMIT_DELAY);\n },\n cancel: end,\n active: () => pending !== undefined,\n };\n return value;\n}\n\nexport function useGesture(): Gesture {\n const { session, editor } = useImageInternals();\n const gesture = useMemo(() => createGesture(session, editor), [editor, session]);\n // A control that goes away ends its gesture, so nothing is left half-done.\n useEffect(() => () => gesture.commit(), [gesture]);\n return gesture;\n}\n\n/** One gesture per editor, for the parts of a tool that share it. */\nconst shared = new WeakMap<Store<ImageEditorState>, Gesture>();\n\n/**\n * A gesture that every caller in the same editor shares, so a tool's frame\n * on the stage and its panel in the inspector end each other's gestures\n * rather than leaving one running under the other's edit.\n */\nexport function useSharedGesture(): Gesture {\n const { session, editor } = useImageInternals();\n const gesture = useMemo(() => {\n const existing = shared.get(editor);\n if (existing) return existing;\n const created = createGesture(session, editor);\n shared.set(editor, created);\n return created;\n }, [editor, session]);\n useEffect(() => () => gesture.commit(), [gesture]);\n return gesture;\n}\n","import { useAnnounce } from \"@hussmartinez/ui/react\";\nimport { useMemo } from \"react\";\nimport { compositionSize, cropRect } from \"../../core/model/geometry.js\";\nimport { createImageKey } from \"../../core/model/keys.js\";\nimport type { ImagePlan, ImageRedaction, ImageRedactionMode } from \"../../core/model/plan.js\";\nimport {\n compositionRectToScene,\n fitRedactionRegion,\n type ImageRect,\n} from \"../../core/model/redaction-geometry.js\";\nimport type { ImageCommand } from \"../../core/operations/commands.js\";\nimport { NO_TOOL } from \"../../features/editor-state.js\";\nimport { DEFAULT_REDACTION_COLOUR } from \"../../features/redact/redact-tool.js\";\nimport { type Gesture, useSharedGesture } from \"../gesture.js\";\nimport { useImageInternals } from \"../hooks.js\";\n\n/** What the redact frames and panel do (docs/adr/0010). */\nexport interface RedactActions {\n /** Adds a region at the middle of the image as it's shown, and selects it. */\n add(): void;\n /** Selects a redaction, or none. */\n select(key: string | null): void;\n /** Removes a redaction, as one step. */\n remove(key: string): void;\n /**\n * Shows a region being dragged out on the stage, in composition pixels,\n * without changing the plan. `commit` then adds it as one step.\n */\n drawing(key: string, rect: ImageRect): void;\n /** Shows a redaction's region while it's moved or resized, in scene pixels. */\n moving(key: string, region: ImageRect): void;\n /** Ends the gesture as one step: a drag let go, or the last arrow key held let go. */\n commit(): void;\n /** Ends the gesture with no step. */\n cancel(): void;\n /** Sets a redaction's region at once, as one step: a number field. */\n setRegion(key: string, region: ImageRect): void;\n /** Sets the mode of the selected redaction, and of the next one added. */\n setMode(mode: ImageRedactionMode): void;\n /** Sets the colour of the selected solid redaction, and of the next one added. */\n setColour(colour: string): void;\n /** Ends redacting. */\n done(): void;\n /** The gesture these actions run. */\n readonly gesture: Gesture;\n}\n\n/** Every key the plan uses. */\nconst keysOf = (plan: ImagePlan) =>\n new Set([...plan.layers, ...plan.redactions].map((item: { key: string }) => item.key));\n\n/** A new key for the plan: the session's keys are generated here, before a command. */\nexport function newRedactionKey(plan: ImagePlan): string {\n return createImageKey(keysOf(plan));\n}\n\nexport function useRedactActions(): RedactActions {\n const { session, editor, messages } = useImageInternals();\n const announce = useAnnounce();\n const gesture = useSharedGesture();\n return useMemo(() => {\n const settings = () =>\n editor.getSnapshot().redact ?? {\n selected: null,\n mode: \"solid\" as const,\n colour: DEFAULT_REDACTION_COLOUR,\n };\n const set = (changes: Partial<ReturnType<typeof settings>>) =>\n editor.set((state) =>\n state.tool === \"redact\" ? { ...state, redact: { ...settings(), ...changes } } : state,\n );\n const redaction = (key: string, region: ImageRect): ImageRedaction => {\n const { mode, colour } = settings();\n const fitted = fitRedactionRegion(region);\n return mode === \"solid\" ? { key, mode, ...fitted, colour } : { key, mode, ...fitted };\n };\n const insert = (item: ImageRedaction, plan: ImagePlan): ImageCommand => ({\n type: \"image.insertRedactions\",\n at: plan.redactions.length,\n redactions: [item],\n });\n const count = () => session.getSnapshot().plan?.redactions.length ?? 0;\n const actions: RedactActions = {\n gesture,\n add() {\n const { plan, source } = session.getSnapshot();\n if (!plan || !source) return;\n gesture.commit();\n // A quarter of the image as it's shown, in its middle.\n const { width, height } = compositionSize(plan, source);\n const shown = {\n x: Math.round(width * 0.375),\n y: Math.round(height * 0.375),\n width: Math.max(1, Math.round(width / 4)),\n height: Math.max(1, Math.round(height / 4)),\n };\n const key = newRedactionKey(plan);\n const region = compositionRectToScene(\n shown,\n cropRect(plan.base.crop, source),\n plan.base.orientation,\n );\n session.execute(insert(redaction(key, region), plan));\n set({ selected: key });\n announce(messages.t(\"redact.added\", { count: count() }));\n },\n select(key) {\n if (settings().selected === key) return;\n gesture.commit();\n const item = session.getSnapshot().plan?.redactions.find((r) => r.key === key);\n // The panel shows the selected redaction's own mode and colour.\n set({\n selected: item ? key : null,\n ...(item ? { mode: item.mode } : {}),\n ...(item?.mode === \"solid\" ? { colour: item.colour } : {}),\n });\n },\n remove(key) {\n gesture.cancel();\n if (!session.getSnapshot().plan?.redactions.some((r) => r.key === key)) return;\n session.execute({ type: \"image.removeRedactions\", keys: [key] });\n if (settings().selected === key) set({ selected: null });\n announce(\n count() === 0\n ? messages.t(\"redact.removedLast\")\n : messages.t(\"redact.removed\", { count: count() }),\n );\n },\n drawing(key, rect) {\n const { plan, source } = session.getSnapshot();\n if (!plan || !source) return;\n const region = compositionRectToScene(\n rect,\n cropRect(plan.base.crop, source),\n plan.base.orientation,\n );\n // The selection waits for the release: selecting now would change\n // the panel, and with it the stage's size, under the drag.\n gesture.preview([insert(redaction(key, region), plan)]);\n },\n moving(key, region) {\n gesture.preview([\n {\n type: \"image.updateRedactions\",\n updates: [{ key, props: fitRedactionRegion(region) }],\n },\n ]);\n },\n commit() {\n const drew = gesture.active() && count();\n gesture.commit();\n if (drew !== false && count() > drew) {\n announce(messages.t(\"redact.added\", { count: count() }));\n }\n },\n cancel() {\n gesture.cancel();\n },\n setRegion(key, region) {\n gesture.commit();\n session.execute({\n type: \"image.updateRedactions\",\n updates: [{ key, props: fitRedactionRegion(region) }],\n });\n },\n setMode(mode) {\n gesture.commit();\n const { selected, colour } = settings();\n const item = session.getSnapshot().plan?.redactions.find((r) => r.key === selected);\n if (item && item.mode !== mode) {\n session.execute({\n type: \"image.updateRedactions\",\n updates: [{ key: item.key, props: mode === \"solid\" ? { mode, colour } : { mode } }],\n });\n }\n set({ mode });\n },\n setColour(colour) {\n gesture.commit();\n const item = session\n .getSnapshot()\n .plan?.redactions.find((r) => r.key === settings().selected);\n if (item?.mode === \"solid\" && item.colour !== colour) {\n session.execute({\n type: \"image.updateRedactions\",\n updates: [{ key: item.key, props: { colour } }],\n });\n }\n set({ colour });\n },\n done() {\n gesture.commit();\n editor.set((state) =>\n state.tool === \"redact\" ? { ...state, ...NO_TOOL, preview: null } : state,\n );\n },\n };\n return actions;\n }, [announce, editor, gesture, messages, session]);\n}\n","import type { Messages } from \"@hussmartinez/sdk-core\";\nimport { useAnnounce } from \"@hussmartinez/ui/react\";\nimport { useMemo } from \"react\";\nimport {\n type ImageLayer,\n MAX_LAYER_NAME_LENGTH,\n MAX_LAYER_TEXT_LENGTH,\n MAX_SCENE_COORDINATE,\n} from \"../../core/model/plan.js\";\nimport { FORBIDDEN_IN_TEXT } from \"../../core/operations/layers.js\";\nimport { NO_TOOL } from \"../../features/editor-state.js\";\nimport type { ImageEditorMessageCatalogue } from \"../editor-messages.js\";\nimport { type Gesture, useSharedGesture } from \"../gesture.js\";\nimport { useImageInternals } from \"../hooks.js\";\nimport { newRedactionKey } from \"../redact/use-redact.js\";\n\n/** How far a copy sits from its original, in scene pixels, so both can be seen. */\nconst DUPLICATE_OFFSET = 8;\n/** How much of a text layer's own text names it in the list. */\nconst LABEL_LENGTH = 40;\nconst EVERY_FORBIDDEN = new RegExp(FORBIDDEN_IN_TEXT.source, \"gu\");\n\n/**\n * What the layers list and the frames call a layer: its name; or, unnamed,\n * the start of a text layer's first line, or its kind. It's shown as text,\n * never as HTML (docs/adr/0009).\n */\nexport function layerLabel(\n layer: ImageLayer,\n messages: Messages<ImageEditorMessageCatalogue>,\n): string {\n if (layer.name !== \"\") return layer.name;\n if (layer.kind === \"text\") {\n const line = layer.text.split(\"\\n\").find((text) => text.trim() !== \"\");\n if (line) return [...line.trim()].slice(0, LABEL_LENGTH).join(\"\");\n }\n return messages.t(`layers.kinds.${layer.kind === \"shape\" ? layer.shape : layer.kind}`);\n}\n\n/** A name as the plan takes it: without the characters it refuses, within its length. */\nexport function fitLayerName(name: string): string {\n return [...name.replace(EVERY_FORBIDDEN, \"\").trim()].slice(0, MAX_LAYER_NAME_LENGTH).join(\"\");\n}\n\n/**\n * Text as the plan takes it (docs/adr/0009): every line break a line feed,\n * whatever it was where the text came from; a tab a space; without the\n * characters text can't hold; within its length.\n */\nexport function fitLayerText(text: string): string {\n const lines = text.replace(/\\r\\n?/g, \"\\n\").replace(/\\t/g, \" \");\n return [...lines.replace(EVERY_FORBIDDEN, \"\")].slice(0, MAX_LAYER_TEXT_LENGTH).join(\"\");\n}\n\n/** What the layers' frames and panel do (docs/adr/0013). */\nexport interface LayerActions {\n /** Selects a layer, or none. */\n select(key: string | null): void;\n /**\n * Removes a layer, as one step, and selects the one now in its place in\n * the list, which shows the top layer first: the one that was under it,\n * or the new bottom one. Returns the key selected, if any.\n */\n remove(key: string): string | null;\n /** Adds a copy over the layer, as one step, and selects it. Throws what the session refuses. */\n duplicate(key: string): void;\n /** Moves a layer one place up the stack, or down, as one step. */\n shift(key: string, by: 1 | -1): void;\n /**\n * Shows some of a layer's fields while it's moved, resized or re-aimed,\n * without changing the plan: a box's place and size, a drawing's origin,\n * an arrow's ends.\n */\n moving(key: string, props: Readonly<Record<string, unknown>>): void;\n /** Ends the gesture as one step: a drag let go, or the last arrow key held let go. */\n commit(): void;\n /** Ends the gesture with no step. */\n cancel(): void;\n /** Sets some of a layer's fields at once, as one step: a field of the panel. */\n set(key: string, props: Readonly<Record<string, unknown>>): void;\n /**\n * Shows some of a layer's fields while they're typed, and sets them as\n * one step once the typing stops: a text field.\n */\n typing(key: string, props: Readonly<Record<string, unknown>>): void;\n /** Stops showing the layers. */\n done(): void;\n /** The gesture these actions run. */\n readonly gesture: Gesture;\n}\n\nexport function useLayerActions(): LayerActions {\n const { session, editor, messages } = useImageInternals();\n const announce = useAnnounce();\n const gesture = useSharedGesture();\n return useMemo(() => {\n const layers = () => session.getSnapshot().plan?.layers ?? [];\n const select = (key: string | null) =>\n editor.set((state) =>\n state.tool === \"layers\" && state.layers?.selected !== key\n ? { ...state, layers: { selected: key } }\n : state,\n );\n const actions: LayerActions = {\n gesture,\n select(key) {\n if (editor.getSnapshot().layers?.selected === key) return;\n gesture.commit();\n select(key !== null && layers().some((layer) => layer.key === key) ? key : null);\n },\n remove(key) {\n gesture.cancel();\n const index = layers().findIndex((layer) => layer.key === key);\n const layer = layers()[index];\n if (!layer) return null;\n session.execute({ type: \"image.removeLayers\", keys: [key] });\n // As the list shows them, the top one first: the layer now in the\n // removed one's place there, which was under it, or the new last one.\n const next = (layers()[index - 1] ?? layers()[0])?.key ?? null;\n select(next);\n announce(messages.t(\"layers.removed\", { name: layerLabel(layer, messages) }));\n return next;\n },\n duplicate(key) {\n gesture.commit();\n const plan = session.getSnapshot().plan;\n const index = layers().findIndex((layer) => layer.key === key);\n const layer = layers()[index];\n if (!plan || !layer) return;\n const moved = (value: number) => Math.min(value + DUPLICATE_OFFSET, MAX_SCENE_COORDINATE);\n const copyKey = newRedactionKey(plan);\n // An arrow is placed by its two ends; every other kind by its x and y.\n const copy: ImageLayer =\n layer.kind === \"arrow\"\n ? {\n ...layer,\n key: copyKey,\n from: { x: moved(layer.from.x), y: moved(layer.from.y) },\n to: { x: moved(layer.to.x), y: moved(layer.to.y) },\n }\n : { ...layer, key: copyKey, x: moved(layer.x), y: moved(layer.y) };\n session.execute({ type: \"image.insertLayers\", at: index + 1, layers: [copy] });\n select(copy.key);\n announce(messages.t(\"layers.duplicated\", { name: layerLabel(layer, messages) }));\n },\n shift(key, by) {\n gesture.commit();\n const index = layers().findIndex((layer) => layer.key === key);\n const layer = layers()[index];\n const to = index + by;\n if (!layer || to < 0 || to >= layers().length) return;\n session.execute({ type: \"image.moveLayers\", keys: [key], to });\n // The list shows the top layer first: its place there, from 1.\n announce(\n messages.t(by > 0 ? \"layers.movedUp\" : \"layers.movedDown\", {\n name: layerLabel(layer, messages),\n index: layers().length - to,\n count: layers().length,\n }),\n );\n },\n moving(key, props) {\n gesture.preview([{ type: \"image.updateLayers\", updates: [{ key, props }] }]);\n },\n commit() {\n gesture.commit();\n },\n cancel() {\n gesture.cancel();\n },\n set(key, props) {\n gesture.commit();\n session.execute({ type: \"image.updateLayers\", updates: [{ key, props }] });\n },\n typing(key, props) {\n gesture.preview([{ type: \"image.updateLayers\", updates: [{ key, props }] }]);\n gesture.commitSoon();\n },\n done() {\n gesture.commit();\n editor.set((state) =>\n state.tool === \"layers\" ? { ...state, ...NO_TOOL, preview: null } : state,\n );\n },\n };\n return actions;\n }, [announce, editor, gesture, messages, session]);\n}\n","import {\n ColorField,\n Field,\n NumberField,\n SegmentedControl,\n TextArea,\n ToggleButton,\n} from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useEffect, useState } from \"react\";\nimport {\n type ImageArrowLayer,\n type ImageShapeLayer,\n type ImageTextLayer,\n LAYER_ALIGNMENTS,\n LAYER_FONTS,\n MAX_SCENE_COORDINATE,\n MAX_STROKE_WIDTH,\n} from \"../../core/model/plan.js\";\nimport {\n DEFAULT_SHAPE_COLOUR,\n DEFAULT_TEXT_COLOUR,\n defaultStrokeWidth,\n} from \"../../features/layers/new-layer.js\";\nimport { useImageMessages, useImageSession } from \"../hooks.js\";\nimport { fitLayerText, type LayerActions } from \"./use-layers.js\";\n\n/** The colours offered as swatches: the plan holds any, and the field takes any. */\nconst SWATCHES = [\n { value: \"#000000\", name: \"black\" },\n { value: \"#ffffff\", name: \"white\" },\n { value: \"#e02020\", name: \"red\" },\n { value: \"#f0c020\", name: \"yellow\" },\n { value: \"#20a040\", name: \"green\" },\n { value: \"#2060e0\", name: \"blue\" },\n] as const;\n\nexport function useSwatches() {\n const messages = useImageMessages();\n return SWATCHES.map(({ value, name }) => ({\n value,\n label: messages.t(`layers.colours.${name}`),\n }));\n}\n\ninterface FieldsProps<Layer> {\n /** The selected layer when it's of this kind; otherwise the fields keep their place, disabled. */\n readonly layer: Layer | null;\n readonly actions: LayerActions;\n /** Runs an action, keeping what the session refused for the panel to say. */\n readonly run: (action: () => void) => void;\n}\n\n/**\n * A text layer's fields (docs/adr/0013): its text, shown on the image as\n * it's typed and set as one step when the typing stops; its font, weight\n * and alignment; and its colour.\n */\nexport function TextLayerFields(props: FieldsProps<ImageTextLayer>): ReactNode {\n const { layer, actions, run } = props;\n const messages = useImageMessages();\n const swatches = useSwatches();\n const key = layer?.key ?? null;\n const text = layer?.text ?? \"\";\n const [value, setValue] = useState(text);\n // biome-ignore lint/correctness/useExhaustiveDependencies: another layer with the same text also resets what was typed\n useEffect(() => setValue(text), [key, text]);\n const off = layer === null;\n return (\n <div className=\"hm-image-layer-kind\" data-hm-inactive={off ? \"\" : undefined}>\n <Field label={messages.t(\"layers.text\")} className=\"hm-image-layers-text\">\n <TextArea\n rows={3}\n value={value}\n disabled={off}\n onValueChange={(typed) => {\n // What the plan takes: line feeds, and none of what text can't hold.\n const fitted = fitLayerText(typed);\n setValue(fitted);\n if (layer) run(() => actions.typing(layer.key, { text: fitted }));\n }}\n onBlur={() => actions.commit()}\n />\n </Field>\n <SegmentedControl\n label={messages.t(\"layers.font\")}\n size=\"small\"\n value={layer?.font ?? \"sans-serif\"}\n options={LAYER_FONTS.map((font) => ({\n value: font,\n label: messages.t(`layers.fonts.${font}`),\n disabled: off,\n }))}\n onValueChange={(font) => layer && run(() => actions.set(layer.key, { font }))}\n />\n <div className=\"hm-image-layer-row\">\n <SegmentedControl\n label={messages.t(\"layers.align\")}\n size=\"small\"\n value={layer?.align ?? \"center\"}\n options={LAYER_ALIGNMENTS.map((align) => ({\n value: align,\n label: messages.t(`layers.alignments.${align}`),\n disabled: off,\n }))}\n onValueChange={(align) => layer && run(() => actions.set(layer.key, { align }))}\n />\n <ToggleButton\n size=\"small\"\n pressed={layer?.bold ?? false}\n disabled={off}\n onPressedChange={(bold) => layer && run(() => actions.set(layer.key, { bold }))}\n >\n {messages.t(\"layers.bold\")}\n </ToggleButton>\n </div>\n <Field label={messages.t(\"layers.colour\")}>\n <ColorField\n value={layer?.colour ?? DEFAULT_TEXT_COLOUR}\n swatches={swatches}\n disabled={off}\n onValueChange={(colour) => {\n if (layer && colour !== layer.colour) run(() => actions.set(layer.key, { colour }));\n }}\n />\n </Field>\n </div>\n );\n}\n\n/**\n * A shape's fields (docs/adr/0013): its fill and its outline, each on or\n * off with a colour, and the outline's width. A shape always has one of\n * them (docs/adr/0009): turning off the only one turns on the other, in\n * its colour, so nothing is refused and the shape never disappears.\n */\nexport function ShapeLayerFields(props: FieldsProps<ImageShapeLayer>): ReactNode {\n const { layer, actions, run } = props;\n const messages = useImageMessages();\n const session = useImageSession();\n const swatches = useSwatches();\n const off = layer === null;\n const fill = layer?.fill ?? null;\n const stroke = layer?.stroke ?? null;\n /** The outline a shape is given: as wide as a new shape's, and inside the box. */\n const outline = (colour: string) => {\n const { plan, source } = session.getSnapshot();\n const widest = layer ? Math.max(1, Math.floor(Math.min(layer.width, layer.height) / 2)) : 1;\n const width = plan && source ? Math.min(defaultStrokeWidth(plan, source), widest) : 1;\n return { colour, width };\n };\n const set = (props: Readonly<Record<string, unknown>>) => {\n if (layer) run(() => actions.set(layer.key, props));\n };\n return (\n <div className=\"hm-image-layer-kind\" data-hm-inactive={off ? \"\" : undefined}>\n <div className=\"hm-image-layer-row\">\n <ToggleButton\n size=\"small\"\n pressed={fill !== null}\n disabled={off}\n onPressedChange={(on) => {\n if (on) set({ fill: stroke?.colour ?? DEFAULT_SHAPE_COLOUR });\n else if (stroke) set({ fill: null });\n else set({ fill: null, stroke: outline(fill ?? DEFAULT_SHAPE_COLOUR) });\n }}\n >\n {messages.t(\"layers.fill\")}\n </ToggleButton>\n <ToggleButton\n size=\"small\"\n pressed={stroke !== null}\n disabled={off}\n onPressedChange={(on) => {\n if (on) set({ stroke: outline(fill ?? DEFAULT_SHAPE_COLOUR) });\n else if (fill !== null) set({ stroke: null });\n else set({ stroke: null, fill: stroke?.colour ?? DEFAULT_SHAPE_COLOUR });\n }}\n >\n {messages.t(\"layers.outline\")}\n </ToggleButton>\n </div>\n <Field label={messages.t(\"layers.fillColour\")}>\n <ColorField\n value={fill ?? DEFAULT_SHAPE_COLOUR}\n swatches={swatches}\n disabled={off || fill === null}\n onValueChange={(colour) => {\n if (fill !== null && colour !== fill) set({ fill: colour });\n }}\n />\n </Field>\n <Field label={messages.t(\"layers.outlineColour\")}>\n <ColorField\n value={stroke?.colour ?? DEFAULT_SHAPE_COLOUR}\n swatches={swatches}\n disabled={off || stroke === null}\n onValueChange={(colour) => {\n if (stroke && colour !== stroke.colour) set({ stroke: { ...stroke, colour } });\n }}\n />\n </Field>\n <Field label={messages.t(\"layers.outlineWidth\")}>\n <NumberField\n value={stroke?.width ?? 1}\n min={1}\n max={MAX_STROKE_WIDTH}\n step={1}\n largeStep={5}\n disabled={off || stroke === null}\n onValueChange={(width) => {\n if (stroke) set({ stroke: { ...stroke, width: Math.round(width) } });\n }}\n />\n </Field>\n </div>\n );\n}\n\n/**\n * An arrow's fields (docs/adr/0015): where its tail and its tip are, in\n * scene pixels, its colour and its width. They re-aim it without a drag\n * (WCAG 2.5.7). An arrow's ends differ, so a value that would put one on\n * the other isn't set.\n */\nexport function ArrowLayerFields(props: FieldsProps<ImageArrowLayer>): ReactNode {\n const { layer, actions, run } = props;\n const messages = useImageMessages();\n const swatches = useSwatches();\n const off = layer === null;\n const end = (which: \"from\" | \"to\", axis: \"x\" | \"y\") => (\n <Field key={`${which}.${axis}`} label={messages.t(`layers.arrow.${which}.${axis}`)}>\n <NumberField\n value={layer ? layer[which][axis] : 0}\n min={-MAX_SCENE_COORDINATE}\n max={MAX_SCENE_COORDINATE}\n step={1}\n largeStep={10}\n disabled={off}\n onValueChange={(value) => {\n if (!layer) return;\n const moved = { ...layer[which], [axis]: Math.round(value) };\n const other = layer[which === \"from\" ? \"to\" : \"from\"];\n if (moved.x === other.x && moved.y === other.y) return;\n run(() => actions.set(layer.key, { [which]: moved }));\n }}\n />\n </Field>\n );\n return (\n <div className=\"hm-image-layer-kind\" data-hm-inactive={off ? \"\" : undefined}>\n <div className=\"hm-image-layer-ends\">\n {end(\"from\", \"x\")}\n {end(\"from\", \"y\")}\n {end(\"to\", \"x\")}\n {end(\"to\", \"y\")}\n </div>\n <Field label={messages.t(\"layers.colour\")}>\n <ColorField\n value={layer?.colour ?? DEFAULT_SHAPE_COLOUR}\n swatches={swatches}\n disabled={off}\n onValueChange={(colour) => {\n if (layer && colour !== layer.colour) run(() => actions.set(layer.key, { colour }));\n }}\n />\n </Field>\n <Field label={messages.t(\"layers.arrow.width\")}>\n <NumberField\n value={layer?.width ?? 1}\n min={1}\n max={MAX_STROKE_WIDTH}\n step={1}\n largeStep={5}\n disabled={off}\n onValueChange={(width) => {\n if (layer) run(() => actions.set(layer.key, { width: Math.round(width) }));\n }}\n />\n </Field>\n </div>\n );\n}\n","import { useAnnounce } from \"@hussmartinez/ui/react\";\nimport { useMemo } from \"react\";\nimport { asImageError } from \"../../core/errors/error-helpers.js\";\nimport { isImageError } from \"../../core/errors/image-error.js\";\nimport { simplifyStroke } from \"../../core/model/drawing-geometry.js\";\nimport {\n type ImageDrawingLayer,\n type ImagePlan,\n type ImageScenePoint,\n type ImageStroke,\n MAX_SCENE_COORDINATE,\n MAX_STROKE_WIDTH,\n} from \"../../core/model/plan.js\";\nimport type { ImageCommand } from \"../../core/operations/commands.js\";\nimport {\n DRAW_COLOUR,\n DRAW_OPACITY,\n drawWidth,\n type ImageDrawMode,\n} from \"../../features/draw/draw-tool.js\";\nimport { NO_TOOL } from \"../../features/editor-state.js\";\nimport { newLayerKey } from \"../../features/layers/new-layer.js\";\nimport { type Gesture, useSharedGesture } from \"../gesture.js\";\nimport { useImageInternals } from \"../hooks.js\";\n\n/** What the draw overlay and panel do (docs/adr/0015). */\nexport interface DrawActions {\n /**\n * Shows a stroke being drawn, from its samples so far, without changing\n * the plan: simplified as it will be committed, so nothing shifts on\n * release (docs/adr/0014).\n *\n * @param key - The key a new drawing takes if this stroke starts one.\n * @param samples - Scene points, in the order they were drawn.\n * @param tolerance - One screen pixel, in whole scene pixels.\n */\n drawing(key: string, samples: readonly ImageScenePoint[], tolerance: number): void;\n /** Ends the stroke as one step. What the session refuses goes to the editor's state. */\n commit(key: string): void;\n /** Ends the stroke with no step. */\n cancel(): void;\n /** A key no layer has, for a drawing a stroke may start. */\n newKey(): string;\n /** Sets the mode, with its own colour and width, or the colour or width alone. */\n set(changes: { mode?: ImageDrawMode; colour?: string; width?: number }): void;\n /** Removes the last stroke of the drawing being drawn into, or the drawing with its only one. */\n removeLast(): void;\n /** The drawing the next stroke joins, if the plan still has one that the mode can add to. */\n target(): ImageDrawingLayer | undefined;\n /** Ends drawing. */\n done(): void;\n readonly gesture: Gesture;\n}\n\nconst clamp = (value: number) =>\n Math.min(MAX_SCENE_COORDINATE, Math.max(-MAX_SCENE_COORDINATE, Math.round(value) || 0));\n\n/** A stroke's samples as the commands' points: whole pixels of the scene, from an origin. */\nfunction relative(samples: readonly ImageScenePoint[], origin: ImageScenePoint): number[] {\n return samples.flatMap((point) => [clamp(point.x) - origin.x, clamp(point.y) - origin.y]);\n}\n\nexport function useDrawActions(): DrawActions {\n const context = useImageInternals();\n const { session, editor, messages } = context;\n const announce = useAnnounce();\n const gesture = useSharedGesture();\n return useMemo(() => {\n const settings = () => editor.getSnapshot().draw;\n const patch = (changes: Partial<NonNullable<ReturnType<typeof settings>>>) =>\n editor.set((state) =>\n state.tool === \"draw\" && state.draw\n ? { ...state, draw: { ...state.draw, ...changes } }\n : state,\n );\n /** The drawing the mode can add to: the target, if the plan has it at the mode's opacity. */\n const targetIn = (plan: ImagePlan | null) => {\n const current = settings();\n const layer = plan?.layers.find((item) => item.key === current?.target);\n return current && layer?.kind === \"drawing\" && layer.opacity === DRAW_OPACITY[current.mode]\n ? layer\n : undefined;\n };\n const actions: DrawActions = {\n gesture,\n newKey: () => {\n const plan = session.getSnapshot().plan;\n return plan ? newLayerKey(plan) : \"\";\n },\n target: () => targetIn(session.getSnapshot().plan),\n drawing(key, samples, tolerance) {\n const current = settings();\n const plan = session.getSnapshot().plan;\n const first = samples[0];\n if (!current || !plan || !first) return;\n const joined = targetIn(plan);\n // A stroke joins the drawing it's aimed at; otherwise it starts one,\n // whose origin is where the stroke began (docs/adr/0014).\n const origin = joined ?? { x: clamp(first.x), y: clamp(first.y) };\n const stroke: ImageStroke = {\n colour: current.colour,\n width: current.width,\n runs: simplifyStroke(relative(samples, origin), tolerance),\n };\n const command: ImageCommand = joined\n ? { type: \"image.addStrokes\", key: joined.key, strokes: [stroke] }\n : {\n type: \"image.insertLayers\",\n at: plan.layers.length,\n layers: [\n {\n key,\n kind: \"drawing\",\n name: \"\",\n visible: true,\n opacity: DRAW_OPACITY[current.mode],\n x: origin.x,\n y: origin.y,\n strokes: [stroke],\n },\n ],\n };\n gesture.preview([command]);\n },\n commit(key) {\n const started = targetIn(session.getSnapshot().plan) === undefined;\n try {\n gesture.commit();\n editor.set((state) => (state.error === null ? state : { ...state, error: null }));\n } catch (reason) {\n // Over the points limit, for one: said on the stage, and nothing is added.\n const error = isImageError(reason) ? reason : asImageError(reason);\n editor.set((state) => ({ ...state, error, preview: null }));\n return;\n }\n // The next stroke joins the drawing this one started.\n if (started && session.getSnapshot().plan?.layers.some((layer) => layer.key === key)) {\n patch({ target: key });\n }\n },\n cancel() {\n gesture.cancel();\n },\n set(changes) {\n gesture.commit();\n const current = settings();\n if (!current) return;\n if (changes.mode !== undefined && changes.mode !== current.mode) {\n // Another mode draws into another drawing, with its own colour and width.\n patch({\n mode: changes.mode,\n colour: DRAW_COLOUR[changes.mode],\n width: drawWidth(context, changes.mode),\n target: null,\n });\n return;\n }\n patch({\n ...(changes.colour === undefined ? {} : { colour: changes.colour }),\n ...(changes.width === undefined\n ? {}\n : { width: Math.min(MAX_STROKE_WIDTH, Math.max(1, Math.round(changes.width))) }),\n });\n },\n removeLast() {\n gesture.cancel();\n const drawing = targetIn(session.getSnapshot().plan);\n if (!drawing) return;\n if (drawing.strokes.length > 1) {\n session.execute({\n type: \"image.removeStrokes\",\n key: drawing.key,\n indexes: [drawing.strokes.length - 1],\n });\n } else {\n // A drawing keeps at least one stroke: its only one goes with it.\n session.execute({ type: \"image.removeLayers\", keys: [drawing.key] });\n patch({ target: null });\n }\n announce(messages.t(\"draw.removed\"));\n },\n done() {\n gesture.commit();\n editor.set((state) =>\n state.tool === \"draw\" ? { ...state, ...NO_TOOL, preview: null } : state,\n );\n },\n };\n return actions;\n }, [announce, context, editor, gesture, messages, session]);\n}\n","import { Button, ColorField, Field, NumberField, SegmentedControl } from \"@hussmartinez/ui/react\";\nimport type { ReactNode } from \"react\";\nimport { MAX_STROKE_WIDTH } from \"../../core/model/plan.js\";\nimport { useImageDocument, useImageEditorState, useImageMessages } from \"../hooks.js\";\nimport { useSwatches } from \"../layers/LayerFields.js\";\nimport { useDrawActions } from \"./use-draw.js\";\n\n/**\n * Props of {@link ImageDrawPanel}.\n *\n * @public\n */\nexport interface ImageDrawPanelProps {\n readonly className?: string;\n}\n\n/**\n * The draw panel (docs/adr/0015), shown while drawing: the pen or the\n * highlighter, the colour and the width the next stroke takes, and a button\n * that removes the last stroke. It says that drawing needs a pointer, and\n * where the keyboard's way to point at something is.\n *\n * The panel keeps its size, whatever is chosen or drawn, so the stage\n * doesn't move under a stroke.\n *\n * @public\n */\nexport function ImageDrawPanel(props: ImageDrawPanelProps): ReactNode {\n const [state] = useImageEditorState();\n // Follows the plan: whether there's a stroke to remove.\n useImageDocument();\n const messages = useImageMessages();\n const actions = useDrawActions();\n const swatches = useSwatches();\n const settings = state.draw;\n if (state.tool !== \"draw\" || !settings) return null;\n const drawing = actions.target();\n return (\n <section\n className={[\"hm-image-draw-panel\", props.className].filter(Boolean).join(\" \")}\n aria-label={messages.t(\"draw.panel\")}\n >\n <p className=\"hm-image-draw-intro\">{messages.t(\"draw.intro\")}</p>\n <SegmentedControl\n label={messages.t(\"draw.mode\")}\n value={settings.mode}\n size=\"small\"\n options={[\n { value: \"pen\", label: messages.t(\"draw.modes.pen\") },\n { value: \"highlighter\", label: messages.t(\"draw.modes.highlighter\") },\n ]}\n onValueChange={(mode) => actions.set({ mode })}\n />\n <Field label={messages.t(\"draw.colour\")}>\n <ColorField\n value={settings.colour}\n swatches={swatches}\n onValueChange={(colour) => {\n if (colour !== settings.colour) actions.set({ colour });\n }}\n />\n </Field>\n <Field label={messages.t(\"draw.width\")}>\n <NumberField\n value={settings.width}\n min={1}\n max={MAX_STROKE_WIDTH}\n step={1}\n largeStep={5}\n onValueChange={(width) => actions.set({ width })}\n />\n </Field>\n <div className=\"hm-image-draw-actions\">\n <Button\n variant=\"secondary\"\n className=\"hm-image-draw-remove\"\n disabled={!drawing}\n focusableWhenDisabled\n onClick={() => actions.removeLast()}\n >\n {messages.t(\"draw.removeLast\")}\n </Button>\n <Button variant=\"primary\" className=\"hm-image-draw-done\" onClick={() => actions.done()}>\n {messages.t(\"draw.done\")}\n </Button>\n </div>\n </section>\n );\n}\n","import { type ReactNode, useEffect, useMemo, useRef, useSyncExternalStore } from \"react\";\nimport { engineInternals } from \"../adapters/image-engine.js\";\nimport { useImageInternals } from \"./hooks.js\";\n\nconst usable = () => false;\nconst unchanged = () => () => {};\n\n/** Private binding: custom adapters do not acquire a built-in lifecycle contract. */\nexport function EngineBoundary({ children }: { readonly children: ReactNode }): ReactNode {\n const { engine, messages } = useImageInternals();\n const lifecycle = engineInternals(engine);\n const surface = useRef<HTMLDivElement>(null);\n const notice = useRef<HTMLParagraphElement>(null);\n const ownedFocus = useRef<Element | null>(null);\n const subscribe = useMemo(\n () =>\n lifecycle\n ? (changed: () => void) =>\n lifecycle.subscribe(() => {\n const active = document.activeElement;\n ownedFocus.current = active && surface.current?.contains(active) ? active : null;\n changed();\n })\n : unchanged,\n [lifecycle],\n );\n const terminal = useSyncExternalStore(subscribe, lifecycle?.getSnapshot ?? usable, usable);\n\n useEffect(() => {\n if (!terminal || !ownedFocus.current) return;\n const active = document.activeElement;\n // A dialog may restore an external opener on unmount; never steal it.\n if (active === document.body || active === ownedFocus.current) notice.current?.focus();\n ownedFocus.current = null;\n }, [terminal]);\n\n return (\n <div ref={surface} className=\"hm-image-engine-boundary\">\n {terminal ? (\n <p ref={notice} role=\"alert\" tabIndex={-1} className=\"hm-image-engine-unavailable\">\n {messages.t(\"editor.engineUnavailable\")}\n </p>\n ) : (\n children\n )}\n </div>\n );\n}\n","import {\n type KeyboardEvent,\n type PointerEvent,\n type ReactNode,\n useEffect,\n useId,\n useRef,\n} from \"react\";\nimport {\n aspectRatio,\n type CropHandle,\n compositionDeltaToSource,\n cropInComposition,\n dragHandle,\n handleInSource,\n moveCrop,\n nudgeCropOnScreen,\n} from \"../../core/model/crop.js\";\nimport { compositionSize } from \"../../core/model/geometry.js\";\nimport type { ImageCrop, ImagePlan } from \"../../core/model/plan.js\";\nimport type { ImageSize } from \"../../core/model/source.js\";\nimport { type ImageView, placement } from \"../../core/ports/image-renderer.js\";\nimport { useImageEditorState, useImageMessages } from \"../hooks.js\";\nimport { useCropActions } from \"./use-crop.js\";\n\nconst HANDLES: readonly CropHandle[] = [\"nw\", \"n\", \"ne\", \"e\", \"se\", \"s\", \"sw\", \"w\"];\nconst ARROWS = new Set([\"ArrowLeft\", \"ArrowRight\", \"ArrowUp\", \"ArrowDown\"]);\n\nexport interface CropFrameProps {\n /** The session's plan, whose crop is being changed. */\n readonly plan: ImagePlan;\n readonly source: ImageSize;\n /** The stage's view, in CSS pixels. */\n readonly view: ImageView;\n}\n\n/**\n * The crop frame (docs/adr/0007): DOM over the canvas, placed with the\n * renderer's geometry. One focusable group, named \"Crop area\" and described\n * by its size, which arrow keys move and Shift with them resizes,\n * Enter applies and Escape cancels. Its handles are pointer targets only,\n * hidden from assistive technology: the keys and the crop panel's fields do\n * what they do.\n */\nexport function CropFrame(props: CropFrameProps): ReactNode {\n const { plan, source, view } = props;\n const [state] = useImageEditorState();\n const messages = useImageMessages();\n const actions = useCropActions();\n const frame = useRef<HTMLDivElement>(null);\n const describedBy = useId();\n const drag = useRef<\n | { pointer: number; x: number; y: number; start: ImageCrop; handle: CropHandle | \"move\" }\n | undefined\n >(undefined);\n\n // Cropping starts with focus on the frame.\n useEffect(() => {\n frame.current?.focus();\n }, []);\n\n const crop = state.crop;\n if (!crop) return null;\n const { orientation } = plan.base;\n const whole = { ...plan, base: { ...plan.base, crop: null } };\n const placed = placement(compositionSize(whole, source), view);\n // A stage with no size yet has nowhere to put the frame, and no scale for a drag.\n if (!(placed.scale > 0)) return null;\n const shown = cropInComposition(crop.pending, orientation, source);\n const ratio = aspectRatio(crop.aspect, source);\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n actions.apply();\n return;\n }\n if (event.key === \"Escape\") {\n event.preventDefault();\n // Escape during a drag cancels the drag; otherwise, the crop.\n if (drag.current) {\n actions.update(drag.current.start);\n drag.current = undefined;\n } else {\n actions.cancel();\n }\n return;\n }\n if (!ARROWS.has(event.key)) return;\n // Only the plain arrows and Shift with them are the frame's. With Alt,\n // Control or Meta they're the browser's or the system's, such as Back\n // and Forward on Alt+Left and Alt+Right, and are left alone (ADR 0007).\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n event.preventDefault();\n // Handled here, so the editor's shortcuts don't also take the arrows.\n event.stopPropagation();\n actions.update(\n nudgeCropOnScreen(\n crop.pending,\n event.key as \"ArrowLeft\",\n 1,\n event.shiftKey,\n orientation,\n source,\n ratio,\n ),\n );\n };\n\n const onPointerDown = (handle: CropHandle | \"move\") => (event: PointerEvent<HTMLElement>) => {\n if (event.button !== 0) return;\n event.preventDefault();\n event.stopPropagation();\n frame.current?.focus();\n try {\n // Keeps the drag when the pointer leaves the frame; a pointer the\n // browser doesn't track can't be captured, and the drag still works.\n event.currentTarget.setPointerCapture(event.pointerId);\n } catch {}\n drag.current = {\n pointer: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n start: crop.pending,\n handle,\n };\n };\n const onPointerMove = (event: PointerEvent<HTMLElement>) => {\n const current = drag.current;\n if (!current || current.pointer !== event.pointerId) return;\n // Screen pixels to composition pixels, then to the source's own axes.\n const moved = compositionDeltaToSource(\n (event.clientX - current.x) / placed.scale,\n (event.clientY - current.y) / placed.scale,\n orientation,\n source,\n );\n actions.update(\n current.handle === \"move\"\n ? moveCrop(current.start, moved.dx, moved.dy, source)\n : dragHandle(\n current.start,\n handleInSource(current.handle, orientation),\n moved.dx,\n moved.dy,\n source,\n ratio,\n ),\n );\n };\n const onPointerEnd = (event: PointerEvent<HTMLElement>) => {\n if (drag.current?.pointer !== event.pointerId) return;\n // A cancelled pointer, such as a lost capture, restores the crop the drag started from.\n if (event.type === \"pointercancel\") actions.update(drag.current.start);\n drag.current = undefined;\n };\n\n const style = {\n left: `${placed.x + shown.x * placed.scale}px`,\n top: `${placed.y + shown.y * placed.scale}px`,\n width: `${shown.width * placed.scale}px`,\n height: `${shown.height * placed.scale}px`,\n };\n const pointer = { onPointerMove, onPointerUp: onPointerEnd, onPointerCancel: onPointerEnd };\n return (\n // A positioned keyboard control over the canvas, not a form's fieldset (docs/adr/0007).\n // biome-ignore lint/a11y/useSemanticElements: a focusable group, not a fieldset\n <div\n ref={frame}\n className=\"hm-image-crop-frame\"\n role=\"group\"\n aria-label={messages.t(\"crop.frame\")}\n aria-describedby={describedBy}\n // biome-ignore lint/a11y/noNoninteractiveTabindex: the frame is a keyboard control, named and described\n tabIndex={0}\n style={style}\n onKeyDown={onKeyDown}\n onPointerDown={onPointerDown(\"move\")}\n {...pointer}\n >\n <span id={describedBy} hidden>\n {messages.t(\"crop.frameDescription\", {\n width: crop.pending.width,\n height: crop.pending.height,\n x: crop.pending.x,\n y: crop.pending.y,\n })}\n </span>\n {HANDLES.map((handle) => (\n <span\n key={handle}\n className=\"hm-image-crop-handle\"\n data-hm-handle={handle}\n aria-hidden=\"true\"\n onPointerDown={onPointerDown(handle)}\n {...pointer}\n />\n ))}\n </div>\n );\n}\n","import { type PointerEvent, type ReactNode, useEffect, useRef } from \"react\";\nimport { compositionSize, compositionToSource, cropRect } from \"../../core/model/geometry.js\";\nimport type { ImagePlan, ImageScenePoint } from \"../../core/model/plan.js\";\nimport type { ImageSize } from \"../../core/model/source.js\";\nimport { type ImageView, placement } from \"../../core/ports/image-renderer.js\";\nimport { useDrawActions } from \"./use-draw.js\";\n\n/**\n * The most samples one stroke takes: what 64 runs hold (docs/adr/0014).\n * There the stroke ends and another starts from the same point.\n */\nconst MAX_SAMPLES = 1 + 64 * 1_999;\n\nexport interface DrawOverlayProps {\n /** The plan the stage shows: the session's, or a stroke's. */\n readonly plan: ImagePlan;\n readonly source: ImageSize;\n /** The stage's view, in CSS pixels. */\n readonly view: ImageView;\n}\n\n/**\n * The surface a stroke is drawn on (docs/adr/0015): a press and a drag\n * across the image draw a stroke, shown on the stage as a transient plan,\n * and the release makes it one undoable step. A press without a drag is a\n * dot. Escape, or a lost pointer, ends the stroke with nothing added.\n *\n * Freehand drawing needs a pointer (WCAG 2.5.7's essential exception, ADR\n * 0009), so this has no keyboard function and nothing for assistive\n * technology: the panel says so, and the arrow tool is the keyboard's way\n * to point at something.\n */\nexport function DrawOverlay(props: DrawOverlayProps): ReactNode {\n const { plan, source, view } = props;\n const actions = useDrawActions();\n const overlay = useRef<HTMLDivElement>(null);\n const stroke = useRef<\n { pointer: number; key: string; samples: ImageScenePoint[]; tolerance: number } | undefined\n >(undefined);\n\n // Escape ends a stroke in progress, wherever focus is.\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || !stroke.current) return;\n event.preventDefault();\n event.stopPropagation();\n stroke.current = undefined;\n actions.cancel();\n };\n document.addEventListener(\"keydown\", onKeyDown, true);\n return () => document.removeEventListener(\"keydown\", onKeyDown, true);\n }, [actions]);\n\n const composition = compositionSize(plan, source);\n const placed = placement(composition, view);\n if (!(placed.scale > 0)) return null;\n const crop = cropRect(plan.base.crop, source);\n const { orientation } = plan.base;\n\n /** A pointer's place in the scene. */\n const sceneOf = (clientX: number, clientY: number): ImageScenePoint => {\n const box = overlay.current?.getBoundingClientRect();\n return compositionToSource(\n {\n x: (clientX - (box?.left ?? 0) - placed.x) / placed.scale,\n y: (clientY - (box?.top ?? 0) - placed.y) / placed.scale,\n },\n crop,\n orientation,\n );\n };\n\n const onPointerDown = (event: PointerEvent<HTMLDivElement>) => {\n if (event.button !== 0 || stroke.current) return;\n event.preventDefault();\n try {\n // Keeps the stroke when the pointer leaves the stage.\n event.currentTarget.setPointerCapture(event.pointerId);\n } catch {}\n const current = {\n pointer: event.pointerId,\n key: actions.newKey(),\n samples: [sceneOf(event.clientX, event.clientY)],\n // A detail smaller than a screen pixel wasn't drawn on purpose.\n tolerance: Math.max(1, Math.round(1 / placed.scale)),\n };\n stroke.current = current;\n actions.drawing(current.key, current.samples, current.tolerance);\n };\n\n const onPointerMove = (event: PointerEvent<HTMLDivElement>) => {\n const current = stroke.current;\n if (!current || current.pointer !== event.pointerId) return;\n // Every sample the browser has since the last event, where it gives them.\n const native = event.nativeEvent;\n const events = native.getCoalescedEvents?.() ?? [];\n for (const sample of events.length > 0 ? events : [native]) {\n current.samples.push(sceneOf(sample.clientX, sample.clientY));\n }\n if (current.samples.length >= MAX_SAMPLES) {\n // A stroke holds no more: it ends here, and the next starts where it ended.\n const last = current.samples[MAX_SAMPLES - 1] as ImageScenePoint;\n const rest = current.samples.slice(MAX_SAMPLES - 1);\n actions.drawing(current.key, current.samples.slice(0, MAX_SAMPLES), current.tolerance);\n actions.commit(current.key);\n current.key = actions.newKey();\n current.samples = rest.length > 0 ? rest : [last];\n }\n actions.drawing(current.key, current.samples, current.tolerance);\n };\n\n const onPointerEnd = (event: PointerEvent<HTMLDivElement>) => {\n const current = stroke.current;\n if (!current || current.pointer !== event.pointerId) return;\n stroke.current = undefined;\n if (event.type === \"pointercancel\") actions.cancel();\n else actions.commit(current.key);\n };\n\n return (\n <div\n ref={overlay}\n className=\"hm-image-draw-overlay\"\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerEnd}\n onPointerCancel={onPointerEnd}\n />\n );\n}\n","/**\n * The arrow keys held on a frame on the stage, so a nudge is one step per\n * press, and one per key held down however many times it repeats\n * (docs/adr/0007): the step is taken when the last key held is let go, or\n * when focus leaves first. Escape during a run cancels it, and the rest of\n * it is ignored until every key is let go, so a key still held doesn't\n * start another.\n *\n * It's the family's rule for keyboard moves, as ui's `Slider` keeps it\n * for a slider's keys.\n */\nexport interface KeyRun {\n /** A key pressed, or repeating. Returns whether it should move the frame. */\n press(key: string): boolean;\n /** A key let go. Returns whether that ended a run to commit. */\n release(key: string): boolean;\n /** Escape. Returns whether there was a run to cancel. */\n cancel(): boolean;\n /** Focus leaving. Returns whether there was a run to commit. */\n leave(): boolean;\n /**\n * A pointer taking the gesture. Returns whether there was a run to\n * commit first. Keys still held after Escape stay ignored until they're\n * let go, as they would be without the pointer.\n */\n handOff(): boolean;\n}\n\nexport function createKeyRun(): KeyRun {\n const held = new Set<string>();\n /** Whether a run is moving the frame, since its first key. */\n let running = false;\n /** After Escape, until every key is let go. */\n let cancelled = false;\n return {\n press(key) {\n held.add(key);\n if (cancelled) return false;\n running = true;\n return true;\n },\n release(key) {\n if (!held.delete(key) || held.size > 0) return false;\n const ended = running && !cancelled;\n running = false;\n cancelled = false;\n return ended;\n },\n cancel() {\n if (!running) return false;\n running = false;\n cancelled = held.size > 0;\n return true;\n },\n handOff() {\n const ended = running && !cancelled;\n running = false;\n return ended;\n },\n leave() {\n held.clear();\n const ended = running && !cancelled;\n running = false;\n cancelled = false;\n return ended;\n },\n };\n}\n","import {\n applyMatrix,\n type ImageMatrix,\n invertMatrix,\n layerToScene,\n} from \"../../core/model/layer-geometry.js\";\nimport {\n type ImageBoxedLayer,\n type ImageLayer,\n type ImageLayerBox,\n type ImageScenePoint,\n MAX_SCENE_COORDINATE,\n} from \"../../core/model/plan.js\";\n\n/**\n * Whether a layer has a box: text, a shape or an image. A drawing and an\n * arrow have none (docs/adr/0014); their frames come with their tools.\n */\nexport const isBoxedLayer = (layer: ImageLayer): layer is ImageBoxedLayer =>\n layer.kind === \"text\" || layer.kind === \"shape\" || layer.kind === \"image\";\n\n/** One of a box's own edges: `n` is its top before it's turned. */\nexport type LayerEdge = \"n\" | \"e\" | \"s\" | \"w\";\n/** An edge or a corner of a box, where a handle sits. */\nexport type LayerHandle = LayerEdge | \"nw\" | \"ne\" | \"se\" | \"sw\";\n\nexport const LAYER_HANDLES: readonly LayerHandle[] = [\"nw\", \"n\", \"ne\", \"e\", \"se\", \"s\", \"sw\", \"w\"];\n\n/** A vector under a transform's turn, flip and scale, without its translation. */\nexport function turned(\n [a, b, c, d]: ImageMatrix,\n x: number,\n y: number,\n): { readonly x: number; readonly y: number } {\n return { x: a * x + c * y, y: b * x + d * y };\n}\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\n/** A whole number, and never a negative zero. */\nconst whole = (value: number) => Math.round(value) || 0;\n\n/** A layer's box, without its other fields. */\nexport const boxOf = ({ x, y, width, height, rotation, flipX }: ImageLayerBox): ImageLayerBox => ({\n x,\n y,\n width,\n height,\n rotation,\n flipX,\n});\n\n/**\n * A box moved by a distance on screen, in composition pixels: through the\n * plan's rotation and flips, back to the scene. The plan turns by quarters,\n * so a whole pixel on screen is a whole pixel of the scene.\n *\n * @param sceneToComposition - `sceneToOutput` at the composition's own size.\n */\nexport function moveLayerBox(\n box: ImageLayerBox,\n sceneToComposition: ImageMatrix,\n dx: number,\n dy: number,\n): ImageLayerBox {\n const by = turned(invertMatrix(sceneToComposition), dx, dy);\n const limit = MAX_SCENE_COORDINATE;\n return {\n ...box,\n x: clamp(box.x + whole(by.x), -limit, limit),\n y: clamp(box.y + whole(by.y), -limit, limit),\n };\n}\n\n/**\n * A box with one handle dragged by a distance along its own axes, at least\n * 1 × 1. What's opposite the handle stays where it is: the other edge, or\n * the other corner. An upright box keeps it exactly. A turned box is turned\n * about its centre, which a resize moves, and the plan holds whole pixels,\n * so its far side stays within a pixel.\n */\nexport function resizeLayerBox(\n box: ImageLayerBox,\n handle: LayerHandle,\n dx: number,\n dy: number,\n): ImageLayerBox {\n const west = handle.includes(\"w\");\n const north = handle.includes(\"n\");\n const size = (length: number, by: number) => clamp(whole(length + by), 1, MAX_SCENE_COORDINATE);\n const width = handle.includes(\"e\")\n ? size(box.width, dx)\n : west\n ? size(box.width, -dx)\n : box.width;\n const height = handle.includes(\"s\")\n ? size(box.height, dy)\n : north\n ? size(box.height, -dy)\n : box.height;\n const matrix = layerToScene(box);\n // The point that stays, in the scene, and where the new box has it.\n const anchor = applyMatrix(matrix, { x: west ? box.width : 0, y: north ? box.height : 0 });\n const fromCentre = turned(\n matrix,\n (west ? width : 0) - width / 2,\n (north ? height : 0) - height / 2,\n );\n const limit = MAX_SCENE_COORDINATE;\n return {\n x: clamp(whole(anchor.x - fromCentre.x - width / 2), -limit, limit),\n y: clamp(whole(anchor.y - fromCentre.y - height / 2), -limit, limit),\n width,\n height,\n rotation: box.rotation,\n flipX: box.flipX,\n };\n}\n\n/**\n * The edge of a box that faces right, or down, on screen: the one a key\n * moves, so `Shift` with Right grows what's seen to the right whatever the\n * layer's turn and the plan's rotation and flips. A box turned an eighth\n * has two such edges; the first of east, south, west and north is taken.\n *\n * @param layerToComposition - `layerToOutput` at the composition's own size.\n */\nexport function edgeFacing(\n layerToComposition: ImageMatrix,\n direction: \"right\" | \"down\",\n): LayerEdge {\n const east = turned(layerToComposition, 1, 0);\n const south = turned(layerToComposition, 0, 1);\n const along = (vector: { x: number; y: number }) => (direction === \"right\" ? vector.x : vector.y);\n const facing: readonly (readonly [LayerEdge, number])[] = [\n [\"e\", along(east)],\n [\"s\", along(south)],\n [\"w\", -along(east)],\n [\"n\", -along(south)],\n ];\n let best = facing[0] as readonly [LayerEdge, number];\n // A later edge wins only by more than rounding's worth.\n for (const edge of facing) if (edge[1] > best[1] + 1e-9) best = edge;\n return best[0];\n}\n\n/** A box with the edge that faces right or down on screen moved out by `by` pixels, or in. */\nexport function resizeLayerBoxOnScreen(\n box: ImageLayerBox,\n layerToComposition: ImageMatrix,\n direction: \"right\" | \"down\",\n by: number,\n): ImageLayerBox {\n const edge = edgeFacing(layerToComposition, direction);\n const outward = edge === \"e\" || edge === \"s\" ? by : -by;\n return resizeLayerBox(box, edge, outward, outward);\n}\n\nconst CURSORS = [\"ew-resize\", \"nwse-resize\", \"ns-resize\", \"nesw-resize\"] as const;\n\n/** The resize cursor for a handle as it's seen: along the direction it moves on screen. */\nexport function handleCursor(layerToComposition: ImageMatrix, handle: LayerHandle): string {\n const x = handle.includes(\"e\") ? 1 : handle.includes(\"w\") ? -1 : 0;\n const y = handle.includes(\"s\") ? 1 : handle.includes(\"n\") ? -1 : 0;\n const seen = turned(layerToComposition, x, y);\n const eighths = Math.round(Math.atan2(seen.y, seen.x) / (Math.PI / 4));\n return CURSORS[((eighths % 4) + 4) % 4] as string;\n}\n\n/** A box's place and size: what a move or a resize sets. */\nexport const placeOf = ({ x, y, width, height }: ImageLayerBox) => ({ x, y, width, height });\n\n/**\n * A point of the scene moved by a distance on screen, in composition\n * pixels, as {@link moveLayerBox} moves a box: a drawing's origin, or an\n * arrow's end.\n */\nexport function moveScenePoint(\n point: ImageScenePoint,\n sceneToComposition: ImageMatrix,\n dx: number,\n dy: number,\n): ImageScenePoint {\n const by = turned(invertMatrix(sceneToComposition), dx, dy);\n const limit = MAX_SCENE_COORDINATE;\n return {\n x: clamp(point.x + whole(by.x), -limit, limit),\n y: clamp(point.y + whole(by.y), -limit, limit),\n };\n}\n","import {\n type KeyboardEvent,\n type PointerEvent,\n type ReactNode,\n useEffect,\n useId,\n useRef,\n} from \"react\";\nimport { arrowBounds, drawingBounds } from \"../../core/model/drawing-geometry.js\";\nimport { compositionSize, cropRect } from \"../../core/model/geometry.js\";\nimport { invertMatrix, layerToOutput, sceneToOutput } from \"../../core/model/layer-geometry.js\";\nimport type {\n ImageLayer,\n ImageLayerBox,\n ImagePlan,\n ImageScenePoint,\n} from \"../../core/model/plan.js\";\nimport { type ImageRect, sceneRectToComposition } from \"../../core/model/redaction-geometry.js\";\nimport type { ImageSize } from \"../../core/model/source.js\";\nimport { type ImageView, placement } from \"../../core/ports/image-renderer.js\";\nimport { useImageEditorState, useImageMessages } from \"../hooks.js\";\nimport { createKeyRun } from \"../key-run.js\";\nimport {\n boxOf,\n handleCursor,\n LAYER_HANDLES,\n type LayerHandle,\n moveLayerBox,\n moveScenePoint,\n placeOf,\n resizeLayerBox,\n resizeLayerBoxOnScreen,\n turned,\n} from \"./frame-geometry.js\";\nimport { layerLabel, useLayerActions } from \"./use-layers.js\";\n\nconst ARROWS: Readonly<Record<string, readonly [number, number]>> = {\n ArrowLeft: [-1, 0],\n ArrowRight: [1, 0],\n ArrowUp: [0, -1],\n ArrowDown: [0, 1],\n};\n\nexport interface LayersOverlayProps {\n /** The plan the stage shows: the session's, or a gesture's. */\n readonly plan: ImagePlan;\n readonly source: ImageSize;\n /** The stage's view, in CSS pixels. */\n readonly view: ImageView;\n}\n\n/** Some of a layer's fields, as `image.updateLayers` takes them. */\ntype Props = Readonly<Record<string, unknown>>;\n\n/**\n * The layers as frames over the canvas (docs/adr/0013, docs/adr/0015). A\n * press on a frame selects its layer, the top one under the pointer, and a\n * drag moves it.\n *\n * - **Text, a shape or an image** has its box as its frame, placed and\n * turned with the transform the renderer draws it through; the selected\n * one's handles resize it.\n * - **A drawing** has the bounds of its strokes as its frame, and moves.\n * - **An arrow** has the bounds of its outline, and a handle on each end\n * that re-aims it.\n *\n * Each frame is a focusable group, named by its place in the stack and what\n * the list calls it, and described by where it is. Its keys are the crop\n * frame's (docs/adr/0007): the arrows move it by a pixel as it's seen,\n * `Shift` with them resizes a box or moves an arrow's tip, `Delete` removes\n * it. Handles are pointer targets only, hidden from assistive technology:\n * the keys and the panel's fields do what they do.\n *\n * Every gesture shows on the stage as a transient plan, and becomes one\n * undoable step when it ends. A hidden layer has a frame only while it's\n * selected, so its place can still be found.\n */\nexport function LayersOverlay(props: LayersOverlayProps): ReactNode {\n const { plan, source, view } = props;\n const [state] = useImageEditorState();\n const messages = useImageMessages();\n const actions = useLayerActions();\n const overlay = useRef<HTMLDivElement>(null);\n const describedBy = useId();\n const drag = useRef<\n | {\n pointer: number;\n x: number;\n y: number;\n key: string;\n /** The fields a drag by this much on screen sets, in composition pixels, or none. */\n at: (dx: number, dy: number) => Props | null;\n moved: boolean;\n }\n | undefined\n >(undefined);\n /** The key whose frame takes focus once it's rendered: the one selected after a removal. */\n const focusNext = useRef<string | null>(null);\n /** The arrow keys held on a frame: one step per press, and per key held down. */\n const keys = useRef(createKeyRun());\n\n const frameOf = (key: string) =>\n overlay.current?.querySelector<HTMLElement>(`[data-hm-layer=\"${CSS.escape(key)}\"]`);\n\n useEffect(() => {\n const key = focusNext.current;\n if (!key) return;\n const frame = frameOf(key);\n if (!frame) return;\n focusNext.current = null;\n frame.focus();\n });\n\n const selected = state.layers?.selected ?? null;\n const composition = compositionSize(plan, source);\n const placed = placement(composition, view);\n // A stage with no size yet has nowhere to put the frames, and no scale for a drag.\n if (!(placed.scale > 0)) return null;\n const crop = cropRect(plan.base.crop, source);\n const { orientation } = plan.base;\n const sceneToComposition = sceneToOutput(crop, orientation, composition);\n const seen = (box: ImageLayerBox) => layerToOutput(box, crop, orientation, composition);\n /** A rectangle of the scene on the stage, in CSS pixels. */\n const onStage = (rect: ImageRect) => {\n const shown = sceneRectToComposition(rect, crop, orientation);\n return {\n left: placed.x + shown.x * placed.scale,\n top: placed.y + shown.y * placed.scale,\n width: shown.width * placed.scale,\n height: shown.height * placed.scale,\n };\n };\n\n /** An arrow's ends moved, when they still differ: an arrow has a direction. */\n const aimed = (from: ImageScenePoint, to: ImageScenePoint, fields: Props): Props | null =>\n from.x === to.x && from.y === to.y ? null : fields;\n\n /** What a drag on a layer, or on one of its handles, sets. */\n const dragOf = (\n layer: ImageLayer,\n part: LayerHandle | \"move\" | \"from\" | \"to\",\n ): ((dx: number, dy: number) => Props | null) => {\n if (layer.kind === \"drawing\") {\n return (dx: number, dy: number): Props => ({\n ...moveScenePoint(layer, sceneToComposition, dx, dy),\n });\n }\n if (layer.kind === \"arrow\") {\n return (dx: number, dy: number) => {\n const from =\n part === \"to\" ? layer.from : moveScenePoint(layer.from, sceneToComposition, dx, dy);\n const to =\n part === \"from\" ? layer.to : moveScenePoint(layer.to, sceneToComposition, dx, dy);\n // Both ends, always: a gesture's latest change replaces its earlier\n // ones, so a tip moved after the whole arrow must carry the tail too.\n return aimed(from, to, { from, to });\n };\n }\n const start = boxOf(layer);\n return (dx: number, dy: number) => {\n if (part === \"move\") return placeOf(moveLayerBox(start, sceneToComposition, dx, dy));\n // Along the box's own axes, as its handles are.\n const own = turned(invertMatrix(seen(start)), dx, dy);\n return placeOf(resizeLayerBox(start, part as LayerHandle, own.x, own.y));\n };\n };\n\n /** What an arrow key sets: a move by a pixel as it's seen, or with Shift a resize or a re-aim. */\n const nudgeOf = (layer: ImageLayer, dx: number, dy: number, shift: boolean): Props | null => {\n if (layer.kind === \"drawing\") {\n // A drawing has no size to change.\n return shift ? null : { ...moveScenePoint(layer, sceneToComposition, dx, dy) };\n }\n if (layer.kind === \"arrow\") return dragOf(layer, shift ? \"to\" : \"move\")(dx, dy);\n const box = boxOf(layer);\n // As seen on screen, whatever the layer's turn and the plan's rotation\n // and flips: Shift moves the edge that faces right with Left and Right,\n // and the one that faces down with Up and Down.\n return placeOf(\n shift\n ? resizeLayerBoxOnScreen(box, seen(box), dx !== 0 ? \"right\" : \"down\", dx + dy)\n : moveLayerBox(box, sceneToComposition, dx, dy),\n );\n };\n\n const capture = (event: PointerEvent<HTMLElement>) => {\n try {\n // Keeps the drag when the pointer leaves the element; a pointer the\n // browser doesn't track can't be captured, and the drag still works.\n event.currentTarget.setPointerCapture(event.pointerId);\n } catch {}\n };\n\n const onFramePointerDown =\n (layer: ImageLayer, part: LayerHandle | \"move\" | \"from\" | \"to\") =>\n (event: PointerEvent<HTMLElement>) => {\n if (event.button !== 0) return;\n // A pointer takes the gesture: a run of arrow keys still going ends first, as its own step.\n if (keys.current.handOff()) actions.commit();\n event.preventDefault();\n event.stopPropagation();\n actions.select(layer.key);\n frameOf(layer.key)?.focus();\n capture(event);\n drag.current = {\n pointer: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n key: layer.key,\n at: dragOf(layer, part),\n moved: false,\n };\n };\n\n const onPointerMove = (event: PointerEvent<HTMLElement>) => {\n const current = drag.current;\n if (!current || current.pointer !== event.pointerId) return;\n // In composition pixels: a move or a resize is by whole pixels of the scene.\n const fields = current.at(\n (event.clientX - current.x) / placed.scale,\n (event.clientY - current.y) / placed.scale,\n );\n if (!fields) return;\n current.moved = true;\n actions.moving(current.key, fields);\n };\n\n const onPointerEnd = (event: PointerEvent<HTMLElement>) => {\n const current = drag.current;\n if (!current || current.pointer !== event.pointerId) return;\n drag.current = undefined;\n // A cancelled pointer, such as a lost capture, leaves the plan as it was.\n if (event.type === \"pointercancel\") actions.cancel();\n else if (current.moved) actions.commit();\n };\n const pointer = { onPointerMove, onPointerUp: onPointerEnd, onPointerCancel: onPointerEnd };\n\n const onKeyDown = (layer: ImageLayer) => (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n // Escape during a drag, or while arrow keys are held, cancels it;\n // otherwise it closes the layers.\n if (drag.current) {\n drag.current = undefined;\n actions.cancel();\n } else if (keys.current.cancel()) {\n actions.cancel();\n } else {\n actions.done();\n }\n return;\n }\n // With Alt, Control or Meta, a key is the browser's or the system's,\n // such as Back and Forward, and is left alone (docs/adr/0007).\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n if (event.key === \"Delete\" || event.key === \"Backspace\") {\n event.preventDefault();\n event.stopPropagation();\n // Focus moves to the frame of the layer selected instead, or the panel's button.\n const next = actions.remove(layer.key);\n // A hidden layer's frame appears once it's selected.\n if (next !== null) focusNext.current = next;\n else {\n overlay.current\n ?.closest(\".hm-image-editor\")\n ?.querySelector<HTMLElement>(\".hm-image-layers-done\")\n ?.focus();\n }\n return;\n }\n const arrow = ARROWS[event.key];\n if (!arrow) return;\n event.preventDefault();\n // Handled here, so the editor's shortcuts don't also take the arrows.\n event.stopPropagation();\n // While a pointer drags, the arrows don't move the frame: the drag owns the gesture.\n if (drag.current) return;\n // A run cancelled with Escape is ignored until its keys are let go.\n if (!keys.current.press(event.key)) return;\n const fields = nudgeOf(layer, arrow[0], arrow[1], event.shiftKey);\n if (!fields) return;\n // Shown at once; it's a step when the last key held is let go.\n actions.moving(layer.key, fields);\n };\n const onKeyUp = (event: KeyboardEvent<HTMLDivElement>) => {\n if (ARROWS[event.key] && keys.current.release(event.key)) actions.commit();\n };\n // Focus leaving with a key held ends its run as one step: the key let go\n // elsewhere isn't seen.\n const onBlur = () => {\n if (keys.current.leave()) actions.commit();\n };\n\n const count = plan.layers.length;\n const shown = plan.layers.filter((layer) => layer.visible || layer.key === selected);\n // One tab stop: the selected frame, or the top one when none is.\n const tabStop = shown.some((layer) => layer.key === selected) ? selected : shown.at(-1)?.key;\n return (\n <div\n ref={overlay}\n className=\"hm-image-layers-overlay\"\n // A press on the image outside every layer selects none.\n onPointerDown={(event) => {\n if (event.button === 0) actions.select(null);\n }}\n >\n {shown.map((layer) => {\n const index = plan.layers.indexOf(layer);\n const isSelected = layer.key === selected;\n // What every frame has: a positioned keyboard control over the\n // canvas, not a form's fieldset (docs/adr/0007).\n const frame = {\n className: \"hm-image-layer-frame\",\n \"data-hm-layer\": layer.key,\n \"data-hm-kind\": layer.kind,\n \"data-hm-selected\": isSelected ? \"\" : undefined,\n \"data-hm-hidden\": layer.visible ? undefined : \"\",\n role: \"group\",\n \"aria-label\": messages.t(\"layers.frame\", {\n // As the list counts them: the top layer is the first.\n index: count - index,\n count,\n name: layerLabel(layer, messages),\n }),\n \"aria-describedby\": `${describedBy}-${index}`,\n tabIndex: layer.key === tabStop ? 0 : -1,\n onFocus: () => actions.select(layer.key),\n onKeyDown: onKeyDown(layer),\n onKeyUp,\n onBlur,\n onPointerDown: onFramePointerDown(layer, \"move\"),\n ...pointer,\n };\n if (layer.kind === \"drawing\" || layer.kind === \"arrow\") {\n const bounds = layer.kind === \"drawing\" ? drawingBounds(layer) : arrowBounds(layer);\n const box = onStage(bounds);\n /** Where a point of the scene is inside the frame, in CSS pixels. */\n const inFrame = (point: ImageScenePoint) => {\n const at = onStage({ ...point, width: 0, height: 0 });\n return { left: `${at.left - box.left}px`, top: `${at.top - box.top}px` };\n };\n return (\n <div\n key={layer.key}\n {...frame}\n style={{\n width: `${box.width}px`,\n height: `${box.height}px`,\n transform: `translate(${box.left}px, ${box.top}px)`,\n }}\n >\n <span id={`${describedBy}-${index}`} hidden>\n {layer.kind === \"drawing\"\n ? messages.t(\"layers.drawingDescription\", {\n count: layer.strokes.length,\n width: bounds.width,\n height: bounds.height,\n x: bounds.x,\n y: bounds.y,\n })\n : messages.t(\"layers.arrowDescription\", {\n fromX: layer.from.x,\n fromY: layer.from.y,\n toX: layer.to.x,\n toY: layer.to.y,\n })}\n </span>\n {isSelected && layer.kind === \"arrow\"\n ? ([\"from\", \"to\"] as const).map((end) => (\n <span\n key={end}\n className=\"hm-image-layer-handle\"\n data-hm-end={end}\n aria-hidden=\"true\"\n style={inFrame(layer[end])}\n onPointerDown={onFramePointerDown(layer, end)}\n {...pointer}\n />\n ))\n : null}\n </div>\n );\n }\n const [a, b, c, d, e, f] = seen(layer);\n return (\n <div\n key={layer.key}\n {...frame}\n style={{\n width: `${layer.width * placed.scale}px`,\n height: `${layer.height * placed.scale}px`,\n // The layer's own transform, at the stage's scale: its turn,\n // the plan's rotation and flips, and its place.\n transform: `matrix(${a}, ${b}, ${c}, ${d}, ${placed.x + e * placed.scale}, ${\n placed.y + f * placed.scale\n })`,\n }}\n >\n <span id={`${describedBy}-${index}`} hidden>\n {messages.t(\"layers.frameDescription\", {\n width: layer.width,\n height: layer.height,\n x: layer.x,\n y: layer.y,\n degrees: layer.rotation / 10,\n })}\n </span>\n {isSelected\n ? LAYER_HANDLES.map((handle) => (\n <span\n key={handle}\n className=\"hm-image-layer-handle\"\n data-hm-handle={handle}\n aria-hidden=\"true\"\n style={{ cursor: handleCursor([a, b, c, d, e, f], handle) }}\n onPointerDown={onFramePointerDown(layer, handle)}\n {...pointer}\n />\n ))\n : null}\n </div>\n );\n })}\n </div>\n );\n}\n","import {\n type KeyboardEvent,\n type PointerEvent,\n type ReactNode,\n useEffect,\n useId,\n useRef,\n} from \"react\";\nimport { compositionSize, cropRect } from \"../../core/model/geometry.js\";\nimport type { ImagePlan, ImageRedaction } from \"../../core/model/plan.js\";\nimport {\n compositionRectToScene,\n type ImageRect,\n sceneRectToComposition,\n} from \"../../core/model/redaction-geometry.js\";\nimport type { ImageSize } from \"../../core/model/source.js\";\nimport { type ImageView, placement } from \"../../core/ports/image-renderer.js\";\nimport { useImageEditorState, useImageMessages } from \"../hooks.js\";\nimport { createKeyRun } from \"../key-run.js\";\nimport { newRedactionKey, useRedactActions } from \"./use-redact.js\";\n\ntype Handle = \"nw\" | \"n\" | \"ne\" | \"e\" | \"se\" | \"s\" | \"sw\" | \"w\";\nconst HANDLES: readonly Handle[] = [\"nw\", \"n\", \"ne\", \"e\", \"se\", \"s\", \"sw\", \"w\"];\nconst ARROWS: Readonly<Record<string, readonly [number, number]>> = {\n ArrowLeft: [-1, 0],\n ArrowRight: [1, 0],\n ArrowUp: [0, -1],\n ArrowDown: [0, 1],\n};\n/** How far the pointer moves, in CSS pixels, before a press on the image draws a region. */\nconst DRAW_THRESHOLD = 3;\n/**\n * How close to an image pixel's edge, in CSS pixels, a pointer counts as on\n * it: a quarter of a screen pixel, finer than a pointer reports and coarser\n * than the layout's own rounding.\n */\nconst EDGE_TOLERANCE = 0.25;\n\n/** A rectangle on the composition, moved or with one handle dragged, at least 1 × 1. */\nfunction dragged(start: ImageRect, handle: Handle | \"move\", dx: number, dy: number): ImageRect {\n if (handle === \"move\") return { ...start, x: start.x + dx, y: start.y + dy };\n let left = start.x;\n let top = start.y;\n let right = start.x + start.width;\n let bottom = start.y + start.height;\n if (handle.includes(\"w\")) left = Math.min(left + dx, right - 1);\n if (handle.includes(\"e\")) right = Math.max(right + dx, left + 1);\n if (handle.includes(\"n\")) top = Math.min(top + dy, bottom - 1);\n if (handle.includes(\"s\")) bottom = Math.max(bottom + dy, top + 1);\n return { x: left, y: top, width: right - left, height: bottom - top };\n}\n\nexport interface RedactOverlayProps {\n /** The plan the stage shows: the session's, or a gesture's. */\n readonly plan: ImagePlan;\n readonly source: ImageSize;\n /** The stage's view, in CSS pixels. */\n readonly view: ImageView;\n}\n\n/**\n * The redactions as frames over the canvas (docs/adr/0010), placed with the\n * renderer's geometry. Each is a focusable group, named by its place in the\n * list and described by its mode and size, which arrow keys move, Shift\n * with them resizes, and Delete removes: the crop frame's keys. Dragging across the image\n * draws a new one. Handles are pointer targets only, hidden from assistive\n * technology: the keys and the panel's fields do what they do.\n *\n * Every gesture shows on the stage as a transient plan, which the renderer\n * draws with the redaction applied, and becomes one undoable step when it\n * ends.\n */\nexport function RedactOverlay(props: RedactOverlayProps): ReactNode {\n const { plan, source, view } = props;\n const [state] = useImageEditorState();\n const messages = useImageMessages();\n const actions = useRedactActions();\n const overlay = useRef<HTMLDivElement>(null);\n const describedBy = useId();\n const drag = useRef<\n | {\n pointer: number;\n x: number;\n y: number;\n key: string;\n handle: Handle | \"move\" | \"draw\";\n start: ImageRect;\n drawn: boolean;\n }\n | undefined\n >(undefined);\n /** The key whose frame takes focus once it's rendered: one just added or selected by the panel. */\n const focusNext = useRef<string | null>(null);\n /** The arrow keys held on a frame: one step per press, and per key held down. */\n const keys = useRef(createKeyRun());\n\n const selected = state.redact?.selected ?? null;\n const exists = plan.redactions.some((redaction) => redaction.key === selected);\n\n // A redaction selected from outside the stage, such as one the panel just\n // added, takes focus, unless focus is in the panel's own fields.\n const previous = useRef<string | null>(null);\n useEffect(() => {\n if (selected === previous.current) return;\n previous.current = selected;\n if (!selected || !exists || drag.current) return;\n const active = document.activeElement;\n const typing =\n active instanceof HTMLElement && active.closest(\".hm-image-redact-panel input\") !== null;\n if (typing) return;\n overlay.current\n ?.querySelector<HTMLElement>(`[data-hm-redaction=\"${CSS.escape(selected)}\"]`)\n ?.focus();\n }, [selected, exists]);\n\n // A region just drawn takes focus once its frame exists.\n useEffect(() => {\n const key = focusNext.current;\n if (!key || !plan.redactions.some((redaction) => redaction.key === key)) return;\n focusNext.current = null;\n overlay.current\n ?.querySelector<HTMLElement>(`[data-hm-redaction=\"${CSS.escape(key)}\"]`)\n ?.focus();\n });\n\n const crop = cropRect(plan.base.crop, source);\n const { orientation } = plan.base;\n const placed = placement(compositionSize(plan, source), view);\n // A stage with no size yet has nowhere to put the frames, and no scale for a drag.\n if (!(placed.scale > 0)) return null;\n const shown = (redaction: ImageRedaction) => sceneRectToComposition(redaction, crop, orientation);\n const toScene = (rect: ImageRect) => compositionRectToScene(rect, crop, orientation);\n\n /** A pointer's position on the composition, in its pixels. */\n const onComposition = (event: PointerEvent<HTMLElement>) => {\n const box = overlay.current?.getBoundingClientRect();\n return {\n x: (event.clientX - (box?.left ?? 0) - placed.x) / placed.scale,\n y: (event.clientY - (box?.top ?? 0) - placed.y) / placed.scale,\n };\n };\n\n const capture = (event: PointerEvent<HTMLElement>) => {\n try {\n // Keeps the drag when the pointer leaves the element; a pointer the\n // browser doesn't track can't be captured, and the drag still works.\n event.currentTarget.setPointerCapture(event.pointerId);\n } catch {}\n };\n\n const onFramePointerDown =\n (redaction: ImageRedaction, handle: Handle | \"move\") => (event: PointerEvent<HTMLElement>) => {\n if (event.button !== 0) return;\n // A pointer takes the gesture: a run of arrow keys still going ends first, as its own step.\n if (keys.current.handOff()) actions.commit();\n event.preventDefault();\n event.stopPropagation();\n actions.select(redaction.key);\n overlay.current\n ?.querySelector<HTMLElement>(`[data-hm-redaction=\"${CSS.escape(redaction.key)}\"]`)\n ?.focus();\n capture(event);\n drag.current = {\n pointer: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n key: redaction.key,\n handle,\n start: shown(redaction),\n drawn: false,\n };\n };\n\n const onBackgroundPointerDown = (event: PointerEvent<HTMLElement>) => {\n if (event.button !== 0) return;\n // A pointer takes the gesture: a run of arrow keys still going ends first, as its own step.\n if (keys.current.handOff()) actions.commit();\n event.preventDefault();\n capture(event);\n const at = onComposition(event);\n drag.current = {\n pointer: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n key: newRedactionKey(plan),\n handle: \"draw\",\n start: { x: at.x, y: at.y, width: 0, height: 0 },\n drawn: false,\n };\n };\n\n const onPointerMove = (event: PointerEvent<HTMLElement>) => {\n const current = drag.current;\n if (!current || current.pointer !== event.pointerId) return;\n const dx = (event.clientX - current.x) / placed.scale;\n const dy = (event.clientY - current.y) / placed.scale;\n if (current.handle === \"draw\") {\n const far =\n Math.hypot(event.clientX - current.x, event.clientY - current.y) >= DRAW_THRESHOLD;\n if (!current.drawn && !far) return;\n current.drawn = true;\n // Whole pixels, outward, so everything the drag touched is covered. A\n // pointer on a pixel's edge is on the edge, not a sliver past it.\n const EDGE = EDGE_TOLERANCE / placed.scale;\n const left = Math.floor(Math.min(current.start.x, current.start.x + dx) + EDGE);\n const top = Math.floor(Math.min(current.start.y, current.start.y + dy) + EDGE);\n const right = Math.ceil(Math.max(current.start.x, current.start.x + dx) - EDGE);\n const bottom = Math.ceil(Math.max(current.start.y, current.start.y + dy) - EDGE);\n actions.drawing(current.key, {\n x: left,\n y: top,\n width: Math.max(1, right - left),\n height: Math.max(1, bottom - top),\n });\n return;\n }\n current.drawn = true;\n // A move or a resize is by whole pixels, so moving never changes the size.\n actions.moving(\n current.key,\n toScene(dragged(current.start, current.handle, Math.round(dx), Math.round(dy))),\n );\n };\n\n const onPointerEnd = (event: PointerEvent<HTMLElement>) => {\n const current = drag.current;\n if (!current || current.pointer !== event.pointerId) return;\n drag.current = undefined;\n if (event.type === \"pointercancel\") {\n // A cancelled pointer, such as a lost capture, leaves the plan as it was.\n actions.cancel();\n return;\n }\n if (current.handle === \"draw\" && !current.drawn) {\n // A press on the image without a drag selects nothing.\n actions.select(null);\n return;\n }\n actions.commit();\n if (current.handle === \"draw\") {\n // Drawn: now it's selected, and takes focus once its frame is there.\n focusNext.current = current.key;\n actions.select(current.key);\n }\n };\n const pointer = { onPointerMove, onPointerUp: onPointerEnd, onPointerCancel: onPointerEnd };\n\n const onKeyDown = (redaction: ImageRedaction) => (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n // Escape during a drag, or while arrow keys are held, cancels it;\n // otherwise it ends redacting.\n if (drag.current) {\n drag.current = undefined;\n actions.cancel();\n } else if (keys.current.cancel()) {\n actions.cancel();\n } else {\n actions.done();\n }\n return;\n }\n if (event.key === \"Delete\" || event.key === \"Backspace\") {\n event.preventDefault();\n event.stopPropagation();\n // Focus moves to the next frame, or the one before, or the panel's button.\n const index = plan.redactions.findIndex((item) => item.key === redaction.key);\n const next = plan.redactions[index + 1] ?? plan.redactions[index - 1];\n actions.remove(redaction.key);\n if (next) actions.select(next.key);\n else {\n overlay.current\n ?.closest(\".hm-image-editor\")\n ?.querySelector<HTMLElement>(\".hm-image-redact-add\")\n ?.focus();\n }\n return;\n }\n const arrow = ARROWS[event.key];\n if (!arrow) return;\n // The frames' keys are the crop frame's (docs/adr/0007): the arrows\n // alone and with Shift. With Alt, Control or Meta they're the browser's\n // or the system's, such as Back and Forward, and are left alone.\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n event.preventDefault();\n // Handled here, so the editor's shortcuts don't also take the arrows.\n event.stopPropagation();\n // While a pointer drags, the arrows don't move the frame: the drag owns the gesture.\n if (drag.current) return;\n // A run cancelled with Escape is ignored until its keys are let go.\n if (!keys.current.press(event.key)) return;\n const [dx, dy] = arrow;\n // As seen on screen, whatever the plan's rotation and flips: Shift moves\n // the right edge with Left and Right, and the bottom edge with Up and Down.\n const moved = event.shiftKey\n ? dragged(shown(redaction), dx !== 0 ? \"e\" : \"s\", dx, dy)\n : dragged(shown(redaction), \"move\", dx, dy);\n // Shown at once; it's a step when the last key held is let go.\n actions.moving(redaction.key, toScene(moved));\n };\n const onKeyUp = (event: KeyboardEvent<HTMLDivElement>) => {\n if (ARROWS[event.key] && keys.current.release(event.key)) actions.commit();\n };\n // Focus leaving with a key held ends its run as one step: the key let go\n // elsewhere isn't seen.\n const onBlur = () => {\n if (keys.current.leave()) actions.commit();\n };\n\n const count = plan.redactions.length;\n // One tab stop: the selected frame, or the first when none is.\n const tabStop = exists ? selected : plan.redactions[0]?.key;\n return (\n <div\n ref={overlay}\n className=\"hm-image-redact-overlay\"\n onPointerDown={onBackgroundPointerDown}\n {...pointer}\n >\n {plan.redactions.map((redaction, index) => {\n const rect = shown(redaction);\n const isSelected = redaction.key === selected;\n return (\n // A positioned keyboard control over the canvas, not a form's fieldset (docs/adr/0007).\n // biome-ignore lint/a11y/useSemanticElements: a focusable group, not a fieldset\n <div\n key={redaction.key}\n className=\"hm-image-redact-frame\"\n data-hm-redaction={redaction.key}\n data-hm-selected={isSelected ? \"\" : undefined}\n role=\"group\"\n aria-label={messages.t(\"redact.frame\", { index: index + 1, count })}\n aria-describedby={`${describedBy}-${index}`}\n tabIndex={redaction.key === tabStop ? 0 : -1}\n style={{\n left: `${placed.x + rect.x * placed.scale}px`,\n top: `${placed.y + rect.y * placed.scale}px`,\n width: `${rect.width * placed.scale}px`,\n height: `${rect.height * placed.scale}px`,\n }}\n onFocus={() => actions.select(redaction.key)}\n onKeyDown={onKeyDown(redaction)}\n onKeyUp={onKeyUp}\n onBlur={onBlur}\n onPointerDown={onFramePointerDown(redaction, \"move\")}\n {...pointer}\n >\n <span id={`${describedBy}-${index}`} hidden>\n {messages.t(\"redact.frameDescription\", {\n mode: messages.t(`redact.modeNames.${redaction.mode}`),\n width: redaction.width,\n height: redaction.height,\n x: redaction.x,\n y: redaction.y,\n })}\n </span>\n {isSelected\n ? HANDLES.map((handle) => (\n <span\n key={handle}\n className=\"hm-image-redact-handle\"\n data-hm-handle={handle}\n aria-hidden=\"true\"\n onPointerDown={onFramePointerDown(redaction, handle)}\n {...pointer}\n />\n ))\n : null}\n </div>\n );\n })}\n </div>\n );\n}\n","import { CloseIcon, IconButton } from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useId, useState } from \"react\";\nimport { ANIMATION_LIMITS, type ImageLimitName } from \"../../core/errors/image-limits.js\";\nimport type { ImageSessionSource } from \"../../core/session/session.js\";\nimport { useImageDocument, useImageMessages } from \"../hooks.js\";\n\ninterface Notice {\n /** The source and the notice, so a dismissal holds for this image only. */\n readonly key: string;\n readonly text: string;\n}\n\n/** A limit warning's values, from what the session knows of the source. */\nfunction warningValues(limit: ImageLimitName, source: ImageSessionSource) {\n if (limit === \"maxFileSize\") return { actual: source.fileSize };\n // The frames the file lists: an animation open as a still holds one.\n if (limit === \"maxFrames\") return { actual: source.fileFrames };\n return {};\n}\n\n/**\n * The stage's notices (docs/adr/0007, \"Warnings\"): the limits the open image\n * came near, and, when it has a colour profile, that colours outside sRGB\n * are clipped on export (ADR 0005). They're polite, in a status region,\n * since nothing failed; errors stay alerts. Each can be dismissed for this\n * image, and shows again for another that has it.\n */\nexport function StageNotices(): ReactNode {\n const { source, warnings, status } = useImageDocument();\n const messages = useImageMessages();\n const id = useId();\n const [dismissed, setDismissed] = useState<ReadonlySet<string>>(() => new Set());\n if (!source || status !== \"ready\") return null;\n\n const t = messages.t as (key: string, values?: Record<string, number>) => string;\n const notices: Notice[] = [];\n /** An animated file that's open as a still: its first frame. */\n const firstFrameOnly = source.frames === 1 && source.fileFrames > 1;\n /** And it's a still because it's over a limit on animations (docs/adr/0011). */\n const tooLarge = firstFrameOnly && ANIMATION_LIMITS.some((limit) => warnings.includes(limit));\n if (tooLarge) {\n // One notice says why it's a still, whichever limits it's over.\n notices.push({\n key: `${source.id}:animationTooLarge`,\n text: messages.t(\"notices.animationTooLarge\"),\n });\n }\n for (const limit of warnings) {\n // The session reports only per-file limits when it opens an image.\n if (limit === \"maxSessionSize\" || limit === \"maxLayers\") continue;\n // Said already, above: these are why the file is a still.\n if (tooLarge && (ANIMATION_LIMITS as readonly string[]).includes(limit)) continue;\n notices.push({\n key: `${source.id}:${limit}`,\n text: t(`warnings.${limit}`, warningValues(limit, source)),\n });\n }\n // An animation that isn't all there, or isn't open as one (docs/adr/0011).\n if (source.incomplete) {\n notices.push({\n key: `${source.id}:incomplete`,\n text: t(source.frames < source.fileFrames ? \"notices.incomplete\" : \"notices.incompleteEnd\", {\n frames: source.frames,\n listed: source.fileFrames,\n }),\n });\n } else if (firstFrameOnly && !tooLarge) {\n notices.push({ key: `${source.id}:firstFrame`, text: messages.t(\"notices.firstFrame\") });\n }\n if (source.metadata.colourProfile) {\n notices.push({ key: `${source.id}:colourProfile`, text: messages.t(\"notices.colourProfile\") });\n }\n const shown = notices.filter((notice) => !dismissed.has(notice.key));\n\n // The region stays while an image is open, so a notice that appears in it\n // is announced; an empty one shows nothing.\n return (\n <div className=\"hm-image-stage-notices\" role=\"status\" aria-label={messages.t(\"notices.label\")}>\n {shown.length > 0 ? (\n <ul>\n {shown.map((notice, index) => (\n <li key={notice.key} className=\"hm-image-stage-notice\">\n <span id={`${id}-${index}`}>{notice.text}</span>\n <IconButton\n label={messages.t(\"notices.dismiss\")}\n aria-describedby={`${id}-${index}`}\n icon={<CloseIcon />}\n size=\"small\"\n variant=\"quiet\"\n onClick={() => setDismissed((before) => new Set(before).add(notice.key))}\n />\n </li>\n ))}\n </ul>\n ) : null}\n </div>\n );\n}\n","import { Button, FileDropZone, ProgressBar, Spinner } from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useEffect, useMemo, useRef, useState } from \"react\";\nimport { createImageRenderer } from \"../../adapters/image-renderer.js\";\nimport { compositionSize } from \"../../core/model/geometry.js\";\nimport { createPlan, type ImagePlan } from \"../../core/model/plan.js\";\nimport type { ImageRenderer } from \"../../core/ports/image-renderer.js\";\nimport { CropFrame } from \"../crop/CropFrame.js\";\nimport { DrawOverlay } from \"../draw/DrawOverlay.js\";\nimport {\n useImageDocument,\n useImageEditorState,\n useImageInternals,\n useImageView,\n} from \"../hooks.js\";\nimport { LayersOverlay } from \"../layers/LayersOverlay.js\";\nimport { RedactOverlay } from \"../redact/RedactOverlay.js\";\nimport { StageNotices } from \"./StageNotices.js\";\n\n/**\n * Props of {@link ImageStage}.\n *\n * @public\n */\nexport interface ImageStageProps {\n /** Extra classes on the stage. */\n readonly className?: string;\n}\n\n/**\n * The margin the image keeps inside the stage while cropping: half of the\n * largest handle target, 44 pixels on touch, so no handle is cut off where\n * the image meets the stage's edge (docs/adr/0007).\n */\nconst CROP_INSET = 24;\n\n/** The stage's size in CSS pixels, and the device pixel ratio. */\ninterface StageSize {\n readonly width: number;\n readonly height: number;\n readonly pixelRatio: number;\n}\n\n/** Follows an element's size and the device pixel ratio. */\nfunction useStageSize(element: HTMLElement | null): StageSize | undefined {\n const [size, setSize] = useState<StageSize>();\n useEffect(() => {\n if (!element) return;\n let ratioQuery: MediaQueryList | undefined;\n const measure = () => {\n const { width, height } = element.getBoundingClientRect();\n const pixelRatio = globalThis.devicePixelRatio || 1;\n setSize((current) =>\n current?.width === width && current.height === height && current.pixelRatio === pixelRatio\n ? current\n : { width, height, pixelRatio },\n );\n };\n // A change of devicePixelRatio, such as moving to another screen, ends the\n // current query's match: listen again for the new ratio.\n const watchRatio = () => {\n ratioQuery?.removeEventListener(\"change\", onRatio);\n ratioQuery = globalThis.matchMedia?.(`(resolution: ${globalThis.devicePixelRatio || 1}dppx)`);\n ratioQuery?.addEventListener(\"change\", onRatio);\n };\n const onRatio = () => {\n measure();\n watchRatio();\n };\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n measure();\n watchRatio();\n return () => {\n observer.disconnect();\n ratioQuery?.removeEventListener(\"change\", onRatio);\n };\n }, [element]);\n return size;\n}\n\n/**\n * The frame of an animated plan the stage shows: the one asked for, or the\n * last when frames were removed under it (docs/adr/0011).\n *\n * @internal\n */\nexport function shownFrame(plan: ImagePlan, frame: number): number {\n const count = plan.animation?.frames.length ?? 1;\n return Math.min(Math.max(0, frame), count - 1);\n}\n\n/**\n * The editor's stage (docs/adr/0007): the preview canvas, drawn by the\n * engine's render worker, with the designed states around it. With no image\n * it's a drop zone with a button to choose one; while an image opens, a\n * spinner with a cancel button over the current one; after a failure, the\n * catalogue's text for it.\n *\n * The canvas is `role=\"img\"`, named with the image's size, and isn't in the\n * tab order. It's created in an effect, never rendered by React: a canvas\n * transferred to a worker can't be transferred again, and StrictMode mounts\n * effects twice.\n *\n * @public\n */\nexport function ImageStage(props: ImageStageProps): ReactNode {\n const { engine, messages, opener, inserter } = useImageInternals();\n const snapshot = useImageDocument();\n const [view] = useImageView();\n const [frame, setFrame] = useState<HTMLDivElement | null>(null);\n const size = useStageSize(frame);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const rendererRef = useRef<\n { renderer: ImageRenderer; attached: Promise<void>; failed: boolean } | undefined\n >(undefined);\n const [editorState] = useImageEditorState();\n const { source, status } = snapshot;\n const cropping = editorState.tool === \"crop\";\n const redacting = editorState.tool === \"redact\";\n // Room around the image for the handles of a frame at its edge.\n const layering = editorState.tool === \"layers\";\n const drawing = editorState.tool === \"draw\";\n // The same room while drawing, so the image doesn't move between it and the layers.\n const inset = cropping || redacting || layering || drawing ? CROP_INSET : 0;\n // What the stage shows: while cropping, the whole image under the plan's\n // other edits; during a gesture, its transient plan; otherwise the plan.\n // With no document yet, an animation being opened shows its first frame\n // while the rest are checked, as a still (docs/adr/0011).\n const opening = snapshot.plan === null ? snapshot.openingFrame : null;\n const plan = useMemo(() => {\n const committed = snapshot.plan;\n if (!committed) return opening ? createPlan(opening.source) : null;\n if (cropping) return { ...committed, base: { ...committed.base, crop: null } };\n return editorState.preview ?? committed;\n }, [snapshot.plan, cropping, editorState.preview, opening]);\n\n // The canvas and its renderer live and die with this effect.\n useEffect(() => {\n if (!frame) return;\n const canvas = document.createElement(\"canvas\");\n canvas.className = \"hm-image-stage-canvas\";\n canvas.setAttribute(\"role\", \"img\");\n frame.append(canvas);\n canvasRef.current = canvas;\n const renderer = createImageRenderer(engine);\n const current = { renderer, attached: renderer.attach(canvas), failed: false };\n current.attached.catch(() => {\n current.failed = true;\n });\n rendererRef.current = current;\n return () => {\n rendererRef.current = undefined;\n canvasRef.current = null;\n void renderer.destroy();\n canvas.remove();\n };\n }, [engine, frame]);\n\n /** Whether the canvas shows the first frame of a file still opening. */\n const showingOpening = snapshot.plan === null && opening !== null;\n // Its name says what it shows, and changes with the document, not each render.\n const composition = plan && source ? compositionSize(plan, source) : (opening ?? undefined);\n const shownWidth = composition?.width;\n const shownHeight = composition?.height;\n useEffect(() => {\n // The canvas appears in the commit after the frame does, so this runs\n // again then.\n const canvas = frame ? canvasRef.current : null;\n if (!canvas) return;\n canvas.hidden = shownWidth === undefined || shownHeight === undefined;\n if (shownWidth !== undefined && shownHeight !== undefined) {\n canvas.setAttribute(\n \"aria-label\",\n messages.t(showingOpening ? \"editor.openingPreview\" : \"editor.preview\", {\n width: shownWidth,\n height: shownHeight,\n }),\n );\n } else {\n canvas.removeAttribute(\"aria-label\");\n }\n }, [shownWidth, shownHeight, messages, frame, showingOpening]);\n\n // Every change of plan, view or size renders; the renderer keeps the latest.\n useEffect(() => {\n const current = rendererRef.current;\n if (!current || !plan || !size || size.width < 1 || size.height < 1) return;\n const { renderer } = current;\n // A later explicit open may succeed after a startup/handshake failure.\n // No canvas was transferred before setup succeeded. Terminal engines\n // reject here and their boundary removes this stage; nothing restarts.\n if (current.failed && canvasRef.current) {\n current.failed = false;\n current.attached = renderer.attach(canvasRef.current);\n current.attached.catch(() => {\n current.failed = true;\n });\n }\n void current.attached\n .then(() =>\n renderer.render(plan, {\n width: size.width,\n height: size.height,\n pixelRatio: size.pixelRatio,\n zoom: view.zoom,\n pan: view.pan,\n inset,\n // An animation's frame being shown, kept within its frames as they change.\n ...(plan.animation === null\n ? {}\n : { frame: shownFrame(plan, editorState.playback.frame) }),\n }),\n )\n .catch(() => {\n // A render that fails leaves the previous frame; the session's state is unaffected.\n });\n }, [plan, view, size, inset, editorState.playback.frame]);\n\n const className = [\"hm-image-stage\", props.className].filter(Boolean).join(\" \");\n const empty = status === \"empty\" && !snapshot.opening;\n // The document's failure, or what an editor's own action failed with.\n const failure = snapshot.error ?? editorState.error;\n const error = failure ? (\n <p className=\"hm-image-stage-error\" role=\"alert\">\n {messages.error(failure)}\n </p>\n ) : null;\n return (\n <div className={className} data-status={status}>\n <div className=\"hm-image-stage-frame\" ref={setFrame} />\n {cropping && snapshot.plan && source && size ? (\n <div className=\"hm-image-stage-overlay\">\n <CropFrame\n plan={snapshot.plan}\n source={source}\n view={{\n width: size.width,\n height: size.height,\n pixelRatio: 1,\n zoom: view.zoom,\n pan: view.pan,\n inset,\n }}\n />\n </div>\n ) : null}\n {redacting && plan && source && size ? (\n <div className=\"hm-image-stage-overlay\">\n <RedactOverlay\n plan={plan}\n source={source}\n view={{\n width: size.width,\n height: size.height,\n pixelRatio: 1,\n zoom: view.zoom,\n pan: view.pan,\n inset,\n }}\n />\n </div>\n ) : null}\n {layering && plan && source && size ? (\n <div className=\"hm-image-stage-overlay\">\n <LayersOverlay\n plan={plan}\n source={source}\n view={{\n width: size.width,\n height: size.height,\n pixelRatio: 1,\n zoom: view.zoom,\n pan: view.pan,\n inset,\n }}\n />\n </div>\n ) : null}\n {drawing && plan && source && size ? (\n <div className=\"hm-image-stage-overlay\">\n <DrawOverlay\n plan={plan}\n source={source}\n view={{\n width: size.width,\n height: size.height,\n pixelRatio: 1,\n zoom: view.zoom,\n pan: view.pan,\n inset,\n }}\n />\n </div>\n ) : null}\n {empty ? (\n <FileDropZone\n className=\"hm-image-stage-drop\"\n accept=\"image/*\"\n onFiles={(files) => {\n const [file] = files;\n if (file) void opener.open(file);\n }}\n buttonLabel={messages.t(\"editor.choose\")}\n hint={messages.t(\"editor.dropHint\")}\n >\n <p className=\"hm-image-stage-empty\">{messages.t(\"editor.empty\")}</p>\n {/* With no image, the failure sits in the drop zone, by the button that retries. */}\n {error}\n </FileDropZone>\n ) : null}\n {snapshot.opening || snapshot.inserting ? (\n <div\n className={\n showingOpening\n ? \"hm-image-stage-opening hm-image-stage-opening--over-image\"\n : \"hm-image-stage-opening\"\n }\n >\n {snapshot.opening && snapshot.progress ? (\n // An animation's frames are checked one by one (docs/adr/0011):\n // how far that's got, in words, where the spinner would be.\n <>\n <ProgressBar\n label={messages.t(\"editor.opening\")}\n value={snapshot.progress.done}\n max={snapshot.progress.total}\n valueText={messages.t(\"editor.checkingFrames\", snapshot.progress)}\n />\n <span aria-hidden=\"true\">\n {messages.t(\"editor.checkingFrames\", snapshot.progress)}\n </span>\n </>\n ) : (\n <Spinner label={messages.t(snapshot.opening ? \"editor.opening\" : \"editor.inserting\")} />\n )}\n <Button\n variant=\"secondary\"\n onClick={() => (snapshot.opening ? opener.cancel() : inserter.cancel())}\n >\n {messages.t(\"editor.cancel\")}\n </Button>\n </div>\n ) : null}\n {/* Over an image, the notices and a failure stack at the stage's foot. */}\n {empty ? null : (\n <div className=\"hm-image-stage-foot\">\n <StageNotices />\n {error}\n </div>\n )}\n </div>\n );\n}\n","import { createContext } from \"react\";\nimport type { ImageKeepableMetadata, ImageMetadataPresence } from \"../../core/model/source.js\";\nimport type { ImageExportFormat } from \"../../core/ports/image-processor.js\";\n\n/**\n * What the export dialog reports about a finished export, for the element's\n * `export` event: no pixels and no file, which an event must never carry\n * (sdk-core ADR 0012). The element's `export()` method returns the file.\n *\n * @public\n */\nexport interface ImageExportReport {\n readonly format: ImageExportFormat[\"type\"];\n readonly width: number;\n readonly height: number;\n /** The file's size in bytes. */\n readonly size: number;\n readonly removed: readonly (keyof ImageMetadataPresence)[];\n readonly kept: readonly (keyof ImageKeepableMetadata)[];\n}\n\n/** Hears about every export the dialog finishes; the element provides it. */\nexport const ExportListenerContext = createContext<((report: ImageExportReport) => void) | null>(\n null,\n);\n","import {\n Button,\n Dialog,\n Field,\n NumberField,\n ProgressBar,\n SegmentedControl,\n Slider,\n TextField,\n useAnnounce,\n} from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useContext, useEffect, useRef, useState } from \"react\";\nimport { engineInternals } from \"../../adapters/image-engine.js\";\nimport { isImageError } from \"../../core/errors/image-error.js\";\nimport { compositionSize, outputSize } from \"../../core/model/geometry.js\";\nimport type { ImageOutput, ImagePlan } from \"../../core/model/plan.js\";\nimport {\n type ImageKeepableMetadata,\n type ImageMetadataPresence,\n longerThan,\n MAX_METADATA_LENGTH,\n} from \"../../core/model/source.js\";\nimport type { ImageCommand } from \"../../core/operations/commands.js\";\nimport { type ImageExportFormat, keepsFields } from \"../../core/ports/image-processor.js\";\nimport type { ImageSessionExport, ImageSessionSource } from \"../../core/session/session.js\";\nimport {\n useImageDocument,\n useImageEditorState,\n useImageInternals,\n useImageMessages,\n useImageSession,\n} from \"../hooks.js\";\nimport { shownFrame } from \"../stage/ImageStage.js\";\nimport { ExportListenerContext } from \"./export-listener.js\";\n\n/**\n * Props of {@link ImageExportDialog}.\n *\n * @public\n */\nexport interface ImageExportDialogProps {\n /**\n * Takes the exported file instead of the dialog's download button: the\n * dialog closes once it's called.\n */\n readonly onExport?: (blob: Blob, details: ImageSessionExport) => void;\n /** The downloaded file's name, without its extension. Defaults to `image`. */\n readonly fileName?: string;\n /** Extra classes on the dialog. */\n readonly className?: string;\n}\n\ntype FormatType = ImageExportFormat[\"type\"];\n\n/** The dialog's choices, until Export applies them to the plan. */\ninterface Draft {\n readonly format: FormatType;\n /** For JPEG and WebP, 1 to 100. */\n readonly quality: number;\n readonly output: ImageOutput;\n readonly metadata: ImageKeepableMetadata;\n}\n\ntype Phase =\n | { readonly kind: \"choose\" }\n | { readonly kind: \"exporting\"; readonly progress: number }\n | { readonly kind: \"done\"; readonly result: ImageSessionExport; readonly format: FormatType };\n\nconst FORMATS: readonly FormatType[] = [\"png\", \"jpeg\", \"webp\", \"gif\"];\nconst EXTENSIONS: Readonly<Record<FormatType, string>> = {\n png: \"png\",\n jpeg: \"jpg\",\n webp: \"webp\",\n gif: \"gif\",\n};\n/** The formats with a quality to choose: the lossy ones. */\nconst LOSSY: ReadonlySet<FormatType> = new Set([\"jpeg\", \"webp\"]);\nconst FIELDS: readonly (keyof ImageKeepableMetadata)[] = [\n \"title\",\n \"description\",\n \"artist\",\n \"copyright\",\n];\nconst KINDS: readonly (keyof ImageMetadataPresence)[] = [\n \"location\",\n \"camera\",\n \"timestamps\",\n \"thumbnail\",\n \"colourProfile\",\n \"other\",\n];\nconst DEFAULT_QUALITY = 92;\n\n/**\n * A field's text, clamped to the limit in code points, as the plan counts\n * it. An input's `maxLength` counts UTF-16 units, which would stop at half\n * as many emoji.\n */\nconst keepable = (text: string) =>\n longerThan(text, MAX_METADATA_LENGTH) ? [...text].slice(0, MAX_METADATA_LENGTH).join(\"\") : text;\n\n/** The choices a dialog opens with: the plan's size and fields, in the source's format if it can be written. */\nfunction initialDraft(plan: ImagePlan, source: ImageSessionSource): Draft {\n const format = (FORMATS as readonly string[]).includes(source.format)\n ? (source.format as FormatType)\n : \"png\";\n return { format, quality: DEFAULT_QUALITY, output: plan.output, metadata: plan.metadata };\n}\n\nconst sameOutput = (a: ImageOutput, b: ImageOutput) =>\n a.kind === \"scale\" && b.kind === \"scale\"\n ? a.scale === b.scale\n : a.kind === \"fit\" && b.kind === \"fit\" && a.width === b.width && a.height === b.height;\n\n/** The commands that bring the plan's size and fields to the dialog's choices. */\nfunction changes(plan: ImagePlan, draft: Draft): ImageCommand[] {\n const commands: ImageCommand[] = [];\n if (!sameOutput(plan.output, draft.output)) {\n commands.push({ type: \"image.setOutput\", output: draft.output });\n }\n for (const field of FIELDS) {\n if (plan.metadata[field] !== draft.metadata[field]) {\n commands.push({ type: \"image.setMetadata\", field, value: draft.metadata[field] });\n }\n }\n return commands;\n}\n\nconst formatOf = (draft: Draft): ImageExportFormat =>\n draft.format === \"jpeg\" || draft.format === \"webp\"\n ? { type: draft.format, quality: draft.quality / 100 }\n : { type: draft.format };\n\n/**\n * The export dialog (docs/adr/0007). Export is irreversible, so it shows a\n * summary before anything is written: the output's size and format, the\n * metadata the source carried that the file won't, and the fields the user\n * chose to keep. Then a progress bar that can stop the export, and a\n * download button, which gets focus, with the file's size.\n *\n * It opens when the editor state's `dialog` is `export`, as the export tool\n * sets it. On Export, the chosen size and fields become one undoable step\n * of the plan, so the plan records what was exported. A format the browser\n * can't encode shows the catalogue's text, and keeps the choices.\n *\n * @public\n */\nexport function ImageExportDialog(props: ImageExportDialogProps): ReactNode {\n const { onExport, fileName = \"image\" } = props;\n const { engine, emit } = useImageInternals();\n const lifecycle = engineInternals(engine);\n const session = useImageSession();\n const { plan, source } = useImageDocument();\n const [editor, editorStore] = useImageEditorState();\n const messages = useImageMessages();\n const announce = useAnnounce();\n const listener = useContext(ExportListenerContext);\n const [draft, setDraft] = useState<Draft | null>(null);\n const [phase, setPhase] = useState<Phase>({ kind: \"choose\" });\n const [error, setError] = useState<unknown>(null);\n const controller = useRef<AbortController | null>(null);\n const objectUrl = useRef<string | null>(null);\n const downloadButton = useRef<HTMLButtonElement>(null);\n\n const open = editor.dialog === \"export\" && plan !== null && source !== null;\n const current = draft ?? (plan && source ? initialDraft(plan, source) : null);\n\n const revoke = () => {\n if (objectUrl.current) URL.revokeObjectURL(objectUrl.current);\n objectUrl.current = null;\n };\n // Whatever closes the dialog, such as another image opening, ends its\n // export and drops its choices and result, so it reopens fresh. The\n // controller is cleared before the abort, so the export's own handlers\n // know it was ended for them, unlike Stop.\n useEffect(() => {\n if (open) return;\n const running = controller.current;\n controller.current = null;\n running?.abort();\n if (objectUrl.current) URL.revokeObjectURL(objectUrl.current);\n objectUrl.current = null;\n setDraft(null);\n setPhase((now) => (now.kind === \"choose\" ? now : { kind: \"choose\" }));\n setError(null);\n }, [open]);\n\n // Unmounting ends an export too, and frees a download's URL.\n useEffect(\n () => () => {\n controller.current?.abort();\n controller.current = null;\n if (objectUrl.current) URL.revokeObjectURL(objectUrl.current);\n },\n [],\n );\n\n // The download button takes focus when the file is ready.\n const done = phase.kind === \"done\";\n useEffect(() => {\n if (done) downloadButton.current?.focus();\n }, [done]);\n\n /** Asks the editor to close the dialog; the effect on `open` resets it. */\n const close = () => {\n editorStore.set((state) => (state.dialog === null ? state : { ...state, dialog: null }));\n };\n\n if (!plan || !source || !current) {\n return null;\n }\n\n const update = (patch: Partial<Draft>) => setDraft({ ...current, ...patch });\n const formatName = (format: FormatType) => messages.t(`export.formats.${format}`);\n\n const run = async () => {\n setError(null);\n try {\n const commands = changes(plan, current);\n if (commands.length > 0) session.execute(commands);\n } catch (reason) {\n setError(reason);\n return;\n }\n const running = new AbortController();\n controller.current = running;\n setPhase({ kind: \"exporting\", progress: 0 });\n try {\n const format = formatOf(current);\n const result = await session.export(format, {\n signal: running.signal,\n // An animation exports as the frame shown, except to GIF, which writes them all (docs/adr/0011).\n ...(plan.animation !== null && format.type !== \"gif\"\n ? { frame: shownFrame(plan, editor.playback.frame) }\n : {}),\n onProgress: (progress) =>\n setPhase((now) => (now.kind === \"exporting\" ? { kind: \"exporting\", progress } : now)),\n });\n // Closed while it ran: the result belongs to no one.\n if (controller.current !== running || lifecycle?.getSnapshot()) return;\n controller.current = null;\n announce(\n messages.t(\"export.done\", { format: formatName(current.format), size: result.blob.size }),\n );\n listener?.({\n format: current.format,\n width: result.width,\n height: result.height,\n size: result.blob.size,\n removed: result.removed,\n kept: result.kept,\n });\n if (onExport) {\n onExport(result.blob, result);\n close();\n return;\n }\n setPhase({ kind: \"done\", result, format: current.format });\n } catch (reason) {\n // Closed while it ran: the reset dialog shows nothing of it.\n if (controller.current !== running || lifecycle?.getSnapshot()) return;\n controller.current = null;\n setPhase({ kind: \"choose\" });\n if (isImageError(reason) && reason.code === \"ABORTED\") {\n announce(messages.t(\"export.cancelled\"));\n return;\n }\n setError(reason);\n }\n };\n\n const stop = () => controller.current?.abort();\n\n const download = () => {\n if (phase.kind !== \"done\" || lifecycle?.getSnapshot()) return;\n revoke();\n objectUrl.current = URL.createObjectURL(phase.result.blob);\n const link = document.createElement(\"a\");\n link.href = objectUrl.current;\n link.download = `${fileName}.${EXTENSIONS[phase.format]}`;\n link.click();\n // The browser is asked to download the file: what a host's guard against\n // leaving unsaved work waits for, which the export alone doesn't mean. It\n // isn't a confirmed save (docs/adr/0007).\n emit({ type: \"download\", outcome: \"done\", commands: [] });\n };\n\n const composition = compositionSize(plan, source);\n const size = outputSize(current.output, composition);\n const removed = KINDS.filter((kind) => source.metadata[kind]);\n // WebP and GIF carry no details: the fields the user filled in aren't written.\n const writesFields = keepsFields(current.format);\n const kept = writesFields ? FIELDS.filter((field) => current.metadata[field] !== \"\") : [];\n const exporting = phase.kind === \"exporting\";\n\n const footer =\n phase.kind === \"done\" ? (\n <>\n <Button variant=\"secondary\" onClick={close}>\n {messages.t(\"export.close\")}\n </Button>\n <Button ref={downloadButton} variant=\"primary\" onClick={download}>\n {messages.t(\"export.download\")}\n </Button>\n </>\n ) : exporting ? (\n <Button variant=\"secondary\" onClick={stop}>\n {messages.t(\"export.stop\")}\n </Button>\n ) : (\n <>\n <Button variant=\"secondary\" onClick={close}>\n {messages.t(\"export.cancel\")}\n </Button>\n <Button variant=\"primary\" onClick={() => void run()}>\n {messages.t(\"export.confirm\")}\n </Button>\n </>\n );\n\n return (\n <Dialog\n open={open}\n onOpenChange={(next) => {\n if (!next) close();\n }}\n title={messages.t(\"export.title\")}\n description={messages.t(\"export.description\")}\n footer={footer}\n className={[\"hm-image-export\", props.className].filter(Boolean).join(\" \")}\n >\n {phase.kind === \"done\" ? (\n <p className=\"hm-image-export-result\">\n {messages.t(\"export.ready\", {\n width: phase.result.width,\n height: phase.result.height,\n format: formatName(phase.format),\n size: phase.result.blob.size,\n })}\n </p>\n ) : (\n <>\n <fieldset className=\"hm-image-export-choices\" disabled={exporting}>\n <SegmentedControl\n label={messages.t(\"export.format\")}\n value={current.format}\n size=\"small\"\n options={FORMATS.map((format) => ({ value: format, label: formatName(format) }))}\n onValueChange={(format) => update({ format: format as FormatType })}\n />\n {!LOSSY.has(current.format) ? null : (\n <Field label={messages.t(\"export.quality\")} className=\"hm-image-slider-field\">\n {(control) => (\n <div className=\"hm-image-adjust-row\">\n <Slider\n {...control}\n min={1}\n max={100}\n step={1}\n largeStep={10}\n value={current.quality}\n formatValue={(quality) => messages.t(\"export.qualityValue\", { quality })}\n onValueChange={(quality) => update({ quality: Math.round(quality) })}\n />\n <output className=\"hm-image-adjust-value\" aria-hidden=\"true\">\n {messages.t(\"export.qualityValue\", { quality: current.quality })}\n </output>\n </div>\n )}\n </Field>\n )}\n <SegmentedControl\n label={messages.t(\"export.size\")}\n value={current.output.kind}\n size=\"small\"\n options={[\n { value: \"scale\", label: messages.t(\"export.sizes.scale\") },\n { value: \"fit\", label: messages.t(\"export.sizes.fit\") },\n ]}\n onValueChange={(kind) =>\n update({\n output:\n kind === \"fit\"\n ? { kind: \"fit\", width: composition.width, height: composition.height }\n : { kind: \"scale\", scale: 1 },\n })\n }\n />\n <div className=\"hm-image-export-fields\">\n {current.output.kind === \"scale\" ? (\n <Field label={messages.t(\"export.scale\")}>\n <NumberField\n value={Math.round(current.output.scale * 100)}\n min={1}\n max={100}\n step={1}\n largeStep={10}\n onValueChange={(percent) =>\n update({ output: { kind: \"scale\", scale: Math.round(percent) / 100 } })\n }\n />\n </Field>\n ) : (\n ([\"width\", \"height\"] as const).map((side) => {\n const output = current.output as Extract<ImageOutput, { kind: \"fit\" }>;\n return (\n <Field\n key={side}\n label={messages.t(side === \"width\" ? \"export.fitWidth\" : \"export.fitHeight\")}\n >\n <NumberField\n value={output[side]}\n min={1}\n step={1}\n largeStep={100}\n onValueChange={(value) =>\n update({ output: { ...output, [side]: Math.max(1, Math.round(value)) } })\n }\n />\n </Field>\n );\n })\n )}\n </div>\n <fieldset className=\"hm-image-export-metadata\">\n <legend>{messages.t(\"export.fields\")}</legend>\n <p className=\"hm-image-export-hint\">\n {writesFields\n ? messages.t(\"export.fieldsHint\")\n : messages.t(\"export.fieldsNone\", { format: formatName(current.format) })}\n </p>\n <div className=\"hm-image-export-fields\">\n {FIELDS.map((field) => (\n <Field key={field} label={messages.t(`export.field.${field}`)}>\n <TextField\n autoComplete=\"off\"\n value={current.metadata[field]}\n onValueChange={(value) =>\n update({ metadata: { ...current.metadata, [field]: keepable(value) } })\n }\n />\n </Field>\n ))}\n </div>\n </fieldset>\n </fieldset>\n <section className=\"hm-image-export-summary\" aria-label={messages.t(\"export.summary\")}>\n <p>\n {messages.t(\"export.output\", {\n width: size.width,\n height: size.height,\n format: formatName(current.format),\n })}\n </p>\n {plan.redactions.length > 0 ? (\n <p>\n {messages.t(\"export.redacted\", { count: plan.redactions.length })}\n {plan.redactions.some((redaction) => redaction.mode === \"pixelate\")\n ? ` ${messages.t(\"export.redactedPixelated\")}`\n : null}\n </p>\n ) : null}\n {removed.length > 0 ? (\n <>\n <p>{messages.t(\"export.removed\")}</p>\n <ul>\n {removed.map((kind) => (\n <li key={kind}>{messages.t(`export.kind.${kind}`)}</li>\n ))}\n </ul>\n </>\n ) : (\n <p>{messages.t(\"export.removedNone\")}</p>\n )}\n {kept.length > 0 ? (\n <>\n <p>{messages.t(\"export.kept\")}</p>\n <ul>\n {kept.map((field) => (\n <li key={field}>{messages.t(`export.field.${field}`)}</li>\n ))}\n </ul>\n </>\n ) : null}\n </section>\n {exporting ? (\n <ProgressBar\n label={messages.t(\"export.progress\")}\n value={Math.round(phase.progress * 100)}\n max={100}\n />\n ) : null}\n {error ? (\n <p className=\"hm-image-export-error\" role=\"alert\">\n {messages.error(error)}\n </p>\n ) : null}\n </>\n )}\n </Dialog>\n );\n}\n","import { defineMessages, plural } from \"@hussmartinez/sdk-core\";\n\n/**\n * The text of the SDK's interface: the editor, its stage, toolbar and\n * tools, its panels and the export dialog. Only the React entry loads it,\n * through `imageEditorMessages`, so the server-safe entry carries no\n * interface text (docs/adr/0012). Keys use the components' prefixes, never\n * `errors.`, `warnings.` or one of ui's (sdk-core ADR 0046).\n */\nexport const imageEditorText = /* @__PURE__ */ defineMessages({\n \"editor.engineUnavailable\":\n \"Image processing stopped. Reload this page or reopen the editor, then choose the image again. Unsaved edits will be lost unless your application has saved them.\",\n \"editor.label\": \"Image editor\",\n \"editor.preview\": \"Edited image preview, {width, number} × {height, number}\",\n \"editor.openingPreview\":\n \"First frame of the image being opened, {width, number} × {height, number}\",\n \"editor.empty\": \"Open an image to start editing. It stays on this device.\",\n \"editor.choose\": \"Choose an image\",\n \"editor.dropHint\": \"or drop it here\",\n \"editor.opening\": \"Opening the image…\",\n \"editor.checkingFrames\": \"Checking frames: {done, number} of {total, number}\",\n \"editor.cancel\": \"Cancel\",\n \"editor.opened\": \"Image opened, {width, number} × {height, number}.\",\n \"editor.undid\": \"Undid {action}.\",\n \"editor.redid\": \"Redid {action}.\",\n \"actions.image.setCrop\": \"crop\",\n \"actions.image.setOrientation\": \"rotate or flip\",\n \"actions.image.setOutput\": \"size\",\n \"actions.image.setMetadata\": \"metadata\",\n \"actions.image.setDevelop\": \"adjustment\",\n \"actions.image.setFilter\": \"filter\",\n \"actions.image.insertLayers\": \"layer\",\n \"actions.image.removeLayers\": \"layer\",\n \"actions.image.restoreLayers\": \"layer\",\n \"actions.image.moveLayers\": \"layer order\",\n \"actions.image.setLayerOrder\": \"layer order\",\n \"actions.image.updateLayers\": \"layer change\",\n \"actions.image.addStrokes\": \"stroke\",\n \"actions.image.removeStrokes\": \"stroke\",\n \"actions.image.restoreStrokes\": \"stroke\",\n \"actions.image.insertRedactions\": \"redaction\",\n \"actions.image.removeRedactions\": \"redaction\",\n \"actions.image.restoreRedactions\": \"redaction\",\n \"actions.image.moveRedactions\": \"redaction order\",\n \"actions.image.setRedactionOrder\": \"redaction order\",\n \"actions.image.updateRedactions\": \"redaction change\",\n \"actions.image.insertFrames\": \"frame\",\n \"actions.image.removeFrames\": \"frame\",\n \"actions.image.restoreFrames\": \"frame\",\n \"actions.image.moveFrames\": \"frame order\",\n \"actions.image.setFrameOrder\": \"frame order\",\n \"actions.image.reverseFrames\": \"frame order\",\n \"actions.image.updateFrames\": \"frame timing\",\n \"actions.image.setLoop\": \"repeat count\",\n \"toolbar.label\": \"Image tools\",\n \"toolbar.groups.file\": \"File\",\n \"toolbar.groups.history\": \"History\",\n \"toolbar.groups.orientation\": \"Rotate\",\n \"toolbar.groups.zoom\": \"Zoom\",\n \"toolbar.groups.other\": \"More tools\",\n \"tools.open\": \"Open image\",\n \"tools.undo\": \"Undo\",\n \"tools.play\": \"Play\",\n \"tools.redo\": \"Redo\",\n \"tools.rotate-left\": \"Rotate left\",\n \"tools.rotate-right\": \"Rotate right\",\n \"tools.zoom-in\": \"Zoom in\",\n \"tools.zoom-out\": \"Zoom out\",\n \"tools.zoom-fit\": \"Fit to the stage\",\n \"tools.crop\": \"Crop\",\n \"tools.flip-horizontal\": \"Flip horizontally\",\n \"tools.flip-vertical\": \"Flip vertically\",\n \"toolbar.groups.crop\": \"Crop\",\n \"crop.frame\": \"Crop area\",\n \"crop.frameDescription\":\n \"{width, number} × {height, number} pixels, from {x, number}, {y, number}. Arrow keys move it; with Shift, they resize it; Enter applies and Escape cancels.\",\n \"crop.size\": \"{width, number} × {height, number}, from {x, number}, {y, number}\",\n \"crop.panel\": \"Crop\",\n \"crop.x\": \"Left\",\n \"crop.y\": \"Top\",\n \"crop.width\": \"Width\",\n \"crop.height\": \"Height\",\n \"crop.aspect\": \"Aspect ratio\",\n \"crop.aspects.free\": \"Free\",\n \"crop.aspects.original\": \"Original\",\n \"crop.aspects.ratio\": \"{width}:{height}\",\n \"crop.apply\": \"Apply crop\",\n \"crop.cancel\": \"Cancel\",\n \"crop.reset\": \"Whole image\",\n \"crop.applied\": \"Cropped to {width, number} × {height, number}.\",\n \"tools.redact\": \"Redact\",\n \"toolbar.groups.redact\": \"Redact\",\n \"redact.panel\": \"Redact\",\n \"redact.intro\":\n \"Cover parts of the image. Only the exported image is redacted: the original stays in the editor.\",\n \"redact.add\": \"Add area\",\n \"redact.done\": \"Done\",\n \"redact.mode\": \"Cover with\",\n \"redact.modes.solid\": \"Solid colour\",\n \"redact.modes.pixelate\": \"Pixelation\",\n \"redact.pixelateHint\": \"Pixelation may not hide text. For text and numbers, use a solid colour.\",\n \"redact.colour\": \"Colour\",\n \"redact.colours.black\": \"Black\",\n \"redact.colours.white\": \"White\",\n \"redact.x\": \"Left\",\n \"redact.y\": \"Top\",\n \"redact.width\": \"Width\",\n \"redact.height\": \"Height\",\n \"redact.areas\": \"Redacted areas\",\n \"redact.none\": \"No areas yet. Drag across the image, or add one.\",\n \"redact.area\": \"Area {index, number}: {mode}, {width, number} × {height, number}\",\n \"redact.modeNames.solid\": \"solid colour\",\n \"redact.modeNames.pixelate\": \"pixelated\",\n \"redact.remove\": \"Remove area {index, number}\",\n \"redact.frame\": \"Redacted area {index, number} of {count, number}\",\n \"redact.frameDescription\":\n \"{mode}, {width, number} × {height, number} pixels, from {x, number}, {y, number}. Arrow keys move it; with Shift, they resize it; Delete removes it and Escape ends redacting.\",\n \"redact.added\": /* @__PURE__ */ plural(\"count\", {\n one: \"Area added. {count} area is redacted.\",\n other: \"Area added. {count, number} areas are redacted.\",\n }),\n \"redact.removedLast\": \"Area removed. Nothing is redacted.\",\n \"redact.removed\": /* @__PURE__ */ plural(\"count\", {\n one: \"Area removed. {count} area is redacted.\",\n other: \"Area removed. {count, number} areas are redacted.\",\n }),\n \"tools.add-text\": \"Add text\",\n \"tools.add-rectangle\": \"Add a rectangle\",\n \"tools.add-ellipse\": \"Add an ellipse\",\n \"tools.add-arrow\": \"Add an arrow\",\n \"tools.add-image\": \"Add an image\",\n \"tools.draw\": \"Draw\",\n \"toolbar.groups.draw\": \"Draw\",\n \"toolbar.groups.add\": \"Add\",\n \"editor.inserting\": \"Adding the image…\",\n \"layers.text\": \"Text\",\n \"layers.font\": \"Font\",\n \"layers.fonts.sans-serif\": \"Sans\",\n \"layers.fonts.serif\": \"Serif\",\n \"layers.fonts.monospace\": \"Mono\",\n \"layers.align\": \"Alignment\",\n \"layers.alignments.start\": \"Start\",\n \"layers.alignments.center\": \"Centre\",\n \"layers.alignments.end\": \"End\",\n \"layers.bold\": \"Bold\",\n \"layers.colour\": \"Colour\",\n \"layers.arrow.from.x\": \"Tail, left\",\n \"layers.arrow.from.y\": \"Tail, top\",\n \"layers.arrow.to.x\": \"Tip, left\",\n \"layers.arrow.to.y\": \"Tip, top\",\n \"layers.arrow.width\": \"Width\",\n \"layers.fill\": \"Fill\",\n \"layers.outline\": \"Outline\",\n \"layers.fillColour\": \"Fill colour\",\n \"layers.outlineColour\": \"Outline colour\",\n \"layers.outlineWidth\": \"Outline width\",\n \"layers.colours.black\": \"Black\",\n \"layers.colours.white\": \"White\",\n \"layers.colours.red\": \"Red\",\n \"layers.colours.yellow\": \"Yellow\",\n \"layers.colours.green\": \"Green\",\n \"layers.colours.blue\": \"Blue\",\n \"draw.panel\": \"Draw\",\n \"draw.intro\":\n \"Drag across the image to draw. Drawing needs a mouse, a pen or a finger; to point at something with the keyboard, add an arrow.\",\n \"draw.mode\": \"Draw with\",\n \"draw.modes.pen\": \"Pen\",\n \"draw.modes.highlighter\": \"Highlighter\",\n \"draw.colour\": \"Colour\",\n \"draw.width\": \"Width\",\n \"draw.removeLast\": \"Remove last stroke\",\n \"draw.removed\": \"Removed the last stroke.\",\n \"draw.done\": \"Done\",\n \"tools.layers\": \"Layers\",\n \"toolbar.groups.layers\": \"Layers\",\n \"layers.panel\": \"Layers\",\n \"layers.list\": \"Layers, the top one first\",\n \"layers.none\": \"No layers yet. Add text, a shape or an image from the toolbar.\",\n \"layers.kinds.text\": \"Text\",\n \"layers.kinds.rectangle\": \"Rectangle\",\n \"layers.kinds.ellipse\": \"Ellipse\",\n \"layers.kinds.image\": \"Image\",\n \"layers.kinds.drawing\": \"Drawing\",\n \"layers.kinds.arrow\": \"Arrow\",\n \"layers.visible\": \"Show {name}\",\n \"layers.selected\": \"Selected layer\",\n \"layers.moveUp\": \"Move up\",\n \"layers.moveDown\": \"Move down\",\n \"layers.mirror\": \"Mirror\",\n \"layers.duplicate\": \"Duplicate\",\n \"layers.remove\": \"Delete\",\n \"layers.name\": \"Name\",\n \"layers.x\": \"Left\",\n \"layers.y\": \"Top\",\n \"layers.width\": \"Width\",\n \"layers.height\": \"Height\",\n \"layers.rotation\": \"Turn, in degrees\",\n \"layers.opacity\": \"Opacity, in percent\",\n \"layers.done\": \"Done\",\n \"layers.frame\": \"Layer {index, number} of {count, number}: {name}\",\n \"layers.frameDescription\":\n \"{width, number} × {height, number} pixels, from {x, number}, {y, number}, turned {degrees, number}°. Arrow keys move it; with Shift, they resize it; Delete removes it and Escape closes the layers.\",\n \"layers.drawingDescription\": /* @__PURE__ */ plural(\"count\", {\n one: \"{count} stroke, {width, number} × {height, number} pixels, from {x, number}, {y, number}. Arrow keys move it; Delete removes it and Escape closes the layers.\",\n other:\n \"{count, number} strokes, {width, number} × {height, number} pixels, from {x, number}, {y, number}. Arrow keys move it; Delete removes it and Escape closes the layers.\",\n }),\n \"layers.arrowDescription\":\n \"From {fromX, number}, {fromY, number} to {toX, number}, {toY, number}. Arrow keys move it; with Shift, they move its tip; Delete removes it and Escape closes the layers.\",\n \"layers.movedUp\": \"Moved {name} up. It's layer {index, number} of {count, number}.\",\n \"layers.movedDown\": \"Moved {name} down. It's layer {index, number} of {count, number}.\",\n \"layers.duplicated\": \"Duplicated {name}.\",\n \"layers.removed\": \"Deleted {name}.\",\n \"inspector.label\": \"Panels\",\n \"inspector.adjust\": \"Adjust\",\n \"inspector.filters\": \"Filters\",\n \"inspector.info\": \"Info\",\n \"timeline.label\": \"Animation\",\n \"timeline.play\": \"Play\",\n \"timeline.frame\": \"Frame\",\n \"timeline.position\": \"Frame {frame, number} of {count, number}\",\n \"timeline.where\": \"Frame {frame, number} of {count, number}, {seconds, number} s\",\n \"tools.frames\": \"Frames\",\n \"toolbar.groups.frames\": \"Frames\",\n \"frames.panel\": \"Frames\",\n \"frames.list\": \"Frames, in the order they play\",\n \"frames.row\": \"Frame {index, number}, {seconds} seconds\",\n \"frames.selected\": \"Selected frame\",\n \"frames.moveEarlier\": \"Move earlier\",\n \"frames.moveLater\": \"Move later\",\n \"frames.duplicate\": \"Duplicate\",\n \"frames.remove\": \"Delete\",\n \"frames.reverse\": \"Reverse order\",\n \"frames.delay\": \"Delay, in seconds\",\n \"frames.delayAll\": \"Use for every frame\",\n \"frames.loop\": \"Plays\",\n \"frames.loops.once\": \"Once\",\n \"frames.loops.repeat\": \"Repeats\",\n \"frames.loops.forever\": \"For ever\",\n \"frames.repeats\": \"Times it repeats after the first\",\n \"frames.done\": \"Done\",\n \"frames.movedEarlier\":\n \"Moved frame {from, number} earlier. It's frame {index, number} of {count, number}.\",\n \"frames.movedLater\":\n \"Moved frame {from, number} later. It's frame {index, number} of {count, number}.\",\n \"frames.duplicated\": \"Duplicated frame {index, number}. The copy is frame {copy, number}.\",\n \"frames.removed\": /* @__PURE__ */ plural(\"count\", {\n one: \"Deleted frame {index, number}. One frame is left.\",\n other: \"Deleted frame {index, number}. {count, number} frames are left.\",\n }),\n \"frames.reversed\": \"Reversed the order of the frames.\",\n \"frames.delayedAll\": \"Every frame now shows for {seconds} seconds.\",\n \"notices.label\": \"Notices\",\n \"notices.dismiss\": \"Dismiss\",\n \"notices.incomplete\": /* @__PURE__ */ plural(\"frames\", {\n one: \"This animation's file is damaged. Only its first frame could be opened, of {listed, number}.\",\n other:\n \"This animation's file is damaged. {frames, number} of its {listed, number} frames could be opened.\",\n }),\n \"notices.incompleteEnd\":\n \"This animation's file is damaged at its end. All {frames, number} of its frames were opened.\",\n \"notices.animationTooLarge\":\n \"This animation is too large to edit as an animation. Its first frame is open as a still image.\",\n \"notices.firstFrame\": \"This file is an animation. Its first frame is open as a still image.\",\n \"notices.colourProfile\":\n \"This image has a colour profile. Colours outside sRGB will be clipped in the exported file.\",\n \"info.panel\": \"Image info\",\n \"info.size\": \"Size\",\n \"info.sizeValue\": \"{width, number} × {height, number} pixels\",\n \"info.format\": \"Format\",\n \"info.formats.png\": \"PNG\",\n \"info.formats.jpeg\": \"JPEG\",\n \"info.formats.webp\": \"WebP\",\n \"info.formats.gif\": \"GIF\",\n \"info.formats.avif\": \"AVIF\",\n \"info.formats.heif\": \"HEIF\",\n \"info.formats.bmp\": \"BMP\",\n \"info.frames\": \"Frames\",\n \"info.fileSize\": \"File size\",\n \"info.fileSizeValue\": \"{size, fileSize}\",\n \"info.metadata\": \"Metadata in the file\",\n \"info.metadataNone\": \"None\",\n \"info.kept\": \"Kept on export\",\n \"info.keptNone\": \"Nothing\",\n \"develop.panel\": \"Adjust\",\n \"develop.temperature\": \"Temperature\",\n \"develop.tint\": \"Tint\",\n \"develop.exposure\": \"Exposure\",\n \"develop.highlights\": \"Highlights\",\n \"develop.shadows\": \"Shadows\",\n \"develop.contrast\": \"Contrast\",\n \"develop.saturation\": \"Saturation\",\n \"develop.vibrance\": \"Vibrance\",\n \"develop.reset\": \"Reset {name}\",\n \"develop.resetAll\": \"Reset all\",\n \"develop.wasReset\": \"All adjustments reset.\",\n \"filters.panel\": \"Filters\",\n \"filters.label\": \"Filter\",\n \"filters.none\": \"None\",\n \"filters.vivid\": \"Vivid\",\n \"filters.warm\": \"Warm\",\n \"filters.cool\": \"Cool\",\n \"filters.fade\": \"Fade\",\n \"filters.mono\": \"Mono\",\n \"filters.noir\": \"Noir\",\n \"filters.sepia\": \"Sepia\",\n \"filters.strength\": \"Strength\",\n \"toolbar.groups.export\": \"Export\",\n \"tools.export\": \"Export\",\n \"tools.exportWhileCropping\": \"Apply or cancel the crop before exporting.\",\n \"export.title\": \"Export image\",\n \"export.description\": \"The file is made on this device, and nothing is uploaded.\",\n \"export.format\": \"Format\",\n \"export.formats.png\": \"PNG\",\n \"export.formats.jpeg\": \"JPEG\",\n \"export.formats.webp\": \"WebP\",\n \"export.formats.gif\": \"GIF\",\n \"export.quality\": \"Quality\",\n \"export.qualityValue\": \"{quality, number}%\",\n \"export.size\": \"Size\",\n \"export.sizes.scale\": \"Scale\",\n \"export.sizes.fit\": \"Fit in a box\",\n \"export.scale\": \"Scale, in percent\",\n \"export.fitWidth\": \"Largest width\",\n \"export.fitHeight\": \"Largest height\",\n \"export.fields\": \"Details to include\",\n \"export.fieldsHint\": \"Only what you fill in is written to the file.\",\n \"export.fieldsNone\": \"A {format} file carries no details: these aren't written to it.\",\n \"export.field.title\": \"Title\",\n \"export.field.description\": \"Description\",\n \"export.field.artist\": \"Artist\",\n \"export.field.copyright\": \"Copyright\",\n \"export.summary\": \"Summary\",\n \"export.output\": \"{width, number} × {height, number} pixels, {format}\",\n \"export.removed\": \"Removed from the file\",\n \"export.removedNone\": \"The image had no other details to remove.\",\n \"export.redacted\": /* @__PURE__ */ plural(\"count\", {\n one: \"{count} area is redacted.\",\n other: \"{count, number} areas are redacted.\",\n }),\n \"export.redactedPixelated\": \"Pixelated areas may not hide text.\",\n \"export.kind.location\": \"Location\",\n \"export.kind.camera\": \"Camera details\",\n \"export.kind.timestamps\": \"Dates and times\",\n \"export.kind.thumbnail\": \"Embedded thumbnail\",\n \"export.kind.colourProfile\": \"Colour profile: colours outside sRGB are clipped\",\n \"export.kind.other\": \"Other metadata\",\n \"export.kept\": \"Kept in the file\",\n \"export.confirm\": \"Export\",\n \"export.cancel\": \"Cancel\",\n \"export.progress\": \"Exporting the image\",\n \"export.stop\": \"Stop exporting\",\n \"export.cancelled\": \"Export stopped.\",\n \"export.done\": \"Exported a {format} of {size, fileSize}.\",\n \"export.ready\": \"{width, number} × {height, number} pixels, {format}, {size, fileSize}\",\n \"export.download\": \"Download\",\n \"export.close\": \"Done\",\n});\n","import { defineMessages } from \"@hussmartinez/sdk-core\";\nimport { uiMessages } from \"@hussmartinez/ui\";\nimport { imageEditorText } from \"../messages/editor-en.js\";\nimport { imageMessages } from \"../messages/en.js\";\n\n/**\n * The English message catalogue of the SDK's components: `imageMessages`,\n * with sdk-core's text, errors and warnings; `@hussmartinez/ui`'s, for the\n * ui components the editor renders (sdk-core ADR 0046); and the text of the\n * editor, its stage, toolbar and tools, its panels and the export dialog.\n *\n * `ImageEditor`, `ImageEditorProvider` and `<hm-image-editor>` each build\n * one `Messages` object from it, with the host's locale and overrides, and\n * the editor gives the same object to its own components and to ui's.\n * Override any of its keys through their `messages`, typed with\n * `ImageEditorMessageCatalogue`.\n *\n * It's defined in the React entry, so the server-safe `.` entry and its\n * `imageMessages` carry no interface text (docs/adr/0012).\n *\n * @public\n */\nexport const imageEditorMessages = /* @__PURE__ */ defineMessages({\n ...imageMessages,\n ...uiMessages,\n ...imageEditorText,\n});\n\n/**\n * The type of {@link imageEditorMessages}, for typing the editor's\n * `messages` overrides with `MessageOverrides<ImageEditorMessageCatalogue>`.\n *\n * @public\n */\nexport type ImageEditorMessageCatalogue = typeof imageEditorMessages;\n","import { createStore, type Store } from \"@hussmartinez/sdk-core\";\n\n/**\n * The stage's zoom and pan: view state, outside the session and its history\n * (ADR 0003, docs/adr/0007). Zoom 1 fits the image to the stage.\n *\n * @public\n */\nexport interface ImageViewState {\n readonly zoom: number;\n readonly pan: { readonly x: number; readonly y: number };\n}\n\n/** The fitted view, with no pan. */\nexport const FITTED: ImageViewState = Object.freeze({\n zoom: 1,\n pan: Object.freeze({ x: 0, y: 0 }),\n});\n\n/** The zoom range, and the step of the zoom tools. */\nexport const MIN_ZOOM = 0.1;\nexport const MAX_ZOOM = 16;\nexport const ZOOM_STEP = 1.25;\n\n/** A store of the view, which the stage reads with the session's plan. */\nexport function createViewStore(): Store<ImageViewState> {\n return createStore<ImageViewState>(FITTED);\n}\n\n/** The view zoomed by a factor, within the range. */\nexport function zoomBy(view: ImageViewState, factor: number): ImageViewState {\n const zoom = Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, view.zoom * factor));\n return { ...view, zoom };\n}\n","import { createMessages, type MessageOverrides } from \"@hussmartinez/sdk-core\";\nimport { UiMessagesProvider } from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useEffect, useInsertionEffect, useMemo, useRef, useState } from \"react\";\nimport { createImageEngine } from \"../adapters/image-engine.js\";\nimport { createImageProcessor } from \"../adapters/image-processor.js\";\nimport type { ImageFilePolicyOverrides } from \"../core/errors/image-limits.js\";\nimport type { ImageEngine } from \"../core/ports/image-engine.js\";\nimport type { ImageProcessor } from \"../core/ports/image-processor.js\";\nimport {\n createImageSession,\n type ImageSession,\n type ImageSessionEvent,\n} from \"../core/session/session.js\";\nimport { createEditorStore } from \"../features/editor-state.js\";\nimport { createInserter, createOpener, ImageContext } from \"./context.js\";\nimport { EngineBoundary } from \"./EngineBoundary.js\";\nimport { type ImageEditorMessageCatalogue, imageEditorMessages } from \"./editor-messages.js\";\nimport { createViewStore } from \"./view-store.js\";\n\n/**\n * Props of {@link ImageEditorProvider}.\n *\n * @public\n */\nexport interface ImageEditorProviderProps {\n /**\n * The engine that probes, decodes and holds images, and draws the stage.\n * Defaults to the SDK's own, created with `assetsUrl`. A session of your own\n * must use this engine.\n */\n readonly engine?: ImageEngine;\n /** The processor for exports. Defaults to the SDK's own, on the engine. */\n readonly processor?: ImageProcessor;\n /** A session of your own, over `engine`, instead of one the provider creates. */\n readonly session?: ImageSession;\n /**\n * Where the application serves the package's `dist/assets/` directory, for\n * the engine the provider creates (docs/adr/0002).\n */\n readonly assetsUrl?: string | URL;\n /** File limits for a session the provider creates (docs/adr/0004). */\n readonly filePolicy?: ImageFilePolicyOverrides;\n /**\n * Whether an animated file opens as an animation, for a session the\n * provider creates (docs/adr/0011). `true` when omitted; with `false`,\n * every file opens as a still, an animated one as its first frame.\n */\n readonly animations?: boolean;\n /** Anonymous usage events from a session the provider creates. */\n readonly onEvent?: (event: ImageSessionEvent) => void;\n /** Text overrides, typed against the English catalogue (ADR 0019). */\n readonly messages?: MessageOverrides<ImageEditorMessageCatalogue>;\n /** The locale for numbers and plurals. Defaults to `\"en\"`. */\n readonly locale?: string;\n /** The components that use the session, such as `ImageStage`. */\n readonly children?: ReactNode;\n}\n\ninterface Owned {\n readonly engine: ImageEngine;\n readonly session: ImageSession;\n pending?: ReturnType<typeof setTimeout>;\n dispose(): void;\n}\n\n/** Creates what the host didn't pass. Creating an engine starts nothing until its first call. */\nfunction own(props: ImageEditorProviderProps): Owned {\n const engine =\n props.engine ??\n createImageEngine(props.assetsUrl === undefined ? {} : { assetsUrl: props.assetsUrl });\n const processor = props.processor ?? createImageProcessor(engine);\n const session =\n props.session ??\n createImageSession({\n engine,\n processor,\n ...(props.filePolicy ? { filePolicy: props.filePolicy } : {}),\n ...(props.animations === undefined ? {} : { animations: props.animations }),\n ...(props.onEvent ? { onEvent: props.onEvent } : {}),\n });\n return {\n engine,\n session,\n dispose() {\n // Only what the provider created itself is destroyed.\n if (!props.session) void session.destroy();\n if (!props.processor) void processor.destroy();\n if (!props.engine) void engine.destroy();\n },\n };\n}\n\n/**\n * Provides an image session, its engine, the stage's view and the SDK's\n * text to the components below it: `ImageStage`, `ImageToolbar` and the\n * hooks (docs/adr/0007). `ImageEditor` renders one itself.\n *\n * @example\n * ```tsx\n * <ImageEditorProvider locale=\"de\" messages={{ \"editor.empty\": \"Öffnen Sie ein Bild.\" }}>\n * <ImageToolbar />\n * <ImageStage />\n * </ImageEditorProvider>\n * ```\n *\n * @public\n */\nexport function ImageEditorProvider(props: ImageEditorProviderProps): ReactNode {\n return <ImageProvider {...props} />;\n}\n\n/** The full editor keeps its labelled/theme root around its own boundary. */\nexport function ImageProvider(\n props: ImageEditorProviderProps & { readonly boundary?: boolean },\n): ReactNode {\n const { messages: overrides, locale = \"en\", children } = props;\n const [owned] = useState(() => own(props));\n const [view] = useState(createViewStore);\n const [editor] = useState(createEditorStore);\n const [opener] = useState(() => createOpener(owned.session));\n const [inserter] = useState(() => createInserter(owned.session, editor));\n // The latest committed handler, so events reach it however often the host\n // passes a new one. Set when the render commits, never during it: a render\n // React discards must not redirect events (useInsertionEffect runs before\n // any other effect, and isn't warned about when rendering on a server).\n const onEvent = useRef(props.onEvent);\n useInsertionEffect(() => {\n onEvent.current = props.onEvent;\n }, [props.onEvent]);\n const [emit] = useState(() => (event: ImageSessionEvent) => {\n try {\n onEvent.current?.(event);\n } catch {\n // A host's handler that throws doesn't break the editor, as with the session's events.\n }\n });\n\n useEffect(() => {\n // React's development mode unmounts and mounts again at once, so the\n // disposal waits a tick, and a remount cancels it.\n if (owned.pending !== undefined) clearTimeout(owned.pending);\n return () => {\n owned.pending = setTimeout(() => owned.dispose(), 0);\n };\n }, [owned]);\n\n const messages = useMemo(\n () =>\n createMessages(imageEditorMessages, {\n locale,\n ...(overrides ? { overrides } : {}),\n }),\n [locale, overrides],\n );\n const value = useMemo(\n () => ({\n session: owned.session,\n engine: owned.engine,\n messages,\n view,\n editor,\n opener,\n inserter,\n emit,\n }),\n [owned, messages, view, editor, opener, inserter, emit],\n );\n // The same object gives ui's components their text, so a host's\n // `messages` reach the drop zone and dialogs too (sdk-core ADR 0046).\n return (\n <ImageContext.Provider value={value}>\n <UiMessagesProvider messages={messages}>\n {props.boundary === false ? children : <EngineBoundary>{children}</EngineBoundary>}\n </UiMessagesProvider>\n </ImageContext.Provider>\n );\n}\n","import { type ReactNode, useEffect, useMemo, useRef, useState } from \"react\";\nimport { createImageRenderer } from \"../../adapters/image-renderer.js\";\nimport type { ImagePlan } from \"../../core/model/plan.js\";\nimport type { ImageEngine } from \"../../core/ports/image-engine.js\";\nimport { fittedView } from \"../../core/ports/image-renderer.js\";\n\n/**\n * The most frame thumbnails drawn at once (docs/adr/0011). Each is a small\n * canvas the render worker draws into, made when its row scrolls into view\n * and released when it leaves, so a list of thousands of frames holds only\n * the canvases of the rows in view. A row in view past the cap shows its\n * name alone until another's thumbnail is released.\n */\nexport const MAX_FRAME_THUMBNAILS = 24;\n\n/** A thumbnail's size, in CSS pixels: square, the frame fitted inside it. */\nexport const FRAME_THUMBNAIL_SIZE = 48;\n\n/**\n * Hands out the right to draw a thumbnail, to at most `max` rows at a time.\n * Rows that ask while none is free wait, first come first served.\n */\nexport interface ThumbnailSlots {\n /** Asks for a slot: `start` runs once one is free. Returns a function that gives it back, or stops waiting. */\n take(start: () => void): () => void;\n /** How many slots are in use, for tests. */\n readonly used: () => number;\n}\n\nexport function createThumbnailSlots(max = MAX_FRAME_THUMBNAILS): ThumbnailSlots {\n let used = 0;\n const waiting: (() => void)[] = [];\n const next = () => {\n while (used < max) {\n const start = waiting.shift();\n if (!start) return;\n used += 1;\n start();\n }\n };\n return {\n take(start) {\n let state: \"waiting\" | \"drawing\" | \"done\" = \"waiting\";\n const begin = () => {\n state = \"drawing\";\n start();\n };\n waiting.push(begin);\n next();\n return () => {\n if (state === \"drawing\") {\n used -= 1;\n next();\n } else if (state === \"waiting\") {\n const at = waiting.indexOf(begin);\n if (at >= 0) waiting.splice(at, 1);\n }\n state = \"done\";\n };\n },\n used: () => used,\n };\n}\n\n/**\n * The plan a thumbnail draws: the frame's own picture, with the plan's\n * other edits. It doesn't change when only the frames' order or delays do,\n * so moving a frame redraws no thumbnail.\n */\nfunction useThumbnailPlan(plan: ImagePlan, frame: number): ImagePlan {\n const { base, layers, redactions, output, metadata } = plan;\n return useMemo(\n () => ({\n base,\n layers,\n redactions,\n output,\n metadata,\n animation: { loop: null, frames: [{ key: \"thumbnail\", frame, delay: 0 }] },\n }),\n [base, layers, redactions, output, metadata, frame],\n );\n}\n\n/**\n * A frame's thumbnail in the frames list, drawn by the engine's render\n * worker with the plan's edits, only while its row is in view\n * (docs/adr/0011). It's decorative: the row's name says which frame it is.\n */\nexport function FrameThumbnail(props: {\n readonly engine: ImageEngine;\n readonly plan: ImagePlan;\n /** The source's frame it shows. */\n readonly frame: number;\n readonly slots: ThumbnailSlots;\n}): ReactNode {\n const { engine, slots } = props;\n const box = useRef<HTMLSpanElement>(null);\n const [visible, setVisible] = useState(false);\n const plan = useThumbnailPlan(props.plan, props.frame);\n const renderer = useRef<ReturnType<typeof createImageRenderer> | null>(null);\n const attached = useRef<Promise<void> | null>(null);\n const [drawing, setDrawing] = useState(false);\n\n // In view or not: rows far down a long list never draw.\n useEffect(() => {\n const element = box.current;\n if (!element) return;\n const observer = new IntersectionObserver((entries) => {\n const entry = entries.at(-1);\n if (entry) setVisible(entry.isIntersecting);\n });\n observer.observe(element);\n return () => observer.disconnect();\n }, []);\n\n // While it's in view and has a slot, a canvas of its own in the worker.\n useEffect(() => {\n const element = box.current;\n if (!visible || !element) return;\n let canvas: HTMLCanvasElement | undefined;\n let created: ReturnType<typeof createImageRenderer> | undefined;\n const give = slots.take(() => {\n try {\n created = createImageRenderer(engine);\n } catch {\n // A host's own engine has no render worker to draw it: the name alone.\n return;\n }\n canvas = document.createElement(\"canvas\");\n canvas.className = \"hm-image-frame-thumbnail-canvas\";\n canvas.setAttribute(\"aria-hidden\", \"true\");\n element.append(canvas);\n renderer.current = created;\n attached.current = created.attach(canvas);\n attached.current.catch(() => {});\n setDrawing(true);\n });\n return () => {\n give();\n if (created) void created.destroy();\n canvas?.remove();\n renderer.current = null;\n attached.current = null;\n setDrawing(false);\n };\n }, [visible, engine, slots]);\n\n useEffect(() => {\n const current = renderer.current;\n const ready = attached.current;\n if (!drawing || !current || !ready) return;\n const pixelRatio = globalThis.devicePixelRatio || 1;\n void ready\n .then(() =>\n current.render(plan, fittedView(FRAME_THUMBNAIL_SIZE, FRAME_THUMBNAIL_SIZE, pixelRatio)),\n )\n .catch(() => {\n // A thumbnail that can't be drawn stays empty; the row still names the frame.\n });\n }, [drawing, plan]);\n\n return (\n <span\n ref={box}\n className=\"hm-image-frame-thumbnail\"\n // The size the worker draws it at, so its pixels aren't scaled again.\n style={{ inlineSize: FRAME_THUMBNAIL_SIZE, blockSize: FRAME_THUMBNAIL_SIZE }}\n />\n );\n}\n","import { useAnnounce } from \"@hussmartinez/ui/react\";\nimport { useMemo } from \"react\";\nimport { createImageKey } from \"../../core/model/keys.js\";\nimport type { ImageFrame, ImagePlan } from \"../../core/model/plan.js\";\nimport { NO_TOOL } from \"../../features/editor-state.js\";\nimport { useImageInternals } from \"../hooks.js\";\n\n/**\n * A frame's delay in seconds, as the frames list shows it: with two\n * decimals, since delays are whole hundredths of a second.\n */\nexport function frameSeconds(delay: number, locale: string): string {\n return new Intl.NumberFormat(locale, {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n }).format(delay / 100);\n}\n\n/** Every key the plan uses, which a new frame's key must avoid. */\nconst keysOf = (plan: ImagePlan) =>\n new Set(\n [...plan.layers, ...plan.redactions, ...(plan.animation?.frames ?? [])].map(\n (item: { key: string }) => item.key,\n ),\n );\n\n/**\n * What the frames panel does (docs/adr/0011). Frames are named by their\n * place, from 0, in the plan's `animation.frames`. Each edit is one step,\n * and says what it did. The frame selected is the frame shown, so selecting\n * one pauses playing and shows it.\n */\nexport interface FrameActions {\n /** Shows a frame, paused. */\n select(index: number): void;\n /** Moves a frame one place earlier, or later, and keeps it selected. */\n shift(index: number, by: 1 | -1): void;\n /** Adds a copy after a frame, and selects it. Throws what the session refuses. */\n duplicate(index: number): void;\n /** Removes a frame, and selects the one now in its place, or the new last. */\n remove(index: number): void;\n /** Reverses the order of the frames. */\n reverse(): void;\n /** Sets a frame's delay, in hundredths of a second. */\n setDelay(index: number, delay: number): void;\n /** Sets every frame's delay to one frame's, as one step. */\n delayAll(index: number): void;\n /** Sets how many times the animation repeats: `null` for once, 0 for ever. */\n setLoop(loop: number | null): void;\n /** Stops showing the frames. */\n done(): void;\n}\n\nexport function useFrameActions(): FrameActions {\n const { session, editor, messages } = useImageInternals();\n const announce = useAnnounce();\n return useMemo(() => {\n const frames = (): readonly ImageFrame[] => session.getSnapshot().plan?.animation?.frames ?? [];\n const show = (index: number) =>\n editor.set((state) =>\n state.playback.frame === index && !state.playback.playing\n ? state\n : { ...state, playback: { frame: index, playing: false } },\n );\n return {\n select(index) {\n if (index >= 0 && index < frames().length) show(index);\n },\n shift(index, by) {\n const frame = frames()[index];\n const to = index + by;\n if (!frame || to < 0 || to >= frames().length) return;\n // `to` is a place in the list without the frame, which is where it ends.\n session.execute({ type: \"image.moveFrames\", keys: [frame.key], to });\n show(to);\n announce(\n messages.t(by < 0 ? \"frames.movedEarlier\" : \"frames.movedLater\", {\n from: index + 1,\n index: to + 1,\n count: frames().length,\n }),\n );\n },\n duplicate(index) {\n const plan = session.getSnapshot().plan;\n const frame = frames()[index];\n if (!plan || !frame) return;\n session.execute({\n type: \"image.insertFrames\",\n at: index + 1,\n frames: [{ ...frame, key: createImageKey(keysOf(plan)) }],\n });\n show(index + 1);\n announce(messages.t(\"frames.duplicated\", { index: index + 1, copy: index + 2 }));\n },\n remove(index) {\n const frame = frames()[index];\n if (!frame || frames().length < 2) return;\n session.execute({ type: \"image.removeFrames\", keys: [frame.key] });\n const count = frames().length;\n show(Math.min(index, count - 1));\n announce(messages.t(\"frames.removed\", { index: index + 1, count }));\n },\n reverse() {\n const count = frames().length;\n if (count < 2) return;\n session.execute({ type: \"image.reverseFrames\" });\n // The frame shown stays shown, at its new place.\n editor.set((state) => ({\n ...state,\n playback: {\n frame: count - 1 - Math.min(state.playback.frame, count - 1),\n playing: false,\n },\n }));\n announce(messages.t(\"frames.reversed\"));\n },\n setDelay(index, delay) {\n const frame = frames()[index];\n if (!frame || frame.delay === delay) return;\n session.execute({\n type: \"image.updateFrames\",\n updates: [{ key: frame.key, props: { delay } }],\n });\n },\n delayAll(index) {\n const delay = frames()[index]?.delay;\n if (delay === undefined) return;\n const updates = frames()\n .filter((frame) => frame.delay !== delay)\n .map((frame) => ({ key: frame.key, props: { delay } }));\n if (updates.length > 0) session.execute({ type: \"image.updateFrames\", updates });\n announce(\n messages.t(\"frames.delayedAll\", { seconds: frameSeconds(delay, messages.locale) }),\n );\n },\n setLoop(loop) {\n if (session.getSnapshot().plan?.animation?.loop === loop) return;\n session.execute({ type: \"image.setLoop\", loop });\n },\n done() {\n editor.set((state) => (state.tool === \"frames\" ? { ...state, ...NO_TOOL } : state));\n },\n };\n }, [session, editor, messages, announce]);\n}\n","import {\n Button,\n DeleteIcon,\n DuplicateIcon,\n Field,\n IconButton,\n MoveDownIcon,\n MoveUpIcon,\n NumberField,\n ReorderableList,\n ReorderableListItem,\n SegmentedControl,\n} from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useEffect, useMemo, useRef, useState } from \"react\";\nimport { MAX_FRAME_DELAY } from \"../../core/model/plan.js\";\nimport { useImageDocument, useImageEditorState, useImageInternals } from \"../hooks.js\";\nimport { shownFrame } from \"../stage/ImageStage.js\";\nimport { createThumbnailSlots, FrameThumbnail } from \"./FrameThumbnail.js\";\nimport { frameSeconds, useFrameActions } from \"./use-frames.js\";\n\n/**\n * Props of {@link ImageFramesPanel}.\n *\n * @public\n */\nexport interface ImageFramesPanelProps {\n readonly className?: string;\n}\n\ntype LoopKind = \"once\" | \"repeat\" | \"forever\";\nconst kindOf = (loop: number | null): LoopKind =>\n loop === null ? \"once\" : loop === 0 ? \"forever\" : \"repeat\";\n\n/**\n * The frames panel (docs/adr/0011), shown while the frames tool is on: an\n * animation's frames in the order they play, each with its thumbnail and\n * named by its place and delay, such as \"Frame 3, 0.10 seconds\"; buttons\n * that move the selected frame earlier and later, copy it and delete it,\n * and reverse the order; the selected frame's delay; and how many times\n * the animation plays. The frame selected is the frame the stage shows.\n *\n * The list is ui's `ReorderableList`, as the layers' is: one tab stop, the\n * Up and Down arrows between frames, `Alt` (`Option` on macOS) with them to\n * move the focused frame, and `Delete` to remove it. Every edit is one undo\n * step, and the panel says what it did.\n *\n * Thumbnails are drawn only for the rows in view, at most\n * `MAX_FRAME_THUMBNAILS` at a time, and released when their rows scroll out\n * of view.\n *\n * @public\n */\nexport function ImageFramesPanel(props: ImageFramesPanelProps): ReactNode {\n const [state] = useImageEditorState();\n const { plan } = useImageDocument();\n const { engine, messages } = useImageInternals();\n const actions = useFrameActions();\n const panel = useRef<HTMLElement>(null);\n const slots = useMemo(() => createThumbnailSlots(), []);\n /** What the session refused, such as a copy over the limit, until the next action. */\n const [problem, setProblem] = useState<unknown>(null);\n /** The number of repeats offered when Repeats is chosen. */\n const [repeats, setRepeats] = useState(1);\n const on = state.tool === \"frames\" && plan?.animation != null;\n const loop = plan?.animation?.loop ?? null;\n // The last count of repeats, offered again when Repeats is chosen after Once or For ever.\n useEffect(() => {\n if (loop !== null && loop > 0) setRepeats(loop);\n }, [loop]);\n\n // The list takes focus when the panel opens, on the frame shown.\n useEffect(() => {\n if (!on) return;\n panel.current?.querySelector<HTMLElement>(\".hm-image-frames-list [data-hm-tab-stop]\")?.focus();\n }, [on]);\n\n const animation = plan?.animation;\n if (!on || !plan || !animation) return null;\n const { frames } = animation;\n const count = frames.length;\n const index = shownFrame(plan, state.playback.frame);\n const selected = frames[index];\n const keyAt = new Map(frames.map((frame, at) => [frame.key, at]));\n\n /** Runs an action, and keeps what the session refused to say why nothing changed. */\n const run = (action: () => void) => {\n try {\n action();\n setProblem(null);\n } catch (error) {\n setProblem(error);\n }\n };\n const at = (key: string) => keyAt.get(key) ?? -1;\n const moveTo = (key: string, toIndex: number) => {\n const from = at(key);\n if (from < 0) return;\n actions.select(from);\n // One place at a time, as the keys and the buttons move it.\n if (Math.abs(toIndex - from) === 1) run(() => actions.shift(from, toIndex > from ? 1 : -1));\n };\n const removeFromList = (key: string) => {\n if (count > 1) run(() => actions.remove(at(key)));\n };\n const setLoopKind = (kind: LoopKind) =>\n run(() => actions.setLoop(kind === \"once\" ? null : kind === \"forever\" ? 0 : repeats));\n\n return (\n <section\n ref={panel}\n className={[\"hm-image-frames-panel\", props.className].filter(Boolean).join(\" \")}\n aria-label={messages.t(\"frames.panel\")}\n >\n <section className=\"hm-image-frames-list\" aria-label={messages.t(\"frames.list\")}>\n <ReorderableList\n label={messages.t(\"frames.list\")}\n selectedId={selected?.key ?? null}\n onSelectedChange={(key) => actions.select(at(key))}\n onMove={moveTo}\n onRemove={removeFromList}\n // A move is announced in the editor's own words, for the keys and the buttons alike.\n announceMoves={false}\n >\n {frames.map((frame, place) => {\n const name = messages.t(\"frames.row\", {\n index: place + 1,\n seconds: frameSeconds(frame.delay, messages.locale),\n });\n return (\n <ReorderableListItem\n key={frame.key}\n id={frame.key}\n label={name}\n classNames={{ item: \"hm-image-frame-row\" }}\n >\n <FrameThumbnail engine={engine} plan={plan} frame={frame.frame} slots={slots} />\n <span className=\"hm-image-frame-name\">{name}</span>\n </ReorderableListItem>\n );\n })}\n </ReorderableList>\n </section>\n {/* biome-ignore lint/a11y/useSemanticElements: a named group of buttons, not a form's fieldset */}\n <div\n className=\"hm-image-frames-order\"\n role=\"group\"\n aria-label={messages.t(\"frames.selected\")}\n >\n <IconButton\n label={messages.t(\"frames.moveEarlier\")}\n icon={<MoveUpIcon />}\n disabled={index === 0}\n focusableWhenDisabled\n // The list's own key for it, while focus is in the list.\n aria-keyshortcuts=\"Alt+ArrowUp\"\n onClick={() => run(() => actions.shift(index, -1))}\n />\n <IconButton\n label={messages.t(\"frames.moveLater\")}\n icon={<MoveDownIcon />}\n disabled={index === count - 1}\n focusableWhenDisabled\n aria-keyshortcuts=\"Alt+ArrowDown\"\n onClick={() => run(() => actions.shift(index, 1))}\n />\n <IconButton\n label={messages.t(\"frames.duplicate\")}\n icon={<DuplicateIcon />}\n onClick={() => run(() => actions.duplicate(index))}\n />\n <IconButton\n label={messages.t(\"frames.remove\")}\n icon={<DeleteIcon />}\n // An animation keeps at least one frame.\n disabled={count < 2}\n focusableWhenDisabled\n onClick={() => run(() => actions.remove(index))}\n />\n <Button\n variant=\"secondary\"\n disabled={count < 2}\n onClick={() => run(() => actions.reverse())}\n >\n {messages.t(\"frames.reverse\")}\n </Button>\n </div>\n {problem === null ? null : (\n <p className=\"hm-image-frames-problem\" role=\"alert\">\n {messages.error(problem)}\n </p>\n )}\n <div className=\"hm-image-frames-fields\">\n <Field label={messages.t(\"frames.delay\")}>\n <NumberField\n value={(selected?.delay ?? 0) / 100}\n min={0}\n max={MAX_FRAME_DELAY / 100}\n step={0.01}\n largeStep={0.1}\n locale={messages.locale}\n // As the rows show it: hundredths, with two decimals.\n format={(value) => frameSeconds(Math.round(value * 100), messages.locale)}\n onValueChange={(value) =>\n run(() =>\n actions.setDelay(\n index,\n Math.min(MAX_FRAME_DELAY, Math.max(0, Math.round(value * 100))),\n ),\n )\n }\n />\n </Field>\n <Button\n variant=\"quiet\"\n size=\"small\"\n disabled={frames.every((frame) => frame.delay === selected?.delay)}\n onClick={() => run(() => actions.delayAll(index))}\n >\n {messages.t(\"frames.delayAll\")}\n </Button>\n <SegmentedControl\n label={messages.t(\"frames.loop\")}\n size=\"small\"\n value={kindOf(loop)}\n options={([\"once\", \"repeat\", \"forever\"] as const).map((kind) => ({\n value: kind,\n label: messages.t(`frames.loops.${kind}`),\n }))}\n onValueChange={(value) => setLoopKind(value as LoopKind)}\n />\n <Field label={messages.t(\"frames.repeats\")}>\n <NumberField\n value={loop !== null && loop > 0 ? loop : repeats}\n min={1}\n max={MAX_FRAME_DELAY}\n step={1}\n largeStep={10}\n // Only a count of repeats has a number; once and for ever don't.\n disabled={kindOf(loop) !== \"repeat\"}\n onValueChange={(value) => {\n const next = Math.min(MAX_FRAME_DELAY, Math.max(1, Math.round(value)));\n setRepeats(next);\n run(() => actions.setLoop(next));\n }}\n />\n </Field>\n </div>\n <div className=\"hm-image-frames-actions\">\n <Button variant=\"primary\" onClick={() => actions.done()}>\n {messages.t(\"frames.done\")}\n </Button>\n </div>\n </section>\n );\n}\n","import {\n Button,\n DeleteIcon,\n DuplicateIcon,\n Field,\n FlipHorizontalIcon,\n HiddenIcon,\n IconButton,\n MoveDownIcon,\n MoveUpIcon,\n NumberField,\n ReorderableList,\n ReorderableListItem,\n TextField,\n VisibleIcon,\n} from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useEffect, useRef, useState } from \"react\";\nimport { MAX_SCENE_COORDINATE } from \"../../core/model/plan.js\";\nimport {\n useImageDocument,\n useImageEditorState,\n useImageMessages,\n useImageSession,\n} from \"../hooks.js\";\nimport { isBoxedLayer } from \"./frame-geometry.js\";\nimport { ArrowLayerFields, ShapeLayerFields, TextLayerFields } from \"./LayerFields.js\";\nimport { fitLayerName, layerLabel, useLayerActions } from \"./use-layers.js\";\n\n/**\n * Props of {@link ImageLayersPanel}.\n *\n * @public\n */\nexport interface ImageLayersPanelProps {\n readonly className?: string;\n}\n\ntype BoxField = \"x\" | \"y\" | \"width\" | \"height\";\n\n/**\n * The selected layer's name: typed freely, and set on the layer when the\n * field is left or Enter is pressed, as one step. It shows the plan's name\n * again whenever that changes, such as after an undo.\n */\nfunction NameField(props: {\n readonly layerKey: string | null;\n readonly name: string;\n readonly placeholder: string;\n readonly onRename: (value: string) => void;\n}): ReactNode {\n const { layerKey, name, onRename } = props;\n const [value, setValue] = useState(name);\n // biome-ignore lint/correctness/useExhaustiveDependencies: another layer with the same name also resets what was typed\n useEffect(() => setValue(name), [layerKey, name]);\n return (\n <TextField\n autoComplete=\"off\"\n value={value}\n placeholder={props.placeholder}\n disabled={layerKey === null}\n onValueChange={setValue}\n onBlur={() => {\n onRename(value);\n // What the plan took, which may be shorter than what was typed.\n setValue(fitLayerName(value));\n }}\n onKeyDown={(event) => {\n if (event.key === \"Enter\") onRename(event.currentTarget.value);\n }}\n />\n );\n}\n\n/**\n * The layers panel (docs/adr/0013), shown while the layers tool is on: the\n * list of layers, the top one first, each with a button that shows or hides\n * it; buttons that move the selected layer up and down the stack, mirror\n * it, copy it and delete it; and its name, place, size, turn and opacity as\n * fields, with its own kind's under them. Everything a frame on the stage\n * does with a drag, the panel does with a button or a field (WCAG 2.5.7).\n *\n * The list is ui's `ReorderableList`: one tab stop, the Up and Down arrows\n * between layers, `Alt` (`Option` on macOS) with them to move the focused\n * layer up and down the stack, and `Delete` to remove it: pdf-sdk's keys\n * for its pages.\n *\n * The panel keeps its size, whatever is selected: with no layer selected its\n * fields are disabled, and keep their place. Where the inspector sits under\n * the stage, a panel that grew would shrink the stage, and move the image\n * under the pointer.\n *\n * @public\n */\nexport function ImageLayersPanel(props: ImageLayersPanelProps): ReactNode {\n const [state, editor] = useImageEditorState();\n const { plan } = useImageDocument();\n const messages = useImageMessages();\n const actions = useLayerActions();\n const session = useImageSession();\n const panel = useRef<HTMLElement>(null);\n /** What the session refused, such as a copy over the limit, until the next action. */\n const [problem, setProblem] = useState<unknown>(null);\n\n // A focus the tool asked for, once: the selected layer in the list when\n // the layers start, or the text field of a text layer just added.\n const focus = state.tool === \"layers\" ? state.layers?.focus : undefined;\n useEffect(() => {\n if (!focus) return;\n panel.current\n ?.querySelector<HTMLElement>(\n focus === \"text\"\n ? \".hm-image-layers-text textarea\"\n : \".hm-image-layers-list [data-hm-tab-stop]\",\n )\n ?.focus();\n editor.set((current) =>\n current.layers?.focus\n ? { ...current, layers: { selected: current.layers.selected } }\n : current,\n );\n }, [focus, editor]);\n\n if (state.tool !== \"layers\" || !state.layers || !plan) return null;\n // The stage may show a gesture's plan; the panel lists what's committed.\n const { layers } = plan;\n const selectedIndex = layers.findIndex((layer) => layer.key === state.layers?.selected);\n const selected = layers[selectedIndex];\n // Its box, when it has one: a drawing and an arrow don't, and their fields\n // for one keep their place, disabled (docs/adr/0014).\n const boxed = selected && isBoxedLayer(selected) ? selected : undefined;\n const count = layers.length;\n\n /** Runs an action, and keeps what the session refused to say why nothing changed. */\n const run = (action: () => void) => {\n try {\n action();\n setProblem(null);\n } catch (error) {\n setProblem(error);\n }\n };\n\n /** The list shows the top layer first: a place in it, as a place in the plan. */\n const moveTo = (key: string, toIndex: number) => {\n const from = layers.findIndex((layer) => layer.key === key);\n const to = count - 1 - toIndex;\n if (from < 0) return;\n // The layer that's moved is the one that's selected, as with the buttons.\n actions.select(key);\n // One place at a time, as the keys and the buttons move it.\n if (Math.abs(to - from) === 1) run(() => actions.shift(key, to > from ? 1 : -1));\n };\n const removeFromList = (key: string) =>\n run(() => {\n // The list keeps focus on the layer now in its place; with none left, it goes to Done.\n if (actions.remove(key) === null) {\n panel.current?.querySelector<HTMLElement>(\".hm-image-layers-done\")?.focus();\n }\n });\n\n // The fields are always there, so the panel keeps its size, and the stage\n // with it: with no layer selected they're disabled, and their place is kept.\n const boxField = (name: BoxField) => {\n const length = name === \"width\" || name === \"height\";\n // A drawing has a place, its origin, and no size; an arrow has its own fields.\n const placedLayer = boxed ?? (!length && selected?.kind === \"drawing\" ? selected : undefined);\n return (\n <Field key={name} label={messages.t(`layers.${name}`)}>\n <NumberField\n value={\n boxed\n ? boxed[name]\n : placedLayer?.kind === \"drawing\" && !length\n ? placedLayer[name as \"x\" | \"y\"]\n : length\n ? 1\n : 0\n }\n min={length ? 1 : -MAX_SCENE_COORDINATE}\n max={MAX_SCENE_COORDINATE}\n step={1}\n largeStep={10}\n disabled={!placedLayer}\n onValueChange={(value) => {\n if (placedLayer) run(() => actions.set(placedLayer.key, { [name]: Math.round(value) }));\n }}\n />\n </Field>\n );\n };\n const rename = (value: string) => {\n // Read from the session, not this render: Enter and the blur after it\n // can both arrive before the panel renders again.\n const current = session.getSnapshot().plan?.layers.find((layer) => layer.key === selected?.key);\n const name = fitLayerName(value);\n if (current && name !== current.name) run(() => actions.set(current.key, { name }));\n };\n\n return (\n <section\n ref={panel}\n className={[\"hm-image-layers-panel\", props.className].filter(Boolean).join(\" \")}\n aria-label={messages.t(\"layers.panel\")}\n >\n <section className=\"hm-image-layers-list\" aria-label={messages.t(\"layers.list\")}>\n {count === 0 ? (\n <p className=\"hm-image-layers-none\">{messages.t(\"layers.none\")}</p>\n ) : (\n // ui's list: one tab stop, the arrows between rows, Alt or Option\n // with Up and Down to move a layer, Delete to remove it.\n <ReorderableList\n label={messages.t(\"layers.list\")}\n selectedId={selected?.key ?? null}\n onSelectedChange={(key) => actions.select(key)}\n onMove={moveTo}\n onRemove={removeFromList}\n // A move is announced in the editor's own words, for the keys and the buttons alike.\n announceMoves={false}\n >\n {/* The top layer first, as it's seen. */}\n {[...layers].reverse().map((layer) => {\n const name = layerLabel(layer, messages);\n return (\n <ReorderableListItem\n key={layer.key}\n id={layer.key}\n label={name}\n data-hm-layer={layer.key}\n classNames={{ item: \"hm-image-layer-select\" }}\n controls={[\n <IconButton\n key=\"visibility\"\n className=\"hm-image-layer-visibility\"\n label={messages.t(\"layers.visible\", { name })}\n icon={layer.visible ? <VisibleIcon /> : <HiddenIcon />}\n pressed={layer.visible}\n onClick={() => run(() => actions.set(layer.key, { visible: !layer.visible }))}\n />,\n ]}\n >\n {name}\n </ReorderableListItem>\n );\n })}\n </ReorderableList>\n )}\n </section>\n {/* biome-ignore lint/a11y/useSemanticElements: a named group of buttons, not a form's fieldset */}\n <div\n className=\"hm-image-layers-order\"\n role=\"group\"\n aria-label={messages.t(\"layers.selected\")}\n >\n <IconButton\n label={messages.t(\"layers.moveUp\")}\n icon={<MoveUpIcon />}\n disabled={!selected || selectedIndex === count - 1}\n focusableWhenDisabled\n // The list's own key for it, while focus is in the list.\n aria-keyshortcuts=\"Alt+ArrowUp\"\n onClick={() => selected && run(() => actions.shift(selected.key, 1))}\n />\n <IconButton\n label={messages.t(\"layers.moveDown\")}\n icon={<MoveDownIcon />}\n disabled={!selected || selectedIndex === 0}\n focusableWhenDisabled\n aria-keyshortcuts=\"Alt+ArrowDown\"\n onClick={() => selected && run(() => actions.shift(selected.key, -1))}\n />\n <IconButton\n label={messages.t(\"layers.mirror\")}\n icon={<FlipHorizontalIcon />}\n // Pressed while the layer is mirrored about its box (docs/adr/0009).\n pressed={boxed?.flipX ?? false}\n disabled={!boxed}\n focusableWhenDisabled\n onClick={() => boxed && run(() => actions.set(boxed.key, { flipX: !boxed.flipX }))}\n />\n <IconButton\n label={messages.t(\"layers.duplicate\")}\n icon={<DuplicateIcon />}\n disabled={!selected}\n focusableWhenDisabled\n onClick={() => selected && run(() => actions.duplicate(selected.key))}\n />\n <IconButton\n label={messages.t(\"layers.remove\")}\n icon={<DeleteIcon />}\n disabled={!selected}\n focusableWhenDisabled\n onClick={() => selected && run(() => void actions.remove(selected.key))}\n />\n </div>\n {problem === null ? null : (\n <p className=\"hm-image-layers-problem\" role=\"alert\">\n {messages.error(problem)}\n </p>\n )}\n <div className=\"hm-image-layers-fields\" data-hm-inactive={selected ? undefined : \"\"}>\n <Field label={messages.t(\"layers.name\")} className=\"hm-image-layers-name\">\n <NameField\n layerKey={selected?.key ?? null}\n name={selected?.name ?? \"\"}\n placeholder={selected ? layerLabel({ ...selected, name: \"\" }, messages) : \"\"}\n onRename={rename}\n />\n </Field>\n {([\"x\", \"y\", \"width\", \"height\"] as const).map(boxField)}\n <Field label={messages.t(\"layers.rotation\")}>\n <NumberField\n value={boxed ? boxed.rotation / 10 : 0}\n min={0}\n max={359.9}\n step={1}\n largeStep={15}\n disabled={!boxed}\n onValueChange={(value) => {\n if (!boxed) return;\n // The plan holds tenths of a degree, from 0 to 3599.\n const rotation = ((Math.round(value * 10) % 3_600) + 3_600) % 3_600;\n run(() => actions.set(boxed.key, { rotation }));\n }}\n />\n </Field>\n <Field label={messages.t(\"layers.opacity\")}>\n <NumberField\n value={selected ? selected.opacity : 100}\n min={0}\n max={100}\n step={1}\n largeStep={10}\n disabled={!selected}\n onValueChange={(value) => {\n if (selected) run(() => actions.set(selected.key, { opacity: Math.round(value) }));\n }}\n />\n </Field>\n </div>\n {/*\n A text layer's fields, a shape's and an arrow's share one place,\n sized for the tallest, so selecting another kind of layer never\n moves the stage. The ones that don't apply are hidden, from sight,\n focus and assistive technology alike. An image layer and a drawing\n have none of their own.\n */}\n <div className=\"hm-image-layer-kinds\">\n <TextLayerFields\n layer={selected?.kind === \"text\" ? selected : null}\n actions={actions}\n run={run}\n />\n <ShapeLayerFields\n layer={selected?.kind === \"shape\" ? selected : null}\n actions={actions}\n run={run}\n />\n <ArrowLayerFields\n layer={selected?.kind === \"arrow\" ? selected : null}\n actions={actions}\n run={run}\n />\n </div>\n <div className=\"hm-image-layers-actions\">\n <Button variant=\"primary\" className=\"hm-image-layers-done\" onClick={() => actions.done()}>\n {messages.t(\"layers.done\")}\n </Button>\n </div>\n </section>\n );\n}\n","import {\n Button,\n DeleteIcon,\n Field,\n IconButton,\n NumberField,\n SegmentedControl,\n} from \"@hussmartinez/ui/react\";\nimport type { ReactNode } from \"react\";\nimport { MAX_SCENE_COORDINATE } from \"../../core/model/plan.js\";\nimport { DEFAULT_REDACTION_COLOUR } from \"../../features/redact/redact-tool.js\";\nimport { useImageDocument, useImageEditorState, useImageMessages } from \"../hooks.js\";\nimport { useRedactActions } from \"./use-redact.js\";\n\n/** The colours a solid redaction can take: the plan holds any, the editor offers these. */\nconst COLOURS = [\n { value: DEFAULT_REDACTION_COLOUR, name: \"black\" },\n { value: \"#ffffff\", name: \"white\" },\n] as const;\n\n/**\n * Props of {@link ImageRedactPanel}.\n *\n * @public\n */\nexport interface ImageRedactPanelProps {\n readonly className?: string;\n}\n\n/**\n * The redact panel (docs/adr/0010), shown while redacting: what a new area\n * is covered with, a button that adds one without dragging (WCAG 2.5.7),\n * the selected area's position and size in source pixels, and the list of\n * every area, each with its mode, its size and a button to remove it, so\n * what's covered can be read without the preview.\n *\n * The panel keeps its size while redacting, whatever is selected or chosen.\n * Where the inspector sits under the stage, a panel that grew would shrink\n * the stage, and move the image under the pointer.\n *\n * @public\n */\nexport function ImageRedactPanel(props: ImageRedactPanelProps): ReactNode {\n const [state] = useImageEditorState();\n const { plan } = useImageDocument();\n const messages = useImageMessages();\n const actions = useRedactActions();\n const settings = state.redact;\n if (state.tool !== \"redact\" || !settings || !plan) return null;\n // The stage may show a gesture's plan; the panel lists what's committed.\n const { redactions } = plan;\n const selected = redactions.find((redaction) => redaction.key === settings.selected);\n // The fields are always there, so the panel keeps its size, and the stage\n // with it: with no area selected they're disabled, and their place is kept.\n const field = (name: \"x\" | \"y\" | \"width\" | \"height\") => {\n const length = name === \"width\" || name === \"height\";\n return (\n <Field key={name} label={messages.t(`redact.${name}`)}>\n <NumberField\n value={selected ? selected[name] : length ? 1 : 0}\n min={length ? 1 : -MAX_SCENE_COORDINATE}\n max={MAX_SCENE_COORDINATE}\n step={1}\n largeStep={10}\n disabled={!selected}\n onValueChange={(value) => {\n if (!selected) return;\n const { x, y, width, height } = selected;\n actions.setRegion(selected.key, { x, y, width, height, [name]: Math.round(value) });\n }}\n />\n </Field>\n );\n };\n const pixelating = settings.mode === \"pixelate\";\n return (\n <section\n className={[\"hm-image-redact-panel\", props.className].filter(Boolean).join(\" \")}\n aria-label={messages.t(\"redact.panel\")}\n >\n <p className=\"hm-image-redact-intro\">{messages.t(\"redact.intro\")}</p>\n <SegmentedControl\n label={messages.t(\"redact.mode\")}\n value={settings.mode}\n size=\"small\"\n options={[\n { value: \"solid\", label: messages.t(\"redact.modes.solid\") },\n { value: \"pixelate\", label: messages.t(\"redact.modes.pixelate\") },\n ]}\n onValueChange={(value) => actions.setMode(value === \"pixelate\" ? \"pixelate\" : \"solid\")}\n />\n {/*\n The colour and pixelation's warning share one place, sized for the\n taller, so choosing a mode never moves what's below it or the stage.\n The one that doesn't apply is hidden, from sight, focus and\n assistive technology alike.\n */}\n <div className=\"hm-image-redact-cover\">\n <div data-hm-inactive={pixelating ? \"\" : undefined}>\n <SegmentedControl\n label={messages.t(\"redact.colour\")}\n // A colour from a plan that isn't one of these shows neither chosen.\n value={settings.colour}\n size=\"small\"\n options={COLOURS.map(({ value, name }) => ({\n value,\n label: messages.t(`redact.colours.${name}`),\n }))}\n onValueChange={(value) => actions.setColour(value)}\n />\n </div>\n <p className=\"hm-image-redact-hint\" data-hm-inactive={pixelating ? undefined : \"\"}>\n {messages.t(\"redact.pixelateHint\")}\n </p>\n </div>\n <Button variant=\"secondary\" className=\"hm-image-redact-add\" onClick={() => actions.add()}>\n {messages.t(\"redact.add\")}\n </Button>\n <div className=\"hm-image-redact-fields\" data-hm-inactive={selected ? undefined : \"\"}>\n {([\"x\", \"y\", \"width\", \"height\"] as const).map(field)}\n </div>\n <section className=\"hm-image-redact-areas\" aria-label={messages.t(\"redact.areas\")}>\n {redactions.length === 0 ? (\n <p className=\"hm-image-redact-none\">{messages.t(\"redact.none\")}</p>\n ) : (\n <ul>\n {redactions.map((redaction, index) => (\n <li key={redaction.key}>\n <Button\n variant=\"secondary\"\n pressed={redaction.key === settings.selected}\n onClick={() => actions.select(redaction.key)}\n >\n {messages.t(\"redact.area\", {\n index: index + 1,\n mode: messages.t(`redact.modeNames.${redaction.mode}`),\n width: redaction.width,\n height: redaction.height,\n })}\n </Button>\n <IconButton\n label={messages.t(\"redact.remove\", { index: index + 1 })}\n icon={<DeleteIcon />}\n onClick={() => actions.remove(redaction.key)}\n />\n </li>\n ))}\n </ul>\n )}\n </section>\n <div className=\"hm-image-redact-actions\">\n <Button variant=\"primary\" onClick={() => actions.done()}>\n {messages.t(\"redact.done\")}\n </Button>\n </div>\n </section>\n );\n}\n","import type { ImageCommand } from \"../../core/operations/commands.js\";\nimport type { Gesture } from \"../gesture.js\";\n\n/**\n * The callbacks that drive one slider's gesture (docs/adr/0007). Each value\n * previews on the stage; ui's `Slider` says when the gesture ends, and it's\n * one step: when the pointer is let go, when the last key held is let go,\n * or when focus leaves first. Escape during a gesture puts the value back\n * and cancels it, with no step.\n */\nexport function sliderGesture(gesture: Gesture, command: (value: number) => ImageCommand) {\n return {\n onValueChange: (value: number) => gesture.preview([command(value)]),\n onValueCommit: (value: number) => {\n // The value it ended on, whatever the last preview was.\n gesture.preview([command(value)]);\n gesture.commit();\n },\n onValueCancel: (_value: number) => gesture.cancel(),\n };\n}\n","import { Button, Field, Slider, useAnnounce } from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useRef } from \"react\";\nimport { DEVELOP_ADJUSTMENTS, type ImageDevelop } from \"../../core/model/plan.js\";\nimport { useGesture } from \"../gesture.js\";\nimport {\n useImageDocument,\n useImageEditorState,\n useImageMessages,\n useImageSession,\n} from \"../hooks.js\";\nimport { sliderGesture } from \"./use-slider-gesture.js\";\n\n/**\n * Props of {@link ImageAdjustPanel}.\n *\n * @public\n */\nexport interface ImageAdjustPanelProps {\n readonly className?: string;\n}\n\nconst signed = (value: number) => (value > 0 ? `+${value}` : String(value));\n\n/**\n * The Adjust panel (docs/adr/0006, docs/adr/0007): a slider per develop\n * adjustment, in the order they're applied, from −100 to 100. A slider's\n * gesture previews on the stage and is one undo step when it ends; each\n * slider resets to 0 with its button, or by double-clicking it, and \"Reset\n * all\" resets every one in one step.\n *\n * @public\n */\nexport function ImageAdjustPanel(props: ImageAdjustPanelProps): ReactNode {\n const session = useImageSession();\n const { plan } = useImageDocument();\n const [editor] = useImageEditorState();\n const messages = useImageMessages();\n const gesture = useGesture();\n const announce = useAnnounce();\n const first = useRef<HTMLInputElement>(null);\n if (!plan) return null;\n // During a gesture the sliders show its values, which the stage renders.\n const develop = (editor.preview ?? plan).base.develop;\n const reset = (values: Partial<ImageDevelop>) => {\n gesture.cancel();\n session.execute({ type: \"image.setDevelop\", values });\n };\n const changed = DEVELOP_ADJUSTMENTS.filter((name) => plan.base.develop[name] !== 0);\n return (\n <section\n className={[\"hm-image-adjust-panel\", props.className].filter(Boolean).join(\" \")}\n aria-label={messages.t(\"develop.panel\")}\n >\n {/* First, so it's in view however far the sliders scroll. */}\n <div className=\"hm-image-adjust-actions\">\n <Button\n variant=\"secondary\"\n disabled={changed.length === 0}\n onClick={() => {\n reset(Object.fromEntries(changed.map((name) => [name, 0])));\n first.current?.focus();\n announce(messages.t(\"develop.wasReset\"));\n }}\n >\n {messages.t(\"develop.resetAll\")}\n </Button>\n </div>\n {DEVELOP_ADJUSTMENTS.map((name, index) => {\n const label = messages.t(`develop.${name}`);\n return (\n // The Field shows the slider's name, and labels it (WCAG 2.5.3).\n <Field key={name} label={label} className=\"hm-image-slider-field\">\n {(control) => (\n <div className=\"hm-image-adjust-row\">\n <Slider\n {...control}\n {...(index === 0 ? { ref: first } : {})}\n min={-100}\n max={100}\n step={1}\n largeStep={10}\n value={develop[name]}\n formatValue={signed}\n {...sliderGesture(gesture, (value) => ({\n type: \"image.setDevelop\",\n values: { [name]: Math.round(value) },\n }))}\n onDoubleClick={() => {\n if (plan.base.develop[name] !== 0) reset({ [name]: 0 });\n }}\n />\n <output className=\"hm-image-adjust-value\" aria-hidden=\"true\">\n {signed(develop[name])}\n </output>\n {plan.base.develop[name] !== 0 ? (\n <Button variant=\"quiet\" size=\"small\" onClick={() => reset({ [name]: 0 })}>\n {messages.t(\"develop.reset\", { name: label })}\n </Button>\n ) : null}\n </div>\n )}\n </Field>\n );\n })}\n </section>\n );\n}\n","import { Field, SegmentedControl, Slider } from \"@hussmartinez/ui/react\";\nimport type { ReactNode } from \"react\";\nimport { FILTER_PRESETS, type ImageFilterPreset } from \"../../core/model/plan.js\";\nimport { useGesture } from \"../gesture.js\";\nimport {\n useImageDocument,\n useImageEditorState,\n useImageMessages,\n useImageSession,\n} from \"../hooks.js\";\nimport { sliderGesture } from \"./use-slider-gesture.js\";\n\n/**\n * Props of {@link ImageFilterPanel}.\n *\n * @public\n */\nexport interface ImageFilterPanelProps {\n readonly className?: string;\n}\n\n/**\n * The Filters panel (docs/adr/0006, docs/adr/0007): the presets, \"None\"\n * first, as one choice, each one undo step; and the chosen preset's\n * strength, whose slider gesture is one undo step.\n *\n * @public\n */\nexport function ImageFilterPanel(props: ImageFilterPanelProps): ReactNode {\n const session = useImageSession();\n const { plan } = useImageDocument();\n const [editor] = useImageEditorState();\n const messages = useImageMessages();\n const gesture = useGesture();\n if (!plan) return null;\n const filter = (editor.preview ?? plan).base.filter;\n const options = [\n { value: \"none\", label: messages.t(\"filters.none\") },\n ...FILTER_PRESETS.map((preset) => ({ value: preset, label: messages.t(`filters.${preset}`) })),\n ];\n return (\n <section\n className={[\"hm-image-filter-panel\", props.className].filter(Boolean).join(\" \")}\n aria-label={messages.t(\"filters.panel\")}\n >\n <SegmentedControl\n label={messages.t(\"filters.label\")}\n value={filter?.preset ?? \"none\"}\n options={options}\n onValueChange={(value) => {\n gesture.cancel();\n session.execute({\n type: \"image.setFilter\",\n filter:\n value === \"none\"\n ? null\n : { preset: value as ImageFilterPreset, strength: filter?.strength ?? 100 },\n });\n }}\n />\n {filter ? (\n <Field label={messages.t(\"filters.strength\")} className=\"hm-image-slider-field\">\n <Slider\n min={0}\n max={100}\n step={1}\n largeStep={10}\n value={filter.strength}\n {...sliderGesture(gesture, (value) => ({\n type: \"image.setFilter\",\n filter: { preset: filter.preset, strength: Math.round(value) },\n }))}\n />\n </Field>\n ) : null}\n </section>\n );\n}\n","import type { ReactNode } from \"react\";\nimport type { ImageKeepableMetadata, ImageMetadataPresence } from \"../../core/model/source.js\";\nimport { useImageDocument, useImageMessages } from \"../hooks.js\";\n\n/**\n * Props of {@link ImageInfoPanel}.\n *\n * @public\n */\nexport interface ImageInfoPanelProps {\n readonly className?: string;\n}\n\nconst KINDS: readonly (keyof ImageMetadataPresence)[] = [\n \"location\",\n \"camera\",\n \"timestamps\",\n \"thumbnail\",\n \"colourProfile\",\n \"other\",\n];\nconst FIELDS: readonly (keyof ImageKeepableMetadata)[] = [\n \"title\",\n \"description\",\n \"artist\",\n \"copyright\",\n];\n\n/**\n * The Info panel (docs/adr/0007): what the editor knows of the open image,\n * as a list of terms: its upright size, format, frames and file size, the\n * kinds of metadata the file carries, and the fields kept on export. It\n * shows only what the session already holds, and never a file name\n * (sdk-core ADR 0012).\n *\n * @public\n */\nexport function ImageInfoPanel(props: ImageInfoPanelProps): ReactNode {\n const { plan, source } = useImageDocument();\n const messages = useImageMessages();\n if (!plan || !source) return null;\n const carried = KINDS.filter((kind) => source.metadata[kind]);\n const kept = FIELDS.filter((field) => plan.metadata[field] !== \"\");\n return (\n <section\n className={[\"hm-image-info-panel\", props.className].filter(Boolean).join(\" \")}\n aria-label={messages.t(\"info.panel\")}\n >\n <dl className=\"hm-image-info-list\">\n <dt>{messages.t(\"info.size\")}</dt>\n <dd>{messages.t(\"info.sizeValue\", { width: source.width, height: source.height })}</dd>\n <dt>{messages.t(\"info.format\")}</dt>\n <dd>{messages.t(`info.formats.${source.format}`)}</dd>\n {source.frames > 1 ? (\n <>\n <dt>{messages.t(\"info.frames\")}</dt>\n <dd>{source.frames}</dd>\n </>\n ) : null}\n <dt>{messages.t(\"info.fileSize\")}</dt>\n <dd>{messages.t(\"info.fileSizeValue\", { size: source.fileSize })}</dd>\n <dt>{messages.t(\"info.metadata\")}</dt>\n <dd>\n {carried.length > 0 ? (\n <ul>\n {carried.map((kind) => (\n <li key={kind}>{messages.t(`export.kind.${kind}`)}</li>\n ))}\n </ul>\n ) : (\n messages.t(\"info.metadataNone\")\n )}\n </dd>\n <dt>{messages.t(\"info.kept\")}</dt>\n <dd>\n {kept.length > 0 ? (\n <ul>\n {kept.map((field) => (\n <li key={field}>{messages.t(`export.field.${field}`)}</li>\n ))}\n </ul>\n ) : (\n messages.t(\"info.keptNone\")\n )}\n </dd>\n </dl>\n </section>\n );\n}\n","import { SegmentedControl } from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useState } from \"react\";\nimport { ImageCropPanel } from \"../crop/CropPanel.js\";\nimport { ImageDrawPanel } from \"../draw/DrawPanel.js\";\nimport type { ImageEditorFeatures } from \"../editor/types.js\";\nimport { ImageFramesPanel } from \"../frames/FramesPanel.js\";\nimport { useImageDocument, useImageEditorState, useImageMessages } from \"../hooks.js\";\nimport { ImageLayersPanel } from \"../layers/LayersPanel.js\";\nimport { ImageRedactPanel } from \"../redact/RedactPanel.js\";\nimport { ImageAdjustPanel } from \"./AdjustPanel.js\";\nimport { ImageFilterPanel } from \"./FilterPanel.js\";\nimport { ImageInfoPanel } from \"./InfoPanel.js\";\n\ntype Panel = \"adjust\" | \"filters\" | \"info\";\nconst PANELS: readonly Panel[] = [\"adjust\", \"filters\", \"info\"];\n\n/**\n * The inspector (docs/adr/0007): the crop panel while cropping, and the\n * redact panel while redacting, the layers panel while the layers are\n * shown, and the frames panel while an animation's frames are; otherwise\n * a choice of the Adjust, Filters and Info panels, once an image is open.\n */\nexport function ImageInspector(props: { readonly features?: ImageEditorFeatures }): ReactNode {\n const { plan } = useImageDocument();\n const [editor] = useImageEditorState();\n const messages = useImageMessages();\n const [chosen, setPanel] = useState<Panel>(\"adjust\");\n if (editor.tool === \"crop\") return <ImageCropPanel />;\n if (editor.tool === \"redact\") return <ImageRedactPanel />;\n if (editor.tool === \"layers\") return <ImageLayersPanel />;\n if (editor.tool === \"draw\") return <ImageDrawPanel />;\n if (editor.tool === \"frames\") return <ImageFramesPanel />;\n if (!plan) return null;\n // The panels the host turned on, in order; the choice falls to the first.\n const panels = PANELS.filter((name) => props.features?.[name] !== false);\n const first = panels[0];\n if (first === undefined) return null;\n const panel = panels.includes(chosen) ? chosen : first;\n return (\n <>\n {panels.length > 1 ? (\n <SegmentedControl\n label={messages.t(\"inspector.label\")}\n value={panel}\n size=\"small\"\n options={panels.map((name) => ({ value: name, label: messages.t(`inspector.${name}`) }))}\n onValueChange={(value) => setPanel(value as Panel)}\n />\n ) : null}\n {panel === \"adjust\" ? <ImageAdjustPanel /> : null}\n {panel === \"filters\" ? <ImageFilterPanel /> : null}\n {panel === \"info\" ? <ImageInfoPanel /> : null}\n </>\n );\n}\n","import type { Store } from \"@hussmartinez/sdk-core\";\nimport { PauseIcon, PlayIcon, Slider, ToggleButton } from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useEffect, useRef } from \"react\";\nimport type { ImageAnimation } from \"../../core/model/plan.js\";\nimport type { ImageEditorState } from \"../../features/editor-state.js\";\nimport { nextFrame, shownDelay, withPlaying } from \"../../features/playback/playback.js\";\nimport { useImageDocument, useImageEditorState, useImageMessages } from \"../hooks.js\";\nimport { shownFrame } from \"../stage/ImageStage.js\";\n\n/**\n * Plays the animation while the editor says it's playing, a frame at a time,\n * at its timing.\n *\n * A tick does nothing unless, when it fires, the animation is still playing\n * the frame it was set for. A pause or a seek cancels the tick only when the\n * effect cleans up, after React renders, and a tick already due by then\n * would otherwise undo it.\n *\n * @internal\n */\nexport function usePlayback(\n animation: ImageAnimation | null,\n playback: ImageEditorState[\"playback\"],\n editor: Store<ImageEditorState>,\n): void {\n /** How many times it has reached its end since Play was pressed. */\n const played = useRef(0);\n useEffect(() => {\n if (!playback.playing) played.current = 0;\n }, [playback.playing]);\n useEffect(() => {\n if (!animation || !playback.playing) return;\n const frame = Math.min(playback.frame, animation.frames.length - 1);\n const delay = shownDelay(animation.frames[frame]?.delay ?? 0);\n const timer = setTimeout(() => {\n const now = editor.getSnapshot().playback;\n if (!now.playing || now.frame !== playback.frame) return;\n const next = nextFrame(animation, frame, played.current);\n if (next) played.current = next.played;\n editor.set((state) => ({\n ...state,\n // The last frame stays when the loop count is spent.\n playback: next ? { frame: next.frame, playing: true } : { frame, playing: false },\n }));\n }, delay);\n return () => clearTimeout(timer);\n }, [animation, playback.frame, playback.playing, editor]);\n}\n\n/**\n * The animation's bar under the stage (docs/adr/0011): Play, a frame\n * scrubber and where it is. Nothing plays on its own: an animation opens\n * paused on its first frame, and plays only when Play is pressed, or with\n * the editor's play-pause shortcut, Space, which the play tool has. Moving\n * the scrubber pauses it.\n *\n * It shows only for an animated plan.\n */\nexport function AnimationBar(props: { readonly className?: string | undefined }): ReactNode {\n const { plan, status } = useImageDocument();\n const [editorState, editor] = useImageEditorState();\n const messages = useImageMessages();\n const animation = status === \"ready\" ? (plan?.animation ?? null) : null;\n const { playback } = editorState;\n usePlayback(animation, playback, editor);\n if (!animation || !plan) return null;\n\n const count = animation.frames.length;\n const frame = shownFrame(plan, playback.frame);\n const delay = animation.frames[frame]?.delay ?? 0;\n const position = (index: number) => messages.t(\"timeline.position\", { frame: index + 1, count });\n const play = (playing: boolean) => editor.set((state) => withPlaying(state, plan, playing));\n const seek = (index: number) =>\n editor.set((state) => ({\n ...state,\n playback: { frame: Math.min(Math.max(0, Math.round(index)), count - 1), playing: false },\n }));\n const className = [\"hm-image-timeline\", props.className].filter(Boolean).join(\" \");\n return (\n <section className={className} aria-label={messages.t(\"timeline.label\")}>\n <ToggleButton\n label={messages.t(\"timeline.play\")}\n // Pause while it plays, as players show it; its name stays Play, and pressed says it's on.\n icon={playback.playing ? <PauseIcon /> : <PlayIcon />}\n pressed={playback.playing}\n onPressedChange={play}\n // Space plays and pauses from anywhere in the editor but a control (sdk-core ADR 0030).\n aria-keyshortcuts=\"Space\"\n disabled={count < 2}\n />\n <Slider\n className=\"hm-image-timeline-scrubber\"\n label={messages.t(\"timeline.frame\")}\n min={0}\n max={Math.max(1, count - 1)}\n step={1}\n value={frame}\n disabled={count < 2}\n formatValue={position}\n onValueChange={seek}\n />\n <output className=\"hm-image-timeline-position\" aria-hidden=\"true\">\n {messages.t(\"timeline.where\", { frame: frame + 1, count, seconds: delay / 100 })}\n </output>\n </section>\n );\n}\n","import type { ShortcutRegistry, ToolRegistry } from \"@hussmartinez/sdk-core\";\nimport {\n IconButton,\n type IconComponent,\n Toolbar,\n ToolbarGroup,\n Tooltip,\n} from \"@hussmartinez/ui/react\";\nimport type { ReactNode } from \"react\";\nimport type { ImageTool, ImageToolContext } from \"../../features/tool-types.js\";\nimport { useImageDocument, useImageEditorState, useImageMessages } from \"../hooks.js\";\n\n/**\n * Props of {@link ImageToolbar}.\n *\n * @public\n */\nexport interface ImageToolbarProps {\n /** The editor's tools, from `createToolRegistry`. */\n readonly registry: ToolRegistry<ImageTool>;\n /** The editor's shortcuts, for each button's `aria-keyshortcuts`. */\n readonly shortcuts?: ShortcutRegistry;\n /** What the tools run against. */\n readonly context: ImageToolContext;\n /** Icon components by name, over the SDK's own. */\n readonly icons: Readonly<Record<string, IconComponent>>;\n readonly className?: string;\n}\n\n/**\n * The editor's toolbar (docs/adr/0007): ui's Toolbar, one group per toolbar\n * group of the registry, one button per tool, disabled when it can't run,\n * with the tool's shortcuts as `aria-keyshortcuts`.\n *\n * @public\n */\nexport function ImageToolbar(props: ImageToolbarProps): ReactNode {\n const { registry, shortcuts, context, icons } = props;\n const messages = useImageMessages();\n const snapshot = useImageDocument();\n const [editor] = useImageEditorState();\n const state = { snapshot, editor };\n const t = messages.t as (key: string) => string;\n return (\n <Toolbar label={messages.t(\"toolbar.label\")} className={props.className}>\n {registry.toolbar.map((group) => {\n const available = group.filter((tool) => tool.isAvailable?.(state) ?? true);\n // A group with nothing to offer, such as the frames for a still, isn't there at all.\n if (available.length === 0) return null;\n return (\n <ToolbarGroup\n key={group.map((tool) => tool.id).join(\" \")}\n label={t(`toolbar.groups.${group[0]?.group ?? \"other\"}`)}\n >\n {available.map((tool) => {\n const Icon = icons[tool.icon];\n const keys = shortcuts?.ariaKeyShortcuts(tool.id);\n const disabled = !(tool.isEnabled?.(state) ?? true);\n // A tool that says why it can't run stays in the keyboard's\n // order, described by the reason, in a tooltip sighted users\n // get too. The others are plainly disabled.\n const reason = disabled ? tool.unavailable?.(state) : undefined;\n const button = (\n <IconButton\n key={tool.id}\n data-tool={tool.id}\n label={t(tool.label)}\n icon={Icon ? <Icon /> : null}\n disabled={disabled}\n {...(reason ? { focusableWhenDisabled: true } : {})}\n {...(tool.isActive ? { pressed: tool.isActive(state) } : {})}\n {...(keys ? { \"aria-keyshortcuts\": keys } : {})}\n onClick={() => void tool.run(context)}\n />\n );\n return reason ? (\n <Tooltip key={tool.id} content={t(reason)}>\n {button}\n </Tooltip>\n ) : (\n button\n );\n })}\n </ToolbarGroup>\n );\n })}\n </Toolbar>\n );\n}\n","import {\n AddIcon,\n ArrowIcon,\n CropIcon,\n DownloadIcon,\n EllipseIcon,\n FitIcon,\n FlipHorizontalIcon,\n FlipVerticalIcon,\n type IconComponent,\n LayersIcon,\n OpenIcon,\n PageGridIcon,\n PenIcon,\n PlayIcon,\n RectangleIcon,\n RedactIcon,\n RedoIcon,\n RotateLeftIcon,\n RotateRightIcon,\n SearchIcon,\n TextIcon,\n UndoIcon,\n ZoomInIcon,\n ZoomOutIcon,\n} from \"@hussmartinez/ui/react\";\n\n/**\n * The components of the icons the editor's tools name, from ui's set\n * (sdk-core ADR 0030). A host's `icons` prop overrides any of them.\n *\n * @public\n */\nexport const imageIcons: Readonly<Record<string, IconComponent>> = {\n open: OpenIcon,\n undo: UndoIcon,\n play: PlayIcon,\n redo: RedoIcon,\n \"rotate-left\": RotateLeftIcon,\n \"rotate-right\": RotateRightIcon,\n \"zoom-in\": ZoomInIcon,\n \"zoom-out\": ZoomOutIcon,\n fit: FitIcon,\n crop: CropIcon,\n redact: RedactIcon,\n layers: LayersIcon,\n frames: PageGridIcon,\n text: TextIcon,\n rectangle: RectangleIcon,\n ellipse: EllipseIcon,\n \"add-image\": AddIcon,\n arrow: ArrowIcon,\n pen: PenIcon,\n export: DownloadIcon,\n \"flip-horizontal\": FlipHorizontalIcon,\n \"flip-vertical\": FlipVerticalIcon,\n search: SearchIcon,\n};\n","import { createShortcutRegistry, createToolRegistry } from \"@hussmartinez/sdk-core\";\nimport { AnnouncerProvider, useAnnounce, usePlatform } from \"@hussmartinez/ui/react\";\nimport {\n type ForwardedRef,\n forwardRef,\n type KeyboardEvent,\n type ReactNode,\n useEffect,\n useImperativeHandle,\n useInsertionEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { engineInternals } from \"../../adapters/image-engine.js\";\nimport type { ImageSessionEvent } from \"../../core/session/session.js\";\nimport { NO_TOOL, PAUSED } from \"../../features/editor-state.js\";\nimport type { ImageToolContext } from \"../../features/tool-types.js\";\nimport { DEFAULT_TOOLBAR, imageTools } from \"../../features/tools.js\";\nimport { EngineBoundary } from \"../EngineBoundary.js\";\nimport { ImageExportDialog } from \"../export/ExportDialog.js\";\nimport { useImageDocument, useImageEditorState, useImageInternals } from \"../hooks.js\";\nimport { ImageProvider } from \"../ImageEditorProvider.js\";\nimport { ImageInspector } from \"../panels/Inspector.js\";\nimport { ImageStage } from \"../stage/ImageStage.js\";\nimport { AnimationBar } from \"../timeline/AnimationBar.js\";\nimport { ImageToolbar } from \"../toolbar/ImageToolbar.js\";\nimport { imageIcons } from \"../toolbar/icons.js\";\nimport type { ImageEditorHandle, ImageEditorProps } from \"./types.js\";\n\nconst join = (...names: (string | undefined | false)[]) => names.filter(Boolean).join(\" \");\n\ninterface BodyProps\n extends Pick<\n ImageEditorProps,\n | \"initialFile\"\n | \"plan\"\n | \"onChange\"\n | \"tools\"\n | \"toolbar\"\n | \"icons\"\n | \"className\"\n | \"classNames\"\n | \"unstyled\"\n | \"onExport\"\n | \"features\"\n | \"theme\"\n > {\n readonly handle: ForwardedRef<ImageEditorHandle>;\n readonly events: { current: ((event: ImageSessionEvent) => void) | undefined };\n}\n\nfunction ImageEditorBody(props: BodyProps): ReactNode {\n const { initialFile, onChange, classNames = {}, unstyled = false, handle, events } = props;\n const { engine, session, messages, view, editor, opener, inserter } = useImageInternals();\n const snapshot = useImageDocument();\n const announce = useAnnounce();\n const root = useRef<HTMLElement>(null);\n const input = useRef<HTMLInputElement>(null);\n const layerInput = useRef<HTMLInputElement>(null);\n const latestOnChange = useRef(onChange);\n latestOnChange.current = onChange;\n\n // Export off takes its tool out of the registry, so no button or key runs it.\n const exportOn = props.features?.export !== false;\n const registry = useMemo(() => {\n const wanted = (id: string) =>\n (!props.tools || props.tools.includes(id)) && (exportOn || id !== \"image.export\");\n const tools = props.tools ?? imageTools.map((tool) => tool.id);\n return createToolRegistry(imageTools, {\n tools: tools.filter(wanted),\n toolbar: (props.toolbar ?? DEFAULT_TOOLBAR)\n .map((group) => group.filter(wanted))\n .filter((group) => group.length > 0),\n });\n }, [props.tools, props.toolbar, exportOn]);\n // \"other\" on the server and during hydration, then the device's own keys.\n const platform = usePlatform();\n const shortcuts = useMemo(\n () => createShortcutRegistry({ platform, tools: registry.tools }),\n [platform, registry],\n );\n const context: ImageToolContext = useMemo(\n () => ({\n session,\n view,\n editor,\n chooseFile: () => input.current?.click(),\n chooseLayerImage: () => layerInput.current?.click(),\n }),\n [session, view, editor],\n );\n const icons = useMemo(() => ({ ...imageIcons, ...props.icons }), [props.icons]);\n\n useImperativeHandle(\n handle,\n () => ({\n session,\n open: async (file) => {\n engineInternals(engine)?.check();\n await opener.open(file);\n },\n insertImage: async (file) => {\n engineInternals(engine)?.check();\n await inserter.insert(file);\n },\n execute: (commands) => session.execute(commands),\n export: (format) => session.export(format),\n undo: () => {\n session.undo();\n },\n redo: () => {\n session.redo();\n },\n }),\n [engine, session, opener, inserter],\n );\n\n // The host's first image opens on mount; a later one replaces it.\n const initial = useRef(initialFile);\n useEffect(() => {\n if (initial.current) void opener.open(initial.current);\n }, [opener]);\n\n // Committed changes reach the host, never a gesture's transient plans.\n useEffect(() => {\n let before = session.getSnapshot().plan;\n return session.subscribe(() => {\n const after = session.getSnapshot().plan;\n if (after === before) return;\n before = after;\n if (after) latestOnChange.current?.(after);\n });\n }, [session]);\n\n // Opens, undos and redos reach screen readers, politely.\n useEffect(() => {\n events.current = (event) => {\n if (event.outcome !== \"done\") return;\n const action = event.commands[0];\n const name = action ? messages.t(`actions.${action}`) : \"\";\n if (event.type === \"undo\") announce(messages.t(\"editor.undid\", { action: name }));\n if (event.type === \"redo\") announce(messages.t(\"editor.redid\", { action: name }));\n if (event.type === \"open\") {\n const source = session.getSnapshot().source;\n if (source)\n announce(messages.t(\"editor.opened\", { width: source.width, height: source.height }));\n }\n };\n return () => {\n events.current = undefined;\n };\n }, [announce, events, messages, session]);\n\n // After an open, focus moves to the first tool it enabled, when focus was\n // in the editor or nowhere; focus elsewhere on the host's page stays.\n const previous = useRef(snapshot.source?.id);\n useEffect(() => {\n const id = snapshot.source?.id;\n if (id === previous.current) return;\n previous.current = id;\n if (!id) return;\n const active = document.activeElement;\n const ours = active === null || active === document.body || root.current?.contains(active);\n if (!ours) return;\n const buttons = root.current?.querySelectorAll<HTMLButtonElement>(\n \".hm-image-editor-toolbar button:not([disabled])\",\n );\n const next = [...(buttons ?? [])].find((button) => button.dataset[\"tool\"] !== \"image.open\");\n next?.focus();\n }, [snapshot.source?.id]);\n\n // A host's plan is applied when it changes: one undoable step of the\n // commands that reach it. A plan for another image waits for that image.\n const hostPlan = props.plan;\n const openSource = snapshot.plan?.base.source;\n useEffect(() => {\n if (!hostPlan || openSource !== hostPlan.base.source) return;\n try {\n session.applyPlan(hostPlan);\n } catch {\n // In the snapshot: the stage shows it.\n }\n }, [hostPlan, session, openSource]);\n\n // Cropping and the export dialog end when another image opens, and an\n // animation starts again from its first frame, paused.\n const sourceId = snapshot.source?.id;\n useEffect(() => {\n if (sourceId === undefined) return;\n editor.set((state) =>\n state.tool === null &&\n state.dialog === null &&\n state.error === null &&\n state.playback === PAUSED\n ? state\n : {\n ...state,\n ...NO_TOOL,\n preview: null,\n dialog: null,\n error: null,\n playback: PAUSED,\n },\n );\n }, [editor, sourceId]);\n\n // Focus returns to where it was when a tool took the stage: its button, or\n // whatever had focus when its shortcut was pressed (docs/adr/0007).\n const [{ tool }] = useImageEditorState();\n const returnTo = useRef<HTMLElement | null>(null);\n const previousTool = useRef(tool);\n useEffect(\n () =>\n editor.subscribe(() => {\n const next = editor.getSnapshot().tool;\n if (next !== null && previousTool.current !== next) {\n const active = document.activeElement;\n returnTo.current =\n active instanceof HTMLElement && root.current?.contains(active) ? active : null;\n }\n }),\n [editor],\n );\n useEffect(() => {\n if (previousTool.current === tool) return;\n const was = previousTool.current;\n previousTool.current = tool;\n if (tool === \"redact\") {\n // Redacting starts on the button that adds an area without dragging;\n // cropping starts on its frame, which focuses itself.\n root.current?.querySelector<HTMLElement>(\".hm-image-redact-add\")?.focus();\n return;\n }\n // The layers' panel takes focus itself, when its tool asks: adding a\n // shape or an image leaves focus where it was.\n if (tool === \"layers\") return;\n if (was === null || tool !== null) return;\n const target = returnTo.current?.isConnected\n ? returnTo.current\n : root.current?.querySelector<HTMLElement>(`[data-tool=\"image.${was}\"]`);\n target?.focus();\n }, [tool]);\n\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n if (engineInternals(engine)?.getSnapshot()) return;\n // The root bounds the search for a modal dialog: keys from one inside the\n // editor, such as export's, stay its own, while a host's dialog holding\n // the whole editor doesn't stop its shortcuts (sdk-core 0.4.2).\n const id = shortcuts.match(event.nativeEvent, { root: event.currentTarget });\n const tool = id ? registry.get(id) : undefined;\n if (!tool) return;\n const state = { snapshot: session.getSnapshot(), editor: editor.getSnapshot() };\n if (!(tool.isEnabled?.(state) ?? true)) return;\n event.preventDefault();\n void tool.run(context);\n };\n\n return (\n // The root takes the editor's shortcuts while focus is inside it, never\n // on window (WCAG 2.1.4, sdk-core ADR 0030). A named section is a region\n // landmark, so the editor is easy to find on a host's page.\n <section\n ref={root}\n className={join(\n \"hm-image-editor\",\n !unstyled && \"hm-image-editor--styled\",\n props.className,\n classNames.root,\n )}\n onKeyDown={onKeyDown}\n aria-label={messages.t(\"editor.label\")}\n // ui's colour mode for the editor alone; unset, it inherits the page's.\n {...(props.theme ? { \"data-hm-theme\": props.theme } : {})}\n >\n <EngineBoundary>\n <input\n ref={input}\n type=\"file\"\n accept=\"image/*\"\n hidden\n tabIndex={-1}\n onChange={(event) => {\n const file = event.currentTarget.files?.[0];\n event.currentTarget.value = \"\";\n if (file) void opener.open(file);\n }}\n />\n <input\n ref={layerInput}\n type=\"file\"\n accept=\"image/*\"\n hidden\n tabIndex={-1}\n onChange={(event) => {\n const file = event.currentTarget.files?.[0];\n event.currentTarget.value = \"\";\n if (file) void inserter.insert(file);\n }}\n />\n <div className=\"hm-image-editor-layout\">\n <ImageToolbar\n registry={registry}\n shortcuts={shortcuts}\n context={context}\n icons={icons}\n className={join(\"hm-image-editor-toolbar\", classNames.toolbar)}\n />\n <ImageStage className={join(\"hm-image-editor-stage\", classNames.stage)} />\n <AnimationBar className=\"hm-image-editor-timeline\" />\n <div className={join(\"hm-image-editor-inspector\", classNames.inspector)}>\n <ImageInspector {...(props.features ? { features: props.features } : {})} />\n </div>\n </div>\n {exportOn ? (\n <ImageExportDialog {...(props.onExport ? { onExport: props.onExport } : {})} />\n ) : null}\n </EngineBoundary>\n </section>\n );\n}\n\n/**\n * The image editor (docs/adr/0007): a toolbar and a stage over an image\n * session, with the family's shortcuts while focus is inside it. It creates\n * its engine, processor and session unless you pass them, and destroys only\n * what it created. Import `@hussmartinez/ui/styles.css` once, then this\n * package's `styles.css`: ui's stylesheet carries the focus rings and target\n * sizes the editor's accessibility relies on (sdk-core ADR 0036).\n *\n * @example\n * ```tsx\n * <ImageEditor initialFile={file} onChange={(plan) => save(plan)} />\n * ```\n *\n * @public\n */\nexport const ImageEditor = forwardRef(function ImageEditor(\n props: ImageEditorProps,\n ref: ForwardedRef<ImageEditorHandle>,\n): ReactNode {\n const {\n initialFile,\n plan,\n onChange,\n tools,\n toolbar,\n icons,\n className,\n classNames,\n unstyled,\n onEvent,\n onExport,\n features,\n theme,\n ...provider\n } = props;\n // The editor listens to the session's events for its announcements, and\n // passes them on to the host's handler.\n const events = useRef<((event: ImageSessionEvent) => void) | undefined>(undefined);\n // Set when the render commits, never during it, as the provider does.\n const latestOnEvent = useRef(onEvent);\n useInsertionEffect(() => {\n latestOnEvent.current = onEvent;\n }, [onEvent]);\n const [onSessionEvent] = useMemo(\n () => [\n (event: ImageSessionEvent) => {\n events.current?.(event);\n latestOnEvent.current?.(event);\n },\n ],\n [],\n );\n return (\n <ImageProvider {...provider} onEvent={onSessionEvent} boundary={false}>\n <AnnouncerProvider>\n <ImageEditorBody\n handle={ref}\n events={events}\n {...(initialFile ? { initialFile } : {})}\n {...(onChange ? { onChange } : {})}\n {...(plan ? { plan } : {})}\n {...(tools ? { tools } : {})}\n {...(toolbar ? { toolbar } : {})}\n {...(icons ? { icons } : {})}\n {...(className ? { className } : {})}\n {...(classNames ? { classNames } : {})}\n {...(unstyled === undefined ? {} : { unstyled })}\n {...(onExport ? { onExport } : {})}\n {...(features ? { features } : {})}\n {...(theme ? { theme } : {})}\n />\n </AnnouncerProvider>\n </ImageProvider>\n );\n});\n"],"mappings":";;;;;;;AAkFA,IAAa,SAAS,OAAO,OAAO;CAAE,OAAO;CAAG,SAAS;AAAM,CAAC;AAMhE,IAAa,UAAU,OAAO,OAAO;CACnC,MAAM;CACN,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,MAAM;AACR,CAAqC;AAErC,IAAa,OAAyB,OAAO,OAAO;CAClD,GAAG;CACH,OAAO;CACP,SAAS;CACT,QAAQ;CACR,UAAU;AACZ,CAAC;AAGD,SAAgB,oBAA6C;CAC3D,OAAO,YAA8B,IAAI;AAC3C;;AC1DA,IAAa,eAAe,EAAE,eAAwC,SAAS,SAAS;;AC1CxF,SAAS,UAAU,E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