@yuzhouu/canvas-standard 0.1.7 → 0.1.8

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.
Files changed (44) hide show
  1. package/_vendor/plugin-draw/_vendor/canvas-core/editor/editor.d.ts +4 -0
  2. package/_vendor/plugin-draw/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  3. package/_vendor/plugin-draw/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  4. package/_vendor/plugin-eraser/_vendor/canvas-core/editor/editor.d.ts +4 -0
  5. package/_vendor/plugin-eraser/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  6. package/_vendor/plugin-eraser/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  7. package/_vendor/plugin-flow/_vendor/canvas-core/editor/editor.d.ts +4 -0
  8. package/_vendor/plugin-flow/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  9. package/_vendor/plugin-flow/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  10. package/_vendor/plugin-frame/_vendor/canvas-core/editor/editor.d.ts +4 -0
  11. package/_vendor/plugin-frame/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  12. package/_vendor/plugin-frame/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  13. package/_vendor/plugin-geo/_vendor/canvas-core/editor/editor.d.ts +4 -0
  14. package/_vendor/plugin-geo/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  15. package/_vendor/plugin-geo/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  16. package/_vendor/plugin-group/_vendor/canvas-core/editor/editor.d.ts +4 -0
  17. package/_vendor/plugin-group/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  18. package/_vendor/plugin-group/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  19. package/_vendor/plugin-html/_vendor/canvas-core/editor/editor.d.ts +4 -0
  20. package/_vendor/plugin-html/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  21. package/_vendor/plugin-html/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  22. package/_vendor/plugin-image/_vendor/canvas-core/editor/editor.d.ts +4 -0
  23. package/_vendor/plugin-image/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  24. package/_vendor/plugin-image/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  25. package/_vendor/plugin-laser/_vendor/canvas-core/editor/editor.d.ts +4 -0
  26. package/_vendor/plugin-laser/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  27. package/_vendor/plugin-laser/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  28. package/_vendor/plugin-path/_vendor/canvas-core/editor/editor.d.ts +4 -0
  29. package/_vendor/plugin-path/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  30. package/_vendor/plugin-path/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  31. package/_vendor/plugin-runtime-clipboard/_vendor/canvas-core/editor/editor.d.ts +4 -0
  32. package/_vendor/plugin-runtime-clipboard/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  33. package/_vendor/plugin-runtime-clipboard/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  34. package/_vendor/plugin-runtime-export/_vendor/canvas-core/editor/editor.d.ts +4 -0
  35. package/_vendor/plugin-runtime-export/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  36. package/_vendor/plugin-runtime-export/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  37. package/_vendor/plugin-text/_vendor/canvas-core/editor/editor.d.ts +4 -0
  38. package/_vendor/plugin-text/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  39. package/_vendor/plugin-text/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  40. package/_vendor/plugin-video/_vendor/canvas-core/editor/editor.d.ts +4 -0
  41. package/_vendor/plugin-video/_vendor/canvas-core/editor/records/documentSnapshots.d.ts +4 -1
  42. package/_vendor/plugin-video/_vendor/canvas-core/editor/viewport/camera.d.ts +6 -3
  43. package/index.mjs +1 -1
  44. package/package.json +2 -2
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -288,6 +291,7 @@ export declare class Editor {
288
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
289
292
  };
290
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
291
295
  readonly getCamera: (pageId?: PageId) => Camera;
292
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
293
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
package/index.mjs CHANGED
@@ -5,7 +5,7 @@ return o(gr,{shape:t,strokeWidth:e})}var wr={id:"draw",editor:hr(),render:mr(),a
5
5
  return i("div",{style:{height:"100%",overflow:"visible",position:"relative",width:"100%"},children:[o(qo,{shape:e}),o(Go,{editor:t,shape:e,isEditing:n?.shapeId===e.id})]})}function qo({shape:t}){const{fill:e,h:n,stroke:r,strokeWidth:i,w:s}=t.props,a=i/2,l=Math.max(s-i,0),c=Math.max(n-i,0);
6
6
  return o("svg",{width:"100%",height:"100%",viewBox:`0 0 ${s} ${n}`,style:{display:"block",overflow:"visible"},shapeRendering:"geometricPrecision",children:o("rect",{x:a,y:a,width:l,height:c,fill:Lt(e),stroke:Lt(r),strokeWidth:i,strokeLinejoin:"round",strokeLinecap:"round"})})}function Vo({shape:e,strokeWidth:n}){const{h:r,w:i}=e.props;
7
7
  return o("svg",{"data-ui":"frame-hover-outline",width:"100%",height:"100%",viewBox:`0 0 ${i} ${r}`,style:{display:"block",overflow:"visible",pointerEvents:"none"},shapeRendering:"geometricPrecision",children:o("rect",{x:0,y:0,width:i,height:r,fill:"none",stroke:t,strokeWidth:n,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})})}function Go({editor:t,shape:n,isEditing:r}){
8
- return o(e,{editor:t,shape:n,isEditing:r,value:n.props.name,fallback:Co(""),bodyWidth:n.props.w,bodyHeight:n.props.h,renderHeight:0,operationKind:Bo,editAriaLabel:"Edit frame name",inputAriaLabel:"Frame name",dataUi:{heading:"frame-canvas-heading",dragHandle:"frame-drag-handle",name:"frame-canvas-name",input:"frame-canvas-name-input"},offsetX:0,showDragHandle:!1,onValueChange:e=>{t.commands.updateShapes([{id:n.id,props:{name:e}}],{source:"user"})}})}var Jo={id:"frame",editor:_o(),render:Xo(),api:Oo,setup:({editor:t})=>({api:zo({editor:t})})},Zo=1e-4,Qo=1e-4,ti="image.crop",ei=[{label:"1:1",value:"1:1",ratio:1},{label:"4:3",value:"4:3",ratio:4/3},{label:"16:9",value:"16:9",ratio:16/9}],ni={top_left:"nwse-resize",top:"ns-resize",top_right:"nesw-resize",right:"ew-resize",bottom_right:"nwse-resize",bottom:"ns-resize",bottom_left:"nesw-resize",left:"ew-resize"},ri=["top_left","top","top_right","right","bottom_right","bottom","bottom_left","left"];function oi(t){return Math.min(1,Math.max(0,t))}function ii(t,e,n){return Math.min(n,Math.max(e,t))}function si(t){return!!t&&"object"==typeof t&&"number"==typeof t.x&&Number.isFinite(t.x)&&"number"==typeof t.y&&Number.isFinite(t.y)}function ai(t,e){const n=oi(t),r=oi(e);let o=Math.min(n,r),i=Math.max(n,r);if(i-o<Zo){const t=(o+i)/2;o=Math.max(0,Math.min(.9999,t-5e-5)),i=o+Zo}return{min:o,max:i}}function li(t){if(!t||"object"!=typeof t)return null;const e=t;if(!si(e.topLeft)||!si(e.bottomRight))return null;const n=ai(e.topLeft.x,e.bottomRight.x),r=ai(e.topLeft.y,e.bottomRight.y);return{topLeft:{x:n.min,y:r.min},bottomRight:{x:n.max,y:r.max}}}function ci(t){const e=li(t);if(!e)return null;const n=e.topLeft.x,r=e.topLeft.y,o=e.bottomRight.x,i=e.bottomRight.y;return{left:n,top:r,right:o,bottom:i,width:o-n,height:i-r}}function di(t){return ci(t)??{left:0,top:0,right:1,bottom:1,width:1,height:1}}function ui(t,e){return Math.abs(t.left-e.left)<=Qo&&Math.abs(t.top-e.top)<=Qo&&Math.abs(t.right-e.right)<=Qo&&Math.abs(t.bottom-e.bottom)<=Qo}function pi(t){return function(t){return Math.abs(t.left)<=Qo&&Math.abs(t.top)<=Qo&&Math.abs(1-t.right)<=Qo&&Math.abs(1-t.bottom)<=Qo}(t)?null:li({topLeft:{x:t.left,y:t.top},bottomRight:{x:t.right,y:t.bottom}})}function hi({centerX:t,centerY:e,height:n,width:r}){const o=ii(r,Zo,1),i=ii(n,Zo,1),s=ii(t-o/2,0,1-o),a=ii(e-i/2,0,1-i);return{left:s,top:a,right:s+o,bottom:a+i,width:o,height:i}}function fi(t){return{x:t.left+t.width/2,y:t.top+t.height/2}}function gi({crop:t,shape:e}){const n=di(t);return{w:e.props.w/n.width,h:e.props.h/n.height}}function mi(t){const e=t.props.w/t.props.h;for(const n of ei)if(Math.abs(e-n.ratio)<=.01)return n.value;return null}function yi(t,e){return e===xi(t.id)}function xi(t){return`image.crop:edit:${t}`}function wi({localToPage:t,shape:e}){const n=e.props.w,r=e.props.h,o=(0+n)/2,i=(0+r)/2,s={top_left:new yt(0,0),top:new yt(o,0),top_right:new yt(n,0),right:new yt(n,i),bottom_right:new yt(n,r),bottom:new yt(o,r),bottom_left:new yt(0,r),left:new yt(0,i)};return ri.map(e=>{return{kind:"custom",type:ti,id:e,point:t.applyToPoint(s[e]),cursor:(n=e,ni[n])};var n})}function bi({change:t,crop:e,shape:n}){const r=gi({crop:e,shape:n}),o=e.bottomRight.x-e.topLeft.x,i=e.bottomRight.y-e.topLeft.y,s=ii(e.topLeft.x-t.x/r.w,0,1-o),a=ii(e.topLeft.y-t.y/r.h,0,1-i),l=li({topLeft:{x:s,y:a},bottomRight:{x:s+o,y:a+i}});return l?{id:n.id,props:{crop:l}}:null}function ki({preset:t,shape:e}){const n=fi(di(e.props.crop)),r=gi({crop:e.props.crop,shape:e}),o=ei.find(e=>e.value===t)?.ratio??null;if(!o)return null;const i=o*(r.h/r.w);let s=1,a=s/i;return a>1&&(a=1,s=a*i),function({nextRect:t,shape:e}){const n=di(e.props.crop);if(ui(n,t))return null;const r=gi({crop:e.props.crop,shape:e}),o=new yt((t.left-n.left)*r.w,(t.top-n.top)*r.h).rot(e.rotation);return{id:e.id,x:e.x+o.x,y:e.y+o.y,props:{w:t.width*r.w,h:t.height*r.h,crop:pi(t)}}}({nextRect:hi({centerX:n.x,centerY:n.y,width:s,height:a}),shape:e})}function vi(t){return Number.isFinite(t)?Number(t.toFixed(4)).toString():"0"}var Si=new WeakMap;function Ii(t,e){return Si.get(t)?.get(e)??null}function Pi(t,e){const n=Si.get(t);n&&(n.delete(e),0===n.size&&Si.delete(t))}function Mi(t){return gt(t)&&"image"===t.type}function Ti(t){return ft(t)&&"image"===t.type}var Ci={propagation:"stop"};function Ei({handleId:t,shapeId:e,startPagePoint:n,startPageToLocal:r,startShape:o,startCrop:i}){return{shapeId:e,operationKind:"image.crop.handle",update({editor:s,pagePoint:a,source:l}){if(!Ti(s.shapes.get(e)))return"stop";const c=function({handleId:t,pageToLocal:e,shape:n,startCrop:r,startPagePoint:o,currentPagePoint:i}){const s=li(r)??{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},a=gi({crop:s,shape:n});if(a.w<8||a.h<8)return null;const l=e.applyToPoint(o),c=e.applyToPoint(i).sub(l);if(0===c.x&&0===c.y)return null;const d={x:s.topLeft.x*a.w,y:s.topLeft.y*a.h,w:(s.bottomRight.x-s.topLeft.x)*a.w,h:(s.bottomRight.y-s.topLeft.y)*a.h},u=d.x+d.w,p=d.y+d.h;let h=d.x,f=d.y,g=d.w,m=d.h;!function(t){return"top_left"===t||"left"===t||"bottom_left"===t}(t)?function(t){return"top_right"===t||"right"===t||"bottom_right"===t}(t)&&(g=ii(u+c.x,d.x+8,a.w)-h):(h=ii(h+c.x,0,u-8),g=u-h),function(t){return"top_left"===t||"top"===t||"top_right"===t}(t)?(f=ii(f+c.y,0,p-8),m=p-f):function(t){return"bottom_left"===t||"bottom"===t||"bottom_right"===t}(t)&&(m=ii(p+c.y,d.y+8,a.h)-f);const y=li({topLeft:{x:h/a.w,y:f/a.h},bottomRight:{x:(h+g)/a.w,y:(f+m)/a.h}});if(!y)return null;const x=new yt(h-s.topLeft.x*a.w,f-s.topLeft.y*a.h).rot(n.rotation);return{id:n.id,x:n.x+x.x,y:n.y+x.y,props:{w:g,h:m,crop:y}}}({handleId:t,currentPagePoint:a,pageToLocal:r,shape:o,startCrop:i,startPagePoint:n});return c?(s.commands.updateShapes([c],{source:l}),"continue"):"continue"}}}function Li(){return{createSession(t,{handle:e,shape:n,originPagePoint:r}){return Ti(n)&&"custom"===e.kind&&"image.crop"===e.type&&(o=e.id,ri.some(t=>t===o))?Ei({handleId:e.id,shapeId:n.id,startPagePoint:r,startPageToLocal:t.shapes.computeLocalToPageTransform(n).invert(),startShape:n,startCrop:n.props.crop}):null;var o}}}function Ai(){let t=null;const e=()=>{t?.operation?.isActive&&t.operation.cancel(),t=null};return{id:"land.image.crop.interactions",editorEvent:{handleEvent(n,r){if("cancel"!==r.type){if("keyboard"===r.type)return function(t,e){if("key_down"!==e.name)return;const n=Ri(t);if(!n)return;if("Escape"===e.key&&!e.altKey&&!e.accelKey)return t.editing.cancel("user")&&Pi(t,n.id),Ci;if("Enter"===e.key&&!e.altKey&&!e.accelKey)return t.editing.complete("user")&&Pi(t,n.id),Ci;const r=function(t){if(t.altKey||t.accelKey)return null;const e=t.shiftKey?10:1;switch(t.key){case"ArrowLeft":return new yt(e,0);case"ArrowRight":return new yt(-e,0);case"ArrowUp":return new yt(0,e);case"ArrowDown":return new yt(0,-e);default:return null}}(e);if(r){const e=function({pageDelta:t,shape:e,startCrop:n}){const r=li(n);return!r||t.equals(yt.Zero())?null:bi({change:t.rot(-e.rotation),crop:r,shape:e})}({pageDelta:r,shape:n,startCrop:n.props.crop});return e&&t.commands.updateShapes([e],{source:"user"}),Ci}}(n,r);if("pointer"===r.type)if("pointer_cancel"!==r.name){if("pointer_down"===r.name){if(e(),0!==r.button||"select"!==n.state.tool.get().activeToolId||!n.tools.isInInitialState())return;if(n.selection.hitTestHandle(r.pagePoint))return;const o=Ri(n);if(!o)return;return function(t,e,n){const r=t.shapes.computeLocalToPageTransform(e).invert().applyToPoint(n.pagePoint);return r.x>=0&&r.y>=0&&r.x<=e.props.w&&r.y<=e.props.h}(n,o,r)?(t={pointerId:r.pointerId,shapeId:o.id,startCrop:o.props.crop,startPagePoint:r.pagePoint.clone(),startScreenPoint:r.screenPoint.clone(),startPageToLocal:n.shapes.computeLocalToPageTransform(o).invert(),startShape:o,hasDragged:!1,operation:null},Ci):n.editing.complete("user")?(Pi(n,o.id),n.handleEvent(r),Ci):void 0}if(t&&r.pointerId===t.pointerId)return"pointer_move"===r.name?($i(n,r,t),Ci):"pointer_up"===r.name?($i(n,r,t),t.operation?.isActive&&t.operation.commit(),e(),Ci):void 0}else e()}else e()}},selectionHandle:Li()}}function Ri(t){const[e]=t.state.selectedShapes.get();if(!Ti(e))return null;const n=t.state.shapeEditingSession.get();return n&&n.shapeId===e.id&&yi(e,n.operationKind)?e:null}function $i(t,e,n){if(!n.hasDragged){if(n.startScreenPoint.dist2(e.screenPoint)<9)return;n.operation=t.operations.begin({kind:"image.crop.translate",label:"shape.edit",source:"user",history:"record"}),n.hasDragged=!0}if(!Ti(t.shapes.get(n.shapeId)))return;const r=function({currentPagePoint:t,pageToLocal:e,shape:n,startCrop:r,startPagePoint:o,shiftKey:i}){const s=li(r);if(!s)return null;const a=e.applyToPoint(o);let l=e.applyToPoint(t).sub(a);return i&&(l=Math.abs(l.x)<Math.abs(l.y)?new yt(0,l.y):new yt(l.x,0)),0===l.x&&0===l.y?null:bi({change:l,crop:s,shape:n})}({currentPagePoint:e.pagePoint,pageToLocal:n.startPageToLocal,shape:n.startShape,shiftKey:e.shiftKey,startCrop:n.startCrop,startPagePoint:n.startPagePoint});r&&t.commands.updateShapes([r],{source:"user"})}function Ni(t,e=0){return Math.max(0,"number"==typeof t&&Number.isFinite(t)?t:e)}function Bi({cornerRadius:t,h:e,w:n}){return Math.min(Ni(t),Math.max(0,n)/2,Math.max(0,e)/2)}var Oi=24,zi="#ffff00",Hi=1,Di=128,Fi=24,Wi=zi,ji=.45,Ui=class{editor;confirmHandler=null;deactivateHistoryScope=null;session=null;snapshot=null;subscribers=new Set;constructor(t){this.editor=t,de("image.smudgeSession.lifecycle",t.state.shapeEditingSession,()=>{this.clearIfEditingSessionInvalid()},{fireImmediately:!1})}start(t,e){if(t.isLocked)return!1;const n=Yi(t.id),r=this.editor.state.shapeEditingSession.get();if(r&&(r.shapeId!==t.id||r.operationKind!==n))return!1;if(this.session&&r?.shapeId===t.id&&qi(t,r.operationKind))return this.updateSession({...this.session,brush:Vi({...this.session.brush,...e})}),!0;this.clear();const o=this.editor.editing.start({shapeId:t.id,operationKind:n,entryMode:"focusEnd"},"user");return!(!o||o.shapeId!==t.id||o.operationKind!==n)&&(this.setSession({shapeId:t.id,brush:Vi(e),strokes:[],activeStroke:null,redoStrokes:[],nextStrokeIndex:1}),this.activateHistoryScope(),!0)}cancel(){const t=this.session?.shapeId??null;this.clear();const e=this.editor.state.shapeEditingSession.get();t&&e?.shapeId===t&&e.operationKind===Yi(t)&&this.editor.editing.cancel("user")}complete(){const t=this.session?.shapeId??null;this.clear();const e=this.editor.state.shapeEditingSession.get();t&&e?.shapeId===t&&e.operationKind===Yi(t)&&this.editor.editing.complete("user")}cancelIfActive(){return!!this.getActiveSession()&&(this.cancel(),!0)}clearForShape(t){this.session?.shapeId===t&&this.clear()}updateBrush(t){if(!this.getActiveSession()||!this.session)return!1;const e=Vi({...this.session.brush,...t});return e.size===this.session.brush.size&&e.color===this.session.brush.color&&e.opacity===this.session.brush.opacity||this.updateSession({...this.session,brush:e}),!0}getSnapshot(t){const e=this.getActiveSession();return e&&e.shapeId===t?this.snapshot:null}getActiveSession(){if(!this.session)return null;const t=this.editor.shapes.get(this.session.shapeId),e=this.editor.state.shapeEditingSession.get();return t&&e&&e.shapeId===this.session.shapeId&&e.operationKind===Yi(this.session.shapeId)?this.snapshot:(this.clear(),null)}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}beginStroke(t){if(!this.session)return;const e=Ki(this.session),n={id:`${e.shapeId}:smudge:${e.nextStrokeIndex}`,points:[as(t)],brush:{...e.brush}};this.updateSession({...e,activeStroke:n,nextStrokeIndex:e.nextStrokeIndex+1})}appendPoint(t){if(!this.session?.activeStroke)return;const e=this.session.activeStroke.points[this.session.activeStroke.points.length-1];e&&Math.hypot(e.x-t.x,e.y-t.y)<.5||this.updateSession({...this.session,activeStroke:{...this.session.activeStroke,points:[...this.session.activeStroke.points,as(t)]}})}endStroke(){this.session?.activeStroke&&this.updateSession(Ki(this.session))}cancelStroke(){this.session?.activeStroke&&this.updateSession({...this.session,activeStroke:null})}undo(){if(!this.getActiveSession()||!this.session)return!1;if(this.session.activeStroke&&this.updateSession(Ki(this.session)),!this.session||0===this.session.strokes.length)return!1;const t=this.session.strokes[this.session.strokes.length-1];return!!t&&(this.updateSession({...this.session,strokes:this.session.strokes.slice(0,-1),redoStrokes:[...this.session.redoStrokes,t]}),!0)}redo(){if(!this.getActiveSession()||!this.session)return!1;if(this.session.activeStroke||0===this.session.redoStrokes.length)return!1;const t=this.session.redoStrokes[this.session.redoStrokes.length-1];return!!t&&(this.updateSession({...this.session,strokes:[...this.session.strokes,t],redoStrokes:this.session.redoStrokes.slice(0,-1)}),!0)}registerConfirmHandler(t){return this.confirmHandler=t,()=>{this.confirmHandler===t&&(this.confirmHandler=null)}}requestConfirm(t){return this.confirmHandler?this.confirmHandler(t):Promise.resolve(null)}clear(){this.session&&(this.session=null,this.snapshot=null,this.deactivateHistoryScope?.(),this.deactivateHistoryScope=null,this.notify())}clearIfEditingSessionInvalid(){if(!this.session)return;const t=this.editor.state.shapeEditingSession.get();t?.shapeId===this.session.shapeId&&t.operationKind===Yi(this.session.shapeId)||this.clear()}activateHistoryScope(){const t={getState:()=>this.getHistoryScopeState(),subscribe:t=>this.subscribe(t),undo:()=>this.undo(),redo:()=>this.redo()};this.deactivateHistoryScope=this.editor.history.activateScope(t)}getHistoryScopeState(){const t=this.session?.activeStroke?1:0,e=this.session?.activeStroke?0:this.session?.redoStrokes.length??0;return{canUndo:(this.session?.strokes.length??0)+t>0,canRedo:e>0}}setSession(t){this.session=t,this.snapshot=function(t){return{shapeId:t.shapeId,brush:t.brush,strokes:t.activeStroke?[...t.strokes,t.activeStroke]:t.strokes,canUndo:t.strokes.length>0||!!t.activeStroke,canRedo:!t.activeStroke&&t.redoStrokes.length>0}}(t),this.notify()}updateSession(t){this.setSession(t)}notify(){for(const t of this.subscribers)t()}};function Ki(t){return t.activeStroke?{...t,strokes:[...t.strokes,t.activeStroke],activeStroke:null,redoStrokes:[]}:t}var _i=new WeakMap;function Xi(t){const e=_i.get(t);if(e)return e;const n=new Ui(t);return _i.set(t,n),n}function Yi(t){return`image.smudge:edit:${t}`}function qi(t,e){return e===Yi(t.id)}function Vi(t){const e="number"==typeof t?.size&&Number.isFinite(t.size)?t.size:Fi,n="number"==typeof t?.opacity&&Number.isFinite(t.opacity)?t.opacity:ji??.45;return{size:Math.min(128,Math.max(1,e)),color:"string"==typeof t?.color&&t.color.trim().length>0?t.color:Wi,opacity:Math.min(1,Math.max(0,n))}}function Gi({brush:t,editor:e,shape:n}){return Xi(e).start(n,t)}function Ji(t){Xi(t).cancel()}function Zi(t){Xi(t).complete()}function Qi(t){return Xi(t).cancelIfActive()}function ts(t,e){return Xi(t).updateBrush(e)}function es(t){return Xi(t).getActiveSession()}function ns(t){return Xi(t).undo()}function rs(t){return Xi(t).redo()}function os(t,e){return Xi(t).registerConfirmHandler(e)}async function is(t,e){return Xi(t).requestConfirm(e)}function ss(t){return t.map(t=>({id:t.id,brush:{...t.brush},points:t.points.map(as)}))}function as(t){return{x:t.x,y:t.y,...void 0===t.pressure?{}:{pressure:t.pressure}}}function ls(t,e){return"number"==typeof t&&Number.isFinite(t)?t:e}var cs=class extends oe{type="image";getDefaultProps(){return{w:240,h:180,assetId:null,crop:null,cornerRadius:0,altText:""}}validateProps(t){const e=t&&"object"==typeof t?t:{},n=this.getDefaultProps();return{w:Math.max(24,ls(e.w,n.w)),h:Math.max(24,ls(e.h,n.h)),assetId:(r=e.assetId,"string"==typeof r&&r.startsWith("asset:")?e.assetId:null),crop:li(e.crop),cornerRadius:Ni(e.cornerRadius,n.cornerRadius),altText:"string"==typeof e.altText?e.altText:n.altText};var r}getLocalBounds(t){return new xt(0,0,t.props.w,t.props.h)}canReceiveTerminalBinding(t){return!0}getAllowedSelectionResizeModes(t,e){return _t}canEdit(t){return!0}onEditEnd(t,e){var n,r;n=e.editor,r=t.id,Xi(n).clearForShape(r)}getSelectionHandleAnchors(t,e){const n={terminalHandleAnchors:[],middleHandleAnchors:[],customHandleAnchors:[]};if(!e.isOnlySelected)return n;const r=e.editor.state.shapeEditingSession.get();return r&&r.shapeId===t.id&&yi(t,r.operationKind)?{terminalHandleAnchors:[],middleHandleAnchors:[],customHandleAnchors:wi({crop:t.props.crop,localToPage:e.editor.shapes.computeLocalToPageTransform(t),shape:t})}:n}},ds=class{type="image";toSvg(t,e){const{assetId:n,altText:r,crop:o,h:i,w:s}=t.props;if(!n)return null;const a=e.resolveAssetUrl(n);if(!a)return null;const l=ci(o),c=l?{tag:"svg",attrs:{x:0,y:0,width:s,height:i,viewBox:(d=l,[vi(d.left),vi(d.top),vi(d.width),vi(d.height)].join(" ")),preserveAspectRatio:"none",overflow:"hidden"},children:[{tag:"image",attrs:{href:a,x:0,y:0,width:1,height:1,preserveAspectRatio:"none","aria-label":r||void 0}}]}:{tag:"image",attrs:{href:a,width:s,height:i,preserveAspectRatio:"none","aria-label":r||void 0}};var d;const u=Bi({cornerRadius:t.props.cornerRadius,h:i,w:s});return u<=0?c:{tag:"g",attrs:{"clip-path":`url(#${e.addDef({tag:"clipPath",attrs:{clipPathUnits:"userSpaceOnUse"},children:[{tag:"rect",attrs:{x:0,y:0,width:s,height:i,rx:u,ry:u}}]})})`},children:[c]}}},us={propagation:"stop"};function ps(){let t=null;const e=e=>{t=null,function(t){Xi(t).endStroke()}(e)},n=e=>{t=null,function(t){Xi(t).cancelStroke()}(e)};return{id:"land.image.smudge.interactions",editorEvent:{handleEvent(r,o){if("keyboard"===o.type)return(fs(o)||hs(o))&&gs(r)&&e(r),function(t,e){if("key_down"!==e.name)return;if(!gs(t))return;if("Escape"===e.key&&!e.altKey&&!e.accelKey)return Ji(t),us;if(hs(e))return is(t,{replace:!0}),us;if(fs(e))return e.shiftKey?t.history.redo():t.history.undo(),us;return us}(r,o);if("cancel"===o.type)return gs(r)?(n(r),"command"!==o.reason&&Ji(r),us):void 0;if("pointer"!==o.type)return;const i=gs(r);if(i){if("pointer_down"===o.name){if(e(r),0!==o.button)return 1===o.button?void 0:us;const n=ys(r,i,o.pagePoint),s=xs(n,i);return t={mode:s?"draw":"pan",originCamera:s?null:r.state.camera.get(),originScreenPoint:s?null:o.screenPoint.clone(),pointerId:o.pointerId,acceptsDrawPoints:s},s&&function(t,e){Xi(t).beginStroke(e)}(r,{x:n.x,y:n.y,pressure:o.pressure}),us}return t&&t.pointerId===o.pointerId?"pointer_move"===o.name?("draw"===t.mode&&1&o.buttons?t.acceptsDrawPoints&&(t.acceptsDrawPoints=ms(r,i,o)):"pan"===t.mode&&t.originCamera&&t.originScreenPoint&&1&o.buttons?ws(r,o,t):e(r),us):"pointer_up"===o.name?("draw"===t.mode&&t.acceptsDrawPoints?ms(r,i,o):"pan"===t.mode&&ws(r,o,t),e(r),us):"pointer_cancel"===o.name?(n(r),us):us:us}n(r)}}}}function hs(t){return"key_down"===t.name&&"Enter"===t.key&&!t.altKey&&!t.accelKey}function fs(t){return"key_down"===t.name&&"z"===t.key.toLowerCase()&&t.accelKey&&!t.altKey}function gs(t){const[e]=t.state.selectedShapes.get();if(!Ti(e))return null;const n=t.state.shapeEditingSession.get();return n&&n.shapeId===e.id&&qi(e,n.operationKind)?e:null}function ms(t,e,n){const r=ys(t,e,n.pagePoint);return!!xs(r,e)&&(function(t,e){Xi(t).appendPoint(e)}(t,{x:r.x,y:r.y,pressure:n.pressure}),!0)}function ys(t,e,n){return t.shapes.computeLocalToPageTransform(e).invert().applyToPoint(n)}function xs(t,e){return t.x>=0&&t.y>=0&&t.x<=e.props.w&&t.y<=e.props.h}function ws(t,e,n){if(!n.originCamera||!n.originScreenPoint)return;const r=e.screenPoint.sub(n.originScreenPoint),o=n.originCamera.z;t.viewport.setCamera({x:n.originCamera.x-r.x/o,y:n.originCamera.y-r.y/o},{source:"user"})}function bs(){return{id:"land.image",shapeUtils:[new cs],shapeSvgExporters:[new ds],interactionHandlers:[Ai(),ps()],setup:t=>function(t){let e=null;return de("image.cropSession.lifecycle",t.state.shapeEditingSession,()=>{const n=t.state.shapeEditingSession.get(),r=n?.shapeId,o=r&&n?.operationKind===xi(r)?r:null;e&&e!==o&&Pi(t,e),e=o})}(t)}}var ks={id:"land.image.crop.dom-events",handle:()=>"continue",getCursor({clientPoint:t,editor:e,element:n,container:r}){const o=function(t){const[e]=t.state.selectedShapes.get();if(!Ti(e))return null;const n=t.state.shapeEditingSession.get();return n&&n.shapeId===e.id&&yi(e,n.operationKind)?e:null}(e);if(!o)return;if(n?.closest('[data-selection-custom-handle-type="image.crop"]'))return;if(!t)return;const i=r.getBoundingClientRect(),s=new yt(t.x-i.left,t.y-i.top);return As(e,o,e.viewport.screenToPage(s))?0!==e.inputs.state.get().buttons?"grabbing":"grab":void 0}},vs={id:"land.image.smudge.dom-events",handle:()=>"continue",getCursor({clientPoint:t,container:e,editor:n}){const r=function(t){const[e]=t.state.selectedShapes.get();if(!Ti(e))return null;const n=t.state.shapeEditingSession.get();return n&&n.shapeId===e.id&&qi(e,n.operationKind)?e:null}(n);if(!r||!t)return;const o=e.getBoundingClientRect(),i=new yt(t.x-o.left,t.y-o.top);return As(n,r,n.viewport.screenToPage(i))?"crosshair":0!==n.inputs.state.get().buttons?"grabbing":"grab"}};function Ss(){return{id:"land.image.react",domEventGuards:[ks,vs],selectionCustomHandleRenderers:[{type:ti,component:Cs}],shapeRenderers:[{type:"image",component:Is,hoverComponent:Ts}]}}function Is({editor:t,shape:e,shapeEditingSession:n}){const{altText:r,assetId:s,crop:a,h:l,w:c}=e.props,d=s?t.assets.resolveUrl(s):null,u=Bi({cornerRadius:e.props.cornerRadius,h:l,w:c}),p=function(t,e){return x(e=>function(t,e){return Xi(t).subscribe(e)}(t,e),()=>function(t,e){return Xi(t).getSnapshot(e)}(t,e),()=>null)}(t,e.id);if(!d)return o("div",{"aria-label":"Empty image","data-ui":"image-shape-missing-asset",role:"img",style:{alignItems:"center",background:"#f8fafc",border:"1px solid #cbd5e1",borderRadius:u,boxSizing:"border-box",color:"#cbd5e1",display:"flex",height:l,justifyContent:"center",overflow:"hidden",width:c},children:i("svg",{"aria-hidden":"true",className:"lucide lucide-sparkles-icon lucide-sparkles",fill:"none",height:"40",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",width:"40",xmlns:"http://www.w3.org/2000/svg",children:[
8
+ return o(e,{editor:t,shape:n,isEditing:r,value:n.props.name,fallback:Co(""),bodyWidth:n.props.w,bodyHeight:n.props.h,renderHeight:0,operationKind:Bo,editAriaLabel:"Edit frame name",inputAriaLabel:"Frame name",dataUi:{heading:"frame-canvas-heading",dragHandle:"frame-drag-handle",name:"frame-canvas-name",input:"frame-canvas-name-input"},offsetX:0,showDragHandle:!1,onValueChange:e=>{t.commands.updateShapes([{id:n.id,props:{name:e}}],{source:"user"})}})}var Jo={id:"frame",editor:_o(),render:Xo(),api:Oo,setup:({editor:t})=>({api:zo({editor:t})})},Zo=1e-4,Qo=1e-4,ti="image.crop",ei=[{label:"1:1",value:"1:1",ratio:1},{label:"4:3",value:"4:3",ratio:4/3},{label:"16:9",value:"16:9",ratio:16/9}],ni={top_left:"nwse-resize",top:"ns-resize",top_right:"nesw-resize",right:"ew-resize",bottom_right:"nwse-resize",bottom:"ns-resize",bottom_left:"nesw-resize",left:"ew-resize"},ri=["top_left","top","top_right","right","bottom_right","bottom","bottom_left","left"];function oi(t){return Math.min(1,Math.max(0,t))}function ii(t,e,n){return Math.min(n,Math.max(e,t))}function si(t){return!!t&&"object"==typeof t&&"number"==typeof t.x&&Number.isFinite(t.x)&&"number"==typeof t.y&&Number.isFinite(t.y)}function ai(t,e){const n=oi(t),r=oi(e);let o=Math.min(n,r),i=Math.max(n,r);if(i-o<Zo){const t=(o+i)/2;o=Math.max(0,Math.min(.9999,t-5e-5)),i=o+Zo}return{min:o,max:i}}function li(t){if(!t||"object"!=typeof t)return null;const e=t;if(!si(e.topLeft)||!si(e.bottomRight))return null;const n=ai(e.topLeft.x,e.bottomRight.x),r=ai(e.topLeft.y,e.bottomRight.y);return{topLeft:{x:n.min,y:r.min},bottomRight:{x:n.max,y:r.max}}}function ci(t){const e=li(t);if(!e)return null;const n=e.topLeft.x,r=e.topLeft.y,o=e.bottomRight.x,i=e.bottomRight.y;return{left:n,top:r,right:o,bottom:i,width:o-n,height:i-r}}function di(t){return ci(t)??{left:0,top:0,right:1,bottom:1,width:1,height:1}}function ui(t,e){return Math.abs(t.left-e.left)<=Qo&&Math.abs(t.top-e.top)<=Qo&&Math.abs(t.right-e.right)<=Qo&&Math.abs(t.bottom-e.bottom)<=Qo}function pi(t){return function(t){return Math.abs(t.left)<=Qo&&Math.abs(t.top)<=Qo&&Math.abs(1-t.right)<=Qo&&Math.abs(1-t.bottom)<=Qo}(t)?null:li({topLeft:{x:t.left,y:t.top},bottomRight:{x:t.right,y:t.bottom}})}function hi({centerX:t,centerY:e,height:n,width:r}){const o=ii(r,Zo,1),i=ii(n,Zo,1),s=ii(t-o/2,0,1-o),a=ii(e-i/2,0,1-i);return{left:s,top:a,right:s+o,bottom:a+i,width:o,height:i}}function fi(t){return{x:t.left+t.width/2,y:t.top+t.height/2}}function gi({crop:t,shape:e}){const n=di(t);return{w:e.props.w/n.width,h:e.props.h/n.height}}function mi(t){const e=t.props.w/t.props.h;for(const n of ei)if(Math.abs(e-n.ratio)<=.01)return n.value;return null}function yi(t,e){return e===xi(t.id)}function xi(t){return`image.crop:edit:${t}`}function wi({localToPage:t,shape:e}){const n=e.props.w,r=e.props.h,o=(0+n)/2,i=(0+r)/2,s={top_left:new yt(0,0),top:new yt(o,0),top_right:new yt(n,0),right:new yt(n,i),bottom_right:new yt(n,r),bottom:new yt(o,r),bottom_left:new yt(0,r),left:new yt(0,i)};return ri.map(e=>{return{kind:"custom",type:ti,id:e,point:t.applyToPoint(s[e]),cursor:(n=e,ni[n])};var n})}function bi({change:t,crop:e,shape:n}){const r=gi({crop:e,shape:n}),o=e.bottomRight.x-e.topLeft.x,i=e.bottomRight.y-e.topLeft.y,s=ii(e.topLeft.x-t.x/r.w,0,1-o),a=ii(e.topLeft.y-t.y/r.h,0,1-i),l=li({topLeft:{x:s,y:a},bottomRight:{x:s+o,y:a+i}});return l?{id:n.id,props:{crop:l}}:null}function ki({preset:t,shape:e}){const n=fi(di(e.props.crop)),r=gi({crop:e.props.crop,shape:e}),o=ei.find(e=>e.value===t)?.ratio??null;if(!o)return null;const i=o*(r.h/r.w);let s=1,a=s/i;return a>1&&(a=1,s=a*i),function({nextRect:t,shape:e}){const n=di(e.props.crop);if(ui(n,t))return null;const r=gi({crop:e.props.crop,shape:e}),o=new yt((t.left-n.left)*r.w,(t.top-n.top)*r.h).rot(e.rotation);return{id:e.id,x:e.x+o.x,y:e.y+o.y,props:{w:t.width*r.w,h:t.height*r.h,crop:pi(t)}}}({nextRect:hi({centerX:n.x,centerY:n.y,width:s,height:a}),shape:e})}function vi(t){return Number.isFinite(t)?Number(t.toFixed(4)).toString():"0"}var Si=new WeakMap;function Ii(t,e){return Si.get(t)?.get(e)??null}function Pi(t,e){const n=Si.get(t);n&&(n.delete(e),0===n.size&&Si.delete(t))}function Mi(t){return gt(t)&&"image"===t.type}function Ti(t){return ft(t)&&"image"===t.type}var Ci={propagation:"stop"};function Ei({handleId:t,shapeId:e,startPagePoint:n,startPageToLocal:r,startShape:o,startCrop:i}){return{shapeId:e,operationKind:"image.crop.handle",update({editor:s,pagePoint:a,source:l}){if(!Ti(s.shapes.get(e)))return"stop";const c=function({handleId:t,pageToLocal:e,shape:n,startCrop:r,startPagePoint:o,currentPagePoint:i}){const s=li(r)??{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},a=gi({crop:s,shape:n});if(a.w<8||a.h<8)return null;const l=e.applyToPoint(o),c=e.applyToPoint(i).sub(l);if(0===c.x&&0===c.y)return null;const d={x:s.topLeft.x*a.w,y:s.topLeft.y*a.h,w:(s.bottomRight.x-s.topLeft.x)*a.w,h:(s.bottomRight.y-s.topLeft.y)*a.h},u=d.x+d.w,p=d.y+d.h;let h=d.x,f=d.y,g=d.w,m=d.h;!function(t){return"top_left"===t||"left"===t||"bottom_left"===t}(t)?function(t){return"top_right"===t||"right"===t||"bottom_right"===t}(t)&&(g=ii(u+c.x,d.x+8,a.w)-h):(h=ii(h+c.x,0,u-8),g=u-h),function(t){return"top_left"===t||"top"===t||"top_right"===t}(t)?(f=ii(f+c.y,0,p-8),m=p-f):function(t){return"bottom_left"===t||"bottom"===t||"bottom_right"===t}(t)&&(m=ii(p+c.y,d.y+8,a.h)-f);const y=li({topLeft:{x:h/a.w,y:f/a.h},bottomRight:{x:(h+g)/a.w,y:(f+m)/a.h}});if(!y)return null;const x=new yt(h-s.topLeft.x*a.w,f-s.topLeft.y*a.h).rot(n.rotation);return{id:n.id,x:n.x+x.x,y:n.y+x.y,props:{w:g,h:m,crop:y}}}({handleId:t,currentPagePoint:a,pageToLocal:r,shape:o,startCrop:i,startPagePoint:n});return c?(s.commands.updateShapes([c],{source:l}),"continue"):"continue"}}}function Li(){return{createSession(t,{handle:e,shape:n,originPagePoint:r}){return Ti(n)&&"custom"===e.kind&&"image.crop"===e.type&&(o=e.id,ri.some(t=>t===o))?Ei({handleId:e.id,shapeId:n.id,startPagePoint:r,startPageToLocal:t.shapes.computeLocalToPageTransform(n).invert(),startShape:n,startCrop:n.props.crop}):null;var o}}}function Ai(){let t=null;const e=()=>{t?.operation?.isActive&&t.operation.cancel(),t=null};return{id:"land.image.crop.interactions",editorEvent:{handleEvent(n,r){if("cancel"!==r.type){if("keyboard"===r.type)return function(t,e){if("key_down"!==e.name)return;const n=Ri(t);if(!n)return;if("Escape"===e.key&&!e.altKey&&!e.accelKey)return t.editing.cancel("user")&&Pi(t,n.id),Ci;if("Enter"===e.key&&!e.altKey&&!e.accelKey)return t.editing.complete("user")&&Pi(t,n.id),Ci;const r=function(t){if(t.altKey||t.accelKey)return null;const e=t.shiftKey?10:1;switch(t.key){case"ArrowLeft":return new yt(e,0);case"ArrowRight":return new yt(-e,0);case"ArrowUp":return new yt(0,e);case"ArrowDown":return new yt(0,-e);default:return null}}(e);if(r){const e=function({pageDelta:t,shape:e,startCrop:n}){const r=li(n);return!r||t.equals(yt.Zero())?null:bi({change:t.rot(-e.rotation),crop:r,shape:e})}({pageDelta:r,shape:n,startCrop:n.props.crop});return e&&t.commands.updateShapes([e],{source:"user"}),Ci}}(n,r);if("pointer"===r.type)if("pointer_cancel"!==r.name){if("pointer_down"===r.name){if(e(),0!==r.button||"select"!==n.state.tool.get().activeToolId||!n.tools.isInInitialState())return;if(n.selection.hitTestHandle(r.pagePoint))return;const o=Ri(n);if(!o)return;return function(t,e,n){const r=t.shapes.computeLocalToPageTransform(e).invert().applyToPoint(n.pagePoint);return r.x>=0&&r.y>=0&&r.x<=e.props.w&&r.y<=e.props.h}(n,o,r)?(t={pointerId:r.pointerId,shapeId:o.id,startCrop:o.props.crop,startPagePoint:r.pagePoint.clone(),startScreenPoint:r.screenPoint.clone(),startPageToLocal:n.shapes.computeLocalToPageTransform(o).invert(),startShape:o,hasDragged:!1,operation:null},Ci):n.editing.complete("user")?(Pi(n,o.id),n.handleEvent(r),Ci):void 0}if(t&&r.pointerId===t.pointerId)return"pointer_move"===r.name?($i(n,r,t),Ci):"pointer_up"===r.name?($i(n,r,t),t.operation?.isActive&&t.operation.commit(),e(),Ci):void 0}else e()}else e()}},selectionHandle:Li()}}function Ri(t){const[e]=t.state.selectedShapes.get();if(!Ti(e))return null;const n=t.state.shapeEditingSession.get();return n&&n.shapeId===e.id&&yi(e,n.operationKind)?e:null}function $i(t,e,n){if(!n.hasDragged){if(n.startScreenPoint.dist2(e.screenPoint)<9)return;n.operation=t.operations.begin({kind:"image.crop.translate",label:"shape.edit",source:"user",history:"record"}),n.hasDragged=!0}if(!Ti(t.shapes.get(n.shapeId)))return;const r=function({currentPagePoint:t,pageToLocal:e,shape:n,startCrop:r,startPagePoint:o,shiftKey:i}){const s=li(r);if(!s)return null;const a=e.applyToPoint(o);let l=e.applyToPoint(t).sub(a);return i&&(l=Math.abs(l.x)<Math.abs(l.y)?new yt(0,l.y):new yt(l.x,0)),0===l.x&&0===l.y?null:bi({change:l,crop:s,shape:n})}({currentPagePoint:e.pagePoint,pageToLocal:n.startPageToLocal,shape:n.startShape,shiftKey:e.shiftKey,startCrop:n.startCrop,startPagePoint:n.startPagePoint});r&&t.commands.updateShapes([r],{source:"user"})}function Ni(t,e=0){return Math.max(0,"number"==typeof t&&Number.isFinite(t)?t:e)}function Bi({cornerRadius:t,h:e,w:n}){return Math.min(Ni(t),Math.max(0,n)/2,Math.max(0,e)/2)}var Oi=24,zi="#ffff00",Hi=1,Di=128,Fi=24,Wi=zi,ji=.45,Ui=class{editor;confirmHandler=null;deactivateHistoryScope=null;session=null;snapshot=null;subscribers=new Set;constructor(t){this.editor=t,de("image.smudgeSession.lifecycle",t.state.shapeEditingSession,()=>{this.clearIfEditingSessionInvalid()},{fireImmediately:!1})}start(t,e){if(t.isLocked)return!1;const n=Yi(t.id),r=this.editor.state.shapeEditingSession.get();if(r&&(r.shapeId!==t.id||r.operationKind!==n))return!1;if(this.session&&r?.shapeId===t.id&&qi(t,r.operationKind))return this.updateSession({...this.session,brush:Vi({...this.session.brush,...e})}),!0;this.clear();const o=this.editor.editing.start({shapeId:t.id,operationKind:n,entryMode:"focusEnd"},"user");return!(!o||o.shapeId!==t.id||o.operationKind!==n)&&(this.setSession({shapeId:t.id,brush:Vi(e),strokes:[],activeStroke:null,redoStrokes:[],nextStrokeIndex:1}),this.activateHistoryScope(),!0)}cancel(){const t=this.session?.shapeId??null;this.clear();const e=this.editor.state.shapeEditingSession.get();t&&e?.shapeId===t&&e.operationKind===Yi(t)&&this.editor.editing.cancel("user")}complete(){const t=this.session?.shapeId??null;this.clear();const e=this.editor.state.shapeEditingSession.get();t&&e?.shapeId===t&&e.operationKind===Yi(t)&&this.editor.editing.complete("user")}cancelIfActive(){return!!this.getActiveSession()&&(this.cancel(),!0)}clearForShape(t){this.session?.shapeId===t&&this.clear()}updateBrush(t){if(!this.getActiveSession()||!this.session)return!1;const e=Vi({...this.session.brush,...t});return e.size===this.session.brush.size&&e.color===this.session.brush.color&&e.opacity===this.session.brush.opacity||this.updateSession({...this.session,brush:e}),!0}getSnapshot(t){const e=this.getActiveSession();return e&&e.shapeId===t?this.snapshot:null}getActiveSession(){if(!this.session)return null;const t=this.editor.shapes.get(this.session.shapeId),e=this.editor.state.shapeEditingSession.get();return t&&e&&e.shapeId===this.session.shapeId&&e.operationKind===Yi(this.session.shapeId)?this.snapshot:(this.clear(),null)}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}beginStroke(t){if(!this.session)return;const e=Ki(this.session),n={id:`${e.shapeId}:smudge:${e.nextStrokeIndex}`,points:[as(t)],brush:{...e.brush}};this.updateSession({...e,activeStroke:n,nextStrokeIndex:e.nextStrokeIndex+1})}appendPoint(t){if(!this.session?.activeStroke)return;const e=this.session.activeStroke.points[this.session.activeStroke.points.length-1];e&&Math.hypot(e.x-t.x,e.y-t.y)<.5||this.updateSession({...this.session,activeStroke:{...this.session.activeStroke,points:[...this.session.activeStroke.points,as(t)]}})}endStroke(){this.session?.activeStroke&&this.updateSession(Ki(this.session))}cancelStroke(){this.session?.activeStroke&&this.updateSession({...this.session,activeStroke:null})}undo(){if(!this.getActiveSession()||!this.session)return!1;if(this.session.activeStroke&&this.updateSession(Ki(this.session)),!this.session||0===this.session.strokes.length)return!1;const t=this.session.strokes[this.session.strokes.length-1];return!!t&&(this.updateSession({...this.session,strokes:this.session.strokes.slice(0,-1),redoStrokes:[...this.session.redoStrokes,t]}),!0)}redo(){if(!this.getActiveSession()||!this.session)return!1;if(this.session.activeStroke||0===this.session.redoStrokes.length)return!1;const t=this.session.redoStrokes[this.session.redoStrokes.length-1];return!!t&&(this.updateSession({...this.session,strokes:[...this.session.strokes,t],redoStrokes:this.session.redoStrokes.slice(0,-1)}),!0)}registerConfirmHandler(t){return this.confirmHandler=t,()=>{this.confirmHandler===t&&(this.confirmHandler=null)}}requestConfirm(t){return this.confirmHandler?this.confirmHandler(t):Promise.resolve(null)}clear(){this.session&&(this.session=null,this.snapshot=null,this.deactivateHistoryScope?.(),this.deactivateHistoryScope=null,this.notify())}clearIfEditingSessionInvalid(){if(!this.session)return;const t=this.editor.state.shapeEditingSession.get();t?.shapeId===this.session.shapeId&&t.operationKind===Yi(this.session.shapeId)||this.clear()}activateHistoryScope(){const t={getState:()=>this.getHistoryScopeState(),subscribe:t=>this.subscribe(t),undo:()=>this.undo(),redo:()=>this.redo()};this.deactivateHistoryScope=this.editor.history.activateScope(t)}getHistoryScopeState(){const t=this.session?.activeStroke?1:0,e=this.session?.activeStroke?0:this.session?.redoStrokes.length??0;return{canUndo:(this.session?.strokes.length??0)+t>0,canRedo:e>0}}setSession(t){this.session=t,this.snapshot=function(t){return{shapeId:t.shapeId,brush:t.brush,strokes:t.activeStroke?[...t.strokes,t.activeStroke]:t.strokes,canUndo:t.strokes.length>0||!!t.activeStroke,canRedo:!t.activeStroke&&t.redoStrokes.length>0}}(t),this.notify()}updateSession(t){this.setSession(t)}notify(){for(const t of this.subscribers)t()}};function Ki(t){return t.activeStroke?{...t,strokes:[...t.strokes,t.activeStroke],activeStroke:null,redoStrokes:[]}:t}var _i=new WeakMap;function Xi(t){const e=_i.get(t);if(e)return e;const n=new Ui(t);return _i.set(t,n),n}function Yi(t){return`image.smudge:edit:${t}`}function qi(t,e){return e===Yi(t.id)}function Vi(t){const e="number"==typeof t?.size&&Number.isFinite(t.size)?t.size:Fi,n="number"==typeof t?.opacity&&Number.isFinite(t.opacity)?t.opacity:ji??.45;return{size:Math.min(128,Math.max(1,e)),color:"string"==typeof t?.color&&t.color.trim().length>0?t.color:Wi,opacity:Math.min(1,Math.max(0,n))}}function Gi({brush:t,editor:e,shape:n}){return Xi(e).start(n,t)}function Ji(t){Xi(t).cancel()}function Zi(t){Xi(t).complete()}function Qi(t){return Xi(t).cancelIfActive()}function ts(t,e){return Xi(t).updateBrush(e)}function es(t){return Xi(t).getActiveSession()}function ns(t){return Xi(t).undo()}function rs(t){return Xi(t).redo()}function os(t,e){return Xi(t).registerConfirmHandler(e)}async function is(t,e){return Xi(t).requestConfirm(e)}function ss(t){return t.map(t=>({id:t.id,brush:{...t.brush},points:t.points.map(as)}))}function as(t){return{x:t.x,y:t.y,...void 0===t.pressure?{}:{pressure:t.pressure}}}function ls(t,e){return"number"==typeof t&&Number.isFinite(t)?t:e}var cs=class extends oe{type="image";getDefaultProps(){return{w:240,h:180,assetId:null,crop:null,cornerRadius:0,altText:""}}validateProps(t){const e=t&&"object"==typeof t?t:{},n=this.getDefaultProps(),r=ls(e.w,n.w),o=ls(e.h,n.h),i=r>0&&o>0?Math.max(1,24/r,24/o):1;return{w:Math.max(24,r*i),h:Math.max(24,o*i),assetId:(s=e.assetId,"string"==typeof s&&s.startsWith("asset:")?e.assetId:null),crop:li(e.crop),cornerRadius:Ni(e.cornerRadius,n.cornerRadius),altText:"string"==typeof e.altText?e.altText:n.altText};var s}getLocalBounds(t){return new xt(0,0,t.props.w,t.props.h)}canReceiveTerminalBinding(t){return!0}getAllowedSelectionResizeModes(t,e){return _t}canEdit(t){return!0}onEditEnd(t,e){var n,r;n=e.editor,r=t.id,Xi(n).clearForShape(r)}getSelectionHandleAnchors(t,e){const n={terminalHandleAnchors:[],middleHandleAnchors:[],customHandleAnchors:[]};if(!e.isOnlySelected)return n;const r=e.editor.state.shapeEditingSession.get();return r&&r.shapeId===t.id&&yi(t,r.operationKind)?{terminalHandleAnchors:[],middleHandleAnchors:[],customHandleAnchors:wi({crop:t.props.crop,localToPage:e.editor.shapes.computeLocalToPageTransform(t),shape:t})}:n}},ds=class{type="image";toSvg(t,e){const{assetId:n,altText:r,crop:o,h:i,w:s}=t.props;if(!n)return null;const a=e.resolveAssetUrl(n);if(!a)return null;const l=ci(o),c=l?{tag:"svg",attrs:{x:0,y:0,width:s,height:i,viewBox:(d=l,[vi(d.left),vi(d.top),vi(d.width),vi(d.height)].join(" ")),preserveAspectRatio:"none",overflow:"hidden"},children:[{tag:"image",attrs:{href:a,x:0,y:0,width:1,height:1,preserveAspectRatio:"none","aria-label":r||void 0}}]}:{tag:"image",attrs:{href:a,width:s,height:i,preserveAspectRatio:"none","aria-label":r||void 0}};var d;const u=Bi({cornerRadius:t.props.cornerRadius,h:i,w:s});return u<=0?c:{tag:"g",attrs:{"clip-path":`url(#${e.addDef({tag:"clipPath",attrs:{clipPathUnits:"userSpaceOnUse"},children:[{tag:"rect",attrs:{x:0,y:0,width:s,height:i,rx:u,ry:u}}]})})`},children:[c]}}},us={propagation:"stop"};function ps(){let t=null;const e=e=>{t=null,function(t){Xi(t).endStroke()}(e)},n=e=>{t=null,function(t){Xi(t).cancelStroke()}(e)};return{id:"land.image.smudge.interactions",editorEvent:{handleEvent(r,o){if("keyboard"===o.type)return(fs(o)||hs(o))&&gs(r)&&e(r),function(t,e){if("key_down"!==e.name)return;if(!gs(t))return;if("Escape"===e.key&&!e.altKey&&!e.accelKey)return Ji(t),us;if(hs(e))return is(t,{replace:!0}),us;if(fs(e))return e.shiftKey?t.history.redo():t.history.undo(),us;return us}(r,o);if("cancel"===o.type)return gs(r)?(n(r),"command"!==o.reason&&Ji(r),us):void 0;if("pointer"!==o.type)return;const i=gs(r);if(i){if("pointer_down"===o.name){if(e(r),0!==o.button)return 1===o.button?void 0:us;const n=ys(r,i,o.pagePoint),s=xs(n,i);return t={mode:s?"draw":"pan",originCamera:s?null:r.state.camera.get(),originScreenPoint:s?null:o.screenPoint.clone(),pointerId:o.pointerId,acceptsDrawPoints:s},s&&function(t,e){Xi(t).beginStroke(e)}(r,{x:n.x,y:n.y,pressure:o.pressure}),us}return t&&t.pointerId===o.pointerId?"pointer_move"===o.name?("draw"===t.mode&&1&o.buttons?t.acceptsDrawPoints&&(t.acceptsDrawPoints=ms(r,i,o)):"pan"===t.mode&&t.originCamera&&t.originScreenPoint&&1&o.buttons?ws(r,o,t):e(r),us):"pointer_up"===o.name?("draw"===t.mode&&t.acceptsDrawPoints?ms(r,i,o):"pan"===t.mode&&ws(r,o,t),e(r),us):"pointer_cancel"===o.name?(n(r),us):us:us}n(r)}}}}function hs(t){return"key_down"===t.name&&"Enter"===t.key&&!t.altKey&&!t.accelKey}function fs(t){return"key_down"===t.name&&"z"===t.key.toLowerCase()&&t.accelKey&&!t.altKey}function gs(t){const[e]=t.state.selectedShapes.get();if(!Ti(e))return null;const n=t.state.shapeEditingSession.get();return n&&n.shapeId===e.id&&qi(e,n.operationKind)?e:null}function ms(t,e,n){const r=ys(t,e,n.pagePoint);return!!xs(r,e)&&(function(t,e){Xi(t).appendPoint(e)}(t,{x:r.x,y:r.y,pressure:n.pressure}),!0)}function ys(t,e,n){return t.shapes.computeLocalToPageTransform(e).invert().applyToPoint(n)}function xs(t,e){return t.x>=0&&t.y>=0&&t.x<=e.props.w&&t.y<=e.props.h}function ws(t,e,n){if(!n.originCamera||!n.originScreenPoint)return;const r=e.screenPoint.sub(n.originScreenPoint),o=n.originCamera.z;t.viewport.setCamera({x:n.originCamera.x-r.x/o,y:n.originCamera.y-r.y/o},{source:"user"})}function bs(){return{id:"land.image",shapeUtils:[new cs],shapeSvgExporters:[new ds],interactionHandlers:[Ai(),ps()],setup:t=>function(t){let e=null;return de("image.cropSession.lifecycle",t.state.shapeEditingSession,()=>{const n=t.state.shapeEditingSession.get(),r=n?.shapeId,o=r&&n?.operationKind===xi(r)?r:null;e&&e!==o&&Pi(t,e),e=o})}(t)}}var ks={id:"land.image.crop.dom-events",handle:()=>"continue",getCursor({clientPoint:t,editor:e,element:n,container:r}){const o=function(t){const[e]=t.state.selectedShapes.get();if(!Ti(e))return null;const n=t.state.shapeEditingSession.get();return n&&n.shapeId===e.id&&yi(e,n.operationKind)?e:null}(e);if(!o)return;if(n?.closest('[data-selection-custom-handle-type="image.crop"]'))return;if(!t)return;const i=r.getBoundingClientRect(),s=new yt(t.x-i.left,t.y-i.top);return As(e,o,e.viewport.screenToPage(s))?0!==e.inputs.state.get().buttons?"grabbing":"grab":void 0}},vs={id:"land.image.smudge.dom-events",handle:()=>"continue",getCursor({clientPoint:t,container:e,editor:n}){const r=function(t){const[e]=t.state.selectedShapes.get();if(!Ti(e))return null;const n=t.state.shapeEditingSession.get();return n&&n.shapeId===e.id&&qi(e,n.operationKind)?e:null}(n);if(!r||!t)return;const o=e.getBoundingClientRect(),i=new yt(t.x-o.left,t.y-o.top);return As(n,r,n.viewport.screenToPage(i))?"crosshair":0!==n.inputs.state.get().buttons?"grabbing":"grab"}};function Ss(){return{id:"land.image.react",domEventGuards:[ks,vs],selectionCustomHandleRenderers:[{type:ti,component:Cs}],shapeRenderers:[{type:"image",component:Is,hoverComponent:Ts}]}}function Is({editor:t,shape:e,shapeEditingSession:n}){const{altText:r,assetId:s,crop:a,h:l,w:c}=e.props,d=s?t.assets.resolveUrl(s):null,u=Bi({cornerRadius:e.props.cornerRadius,h:l,w:c}),p=function(t,e){return x(e=>function(t,e){return Xi(t).subscribe(e)}(t,e),()=>function(t,e){return Xi(t).getSnapshot(e)}(t,e),()=>null)}(t,e.id);if(!d)return o("div",{"aria-label":"Empty image","data-ui":"image-shape-missing-asset",role:"img",style:{alignItems:"center",background:"#f8fafc",border:"1px solid #cbd5e1",borderRadius:u,boxSizing:"border-box",color:"#cbd5e1",display:"flex",height:l,justifyContent:"center",overflow:"hidden",width:c},children:i("svg",{"aria-hidden":"true",className:"lucide lucide-sparkles-icon lucide-sparkles",fill:"none",height:"40",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",width:"40",xmlns:"http://www.w3.org/2000/svg",children:[
9
9
  o("path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"}),
10
10
  o("path",{d:"M20 2v4"}),
11
11
  o("path",{d:"M22 4h-4"}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuzhouu/canvas-standard",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Standard Land canvas profile with Arrow, Connector and Packaging kept as opt-in plugins.",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",
@@ -16,7 +16,7 @@
16
16
  "./package.json": "./package.json"
17
17
  },
18
18
  "dependencies": {
19
- "@yuzhouu/canvas-kit": "^0.1.20",
19
+ "@yuzhouu/canvas-kit": "^0.1.21",
20
20
  "polygon-clipping": "^0.15.7",
21
21
  "@tiptap/core": "3.27.3",
22
22
  "@tiptap/react": "3.27.3",