@embedpdf/utils 2.0.0 → 2.0.2

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/dist/vue/index.js CHANGED
@@ -43,6 +43,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
43
43
  };
44
44
  }
45
45
  });
46
+ function getAnchor(handle) {
47
+ return {
48
+ x: handle.includes("e") ? "left" : handle.includes("w") ? "right" : "center",
49
+ y: handle.includes("s") ? "top" : handle.includes("n") ? "bottom" : "center"
50
+ };
51
+ }
46
52
  class DragResizeController {
47
53
  constructor(config, onUpdate) {
48
54
  this.config = config;
@@ -300,134 +306,124 @@ class DragResizeController {
300
306
  };
301
307
  return this.applyConstraints(position);
302
308
  }
309
+ /**
310
+ * Calculate the new rect after a resize operation.
311
+ * Pipeline: applyDelta → enforceAspectRatio → clampToBounds → applyConstraints
312
+ */
303
313
  calculateResizePosition(delta, handle) {
304
- var _a;
305
314
  if (!this.startElement) return this.config.element;
306
- let {
307
- origin: { x, y },
308
- size: { width, height }
309
- } = this.startElement;
310
- switch (handle) {
311
- case "se":
312
- width += delta.x;
313
- height += delta.y;
314
- break;
315
- case "sw":
316
- x += delta.x;
317
- width -= delta.x;
318
- height += delta.y;
319
- break;
320
- case "ne":
321
- width += delta.x;
322
- y += delta.y;
323
- height -= delta.y;
324
- break;
325
- case "nw":
326
- x += delta.x;
327
- width -= delta.x;
328
- y += delta.y;
329
- height -= delta.y;
330
- break;
331
- case "n":
332
- y += delta.y;
333
- height -= delta.y;
334
- break;
335
- case "s":
336
- height += delta.y;
337
- break;
338
- case "e":
339
- width += delta.x;
340
- break;
341
- case "w":
342
- x += delta.x;
343
- width -= delta.x;
344
- break;
315
+ const anchor = getAnchor(handle);
316
+ const aspectRatio = this.startElement.size.width / this.startElement.size.height || 1;
317
+ let rect = this.applyResizeDelta(delta, anchor);
318
+ if (this.config.maintainAspectRatio) {
319
+ rect = this.enforceAspectRatio(rect, anchor, aspectRatio);
345
320
  }
346
- if (this.config.maintainAspectRatio && this.startElement) {
347
- const aspectRatio = this.startElement.size.width / this.startElement.size.height;
348
- if (["n", "s", "e", "w"].includes(handle)) {
349
- if (handle === "n" || handle === "s") {
350
- const newWidth = height * aspectRatio;
351
- const widthDiff = newWidth - width;
352
- width = newWidth;
353
- x -= widthDiff / 2;
354
- } else {
355
- const newHeight = width / aspectRatio;
356
- const heightDiff = newHeight - height;
357
- height = newHeight;
358
- if (handle === "w") {
359
- x = this.startElement.origin.x + this.startElement.size.width - width;
360
- }
361
- y -= heightDiff / 2;
362
- }
321
+ rect = this.clampToBounds(rect, anchor, aspectRatio);
322
+ return this.applyConstraints(rect);
323
+ }
324
+ /**
325
+ * Apply the mouse delta to produce a raw (unconstrained) resized rect.
326
+ */
327
+ applyResizeDelta(delta, anchor) {
328
+ const start = this.startElement;
329
+ let x = start.origin.x;
330
+ let y = start.origin.y;
331
+ let width = start.size.width;
332
+ let height = start.size.height;
333
+ if (anchor.x === "left") {
334
+ width += delta.x;
335
+ } else if (anchor.x === "right") {
336
+ x += delta.x;
337
+ width -= delta.x;
338
+ }
339
+ if (anchor.y === "top") {
340
+ height += delta.y;
341
+ } else if (anchor.y === "bottom") {
342
+ y += delta.y;
343
+ height -= delta.y;
344
+ }
345
+ return { origin: { x, y }, size: { width, height } };
346
+ }
347
+ /**
348
+ * Enforce aspect ratio while respecting the anchor.
349
+ * For edge handles (center anchor on one axis), the rect expands symmetrically on that axis.
350
+ * For corner handles, the anchor corner stays fixed.
351
+ */
352
+ enforceAspectRatio(rect, anchor, aspectRatio) {
353
+ const start = this.startElement;
354
+ let { x, y } = rect.origin;
355
+ let { width, height } = rect.size;
356
+ const isEdgeHandle = anchor.x === "center" || anchor.y === "center";
357
+ if (isEdgeHandle) {
358
+ if (anchor.y === "center") {
359
+ height = width / aspectRatio;
360
+ y = start.origin.y + (start.size.height - height) / 2;
363
361
  } else {
364
- const widthChange = Math.abs(width - this.startElement.size.width);
365
- const heightChange = Math.abs(height - this.startElement.size.height);
366
- if (widthChange > heightChange) {
367
- height = width / aspectRatio;
368
- } else {
369
- width = height * aspectRatio;
370
- }
371
- if (handle.includes("w")) {
372
- x = this.startElement.origin.x + this.startElement.size.width - width;
373
- }
374
- if (handle.includes("n")) {
375
- y = this.startElement.origin.y + this.startElement.size.height - height;
376
- }
362
+ width = height * aspectRatio;
363
+ x = start.origin.x + (start.size.width - width) / 2;
377
364
  }
365
+ } else {
366
+ const dw = Math.abs(width - start.size.width);
367
+ const dh = Math.abs(height - start.size.height);
368
+ if (dw >= dh) {
369
+ height = width / aspectRatio;
370
+ } else {
371
+ width = height * aspectRatio;
372
+ }
373
+ }
374
+ if (anchor.x === "right") {
375
+ x = start.origin.x + start.size.width - width;
376
+ }
377
+ if (anchor.y === "bottom") {
378
+ y = start.origin.y + start.size.height - height;
378
379
  }
380
+ return { origin: { x, y }, size: { width, height } };
381
+ }
382
+ /**
383
+ * Clamp rect to bounding box while respecting anchor and aspect ratio.
384
+ */
385
+ clampToBounds(rect, anchor, aspectRatio) {
386
+ var _a;
379
387
  const bbox = (_a = this.config.constraints) == null ? void 0 : _a.boundingBox;
380
- if (bbox) {
381
- switch (handle) {
382
- case "e":
383
- width = Math.min(width, bbox.width - x);
384
- break;
385
- case "s":
386
- height = Math.min(height, bbox.height - y);
387
- break;
388
- case "se":
389
- width = Math.min(width, bbox.width - x);
390
- height = Math.min(height, bbox.height - y);
391
- break;
392
- case "w":
393
- if (x < 0) {
394
- width += x;
395
- x = 0;
396
- }
397
- break;
398
- case "n":
399
- if (y < 0) {
400
- height += y;
401
- y = 0;
402
- }
403
- break;
404
- case "sw":
405
- if (x < 0) {
406
- width += x;
407
- x = 0;
408
- }
409
- height = Math.min(height, bbox.height - y);
410
- break;
411
- case "nw":
412
- if (x < 0) {
413
- width += x;
414
- x = 0;
415
- }
416
- if (y < 0) {
417
- height += y;
418
- y = 0;
419
- }
420
- break;
421
- case "ne":
422
- width = Math.min(width, bbox.width - x);
423
- if (y < 0) {
424
- height += y;
425
- y = 0;
426
- }
427
- break;
388
+ if (!bbox) return rect;
389
+ const start = this.startElement;
390
+ let { x, y } = rect.origin;
391
+ let { width, height } = rect.size;
392
+ width = Math.max(1, width);
393
+ height = Math.max(1, height);
394
+ const anchorX = anchor.x === "left" ? start.origin.x : start.origin.x + start.size.width;
395
+ const anchorY = anchor.y === "top" ? start.origin.y : start.origin.y + start.size.height;
396
+ const maxW = anchor.x === "left" ? bbox.width - anchorX : anchor.x === "right" ? anchorX : Math.min(start.origin.x, bbox.width - start.origin.x - start.size.width) * 2 + start.size.width;
397
+ const maxH = anchor.y === "top" ? bbox.height - anchorY : anchor.y === "bottom" ? anchorY : Math.min(start.origin.y, bbox.height - start.origin.y - start.size.height) * 2 + start.size.height;
398
+ if (this.config.maintainAspectRatio) {
399
+ const scaleW = width > maxW ? maxW / width : 1;
400
+ const scaleH = height > maxH ? maxH / height : 1;
401
+ const scale = Math.min(scaleW, scaleH);
402
+ if (scale < 1) {
403
+ width *= scale;
404
+ height *= scale;
428
405
  }
406
+ } else {
407
+ width = Math.min(width, maxW);
408
+ height = Math.min(height, maxH);
429
409
  }
430
- return this.applyConstraints({ origin: { x, y }, size: { width, height } });
410
+ if (anchor.x === "left") {
411
+ x = anchorX;
412
+ } else if (anchor.x === "right") {
413
+ x = anchorX - width;
414
+ } else {
415
+ x = start.origin.x + (start.size.width - width) / 2;
416
+ }
417
+ if (anchor.y === "top") {
418
+ y = anchorY;
419
+ } else if (anchor.y === "bottom") {
420
+ y = anchorY - height;
421
+ } else {
422
+ y = start.origin.y + (start.size.height - height) / 2;
423
+ }
424
+ x = Math.max(0, Math.min(x, bbox.width - width));
425
+ y = Math.max(0, Math.min(y, bbox.height - height));
426
+ return { origin: { x, y }, size: { width, height } };
431
427
  }
432
428
  applyConstraints(position) {
433
429
  const { constraints } = this.config;
@@ -436,10 +432,34 @@ class DragResizeController {
436
432
  origin: { x, y },
437
433
  size: { width, height }
438
434
  } = position;
439
- width = Math.max(constraints.minWidth || 1, width);
440
- height = Math.max(constraints.minHeight || 1, height);
441
- if (constraints.maxWidth) width = Math.min(constraints.maxWidth, width);
442
- if (constraints.maxHeight) height = Math.min(constraints.maxHeight, height);
435
+ const minW = constraints.minWidth ?? 1;
436
+ const minH = constraints.minHeight ?? 1;
437
+ const maxW = constraints.maxWidth;
438
+ const maxH = constraints.maxHeight;
439
+ if (this.config.maintainAspectRatio && width > 0 && height > 0) {
440
+ const ratio = width / height;
441
+ if (width < minW) {
442
+ width = minW;
443
+ height = width / ratio;
444
+ }
445
+ if (height < minH) {
446
+ height = minH;
447
+ width = height * ratio;
448
+ }
449
+ if (maxW !== void 0 && width > maxW) {
450
+ width = maxW;
451
+ height = width / ratio;
452
+ }
453
+ if (maxH !== void 0 && height > maxH) {
454
+ height = maxH;
455
+ width = height * ratio;
456
+ }
457
+ } else {
458
+ width = Math.max(minW, width);
459
+ height = Math.max(minH, height);
460
+ if (maxW !== void 0) width = Math.min(maxW, width);
461
+ if (maxH !== void 0) height = Math.min(maxH, height);
462
+ }
443
463
  if (constraints.boundingBox) {
444
464
  x = Math.max(0, Math.min(x, constraints.boundingBox.width - width));
445
465
  y = Math.max(0, Math.min(y, constraints.boundingBox.height - height));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/vue/components/counter-rotate-container.vue","../../src/shared/plugin-interaction-primitives/drag-resize-controller.ts","../../src/shared/plugin-interaction-primitives/utils.ts","../../src/vue/utils/interaction-normalize.ts","../../src/vue/hooks/use-drag-resize.ts","../../src/vue/hooks/use-double-press-props.ts","../../src/vue/hooks/use-interaction-handles.ts","../../src/vue/utils/deep-to-raw.ts"],"sourcesContent":["<template>\n <slot\n :menu-wrapper-props=\"menuWrapperProps\"\n :matrix=\"counterRotation.matrix\"\n :rect=\"adjustedRect\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, type CSSProperties } from 'vue';\nimport type { Rect, Rotation } from '@embedpdf/models';\nimport { getCounterRotation } from '@embedpdf/utils';\n\ninterface CounterRotateProps {\n rect: Rect;\n rotation: Rotation;\n}\n\nconst props = defineProps<CounterRotateProps>();\n\nconst counterRotation = computed(() => getCounterRotation(props.rect, props.rotation));\n\nconst menuWrapperProps = computed(() => ({\n style: {\n position: 'absolute',\n left: `${props.rect.origin.x}px`,\n top: `${props.rect.origin.y}px`,\n transform: counterRotation.value.matrix,\n transformOrigin: '0 0',\n width: `${counterRotation.value.width}px`,\n height: `${counterRotation.value.height}px`,\n pointerEvents: 'none',\n zIndex: 3,\n } as CSSProperties,\n onPointerdown: (e: PointerEvent) => {\n e.stopPropagation();\n e.preventDefault();\n },\n onTouchstart: (e: TouchEvent) => {\n e.stopPropagation();\n e.preventDefault();\n },\n}));\n\nconst adjustedRect = computed(() => ({\n origin: { x: props.rect.origin.x, y: props.rect.origin.y },\n size: { width: counterRotation.value.width, height: counterRotation.value.height },\n}));\n</script>\n","import { Position, Rect } from '@embedpdf/models';\n\nexport interface DragResizeConfig {\n element: Rect;\n vertices?: Position[];\n constraints?: {\n minWidth?: number;\n minHeight?: number;\n maxWidth?: number;\n maxHeight?: number;\n boundingBox?: { width: number; height: number }; // page bounds\n };\n maintainAspectRatio?: boolean;\n pageRotation?: number;\n scale?: number;\n}\n\nexport type InteractionState = 'idle' | 'dragging' | 'resizing' | 'vertex-editing';\nexport type ResizeHandle = 'nw' | 'ne' | 'sw' | 'se' | 'n' | 'e' | 's' | 'w';\n\nexport interface TransformData {\n type: 'move' | 'resize' | 'vertex-edit';\n changes: {\n rect?: Rect;\n vertices?: Position[];\n };\n metadata?: {\n handle?: ResizeHandle;\n vertexIndex?: number;\n maintainAspectRatio?: boolean;\n };\n}\n\nexport interface InteractionEvent {\n state: 'start' | 'move' | 'end';\n transformData?: TransformData;\n}\n\n/**\n * Pure geometric controller that manages drag/resize/vertex-edit logic.\n */\nexport class DragResizeController {\n private state: InteractionState = 'idle';\n private startPoint: Position | null = null;\n private startElement: Rect | null = null;\n private activeHandle: ResizeHandle | null = null;\n private currentPosition: Rect | null = null;\n\n // Vertex editing state - pure geometric\n private activeVertexIndex: number | null = null;\n private startVertices: Position[] = [];\n private currentVertices: Position[] = [];\n\n constructor(\n private config: DragResizeConfig,\n private onUpdate: (event: InteractionEvent) => void,\n ) {\n this.currentVertices = config.vertices || [];\n }\n\n updateConfig(config: Partial<DragResizeConfig>) {\n this.config = { ...this.config, ...config };\n this.currentVertices = config.vertices || [];\n }\n\n startDrag(clientX: number, clientY: number) {\n this.state = 'dragging';\n this.startPoint = { x: clientX, y: clientY };\n this.startElement = { ...this.config.element };\n this.currentPosition = { ...this.config.element };\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'move',\n changes: {\n rect: this.startElement,\n },\n },\n });\n }\n\n startResize(handle: ResizeHandle, clientX: number, clientY: number) {\n this.state = 'resizing';\n this.activeHandle = handle;\n this.startPoint = { x: clientX, y: clientY };\n this.startElement = { ...this.config.element };\n this.currentPosition = { ...this.config.element };\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'resize',\n changes: {\n rect: this.startElement,\n },\n metadata: {\n handle: this.activeHandle,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n startVertexEdit(vertexIndex: number, clientX: number, clientY: number) {\n // Refresh vertices from latest config before validating index\n this.currentVertices = [...(this.config.vertices ?? this.currentVertices)];\n if (vertexIndex < 0 || vertexIndex >= this.currentVertices.length) return;\n\n this.state = 'vertex-editing';\n this.activeVertexIndex = vertexIndex;\n this.startPoint = { x: clientX, y: clientY };\n this.startVertices = [...this.currentVertices];\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.startVertices,\n },\n metadata: {\n vertexIndex,\n },\n },\n });\n }\n\n move(clientX: number, clientY: number) {\n if (this.state === 'idle' || !this.startPoint) return;\n\n if (this.state === 'dragging' && this.startElement) {\n const delta = this.calculateDelta(clientX, clientY);\n const position = this.calculateDragPosition(delta);\n this.currentPosition = position;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'move',\n changes: {\n rect: position,\n },\n },\n });\n } else if (this.state === 'resizing' && this.activeHandle && this.startElement) {\n const delta = this.calculateDelta(clientX, clientY);\n const position = this.calculateResizePosition(delta, this.activeHandle);\n this.currentPosition = position;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'resize',\n changes: {\n rect: position,\n },\n metadata: {\n handle: this.activeHandle,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n } else if (this.state === 'vertex-editing' && this.activeVertexIndex !== null) {\n const vertices = this.calculateVertexPosition(clientX, clientY);\n this.currentVertices = vertices;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices,\n },\n metadata: {\n vertexIndex: this.activeVertexIndex,\n },\n },\n });\n }\n }\n\n end() {\n if (this.state === 'idle') return;\n\n const wasState = this.state;\n const handle = this.activeHandle;\n const vertexIndex = this.activeVertexIndex;\n\n if (wasState === 'vertex-editing') {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.currentVertices,\n },\n metadata: {\n vertexIndex: vertexIndex || undefined,\n },\n },\n });\n } else {\n const finalPosition = this.getCurrentPosition();\n this.onUpdate({\n state: 'end',\n transformData: {\n type: wasState === 'dragging' ? 'move' : 'resize',\n changes: {\n rect: finalPosition,\n },\n metadata:\n wasState === 'dragging'\n ? undefined\n : {\n handle: handle || undefined,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n this.reset();\n }\n\n cancel() {\n if (this.state === 'idle') return;\n\n if (this.state === 'vertex-editing') {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.startVertices,\n },\n metadata: {\n vertexIndex: this.activeVertexIndex || undefined,\n },\n },\n });\n } else if (this.startElement) {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: this.state === 'dragging' ? 'move' : 'resize',\n changes: {\n rect: this.startElement,\n },\n metadata:\n this.state === 'dragging'\n ? undefined\n : {\n handle: this.activeHandle || undefined,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n this.reset();\n }\n\n private reset() {\n this.state = 'idle';\n this.startPoint = null;\n this.startElement = null;\n this.activeHandle = null;\n this.currentPosition = null;\n this.activeVertexIndex = null;\n this.startVertices = [];\n }\n\n private getCurrentPosition() {\n return this.currentPosition || this.config.element;\n }\n\n private calculateDelta(clientX: number, clientY: number): Position {\n if (!this.startPoint) return { x: 0, y: 0 };\n\n const rawDelta: Position = {\n x: clientX - this.startPoint.x,\n y: clientY - this.startPoint.y,\n };\n\n return this.transformDelta(rawDelta);\n }\n\n private transformDelta(delta: Position): Position {\n const { pageRotation = 0, scale = 1 } = this.config;\n\n const rad = (pageRotation * Math.PI) / 2;\n const cos = Math.cos(rad);\n const sin = Math.sin(rad);\n\n const scaledX = delta.x / scale;\n const scaledY = delta.y / scale;\n\n return {\n x: cos * scaledX + sin * scaledY,\n y: -sin * scaledX + cos * scaledY,\n };\n }\n\n private clampPoint(p: Position): Position {\n const bbox = this.config.constraints?.boundingBox;\n if (!bbox) return p;\n return {\n x: Math.max(0, Math.min(p.x, bbox.width)),\n y: Math.max(0, Math.min(p.y, bbox.height)),\n };\n }\n\n private calculateVertexPosition(clientX: number, clientY: number): Position[] {\n if (this.activeVertexIndex === null) return this.startVertices;\n\n const delta = this.calculateDelta(clientX, clientY);\n const newVertices = [...this.startVertices];\n const currentVertex = newVertices[this.activeVertexIndex];\n\n const moved = {\n x: currentVertex.x + delta.x,\n y: currentVertex.y + delta.y,\n };\n newVertices[this.activeVertexIndex] = this.clampPoint(moved);\n\n return newVertices;\n }\n\n private calculateDragPosition(delta: Position): Rect {\n if (!this.startElement) return this.config.element;\n\n const position: Rect = {\n origin: {\n x: this.startElement.origin.x + delta.x,\n y: this.startElement.origin.y + delta.y,\n },\n size: {\n width: this.startElement.size.width,\n height: this.startElement.size.height,\n },\n };\n\n return this.applyConstraints(position);\n }\n\n private calculateResizePosition(delta: Position, handle: ResizeHandle): Rect {\n if (!this.startElement) return this.config.element;\n\n let {\n origin: { x, y },\n size: { width, height },\n } = this.startElement;\n\n switch (handle) {\n case 'se':\n width += delta.x;\n height += delta.y;\n break;\n case 'sw':\n x += delta.x;\n width -= delta.x;\n height += delta.y;\n break;\n case 'ne':\n width += delta.x;\n y += delta.y;\n height -= delta.y;\n break;\n case 'nw':\n x += delta.x;\n width -= delta.x;\n y += delta.y;\n height -= delta.y;\n break;\n case 'n':\n y += delta.y;\n height -= delta.y;\n break;\n case 's':\n height += delta.y;\n break;\n case 'e':\n width += delta.x;\n break;\n case 'w':\n x += delta.x;\n width -= delta.x;\n break;\n }\n\n // Maintain aspect ratio if needed\n if (this.config.maintainAspectRatio && this.startElement) {\n const aspectRatio = this.startElement.size.width / this.startElement.size.height;\n\n if (['n', 's', 'e', 'w'].includes(handle)) {\n if (handle === 'n' || handle === 's') {\n const newWidth = height * aspectRatio;\n const widthDiff = newWidth - width;\n width = newWidth;\n x -= widthDiff / 2;\n } else {\n const newHeight = width / aspectRatio;\n const heightDiff = newHeight - height;\n height = newHeight;\n if (handle === 'w') {\n x = this.startElement.origin.x + this.startElement.size.width - width;\n }\n y -= heightDiff / 2;\n }\n } else {\n const widthChange = Math.abs(width - this.startElement.size.width);\n const heightChange = Math.abs(height - this.startElement.size.height);\n if (widthChange > heightChange) {\n height = width / aspectRatio;\n } else {\n width = height * aspectRatio;\n }\n if (handle.includes('w')) {\n x = this.startElement.origin.x + this.startElement.size.width - width;\n }\n if (handle.includes('n')) {\n y = this.startElement.origin.y + this.startElement.size.height - height;\n }\n }\n }\n\n // Handle-aware bounding box clamping to avoid shifting opposite edge\n const bbox = this.config.constraints?.boundingBox;\n if (bbox) {\n switch (handle) {\n case 'e':\n width = Math.min(width, bbox.width - x);\n break;\n case 's':\n height = Math.min(height, bbox.height - y);\n break;\n case 'se':\n width = Math.min(width, bbox.width - x);\n height = Math.min(height, bbox.height - y);\n break;\n case 'w':\n if (x < 0) {\n width += x;\n x = 0;\n }\n break;\n case 'n':\n if (y < 0) {\n height += y;\n y = 0;\n }\n break;\n case 'sw':\n if (x < 0) {\n width += x;\n x = 0;\n }\n height = Math.min(height, bbox.height - y);\n break;\n case 'nw':\n if (x < 0) {\n width += x;\n x = 0;\n }\n if (y < 0) {\n height += y;\n y = 0;\n }\n break;\n case 'ne':\n width = Math.min(width, bbox.width - x);\n if (y < 0) {\n height += y;\n y = 0;\n }\n break;\n }\n }\n\n return this.applyConstraints({ origin: { x, y }, size: { width, height } });\n }\n\n private applyConstraints(position: Rect): Rect {\n const { constraints } = this.config;\n if (!constraints) return position;\n\n let {\n origin: { x, y },\n size: { width, height },\n } = position;\n\n // Apply size constraints\n width = Math.max(constraints.minWidth || 1, width);\n height = Math.max(constraints.minHeight || 1, height);\n\n if (constraints.maxWidth) width = Math.min(constraints.maxWidth, width);\n if (constraints.maxHeight) height = Math.min(constraints.maxHeight, height);\n\n // Apply bounding box constraints\n if (constraints.boundingBox) {\n x = Math.max(0, Math.min(x, constraints.boundingBox.width - width));\n y = Math.max(0, Math.min(y, constraints.boundingBox.height - height));\n }\n\n return { origin: { x, y }, size: { width, height } };\n }\n}\n","import type { Position, Rect } from '@embedpdf/models';\nimport type { ResizeHandle, DragResizeConfig } from './drag-resize-controller';\n\nexport type QuarterTurns = 0 | 1 | 2 | 3;\n\nexport interface ResizeUI {\n handleSize?: number; // px (default 8)\n spacing?: number; // px distance from the box edge (default 1)\n offsetMode?: 'outside' | 'inside' | 'center'; // default 'outside'\n includeSides?: boolean; // default false\n zIndex?: number; // default 3\n rotationAwareCursor?: boolean; // default true\n}\n\nexport interface VertexUI {\n vertexSize?: number; // px (default 12)\n zIndex?: number; // default 4\n}\n\nexport interface HandleDescriptor {\n handle: ResizeHandle;\n style: Record<string, number | string>;\n attrs?: Record<string, any>;\n}\n\nfunction diagonalCursor(handle: ResizeHandle, rot: QuarterTurns): string {\n // Standard cursors; diagonals flip on odd quarter-turns\n const diag0: Record<'nw' | 'ne' | 'sw' | 'se', string> = {\n nw: 'nwse-resize',\n ne: 'nesw-resize',\n sw: 'nesw-resize',\n se: 'nwse-resize',\n };\n if (handle === 'n' || handle === 's') return 'ns-resize';\n if (handle === 'e' || handle === 'w') return 'ew-resize';\n if (rot % 2 === 0) return diag0[handle as 'nw' | 'ne' | 'sw' | 'se'];\n return { nw: 'nesw-resize', ne: 'nwse-resize', sw: 'nwse-resize', se: 'nesw-resize' }[\n handle as 'nw' | 'ne' | 'sw' | 'se'\n ]!;\n}\n\nfunction edgeOffset(k: number, spacing: number, mode: 'outside' | 'inside' | 'center') {\n // Base puts the handle centered on the edge\n const base = -k / 2;\n if (mode === 'center') return base;\n // outside moves further out (more negative), inside moves in (less negative)\n return mode === 'outside' ? base - spacing : base + spacing;\n}\n\nexport function describeResizeFromConfig(\n cfg: DragResizeConfig,\n ui: ResizeUI = {},\n): HandleDescriptor[] {\n const {\n handleSize = 8,\n spacing = 1,\n offsetMode = 'outside',\n includeSides = false,\n zIndex = 3,\n rotationAwareCursor = true,\n } = ui;\n\n const rotation = ((cfg.pageRotation ?? 0) % 4) as QuarterTurns;\n\n const off = (edge: 'top' | 'right' | 'bottom' | 'left') => ({\n [edge]: edgeOffset(handleSize, spacing, offsetMode) + 'px',\n });\n\n const corners: Array<[ResizeHandle, Record<string, number | string>]> = [\n ['nw', { ...off('top'), ...off('left') }],\n ['ne', { ...off('top'), ...off('right') }],\n ['sw', { ...off('bottom'), ...off('left') }],\n ['se', { ...off('bottom'), ...off('right') }],\n ];\n const sides: Array<[ResizeHandle, Record<string, number | string>]> = includeSides\n ? [\n ['n', { ...off('top'), left: `calc(50% - ${handleSize / 2}px)` }],\n ['s', { ...off('bottom'), left: `calc(50% - ${handleSize / 2}px)` }],\n ['w', { ...off('left'), top: `calc(50% - ${handleSize / 2}px)` }],\n ['e', { ...off('right'), top: `calc(50% - ${handleSize / 2}px)` }],\n ]\n : [];\n\n const all = [...corners, ...sides];\n\n return all.map(([handle, pos]) => ({\n handle,\n style: {\n position: 'absolute',\n width: handleSize + 'px',\n height: handleSize + 'px',\n borderRadius: '50%',\n zIndex,\n cursor: rotationAwareCursor ? diagonalCursor(handle, rotation) : 'default',\n touchAction: 'none',\n ...(pos as any),\n },\n attrs: { 'data-epdf-handle': handle },\n }));\n}\n\nexport function describeVerticesFromConfig(\n cfg: DragResizeConfig,\n ui: VertexUI = {},\n liveVertices?: Position[],\n): HandleDescriptor[] {\n const { vertexSize = 12, zIndex = 4 } = ui;\n const rect: Rect = cfg.element;\n const scale = cfg.scale ?? 1;\n const verts = liveVertices ?? cfg.vertices ?? [];\n\n return verts.map((v, i) => {\n const left = (v.x - rect.origin.x) * scale - vertexSize / 2;\n const top = (v.y - rect.origin.y) * scale - vertexSize / 2;\n return {\n handle: 'nw', // not used; kept for type\n style: {\n position: 'absolute',\n left: left + 'px',\n top: top + 'px',\n width: vertexSize + 'px',\n height: vertexSize + 'px',\n borderRadius: '50%',\n cursor: 'pointer',\n zIndex,\n touchAction: 'none',\n },\n attrs: { 'data-epdf-vertex': i },\n };\n });\n}\n","import { isRef, unref, toRaw, type Ref } from 'vue';\nimport type { Rect, Position } from '@embedpdf/models';\nimport type { DragResizeConfig } from '../../shared/plugin-interaction-primitives';\n\nexport type MaybeRef<T> = T | Ref<T>;\n\nexport const norm = <T>(v: MaybeRef<T>): T => toRaw(isRef(v) ? unref(v) : (v as T));\n\nexport const toNum = (n: unknown, fallback = 0): number => {\n const v = Number(n);\n return Number.isFinite(v) ? v : fallback;\n};\n\nexport const rectDTO = (r: any): Rect => ({\n origin: { x: toNum(r?.origin?.x), y: toNum(r?.origin?.y) },\n size: { width: toNum(r?.size?.width), height: toNum(r?.size?.height) },\n});\n\nexport const vertsDTO = (arr: any[] = []): Position[] =>\n arr.map((p) => ({ x: toNum(p?.x), y: toNum(p?.y) }));\n\nexport const boolDTO = (b: unknown): boolean | undefined =>\n b === undefined ? undefined : Boolean(b);\n\nexport const numDTO = (n: unknown): number | undefined => (n === undefined ? undefined : toNum(n));\n\nexport const constraintsDTO = (\n c: MaybeRef<DragResizeConfig['constraints']> | undefined,\n): DragResizeConfig['constraints'] | undefined => (c ? norm(c) : undefined);\n","import { ref, watch, computed, onUnmounted, markRaw, type Ref } from 'vue';\nimport type { Position, Rect } from '@embedpdf/models';\nimport {\n DragResizeController,\n type DragResizeConfig,\n type InteractionEvent,\n type ResizeHandle,\n} from '../../shared/plugin-interaction-primitives';\nimport {\n norm,\n rectDTO,\n vertsDTO,\n constraintsDTO,\n boolDTO,\n numDTO,\n type MaybeRef,\n} from '../utils/interaction-normalize';\n\nexport interface UseDragResizeOptions {\n element: MaybeRef<Rect>;\n vertices?: MaybeRef<Position[]>;\n constraints?: MaybeRef<DragResizeConfig['constraints']>;\n maintainAspectRatio?: MaybeRef<boolean>;\n pageRotation?: MaybeRef<number>;\n scale?: MaybeRef<number>;\n onUpdate?: (event: InteractionEvent) => void;\n enabled?: MaybeRef<boolean>;\n}\n\nexport function useDragResize(options: UseDragResizeOptions) {\n const controller = ref<DragResizeController | null>(null);\n\n const {\n onUpdate,\n element,\n vertices,\n constraints,\n maintainAspectRatio,\n pageRotation,\n scale,\n enabled,\n } = options;\n\n // Build initial plain config\n const initialCfg: DragResizeConfig = {\n element: rectDTO(norm(element)),\n vertices: vertices ? vertsDTO(norm(vertices)) : undefined,\n constraints: constraintsDTO(constraints),\n maintainAspectRatio: boolDTO(enabled === undefined ? undefined : norm(maintainAspectRatio!)),\n pageRotation: numDTO(pageRotation === undefined ? undefined : norm(pageRotation!)),\n scale: numDTO(scale === undefined ? undefined : norm(scale!)),\n };\n\n if (!controller.value) {\n controller.value = markRaw(new DragResizeController(initialCfg, (ev) => onUpdate?.(ev)));\n }\n\n // Reactive updates → always normalize before passing to controller\n watch(\n () => ({\n element,\n vertices,\n constraints,\n maintainAspectRatio,\n pageRotation,\n scale,\n }),\n (nc) => {\n controller.value?.updateConfig({\n element: rectDTO(norm(nc.element)),\n vertices: nc.vertices ? vertsDTO(norm(nc.vertices)) : undefined,\n constraints: constraintsDTO(nc.constraints),\n maintainAspectRatio: boolDTO(\n nc.maintainAspectRatio === undefined ? undefined : norm(nc.maintainAspectRatio!),\n ),\n pageRotation: numDTO(nc.pageRotation === undefined ? undefined : norm(nc.pageRotation!)),\n scale: numDTO(nc.scale === undefined ? undefined : norm(nc.scale!)),\n });\n },\n { deep: true },\n );\n\n onUnmounted(() => {\n controller.value = null;\n });\n\n const isEnabled = () => Boolean(enabled === undefined ? true : norm(enabled));\n\n // Pointer handlers\n const handleDragStart = (e: PointerEvent) => {\n if (!isEnabled()) return;\n e.preventDefault();\n e.stopPropagation();\n controller.value?.startDrag(e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n };\n const handleMove = (e: PointerEvent) => controller.value?.move(e.clientX, e.clientY);\n const handleEnd = (e: PointerEvent) => {\n controller.value?.end();\n (e.currentTarget as HTMLElement).releasePointerCapture?.(e.pointerId);\n };\n const handleCancel = (e: PointerEvent) => {\n controller.value?.cancel();\n (e.currentTarget as HTMLElement).releasePointerCapture?.(e.pointerId);\n };\n\n const createResizeProps = (handle: ResizeHandle) => ({\n onPointerdown: (e: PointerEvent) => {\n if (!isEnabled()) return;\n e.preventDefault();\n e.stopPropagation();\n controller.value?.startResize(handle, e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n },\n onPointermove: handleMove,\n onPointerup: handleEnd,\n onPointercancel: handleCancel,\n });\n\n const createVertexProps = (vertexIndex: number) => ({\n onPointerdown: (e: PointerEvent) => {\n if (!isEnabled()) return;\n e.preventDefault();\n e.stopPropagation();\n controller.value?.startVertexEdit(vertexIndex, e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n },\n onPointermove: handleMove,\n onPointerup: handleEnd,\n onPointercancel: handleCancel,\n });\n\n const dragProps = computed(() =>\n isEnabled()\n ? {\n onPointerdown: handleDragStart,\n onPointermove: handleMove,\n onPointerup: handleEnd,\n onPointercancel: handleCancel,\n }\n : {},\n );\n\n return { dragProps, createResizeProps, createVertexProps };\n}\n","import { ref } from 'vue';\n\ntype DoublePressOptions = {\n delay?: number; // ms between taps\n tolerancePx?: number; // spatial tolerance\n};\n\ntype DoubleHandler = ((e: PointerEvent | MouseEvent) => void) | undefined;\n\ntype DoubleProps = {\n onDblclick?: (e: MouseEvent) => void;\n onPointerupCapture?: (e: PointerEvent) => void;\n};\n\n/**\n * Vue composable for handling double-press/double-tap interactions.\n *\n * @param onDouble - Callback to invoke on double press/tap\n * @param options - Configuration for delay and spatial tolerance\n * @returns Event handler props to be spread on an element with v-bind\n *\n * @example\n * ```vue\n * <script setup>\n * import { useDoublePressProps } from '@embedpdf/utils/vue';\n *\n * const handleDoubleClick = (e) => {\n * console.log('Double clicked!');\n * };\n *\n * const doubleProps = useDoublePressProps(handleDoubleClick);\n * </script>\n *\n * <template>\n * <div v-bind=\"doubleProps\">\n * Double click/tap me\n * </div>\n * </template>\n * ```\n */\nexport function useDoublePressProps(\n onDouble?: DoubleHandler,\n { delay = 300, tolerancePx = 18 }: DoublePressOptions = {},\n): DoubleProps {\n const last = ref({ t: 0, x: 0, y: 0 });\n\n const handlePointerUp = (e: PointerEvent) => {\n if (!onDouble) return;\n\n // Ignore mouse (it will use native dblclick),\n // and ignore non-primary pointers (multi-touch, etc.)\n if (e.pointerType === 'mouse' || e.isPrimary === false) return;\n\n const now = performance.now();\n const x = e.clientX;\n const y = e.clientY;\n\n const withinTime = now - last.value.t <= delay;\n const dx = x - last.value.x;\n const dy = y - last.value.y;\n const withinDist = dx * dx + dy * dy <= tolerancePx * tolerancePx;\n\n if (withinTime && withinDist) {\n onDouble?.(e);\n }\n\n last.value = { t: now, x, y };\n };\n\n const handleDouble = (e: MouseEvent) => {\n onDouble?.(e);\n };\n\n return onDouble\n ? {\n // Vue uses lowercase 'c' in dblclick\n onDblclick: handleDouble,\n onPointerupCapture: handlePointerUp,\n }\n : {};\n}\n","import { computed, type CSSProperties } from 'vue';\nimport { useDragResize, type UseDragResizeOptions } from './use-drag-resize';\nimport {\n describeResizeFromConfig,\n describeVerticesFromConfig,\n type ResizeUI,\n type VertexUI,\n} from '../../shared/plugin-interaction-primitives/utils';\nimport type { Position, Rect } from '@embedpdf/models';\nimport { norm, rectDTO, vertsDTO } from '../utils/interaction-normalize';\n\nexport type HandleElementProps = {\n key: string | number;\n style: CSSProperties;\n onPointerdown: (e: PointerEvent) => void;\n onPointermove: (e: PointerEvent) => void;\n onPointerup: (e: PointerEvent) => void;\n onPointercancel: (e: PointerEvent) => void;\n} & Record<string, any>;\n\nexport interface UseInteractionHandlesOptions {\n controller: UseDragResizeOptions; // may contain refs\n resizeUI?: ResizeUI;\n vertexUI?: VertexUI;\n includeVertices?: boolean;\n handleAttrs?: (\n h: 'nw' | 'ne' | 'sw' | 'se' | 'n' | 'e' | 's' | 'w',\n ) => Record<string, any> | void;\n vertexAttrs?: (i: number) => Record<string, any> | void;\n}\n\nexport function useInteractionHandles(opts: UseInteractionHandlesOptions) {\n const {\n controller,\n resizeUI,\n vertexUI,\n includeVertices = false,\n handleAttrs,\n vertexAttrs,\n } = opts;\n\n // Owns live interaction handlers\n const { dragProps, createResizeProps, createVertexProps } = useDragResize(controller);\n\n // Plain snapshots for the *descriptor* helpers\n const elementPlain = computed<Rect>(() => rectDTO(norm(controller.element)));\n const verticesPlain = computed<Position[] | undefined>(() =>\n controller.vertices ? vertsDTO(norm(controller.vertices)) : undefined,\n );\n const scalePlain = computed<number>(() => Number(norm(controller.scale ?? 1)));\n const rotationPlain = computed<number>(() => Number(norm(controller.pageRotation ?? 0)));\n const maintainPlain = computed<boolean | undefined>(() =>\n controller.maintainAspectRatio === undefined\n ? undefined\n : Boolean(norm(controller.maintainAspectRatio)),\n );\n const constraintsPlain = computed(() => norm(controller.constraints ?? undefined));\n\n const resize = computed<HandleElementProps[]>(() => {\n const desc = describeResizeFromConfig(\n {\n element: elementPlain.value,\n scale: scalePlain.value,\n pageRotation: rotationPlain.value,\n maintainAspectRatio: maintainPlain.value,\n constraints: constraintsPlain.value,\n },\n resizeUI,\n );\n return desc.map((d) => ({\n key: (d.attrs?.['data-epdf-handle'] as string) ?? d.handle,\n style: d.style as CSSProperties,\n ...createResizeProps(d.handle),\n ...(d.attrs ?? {}),\n ...(handleAttrs?.(d.handle) ?? {}),\n }));\n });\n\n const vertices = computed<HandleElementProps[]>(() => {\n if (!includeVertices) return [];\n const verts = verticesPlain.value ?? [];\n const desc = describeVerticesFromConfig(\n { element: elementPlain.value, scale: scalePlain.value, vertices: verts },\n vertexUI,\n verts,\n );\n return desc.map((d, i) => ({\n key: i,\n style: d.style as CSSProperties,\n ...createVertexProps(i),\n ...(d.attrs ?? {}),\n ...(vertexAttrs?.(i) ?? {}),\n }));\n });\n\n return { dragProps, resize, vertices };\n}\n","import { toRaw, isRef, isReactive, isProxy } from 'vue';\n\nexport function deepToRaw<T extends Record<string, any>>(sourceObj: T): T {\n const objectIterator = (input: any): any => {\n if (Array.isArray(input)) {\n return input.map((item) => objectIterator(item));\n }\n if (isRef(input) || isReactive(input) || isProxy(input)) {\n return objectIterator(toRaw(input));\n }\n if (input && typeof input === 'object') {\n return Object.keys(input).reduce((acc, key) => {\n acc[key as keyof typeof acc] = objectIterator(input[key]);\n return acc;\n }, {} as T);\n }\n return input;\n };\n\n return objectIterator(sourceObj);\n}\n"],"names":["_renderSlot"],"mappings":";;;;;;;;;AAkBA,UAAM,QAAQ;AAEd,UAAM,kBAAkB,SAAS,MAAM,mBAAmB,MAAM,MAAM,MAAM,QAAQ,CAAC;AAErF,UAAM,mBAAmB,SAAS,OAAO;AAAA,MACvC,OAAO;AAAA,QACL,UAAU;AAAA,QACV,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC;AAAA,QAC5B,KAAK,GAAG,MAAM,KAAK,OAAO,CAAC;AAAA,QAC3B,WAAW,gBAAgB,MAAM;AAAA,QACjC,iBAAiB;AAAA,QACjB,OAA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AAQ,cAAc,SAAS,CAAA;AACrC,UAAM,OAAO;AAAA,MACX,EAAE,SAAS,aAAa,OAAO,OAAO,WAAW,OAAO,UAAU,MAAA;AAAA,MAClE;AAAA,MACA;AAAA,IAAA;AAEF,WAAO,KAAK,IAAI,CAAC,GAAG,OAAO;AAAA,MACzB,KAAK;AAAA,MACL,OAAO,EAAE;AAAA,MACT,GAAG,kBAAkB,CAAC;AAAA,MACtB,GAAI,EAAE,SAAS,CAAA;AAAA,MACf,IAAI,2CAAc,OAAM,CAAA;AAAA,IAAC,EACzB;AAAA,EACJ,CAAC;AAED,SAAO,EAAE,WAAW,QAAQ,SAAA;AAC9B;AC9FO,SAAS,UAAyC,WAAiB;AACxE,QAAM,iBAAiB,CAAC,UAAoB;AAC1C,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,aAAO,MAAM,IAAI,CAAC,SAAS,eAAe,IAAI,CAAC;AAAA,IACjD;AACA,QAAI,MAAM,KAAK,KAAK,WAAW,KAAK,KAAK,QAAQ,KAAK,GAAG;AACvD,aAAO,eAAe,MAAM,KAAK,CAAC;AAAA,IACpC;AACA,QAAI,SAAS,OAAO,UAAU,UAAU;AACtC,aAAO,OAAO,KAAK,KAAK,EAAE,OAAO,CAAC,KAAK,QAAQ;AAC7C,YAAI,GAAuB,IAAI,eAAe,MAAM,GAAG,CAAC;AACxD,eAAO;AAAA,MACT,GAAG,CAAA,CAAO;AAAA,IACZ;AACA,WAAO;AAAA,EACT;AAEA,SAAO,eAAe,SAAS;AACjC;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/vue/components/counter-rotate-container.vue","../../src/shared/plugin-interaction-primitives/drag-resize-controller.ts","../../src/shared/plugin-interaction-primitives/utils.ts","../../src/vue/utils/interaction-normalize.ts","../../src/vue/hooks/use-drag-resize.ts","../../src/vue/hooks/use-double-press-props.ts","../../src/vue/hooks/use-interaction-handles.ts","../../src/vue/utils/deep-to-raw.ts"],"sourcesContent":["<template>\n <slot\n :menu-wrapper-props=\"menuWrapperProps\"\n :matrix=\"counterRotation.matrix\"\n :rect=\"adjustedRect\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, type CSSProperties } from 'vue';\nimport type { Rect, Rotation } from '@embedpdf/models';\nimport { getCounterRotation } from '@embedpdf/utils';\n\ninterface CounterRotateProps {\n rect: Rect;\n rotation: Rotation;\n}\n\nconst props = defineProps<CounterRotateProps>();\n\nconst counterRotation = computed(() => getCounterRotation(props.rect, props.rotation));\n\nconst menuWrapperProps = computed(() => ({\n style: {\n position: 'absolute',\n left: `${props.rect.origin.x}px`,\n top: `${props.rect.origin.y}px`,\n transform: counterRotation.value.matrix,\n transformOrigin: '0 0',\n width: `${counterRotation.value.width}px`,\n height: `${counterRotation.value.height}px`,\n pointerEvents: 'none',\n zIndex: 3,\n } as CSSProperties,\n onPointerdown: (e: PointerEvent) => {\n e.stopPropagation();\n e.preventDefault();\n },\n onTouchstart: (e: TouchEvent) => {\n e.stopPropagation();\n e.preventDefault();\n },\n}));\n\nconst adjustedRect = computed(() => ({\n origin: { x: props.rect.origin.x, y: props.rect.origin.y },\n size: { width: counterRotation.value.width, height: counterRotation.value.height },\n}));\n</script>\n","import { Position, Rect } from '@embedpdf/models';\n\nexport interface DragResizeConfig {\n element: Rect;\n vertices?: Position[];\n constraints?: {\n minWidth?: number;\n minHeight?: number;\n maxWidth?: number;\n maxHeight?: number;\n boundingBox?: { width: number; height: number }; // page bounds\n };\n maintainAspectRatio?: boolean;\n pageRotation?: number;\n scale?: number;\n}\n\nexport type InteractionState = 'idle' | 'dragging' | 'resizing' | 'vertex-editing';\nexport type ResizeHandle = 'nw' | 'ne' | 'sw' | 'se' | 'n' | 'e' | 's' | 'w';\n\nexport interface TransformData {\n type: 'move' | 'resize' | 'vertex-edit';\n changes: {\n rect?: Rect;\n vertices?: Position[];\n };\n metadata?: {\n handle?: ResizeHandle;\n vertexIndex?: number;\n maintainAspectRatio?: boolean;\n };\n}\n\nexport interface InteractionEvent {\n state: 'start' | 'move' | 'end';\n transformData?: TransformData;\n}\n\n/** Anchor describes which edges stay fixed when resizing. */\ntype Anchor = {\n x: 'left' | 'right' | 'center';\n y: 'top' | 'bottom' | 'center';\n};\n\n/**\n * Derive anchor from handle.\n * - 'e' means we're dragging east → left edge is anchored\n * - 'nw' means we're dragging north-west → bottom-right corner is anchored\n */\nfunction getAnchor(handle: ResizeHandle): Anchor {\n return {\n x: handle.includes('e') ? 'left' : handle.includes('w') ? 'right' : 'center',\n y: handle.includes('s') ? 'top' : handle.includes('n') ? 'bottom' : 'center',\n };\n}\n\n/**\n * Pure geometric controller that manages drag/resize/vertex-edit logic.\n */\nexport class DragResizeController {\n private state: InteractionState = 'idle';\n private startPoint: Position | null = null;\n private startElement: Rect | null = null;\n private activeHandle: ResizeHandle | null = null;\n private currentPosition: Rect | null = null;\n\n // Vertex editing state - pure geometric\n private activeVertexIndex: number | null = null;\n private startVertices: Position[] = [];\n private currentVertices: Position[] = [];\n\n constructor(\n private config: DragResizeConfig,\n private onUpdate: (event: InteractionEvent) => void,\n ) {\n this.currentVertices = config.vertices || [];\n }\n\n updateConfig(config: Partial<DragResizeConfig>) {\n this.config = { ...this.config, ...config };\n this.currentVertices = config.vertices || [];\n }\n\n startDrag(clientX: number, clientY: number) {\n this.state = 'dragging';\n this.startPoint = { x: clientX, y: clientY };\n this.startElement = { ...this.config.element };\n this.currentPosition = { ...this.config.element };\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'move',\n changes: {\n rect: this.startElement,\n },\n },\n });\n }\n\n startResize(handle: ResizeHandle, clientX: number, clientY: number) {\n this.state = 'resizing';\n this.activeHandle = handle;\n this.startPoint = { x: clientX, y: clientY };\n this.startElement = { ...this.config.element };\n this.currentPosition = { ...this.config.element };\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'resize',\n changes: {\n rect: this.startElement,\n },\n metadata: {\n handle: this.activeHandle,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n startVertexEdit(vertexIndex: number, clientX: number, clientY: number) {\n // Refresh vertices from latest config before validating index\n this.currentVertices = [...(this.config.vertices ?? this.currentVertices)];\n if (vertexIndex < 0 || vertexIndex >= this.currentVertices.length) return;\n\n this.state = 'vertex-editing';\n this.activeVertexIndex = vertexIndex;\n this.startPoint = { x: clientX, y: clientY };\n this.startVertices = [...this.currentVertices];\n\n this.onUpdate({\n state: 'start',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.startVertices,\n },\n metadata: {\n vertexIndex,\n },\n },\n });\n }\n\n move(clientX: number, clientY: number) {\n if (this.state === 'idle' || !this.startPoint) return;\n\n if (this.state === 'dragging' && this.startElement) {\n const delta = this.calculateDelta(clientX, clientY);\n const position = this.calculateDragPosition(delta);\n this.currentPosition = position;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'move',\n changes: {\n rect: position,\n },\n },\n });\n } else if (this.state === 'resizing' && this.activeHandle && this.startElement) {\n const delta = this.calculateDelta(clientX, clientY);\n const position = this.calculateResizePosition(delta, this.activeHandle);\n this.currentPosition = position;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'resize',\n changes: {\n rect: position,\n },\n metadata: {\n handle: this.activeHandle,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n } else if (this.state === 'vertex-editing' && this.activeVertexIndex !== null) {\n const vertices = this.calculateVertexPosition(clientX, clientY);\n this.currentVertices = vertices;\n\n this.onUpdate({\n state: 'move',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices,\n },\n metadata: {\n vertexIndex: this.activeVertexIndex,\n },\n },\n });\n }\n }\n\n end() {\n if (this.state === 'idle') return;\n\n const wasState = this.state;\n const handle = this.activeHandle;\n const vertexIndex = this.activeVertexIndex;\n\n if (wasState === 'vertex-editing') {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.currentVertices,\n },\n metadata: {\n vertexIndex: vertexIndex || undefined,\n },\n },\n });\n } else {\n const finalPosition = this.getCurrentPosition();\n this.onUpdate({\n state: 'end',\n transformData: {\n type: wasState === 'dragging' ? 'move' : 'resize',\n changes: {\n rect: finalPosition,\n },\n metadata:\n wasState === 'dragging'\n ? undefined\n : {\n handle: handle || undefined,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n this.reset();\n }\n\n cancel() {\n if (this.state === 'idle') return;\n\n if (this.state === 'vertex-editing') {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: 'vertex-edit',\n changes: {\n vertices: this.startVertices,\n },\n metadata: {\n vertexIndex: this.activeVertexIndex || undefined,\n },\n },\n });\n } else if (this.startElement) {\n this.onUpdate({\n state: 'end',\n transformData: {\n type: this.state === 'dragging' ? 'move' : 'resize',\n changes: {\n rect: this.startElement,\n },\n metadata:\n this.state === 'dragging'\n ? undefined\n : {\n handle: this.activeHandle || undefined,\n maintainAspectRatio: this.config.maintainAspectRatio,\n },\n },\n });\n }\n\n this.reset();\n }\n\n private reset() {\n this.state = 'idle';\n this.startPoint = null;\n this.startElement = null;\n this.activeHandle = null;\n this.currentPosition = null;\n this.activeVertexIndex = null;\n this.startVertices = [];\n }\n\n private getCurrentPosition() {\n return this.currentPosition || this.config.element;\n }\n\n private calculateDelta(clientX: number, clientY: number): Position {\n if (!this.startPoint) return { x: 0, y: 0 };\n\n const rawDelta: Position = {\n x: clientX - this.startPoint.x,\n y: clientY - this.startPoint.y,\n };\n\n return this.transformDelta(rawDelta);\n }\n\n private transformDelta(delta: Position): Position {\n const { pageRotation = 0, scale = 1 } = this.config;\n\n const rad = (pageRotation * Math.PI) / 2;\n const cos = Math.cos(rad);\n const sin = Math.sin(rad);\n\n const scaledX = delta.x / scale;\n const scaledY = delta.y / scale;\n\n return {\n x: cos * scaledX + sin * scaledY,\n y: -sin * scaledX + cos * scaledY,\n };\n }\n\n private clampPoint(p: Position): Position {\n const bbox = this.config.constraints?.boundingBox;\n if (!bbox) return p;\n return {\n x: Math.max(0, Math.min(p.x, bbox.width)),\n y: Math.max(0, Math.min(p.y, bbox.height)),\n };\n }\n\n private calculateVertexPosition(clientX: number, clientY: number): Position[] {\n if (this.activeVertexIndex === null) return this.startVertices;\n\n const delta = this.calculateDelta(clientX, clientY);\n const newVertices = [...this.startVertices];\n const currentVertex = newVertices[this.activeVertexIndex];\n\n const moved = {\n x: currentVertex.x + delta.x,\n y: currentVertex.y + delta.y,\n };\n newVertices[this.activeVertexIndex] = this.clampPoint(moved);\n\n return newVertices;\n }\n\n private calculateDragPosition(delta: Position): Rect {\n if (!this.startElement) return this.config.element;\n\n const position: Rect = {\n origin: {\n x: this.startElement.origin.x + delta.x,\n y: this.startElement.origin.y + delta.y,\n },\n size: {\n width: this.startElement.size.width,\n height: this.startElement.size.height,\n },\n };\n\n return this.applyConstraints(position);\n }\n\n /**\n * Calculate the new rect after a resize operation.\n * Pipeline: applyDelta → enforceAspectRatio → clampToBounds → applyConstraints\n */\n private calculateResizePosition(delta: Position, handle: ResizeHandle): Rect {\n if (!this.startElement) return this.config.element;\n\n const anchor = getAnchor(handle);\n const aspectRatio = this.startElement.size.width / this.startElement.size.height || 1;\n\n // Step 1: Apply delta to get raw resize\n let rect = this.applyResizeDelta(delta, anchor);\n\n // Step 2: Enforce aspect ratio if enabled\n if (this.config.maintainAspectRatio) {\n rect = this.enforceAspectRatio(rect, anchor, aspectRatio);\n }\n\n // Step 3: Clamp to bounding box\n rect = this.clampToBounds(rect, anchor, aspectRatio);\n\n // Step 4: Apply min/max constraints\n return this.applyConstraints(rect);\n }\n\n /**\n * Apply the mouse delta to produce a raw (unconstrained) resized rect.\n */\n private applyResizeDelta(delta: Position, anchor: Anchor): Rect {\n const start = this.startElement!;\n let x = start.origin.x;\n let y = start.origin.y;\n let width = start.size.width;\n let height = start.size.height;\n\n // Horizontal: if anchor is left, right edge moves; if anchor is right, left edge moves\n if (anchor.x === 'left') {\n width += delta.x;\n } else if (anchor.x === 'right') {\n x += delta.x;\n width -= delta.x;\n }\n // anchor.x === 'center' means no horizontal resize from this handle\n\n // Vertical: if anchor is top, bottom edge moves; if anchor is bottom, top edge moves\n if (anchor.y === 'top') {\n height += delta.y;\n } else if (anchor.y === 'bottom') {\n y += delta.y;\n height -= delta.y;\n }\n\n return { origin: { x, y }, size: { width, height } };\n }\n\n /**\n * Enforce aspect ratio while respecting the anchor.\n * For edge handles (center anchor on one axis), the rect expands symmetrically on that axis.\n * For corner handles, the anchor corner stays fixed.\n */\n private enforceAspectRatio(rect: Rect, anchor: Anchor, aspectRatio: number): Rect {\n const start = this.startElement!;\n let { x, y } = rect.origin;\n let { width, height } = rect.size;\n\n const isEdgeHandle = anchor.x === 'center' || anchor.y === 'center';\n\n if (isEdgeHandle) {\n // Edge handle: one dimension drives, the other follows, centered on the non-moving axis\n if (anchor.y === 'center') {\n // Horizontal edge (e/w): width is primary\n height = width / aspectRatio;\n // Center vertically relative to original\n y = start.origin.y + (start.size.height - height) / 2;\n } else {\n // Vertical edge (n/s): height is primary\n width = height * aspectRatio;\n // Center horizontally relative to original\n x = start.origin.x + (start.size.width - width) / 2;\n }\n } else {\n // Corner handle: pick the dominant axis based on which changed more\n const dw = Math.abs(width - start.size.width);\n const dh = Math.abs(height - start.size.height);\n\n if (dw >= dh) {\n height = width / aspectRatio;\n } else {\n width = height * aspectRatio;\n }\n }\n\n // Reposition based on anchor\n if (anchor.x === 'right') {\n x = start.origin.x + start.size.width - width;\n }\n if (anchor.y === 'bottom') {\n y = start.origin.y + start.size.height - height;\n }\n\n return { origin: { x, y }, size: { width, height } };\n }\n\n /**\n * Clamp rect to bounding box while respecting anchor and aspect ratio.\n */\n private clampToBounds(rect: Rect, anchor: Anchor, aspectRatio: number): Rect {\n const bbox = this.config.constraints?.boundingBox;\n if (!bbox) return rect;\n\n const start = this.startElement!;\n let { x, y } = rect.origin;\n let { width, height } = rect.size;\n\n // Ensure positive dimensions\n width = Math.max(1, width);\n height = Math.max(1, height);\n\n // Calculate anchor points (the edges/corners that must stay fixed)\n const anchorX = anchor.x === 'left' ? start.origin.x : start.origin.x + start.size.width;\n const anchorY = anchor.y === 'top' ? start.origin.y : start.origin.y + start.size.height;\n\n // Calculate max available space from anchor\n const maxW =\n anchor.x === 'left'\n ? bbox.width - anchorX\n : anchor.x === 'right'\n ? anchorX\n : Math.min(start.origin.x, bbox.width - start.origin.x - start.size.width) * 2 +\n start.size.width;\n\n const maxH =\n anchor.y === 'top'\n ? bbox.height - anchorY\n : anchor.y === 'bottom'\n ? anchorY\n : Math.min(start.origin.y, bbox.height - start.origin.y - start.size.height) * 2 +\n start.size.height;\n\n if (this.config.maintainAspectRatio) {\n // Find the scaling factor that fits both constraints\n const scaleW = width > maxW ? maxW / width : 1;\n const scaleH = height > maxH ? maxH / height : 1;\n const scale = Math.min(scaleW, scaleH);\n\n if (scale < 1) {\n width *= scale;\n height *= scale;\n }\n } else {\n // Clamp independently\n width = Math.min(width, maxW);\n height = Math.min(height, maxH);\n }\n\n // Recompute position based on anchor\n if (anchor.x === 'left') {\n x = anchorX;\n } else if (anchor.x === 'right') {\n x = anchorX - width;\n } else {\n x = start.origin.x + (start.size.width - width) / 2;\n }\n\n if (anchor.y === 'top') {\n y = anchorY;\n } else if (anchor.y === 'bottom') {\n y = anchorY - height;\n } else {\n y = start.origin.y + (start.size.height - height) / 2;\n }\n\n // Final clamp to ensure we're within bounds (handles center anchor edge cases)\n x = Math.max(0, Math.min(x, bbox.width - width));\n y = Math.max(0, Math.min(y, bbox.height - height));\n\n return { origin: { x, y }, size: { width, height } };\n }\n\n private applyConstraints(position: Rect): Rect {\n const { constraints } = this.config;\n if (!constraints) return position;\n\n let {\n origin: { x, y },\n size: { width, height },\n } = position;\n\n const minW = constraints.minWidth ?? 1;\n const minH = constraints.minHeight ?? 1;\n const maxW = constraints.maxWidth;\n const maxH = constraints.maxHeight;\n\n if (this.config.maintainAspectRatio && width > 0 && height > 0) {\n const ratio = width / height;\n\n // Enforce mins (scale up)\n if (width < minW) {\n width = minW;\n height = width / ratio;\n }\n if (height < minH) {\n height = minH;\n width = height * ratio;\n }\n\n // Enforce maxes (scale down)\n if (maxW !== undefined && width > maxW) {\n width = maxW;\n height = width / ratio;\n }\n if (maxH !== undefined && height > maxH) {\n height = maxH;\n width = height * ratio;\n }\n } else {\n width = Math.max(minW, width);\n height = Math.max(minH, height);\n if (maxW !== undefined) width = Math.min(maxW, width);\n if (maxH !== undefined) height = Math.min(maxH, height);\n }\n\n // Clamp position to bounding box\n if (constraints.boundingBox) {\n x = Math.max(0, Math.min(x, constraints.boundingBox.width - width));\n y = Math.max(0, Math.min(y, constraints.boundingBox.height - height));\n }\n\n return { origin: { x, y }, size: { width, height } };\n }\n}\n","import type { Position, Rect } from '@embedpdf/models';\nimport type { ResizeHandle, DragResizeConfig } from './drag-resize-controller';\n\nexport type QuarterTurns = 0 | 1 | 2 | 3;\n\nexport interface ResizeUI {\n handleSize?: number; // px (default 8)\n spacing?: number; // px distance from the box edge (default 1)\n offsetMode?: 'outside' | 'inside' | 'center'; // default 'outside'\n includeSides?: boolean; // default false\n zIndex?: number; // default 3\n rotationAwareCursor?: boolean; // default true\n}\n\nexport interface VertexUI {\n vertexSize?: number; // px (default 12)\n zIndex?: number; // default 4\n}\n\nexport interface HandleDescriptor {\n handle: ResizeHandle;\n style: Record<string, number | string>;\n attrs?: Record<string, any>;\n}\n\nfunction diagonalCursor(handle: ResizeHandle, rot: QuarterTurns): string {\n // Standard cursors; diagonals flip on odd quarter-turns\n const diag0: Record<'nw' | 'ne' | 'sw' | 'se', string> = {\n nw: 'nwse-resize',\n ne: 'nesw-resize',\n sw: 'nesw-resize',\n se: 'nwse-resize',\n };\n if (handle === 'n' || handle === 's') return 'ns-resize';\n if (handle === 'e' || handle === 'w') return 'ew-resize';\n if (rot % 2 === 0) return diag0[handle as 'nw' | 'ne' | 'sw' | 'se'];\n return { nw: 'nesw-resize', ne: 'nwse-resize', sw: 'nwse-resize', se: 'nesw-resize' }[\n handle as 'nw' | 'ne' | 'sw' | 'se'\n ]!;\n}\n\nfunction edgeOffset(k: number, spacing: number, mode: 'outside' | 'inside' | 'center') {\n // Base puts the handle centered on the edge\n const base = -k / 2;\n if (mode === 'center') return base;\n // outside moves further out (more negative), inside moves in (less negative)\n return mode === 'outside' ? base - spacing : base + spacing;\n}\n\nexport function describeResizeFromConfig(\n cfg: DragResizeConfig,\n ui: ResizeUI = {},\n): HandleDescriptor[] {\n const {\n handleSize = 8,\n spacing = 1,\n offsetMode = 'outside',\n includeSides = false,\n zIndex = 3,\n rotationAwareCursor = true,\n } = ui;\n\n const rotation = ((cfg.pageRotation ?? 0) % 4) as QuarterTurns;\n\n const off = (edge: 'top' | 'right' | 'bottom' | 'left') => ({\n [edge]: edgeOffset(handleSize, spacing, offsetMode) + 'px',\n });\n\n const corners: Array<[ResizeHandle, Record<string, number | string>]> = [\n ['nw', { ...off('top'), ...off('left') }],\n ['ne', { ...off('top'), ...off('right') }],\n ['sw', { ...off('bottom'), ...off('left') }],\n ['se', { ...off('bottom'), ...off('right') }],\n ];\n const sides: Array<[ResizeHandle, Record<string, number | string>]> = includeSides\n ? [\n ['n', { ...off('top'), left: `calc(50% - ${handleSize / 2}px)` }],\n ['s', { ...off('bottom'), left: `calc(50% - ${handleSize / 2}px)` }],\n ['w', { ...off('left'), top: `calc(50% - ${handleSize / 2}px)` }],\n ['e', { ...off('right'), top: `calc(50% - ${handleSize / 2}px)` }],\n ]\n : [];\n\n const all = [...corners, ...sides];\n\n return all.map(([handle, pos]) => ({\n handle,\n style: {\n position: 'absolute',\n width: handleSize + 'px',\n height: handleSize + 'px',\n borderRadius: '50%',\n zIndex,\n cursor: rotationAwareCursor ? diagonalCursor(handle, rotation) : 'default',\n touchAction: 'none',\n ...(pos as any),\n },\n attrs: { 'data-epdf-handle': handle },\n }));\n}\n\nexport function describeVerticesFromConfig(\n cfg: DragResizeConfig,\n ui: VertexUI = {},\n liveVertices?: Position[],\n): HandleDescriptor[] {\n const { vertexSize = 12, zIndex = 4 } = ui;\n const rect: Rect = cfg.element;\n const scale = cfg.scale ?? 1;\n const verts = liveVertices ?? cfg.vertices ?? [];\n\n return verts.map((v, i) => {\n const left = (v.x - rect.origin.x) * scale - vertexSize / 2;\n const top = (v.y - rect.origin.y) * scale - vertexSize / 2;\n return {\n handle: 'nw', // not used; kept for type\n style: {\n position: 'absolute',\n left: left + 'px',\n top: top + 'px',\n width: vertexSize + 'px',\n height: vertexSize + 'px',\n borderRadius: '50%',\n cursor: 'pointer',\n zIndex,\n touchAction: 'none',\n },\n attrs: { 'data-epdf-vertex': i },\n };\n });\n}\n","import { isRef, unref, toRaw, type Ref } from 'vue';\nimport type { Rect, Position } from '@embedpdf/models';\nimport type { DragResizeConfig } from '../../shared/plugin-interaction-primitives';\n\nexport type MaybeRef<T> = T | Ref<T>;\n\nexport const norm = <T>(v: MaybeRef<T>): T => toRaw(isRef(v) ? unref(v) : (v as T));\n\nexport const toNum = (n: unknown, fallback = 0): number => {\n const v = Number(n);\n return Number.isFinite(v) ? v : fallback;\n};\n\nexport const rectDTO = (r: any): Rect => ({\n origin: { x: toNum(r?.origin?.x), y: toNum(r?.origin?.y) },\n size: { width: toNum(r?.size?.width), height: toNum(r?.size?.height) },\n});\n\nexport const vertsDTO = (arr: any[] = []): Position[] =>\n arr.map((p) => ({ x: toNum(p?.x), y: toNum(p?.y) }));\n\nexport const boolDTO = (b: unknown): boolean | undefined =>\n b === undefined ? undefined : Boolean(b);\n\nexport const numDTO = (n: unknown): number | undefined => (n === undefined ? undefined : toNum(n));\n\nexport const constraintsDTO = (\n c: MaybeRef<DragResizeConfig['constraints']> | undefined,\n): DragResizeConfig['constraints'] | undefined => (c ? norm(c) : undefined);\n","import { ref, watch, computed, onUnmounted, markRaw, type Ref } from 'vue';\nimport type { Position, Rect } from '@embedpdf/models';\nimport {\n DragResizeController,\n type DragResizeConfig,\n type InteractionEvent,\n type ResizeHandle,\n} from '../../shared/plugin-interaction-primitives';\nimport {\n norm,\n rectDTO,\n vertsDTO,\n constraintsDTO,\n boolDTO,\n numDTO,\n type MaybeRef,\n} from '../utils/interaction-normalize';\n\nexport interface UseDragResizeOptions {\n element: MaybeRef<Rect>;\n vertices?: MaybeRef<Position[]>;\n constraints?: MaybeRef<DragResizeConfig['constraints']>;\n maintainAspectRatio?: MaybeRef<boolean>;\n pageRotation?: MaybeRef<number>;\n scale?: MaybeRef<number>;\n onUpdate?: (event: InteractionEvent) => void;\n enabled?: MaybeRef<boolean>;\n}\n\nexport function useDragResize(options: UseDragResizeOptions) {\n const controller = ref<DragResizeController | null>(null);\n\n const {\n onUpdate,\n element,\n vertices,\n constraints,\n maintainAspectRatio,\n pageRotation,\n scale,\n enabled,\n } = options;\n\n // Build initial plain config\n const initialCfg: DragResizeConfig = {\n element: rectDTO(norm(element)),\n vertices: vertices ? vertsDTO(norm(vertices)) : undefined,\n constraints: constraintsDTO(constraints),\n maintainAspectRatio: boolDTO(enabled === undefined ? undefined : norm(maintainAspectRatio!)),\n pageRotation: numDTO(pageRotation === undefined ? undefined : norm(pageRotation!)),\n scale: numDTO(scale === undefined ? undefined : norm(scale!)),\n };\n\n if (!controller.value) {\n controller.value = markRaw(new DragResizeController(initialCfg, (ev) => onUpdate?.(ev)));\n }\n\n // Reactive updates → always normalize before passing to controller\n watch(\n () => ({\n element,\n vertices,\n constraints,\n maintainAspectRatio,\n pageRotation,\n scale,\n }),\n (nc) => {\n controller.value?.updateConfig({\n element: rectDTO(norm(nc.element)),\n vertices: nc.vertices ? vertsDTO(norm(nc.vertices)) : undefined,\n constraints: constraintsDTO(nc.constraints),\n maintainAspectRatio: boolDTO(\n nc.maintainAspectRatio === undefined ? undefined : norm(nc.maintainAspectRatio!),\n ),\n pageRotation: numDTO(nc.pageRotation === undefined ? undefined : norm(nc.pageRotation!)),\n scale: numDTO(nc.scale === undefined ? undefined : norm(nc.scale!)),\n });\n },\n { deep: true },\n );\n\n onUnmounted(() => {\n controller.value = null;\n });\n\n const isEnabled = () => Boolean(enabled === undefined ? true : norm(enabled));\n\n // Pointer handlers\n const handleDragStart = (e: PointerEvent) => {\n if (!isEnabled()) return;\n e.preventDefault();\n e.stopPropagation();\n controller.value?.startDrag(e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n };\n const handleMove = (e: PointerEvent) => controller.value?.move(e.clientX, e.clientY);\n const handleEnd = (e: PointerEvent) => {\n controller.value?.end();\n (e.currentTarget as HTMLElement).releasePointerCapture?.(e.pointerId);\n };\n const handleCancel = (e: PointerEvent) => {\n controller.value?.cancel();\n (e.currentTarget as HTMLElement).releasePointerCapture?.(e.pointerId);\n };\n\n const createResizeProps = (handle: ResizeHandle) => ({\n onPointerdown: (e: PointerEvent) => {\n if (!isEnabled()) return;\n e.preventDefault();\n e.stopPropagation();\n controller.value?.startResize(handle, e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n },\n onPointermove: handleMove,\n onPointerup: handleEnd,\n onPointercancel: handleCancel,\n });\n\n const createVertexProps = (vertexIndex: number) => ({\n onPointerdown: (e: PointerEvent) => {\n if (!isEnabled()) return;\n e.preventDefault();\n e.stopPropagation();\n controller.value?.startVertexEdit(vertexIndex, e.clientX, e.clientY);\n (e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId);\n },\n onPointermove: handleMove,\n onPointerup: handleEnd,\n onPointercancel: handleCancel,\n });\n\n const dragProps = computed(() =>\n isEnabled()\n ? {\n onPointerdown: handleDragStart,\n onPointermove: handleMove,\n onPointerup: handleEnd,\n onPointercancel: handleCancel,\n }\n : {},\n );\n\n return { dragProps, createResizeProps, createVertexProps };\n}\n","import { ref } from 'vue';\n\ntype DoublePressOptions = {\n delay?: number; // ms between taps\n tolerancePx?: number; // spatial tolerance\n};\n\ntype DoubleHandler = ((e: PointerEvent | MouseEvent) => void) | undefined;\n\ntype DoubleProps = {\n onDblclick?: (e: MouseEvent) => void;\n onPointerupCapture?: (e: PointerEvent) => void;\n};\n\n/**\n * Vue composable for handling double-press/double-tap interactions.\n *\n * @param onDouble - Callback to invoke on double press/tap\n * @param options - Configuration for delay and spatial tolerance\n * @returns Event handler props to be spread on an element with v-bind\n *\n * @example\n * ```vue\n * <script setup>\n * import { useDoublePressProps } from '@embedpdf/utils/vue';\n *\n * const handleDoubleClick = (e) => {\n * console.log('Double clicked!');\n * };\n *\n * const doubleProps = useDoublePressProps(handleDoubleClick);\n * </script>\n *\n * <template>\n * <div v-bind=\"doubleProps\">\n * Double click/tap me\n * </div>\n * </template>\n * ```\n */\nexport function useDoublePressProps(\n onDouble?: DoubleHandler,\n { delay = 300, tolerancePx = 18 }: DoublePressOptions = {},\n): DoubleProps {\n const last = ref({ t: 0, x: 0, y: 0 });\n\n const handlePointerUp = (e: PointerEvent) => {\n if (!onDouble) return;\n\n // Ignore mouse (it will use native dblclick),\n // and ignore non-primary pointers (multi-touch, etc.)\n if (e.pointerType === 'mouse' || e.isPrimary === false) return;\n\n const now = performance.now();\n const x = e.clientX;\n const y = e.clientY;\n\n const withinTime = now - last.value.t <= delay;\n const dx = x - last.value.x;\n const dy = y - last.value.y;\n const withinDist = dx * dx + dy * dy <= tolerancePx * tolerancePx;\n\n if (withinTime && withinDist) {\n onDouble?.(e);\n }\n\n last.value = { t: now, x, y };\n };\n\n const handleDouble = (e: MouseEvent) => {\n onDouble?.(e);\n };\n\n return onDouble\n ? {\n // Vue uses lowercase 'c' in dblclick\n onDblclick: handleDouble,\n onPointerupCapture: handlePointerUp,\n }\n : {};\n}\n","import { computed, type CSSProperties } from 'vue';\nimport { useDragResize, type UseDragResizeOptions } from './use-drag-resize';\nimport {\n describeResizeFromConfig,\n describeVerticesFromConfig,\n type ResizeUI,\n type VertexUI,\n} from '../../shared/plugin-interaction-primitives/utils';\nimport type { Position, Rect } from '@embedpdf/models';\nimport { norm, rectDTO, vertsDTO } from '../utils/interaction-normalize';\n\nexport type HandleElementProps = {\n key: string | number;\n style: CSSProperties;\n onPointerdown: (e: PointerEvent) => void;\n onPointermove: (e: PointerEvent) => void;\n onPointerup: (e: PointerEvent) => void;\n onPointercancel: (e: PointerEvent) => void;\n} & Record<string, any>;\n\nexport interface UseInteractionHandlesOptions {\n controller: UseDragResizeOptions; // may contain refs\n resizeUI?: ResizeUI;\n vertexUI?: VertexUI;\n includeVertices?: boolean;\n handleAttrs?: (\n h: 'nw' | 'ne' | 'sw' | 'se' | 'n' | 'e' | 's' | 'w',\n ) => Record<string, any> | void;\n vertexAttrs?: (i: number) => Record<string, any> | void;\n}\n\nexport function useInteractionHandles(opts: UseInteractionHandlesOptions) {\n const {\n controller,\n resizeUI,\n vertexUI,\n includeVertices = false,\n handleAttrs,\n vertexAttrs,\n } = opts;\n\n // Owns live interaction handlers\n const { dragProps, createResizeProps, createVertexProps } = useDragResize(controller);\n\n // Plain snapshots for the *descriptor* helpers\n const elementPlain = computed<Rect>(() => rectDTO(norm(controller.element)));\n const verticesPlain = computed<Position[] | undefined>(() =>\n controller.vertices ? vertsDTO(norm(controller.vertices)) : undefined,\n );\n const scalePlain = computed<number>(() => Number(norm(controller.scale ?? 1)));\n const rotationPlain = computed<number>(() => Number(norm(controller.pageRotation ?? 0)));\n const maintainPlain = computed<boolean | undefined>(() =>\n controller.maintainAspectRatio === undefined\n ? undefined\n : Boolean(norm(controller.maintainAspectRatio)),\n );\n const constraintsPlain = computed(() => norm(controller.constraints ?? undefined));\n\n const resize = computed<HandleElementProps[]>(() => {\n const desc = describeResizeFromConfig(\n {\n element: elementPlain.value,\n scale: scalePlain.value,\n pageRotation: rotationPlain.value,\n maintainAspectRatio: maintainPlain.value,\n constraints: constraintsPlain.value,\n },\n resizeUI,\n );\n return desc.map((d) => ({\n key: (d.attrs?.['data-epdf-handle'] as string) ?? d.handle,\n style: d.style as CSSProperties,\n ...createResizeProps(d.handle),\n ...(d.attrs ?? {}),\n ...(handleAttrs?.(d.handle) ?? {}),\n }));\n });\n\n const vertices = computed<HandleElementProps[]>(() => {\n if (!includeVertices) return [];\n const verts = verticesPlain.value ?? [];\n const desc = describeVerticesFromConfig(\n { element: elementPlain.value, scale: scalePlain.value, vertices: verts },\n vertexUI,\n verts,\n );\n return desc.map((d, i) => ({\n key: i,\n style: d.style as CSSProperties,\n ...createVertexProps(i),\n ...(d.attrs ?? {}),\n ...(vertexAttrs?.(i) ?? {}),\n }));\n });\n\n return { dragProps, resize, vertices };\n}\n","import { toRaw, isRef, isReactive, isProxy } from 'vue';\n\nexport function deepToRaw<T extends Record<string, any>>(sourceObj: T): T {\n const objectIterator = (input: any): any => {\n if (Array.isArray(input)) {\n return input.map((item) => objectIterator(item));\n }\n if (isRef(input) || isReactive(input) || isProxy(input)) {\n return objectIterator(toRaw(input));\n }\n if (input && typeof input === 'object') {\n return Object.keys(input).reduce((acc, key) => {\n acc[key as keyof typeof acc] = objectIterator(input[key]);\n return acc;\n }, {} as T);\n }\n return input;\n };\n\n return objectIterator(sourceObj);\n}\n"],"names":["_renderSlot"],"mappings":";;;;;;;;;AAkBA,UAAM,QAAQ;AAEd,UAAM,kBAAkB,SAAS,MAAM,mBAAmB,MAAM,MAAM,MAAM,QAAQ,CAAC;AAErF,UAAM,mBAAmB,SAAS,OAAO;AAAA,MACvC,OAAO;AAAA,QACL,UAAU;AAAA,QACV,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC;AAAA,QAC5B,KAAK,GAAG,MAAM,KAAK,OAAO,CAAC;AAAA,QAC3B,WAAW,gBAAgB,MAAM;AAAA,QACjC,iBAAiB;AAAA,QACjB,OAAO,GAAG,gBAAgB,MAAM,KAAK;AAAA,QACrC,QAAQ,GAAG,gBAAgB,MAAM,MAAM;AAAA,QACvC,eAAe;AAAA,QACf,QAAQ;AAAA,MAAA;AAAA,MAEV,eAAe,CAAC,MAAoB;AAClC,UAAE,gBAAA;AACF,UAAE,eAAA;AAAA,MACJ;AAAA,MACA,cAAc,CAAC,MAAkB;AAC/B,UAAE,gBAAA;AACF,UAAE,eAAA;AAAA,MACJ;AAAA,IAAA,EACA;AAEF,UAAM,eAAe,SAAS,OAAO;AAAA,MACnC,QAAQ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AAA,MAAC;AAAA,KAChC;AAAA,EACJ,CAAC;AAED,QAAM,WAAW,SAA+B,MAAM;AACpD,QAAI,CAAC,gBAAiB,QAAO,CAAA;AAC7B,UAAM,QAAQ,cAAc,SAAS,CAAA;AACrC,UAAM,OAAO;AAAA,MACX,EAAE,SAAS,aAAa,OAAO,OAAO,WAAW,OAAO,UAAU,MAAA;AAAA,MAClE;AAAA,MACA;AAAA,IAAA;AAEF,WAAO,KAAK,IAAI,CAAC,GAAG,OAAO;AAAA,MACzB,KAAK;AAAA,MACL,OAAO,EAAE;AAAA,MACT,GAAG,kBAAkB,CAAC;AAAA,MACtB,GAAI,EAAE,SAAS,CAAA;AAAA,MACf,IAAI,2CAAc,OAAM,CAAA;AAAA,IAAC,EACzB;AAAA,EACJ,CAAC;AAED,SAAO,EAAE,WAAW,QAAQ,SAAA;AAC9B;AC9FO,SAAS,UAAyC,WAAiB;AACxE,QAAM,iBAAiB,CAAC,UAAoB;AAC1C,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,aAAO,MAAM,IAAI,CAAC,SAAS,eAAe,IAAI,CAAC;AAAA,IACjD;AACA,QAAI,MAAM,KAAK,KAAK,WAAW,KAAK,KAAK,QAAQ,KAAK,GAAG;AACvD,aAAO,eAAe,MAAM,KAAK,CAAC;AAAA,IACpC;AACA,QAAI,SAAS,OAAO,UAAU,UAAU;AACtC,aAAO,OAAO,KAAK,KAAK,EAAE,OAAO,CAAC,KAAK,QAAQ;AAC7C,YAAI,GAAuB,IAAI,eAAe,MAAM,GAAG,CAAC;AACxD,eAAO;AAAA,MACT,GAAG,CAAA,CAAO;AAAA,IACZ;AACA,WAAO;AAAA,EACT;AAEA,SAAO,eAAe,SAAS;AACjC;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/utils",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "private": false,
5
5
  "description": "Shared utility helpers (geometry, tasks, logging, PDF primitives) that underpin every package in the EmbedPDF ecosystem.",
6
6
  "type": "module",
@@ -53,7 +53,7 @@
53
53
  "devDependencies": {
54
54
  "typescript": "^5.0.0",
55
55
  "@types/react": "^18.2.0",
56
- "@embedpdf/models": "2.0.0",
56
+ "@embedpdf/models": "2.0.2",
57
57
  "@embedpdf/build": "1.1.0"
58
58
  },
59
59
  "peerDependencies": {