@wordpress/media-editor 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/components/media-editor/index.cjs +74 -21
  3. package/build/components/media-editor/index.cjs.map +1 -1
  4. package/build/components/media-editor/use-crop-options.cjs +4 -5
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -1
  6. package/build/components/media-editor/use-save-media-editor.cjs +23 -3
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
  8. package/build/components/media-editor-canvas/index.cjs +6 -11
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -1
  10. package/build/components/media-editor-crop-panel/index.cjs +17 -1
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
  12. package/build/components/media-editor-fine-rotation/index.cjs +4 -5
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -1
  14. package/build/components/media-editor-image-controls/index.cjs +4 -6
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -1
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +1 -0
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
  18. package/build/components/media-editor-modal/index.cjs.map +1 -1
  19. package/build/components/media-form/index.cjs +7 -1
  20. package/build/components/media-form/index.cjs.map +1 -1
  21. package/build/components/media-preview/index.cjs +0 -1
  22. package/build/components/media-preview/index.cjs.map +1 -1
  23. package/build/state/aspect-ratio-presets.cjs +10 -4
  24. package/build/state/aspect-ratio-presets.cjs.map +1 -1
  25. package/build/state/composite-reducer.cjs +32 -67
  26. package/build/state/composite-reducer.cjs.map +1 -1
  27. package/build/state/index.cjs +0 -39
  28. package/build/state/types.cjs +1 -2
  29. package/build/state/types.cjs.map +1 -1
  30. package/build/state/use-media-editor-state.cjs +70 -106
  31. package/build/state/use-media-editor-state.cjs.map +1 -1
  32. package/build-module/components/media-editor/index.mjs +78 -25
  33. package/build-module/components/media-editor/index.mjs.map +1 -1
  34. package/build-module/components/media-editor/use-crop-options.mjs +4 -5
  35. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -1
  36. package/build-module/components/media-editor/use-save-media-editor.mjs +23 -3
  37. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -1
  38. package/build-module/components/media-editor-canvas/index.mjs +8 -13
  39. package/build-module/components/media-editor-canvas/index.mjs.map +1 -1
  40. package/build-module/components/media-editor-crop-panel/index.mjs +17 -1
  41. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -1
  42. package/build-module/components/media-editor-fine-rotation/index.mjs +4 -5
  43. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -1
  44. package/build-module/components/media-editor-image-controls/index.mjs +5 -7
  45. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -1
  46. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +1 -0
  47. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
  48. package/build-module/components/media-editor-modal/index.mjs.map +1 -1
  49. package/build-module/components/media-form/index.mjs +7 -1
  50. package/build-module/components/media-form/index.mjs.map +1 -1
  51. package/build-module/components/media-preview/index.mjs +0 -1
  52. package/build-module/components/media-preview/index.mjs.map +1 -1
  53. package/build-module/state/aspect-ratio-presets.mjs +10 -5
  54. package/build-module/state/aspect-ratio-presets.mjs.map +1 -1
  55. package/build-module/state/composite-reducer.mjs +32 -67
  56. package/build-module/state/composite-reducer.mjs.map +1 -1
  57. package/build-module/state/index.mjs +2 -5
  58. package/build-module/state/types.mjs +1 -2
  59. package/build-module/state/types.mjs.map +1 -1
  60. package/build-module/state/use-media-editor-state.mjs +70 -105
  61. package/build-module/state/use-media-editor-state.mjs.map +1 -1
  62. package/build-style/style-rtl.css +104 -57
  63. package/build-style/style.css +103 -57
  64. package/build-types/components/media-editor/index.d.ts +17 -3
  65. package/build-types/components/media-editor/index.d.ts.map +1 -1
  66. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  67. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  68. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  69. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  70. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  71. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  72. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  73. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  74. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  75. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  76. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  77. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  78. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  79. package/build-types/components/media-form/index.d.ts.map +1 -1
  80. package/build-types/components/media-preview/index.d.ts.map +1 -1
  81. package/build-types/state/aspect-ratio-presets.d.ts +20 -3
  82. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -1
  83. package/build-types/state/composite-reducer.d.ts +17 -19
  84. package/build-types/state/composite-reducer.d.ts.map +1 -1
  85. package/build-types/state/index.d.ts +2 -5
  86. package/build-types/state/index.d.ts.map +1 -1
  87. package/build-types/state/types.d.ts +20 -64
  88. package/build-types/state/types.d.ts.map +1 -1
  89. package/build-types/state/use-media-editor-state.d.ts +33 -52
  90. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  91. package/package.json +22 -23
  92. package/src/components/media-editor/index.tsx +163 -28
  93. package/src/components/media-editor/use-crop-options.ts +7 -11
  94. package/src/components/media-editor/use-save-media-editor.ts +48 -6
  95. package/src/components/media-editor-canvas/index.tsx +15 -26
  96. package/src/components/media-editor-canvas/style.scss +6 -6
  97. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  98. package/src/components/media-editor-crop-panel/style.scss +21 -0
  99. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  100. package/src/components/media-editor-image-controls/index.tsx +11 -9
  101. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +1 -0
  102. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  103. package/src/components/media-editor-modal/index.tsx +1 -1
  104. package/src/components/media-form/index.tsx +7 -1
  105. package/src/components/media-preview/index.tsx +0 -1
  106. package/src/components/rotation-ruler/style.scss +3 -3
  107. package/src/state/README.md +32 -0
  108. package/src/state/aspect-ratio-presets.ts +22 -3
  109. package/src/state/composite-reducer.ts +42 -80
  110. package/src/state/index.ts +2 -18
  111. package/src/state/types.ts +18 -68
  112. package/src/state/use-media-editor-state.ts +155 -240
  113. package/src/style.scss +2 -1
  114. package/build/components/media-editor-modal/build-modifiers.cjs +0 -110
  115. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -1
  116. package/build/image-editor/core/camera.cjs +0 -277
  117. package/build/image-editor/core/camera.cjs.map +0 -1
  118. package/build/image-editor/core/constants.cjs +0 -133
  119. package/build/image-editor/core/constants.cjs.map +0 -1
  120. package/build/image-editor/core/containment.cjs +0 -289
  121. package/build/image-editor/core/containment.cjs.map +0 -1
  122. package/build/image-editor/core/crop-rect.cjs +0 -37
  123. package/build/image-editor/core/crop-rect.cjs.map +0 -1
  124. package/build/image-editor/core/export/canvas-renderer.cjs +0 -181
  125. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -1
  126. package/build/image-editor/core/index.cjs +0 -89
  127. package/build/image-editor/core/interaction-controller.cjs +0 -591
  128. package/build/image-editor/core/interaction-controller.cjs.map +0 -1
  129. package/build/image-editor/core/math/rotation.cjs +0 -32
  130. package/build/image-editor/core/math/rotation.cjs.map +0 -1
  131. package/build/image-editor/core/math/sanitize.cjs +0 -136
  132. package/build/image-editor/core/math/sanitize.cjs.map +0 -1
  133. package/build/image-editor/core/setter-helpers.cjs +0 -61
  134. package/build/image-editor/core/setter-helpers.cjs.map +0 -1
  135. package/build/image-editor/core/source-region.cjs +0 -236
  136. package/build/image-editor/core/source-region.cjs.map +0 -1
  137. package/build/image-editor/core/state.cjs +0 -296
  138. package/build/image-editor/core/state.cjs.map +0 -1
  139. package/build/image-editor/core/stencil-math.cjs +0 -203
  140. package/build/image-editor/core/stencil-math.cjs.map +0 -1
  141. package/build/image-editor/core/transform-style.cjs +0 -43
  142. package/build/image-editor/core/transform-style.cjs.map +0 -1
  143. package/build/image-editor/core/transforms/pipeline.cjs +0 -41
  144. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -1
  145. package/build/image-editor/core/types.cjs +0 -5
  146. package/build/image-editor/core/viewport-state.cjs +0 -36
  147. package/build/image-editor/core/viewport-state.cjs.map +0 -1
  148. package/build/image-editor/index.cjs +0 -68
  149. package/build/image-editor/react/components/cropper-provider.cjs +0 -49
  150. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -1
  151. package/build/image-editor/react/components/cropper.cjs +0 -595
  152. package/build/image-editor/react/components/cropper.cjs.map +0 -1
  153. package/build/image-editor/react/components/index.cjs +0 -25
  154. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -147
  155. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -1
  156. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -31
  157. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -1
  158. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -61
  159. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -1
  160. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -367
  161. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -1
  162. package/build/image-editor/react/components/viewport-provider.cjs +0 -26
  163. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -1
  164. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -80
  165. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -1
  166. package/build/image-editor/react/hooks/index.cjs +0 -19
  167. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -104
  168. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -1
  169. package/build/image-editor/react/hooks/use-cropper-controller.cjs +0 -80
  170. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +0 -1
  171. package/build/image-editor/react/hooks/use-interaction.cjs +0 -187
  172. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -1
  173. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -24
  174. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -1
  175. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -40
  176. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -1
  177. package/build/image-editor/react/visually-hidden-style.cjs +0 -24
  178. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -1
  179. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -105
  180. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -1
  181. package/build-module/image-editor/core/camera.mjs +0 -265
  182. package/build-module/image-editor/core/camera.mjs.map +0 -1
  183. package/build-module/image-editor/core/constants.mjs +0 -115
  184. package/build-module/image-editor/core/constants.mjs.map +0 -1
  185. package/build-module/image-editor/core/containment.mjs +0 -281
  186. package/build-module/image-editor/core/containment.mjs.map +0 -1
  187. package/build-module/image-editor/core/crop-rect.mjs +0 -32
  188. package/build-module/image-editor/core/crop-rect.mjs.map +0 -1
  189. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -170
  190. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -1
  191. package/build-module/image-editor/core/index.mjs +0 -7
  192. package/build-module/image-editor/core/interaction-controller.mjs +0 -586
  193. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -1
  194. package/build-module/image-editor/core/math/rotation.mjs +0 -26
  195. package/build-module/image-editor/core/math/rotation.mjs.map +0 -1
  196. package/build-module/image-editor/core/math/sanitize.mjs +0 -127
  197. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -1
  198. package/build-module/image-editor/core/setter-helpers.mjs +0 -56
  199. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -1
  200. package/build-module/image-editor/core/source-region.mjs +0 -228
  201. package/build-module/image-editor/core/source-region.mjs.map +0 -1
  202. package/build-module/image-editor/core/state.mjs +0 -288
  203. package/build-module/image-editor/core/state.mjs.map +0 -1
  204. package/build-module/image-editor/core/stencil-math.mjs +0 -194
  205. package/build-module/image-editor/core/stencil-math.mjs.map +0 -1
  206. package/build-module/image-editor/core/transform-style.mjs +0 -38
  207. package/build-module/image-editor/core/transform-style.mjs.map +0 -1
  208. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -35
  209. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -1
  210. package/build-module/image-editor/core/types.mjs +0 -0
  211. package/build-module/image-editor/core/viewport-state.mjs +0 -30
  212. package/build-module/image-editor/core/viewport-state.mjs.map +0 -1
  213. package/build-module/image-editor/index.mjs +0 -4
  214. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -43
  215. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -1
  216. package/build-module/image-editor/react/components/cropper.mjs +0 -568
  217. package/build-module/image-editor/react/components/cropper.mjs.map +0 -1
  218. package/build-module/image-editor/react/components/index.mjs +0 -3
  219. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -142
  220. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -1
  221. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -26
  222. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -1
  223. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -56
  224. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -1
  225. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -362
  226. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -1
  227. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -20
  228. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -1
  229. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -75
  230. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -1
  231. package/build-module/image-editor/react/hooks/index.mjs +0 -3
  232. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -99
  233. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -1
  234. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +0 -75
  235. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +0 -1
  236. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -182
  237. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -1
  238. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -19
  239. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -1
  240. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -35
  241. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -1
  242. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -19
  243. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -1
  244. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -81
  245. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  246. package/build-types/image-editor/core/camera.d.ts +0 -128
  247. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  248. package/build-types/image-editor/core/constants.d.ts +0 -98
  249. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  250. package/build-types/image-editor/core/containment.d.ts +0 -72
  251. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  252. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  253. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  254. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  255. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  256. package/build-types/image-editor/core/index.d.ts +0 -10
  257. package/build-types/image-editor/core/index.d.ts.map +0 -1
  258. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  259. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  260. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  261. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  262. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  263. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  264. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  265. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  266. package/build-types/image-editor/core/source-region.d.ts +0 -94
  267. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  268. package/build-types/image-editor/core/state.d.ts +0 -51
  269. package/build-types/image-editor/core/state.d.ts.map +0 -1
  270. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  271. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  272. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  273. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  274. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  275. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  276. package/build-types/image-editor/core/types.d.ts +0 -269
  277. package/build-types/image-editor/core/types.d.ts.map +0 -1
  278. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  279. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  280. package/build-types/image-editor/index.d.ts +0 -17
  281. package/build-types/image-editor/index.d.ts.map +0 -1
  282. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  283. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  284. package/build-types/image-editor/react/components/cropper.d.ts +0 -54
  285. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  286. package/build-types/image-editor/react/components/index.d.ts +0 -4
  287. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  288. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  289. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  290. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  291. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  292. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  293. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  294. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  295. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  296. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  297. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  298. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  299. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  300. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  301. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  302. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  303. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  304. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts +0 -55
  305. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +0 -1
  306. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  307. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  308. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  309. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  310. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  311. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  312. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  313. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  314. package/src/components/media-editor-modal/build-modifiers.ts +0 -167
  315. package/src/image-editor/README.md +0 -61
  316. package/src/image-editor/core/camera.ts +0 -429
  317. package/src/image-editor/core/constants.ts +0 -137
  318. package/src/image-editor/core/containment.ts +0 -469
  319. package/src/image-editor/core/crop-rect.ts +0 -42
  320. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  321. package/src/image-editor/core/index.ts +0 -43
  322. package/src/image-editor/core/interaction-controller.ts +0 -976
  323. package/src/image-editor/core/math/rotation.ts +0 -26
  324. package/src/image-editor/core/math/sanitize.ts +0 -155
  325. package/src/image-editor/core/setter-helpers.ts +0 -63
  326. package/src/image-editor/core/source-region.ts +0 -367
  327. package/src/image-editor/core/state.ts +0 -484
  328. package/src/image-editor/core/stencil-math.ts +0 -379
  329. package/src/image-editor/core/transform-style.ts +0 -56
  330. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  331. package/src/image-editor/core/types.ts +0 -230
  332. package/src/image-editor/core/viewport-state.ts +0 -30
  333. package/src/image-editor/docs/architecture.md +0 -63
  334. package/src/image-editor/docs/recipes.md +0 -184
  335. package/src/image-editor/index.ts +0 -43
  336. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  337. package/src/image-editor/react/components/cropper.scss +0 -259
  338. package/src/image-editor/react/components/cropper.tsx +0 -1108
  339. package/src/image-editor/react/components/index.ts +0 -3
  340. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  341. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  342. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  343. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  344. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  345. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  346. package/src/image-editor/react/hooks/index.ts +0 -4
  347. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  348. package/src/image-editor/react/hooks/use-cropper-controller.ts +0 -197
  349. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  350. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  351. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  352. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  353. package/src/image-editor/style.scss +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"interaction-controller.cjs","names":["MIN_ZOOM","MAX_ZOOM","DEFAULT_WHEEL_ZOOM_SPEED","DEFAULT_KEYBOARD_STEP","KEYBOARD_SHIFT_STEP_MULTIPLIER","restrictPanZoom"],"sources":["../../../src/image-editor/core/interaction-controller.ts"],"sourcesContent":["import type { CropperState, NormalizedPoint, Size } from './types';\nimport {\n\tDEFAULT_KEYBOARD_STEP,\n\tDEFAULT_WHEEL_ZOOM_SPEED,\n\tKEYBOARD_SHIFT_STEP_MULTIPLIER,\n\tMIN_ZOOM,\n\tMAX_ZOOM,\n} from './constants';\nimport { restrictPanZoom } from './containment';\n\n/** Time window for detecting a double-tap gesture (ms). */\nconst DOUBLE_TAP_TIME = 300;\n/** Max distance between taps to count as a double-tap (px). */\nconst DOUBLE_TAP_DISTANCE = 30;\n/** Duration of the zoom animation state (ms). */\nconst ZOOM_ANIMATION_DURATION = 200;\n\n/**\n * Get the natural image dimensions from cropper state, falling back to 1x1.\n *\n * @param state The current cropper state.\n * @return The image dimensions.\n */\nfunction getImageSizeFromState( state: CropperState ): {\n\twidth: number;\n\theight: number;\n} {\n\treturn state.image\n\t\t? { width: state.image.naturalWidth, height: state.image.naturalHeight }\n\t\t: { width: 1, height: 1 };\n}\n\n/**\n * Get the distance between two touch points.\n *\n * @param t1 The first touch.\n * @param t2 The second touch.\n * @return The pixel distance between the two touches.\n */\nfunction getTouchDistance( t1: Touch, t2: Touch ): number {\n\tconst dx = t1.clientX - t2.clientX;\n\tconst dy = t1.clientY - t2.clientY;\n\treturn Math.sqrt( dx * dx + dy * dy );\n}\n\n/**\n * Status reported by the interaction controller when drag/zoom state changes.\n */\nexport interface InteractionStatus {\n\t/** Whether a drag (pan) interaction is in progress. */\n\tisDragging: boolean;\n\t/** Whether a double-tap zoom animation is in progress. */\n\tisZooming: boolean;\n}\n\n/**\n * State updates the interaction controller can request from its host UI.\n */\nexport interface CropperInteractionActions {\n\t/** Set the image pan offset in normalized coordinates. */\n\tsetPan: ( pan: NormalizedPoint ) => void;\n\t/**\n\t * Set the zoom level. Cursorless surfaces (slider, keyboard `+`/`-`)\n\t * rely on this anchoring at the crop center; pointer-driven zoom\n\t * paths use `setZoomAtPoint` with an explicit focal point instead.\n\t */\n\tsetZoom: ( zoom: number ) => void;\n\t/** Set zoom and pan together for focal-point zoom. */\n\tsetZoomAtPoint: ( zoom: number, pan: NormalizedPoint ) => void;\n\t/** Snap rotate by 90 degrees. */\n\tsnapRotate90: ( direction: 1 | -1 ) => void;\n\t/** Toggle flip on the given axis. */\n\ttoggleFlip?: ( direction: 'horizontal' | 'vertical' ) => void;\n}\n\n/**\n * Options for creating an InteractionController.\n *\n * Scalar options (minZoom, maxZoom, etc.) are read lazily on each\n * interaction, so changes to the options object take effect immediately\n * without recreating the controller.\n */\nexport interface InteractionControllerOptions {\n\t/** Returns the current cropper state. Called on every interaction. */\n\tgetState: () => CropperState;\n\t/** State updates the interaction controller can request from its host UI. */\n\tactions: CropperInteractionActions;\n\t/** Returns the container dimensions in pixels. */\n\tgetContainerSize: () => Size;\n\t/** Returns the rendered image dimensions in pixels, if available. */\n\tgetImageSize: () => Size | undefined;\n\t/** Minimum zoom level. Defaults to MIN_ZOOM. Read lazily. */\n\tminZoom?: number;\n\t/** Maximum zoom level. Defaults to MAX_ZOOM. Read lazily. */\n\tmaxZoom?: number;\n\t/** Zoom speed multiplier for wheel events. Defaults to 0.0025. Read lazily. */\n\tzoomSpeed?: number;\n\t/**\n\t * Pan step size in normalized coords for keyboard events.\n\t * Defaults to 0.01. Read lazily. Shift multiplies it by 10.\n\t */\n\tkeyboardStep?: number;\n\t/** Zoom level for double-tap zoom. Defaults to 2. Read lazily. */\n\tdoubleTapZoom?: number;\n\t/** Fires when a continuous gesture begins (pan drag, pinch zoom). */\n\tonGestureStart?: () => void;\n\t/** Fires when a continuous gesture ends (pointer release). */\n\tonGestureEnd?: () => void;\n\t/** Called when isDragging or isZooming changes. */\n\tonStatusChange?: ( status: InteractionStatus ) => void;\n}\n\n/**\n * Framework-agnostic imperative controller for image cropper interactions.\n *\n * Handles mouse, touch, and keyboard event processing for pan, zoom,\n * and crop manipulation. Uses requestAnimationFrame for drag/pinch\n * updates to avoid layout thrashing.\n *\n * The controller does not register DOM event listeners itself — that is the\n * responsibility of the UI layer (React hook, Vue directive, or vanilla JS).\n * Instead it exposes `handlePointerDown`, `handleWheel`, `handleTouchStart`,\n * and `handleKeyDown` methods that the UI layer calls with native DOM events.\n *\n * Scalar options (minZoom, maxZoom, zoomSpeed, keyboardStep, doubleTapZoom)\n * are read lazily from `this.options` on each interaction, so the UI layer\n * can update them without recreating the controller.\n *\n * Call `destroy()` to clean up timers and pending animation frames.\n */\nexport class InteractionController {\n\tprivate readonly options: InteractionControllerOptions;\n\n\t/** Current drag/zoom status. */\n\tprivate isDragging = false;\n\tprivate isZooming = false;\n\n\t/** Active drag state during pointer interactions. */\n\tprivate drag: {\n\t\tstartX: number;\n\t\tstartY: number;\n\t\tstartPanX: number;\n\t\tstartPanY: number;\n\t} | null = null;\n\n\t/** Active touch state during touch interactions. */\n\tprivate touch: {\n\t\t/** Finger distance at pinch start (0 until pinch detected). */\n\t\tstartDistance: number;\n\t\t/** Zoom level when pinch was detected. */\n\t\tstartZoom: number;\n\t\t/** First touch X/Y (for single-finger pan delta). */\n\t\tlastTouchX: number;\n\t\tlastTouchY: number;\n\t\t/** Pan when gesture started. */\n\t\tstartPanX: number;\n\t\tstartPanY: number;\n\t\t/** Container rect snapshot for focal-point math. */\n\t\tcontainerRect?: DOMRect;\n\t\t/** Midpoint of two fingers when pinch was detected. */\n\t\tstartMidX: number;\n\t\tstartMidY: number;\n\t\t/** Whether pinch was ever detected during this gesture. */\n\t\tdidPinch: boolean;\n\t\t/** Whether any dispatch has occurred (prevents dispatching before first move). */\n\t\tmoved: boolean;\n\t} | null = null;\n\n\t/** Cleanup function for active touch listeners on document. */\n\tprivate touchCleanup: ( () => void ) | null = null;\n\n\t/**\n\t * Cleanup function for active pointer-drag listeners on the\n\t * captured element. Set while a pointer drag is in progress so\n\t * `destroy()` can tear the drag down cleanly if the consumer\n\t * unmounts mid-drag. Cleared on pointerup/lostpointercapture.\n\t */\n\tprivate pointerCleanup: ( () => void ) | null = null;\n\n\t/** Last tap info for double-tap detection. */\n\tprivate lastTap: {\n\t\ttime: number;\n\t\tx: number;\n\t\ty: number;\n\t} | null = null;\n\n\t/** Timer for the zoom animation state (double-tap). */\n\tprivate zoomTimer: ReturnType< typeof setTimeout > | undefined;\n\n\t/** Timer for wheel gesture debounce. */\n\tprivate wheelGestureTimer: ReturnType< typeof setTimeout > | undefined;\n\n\t/** Whether a wheel gesture is currently active. */\n\tprivate wheelGestureActive = false;\n\n\t/** Current requestAnimationFrame ID. */\n\tprivate rafId = 0;\n\n\tconstructor( options: InteractionControllerOptions ) {\n\t\tthis.options = options;\n\t}\n\n\t/** Read minZoom lazily so option changes take effect immediately. */\n\tprivate get minZoom(): number {\n\t\treturn this.options.minZoom ?? MIN_ZOOM;\n\t}\n\n\t/** Read maxZoom lazily so option changes take effect immediately. */\n\tprivate get maxZoom(): number {\n\t\treturn this.options.maxZoom ?? MAX_ZOOM;\n\t}\n\n\t/** Read zoomSpeed lazily so option changes take effect immediately. */\n\tprivate get zoomSpeed(): number {\n\t\treturn this.options.zoomSpeed ?? DEFAULT_WHEEL_ZOOM_SPEED;\n\t}\n\n\t/** Read keyboardStep lazily so option changes take effect immediately. */\n\tprivate get keyboardStep(): number {\n\t\treturn this.options.keyboardStep ?? DEFAULT_KEYBOARD_STEP;\n\t}\n\n\t/**\n\t * Get the keyboard pan step, including modifier-based coarse movement.\n\t *\n\t * @param event The native KeyboardEvent.\n\t * @return The normalized pan step.\n\t */\n\tprivate getKeyboardStep( event: KeyboardEvent ): number {\n\t\treturn event.shiftKey\n\t\t\t? this.keyboardStep * KEYBOARD_SHIFT_STEP_MULTIPLIER\n\t\t\t: this.keyboardStep;\n\t}\n\n\t/** Read doubleTapZoom lazily so option changes take effect immediately. */\n\tprivate get doubleTapZoom(): number {\n\t\treturn this.options.doubleTapZoom ?? 2;\n\t}\n\n\t/**\n\t * Update the drag/zoom status and notify via callback if changed.\n\t *\n\t * @param update Partial status with isDragging and/or isZooming.\n\t */\n\tprivate setStatus(\n\t\tupdate: Partial< { isDragging: boolean; isZooming: boolean } >\n\t): void {\n\t\tlet changed = false;\n\t\tif (\n\t\t\tupdate.isDragging !== undefined &&\n\t\t\tupdate.isDragging !== this.isDragging\n\t\t) {\n\t\t\tthis.isDragging = update.isDragging;\n\t\t\tchanged = true;\n\t\t}\n\t\tif (\n\t\t\tupdate.isZooming !== undefined &&\n\t\t\tupdate.isZooming !== this.isZooming\n\t\t) {\n\t\t\tthis.isZooming = update.isZooming;\n\t\t\tchanged = true;\n\t\t}\n\t\tif ( changed ) {\n\t\t\tthis.options.onStatusChange?.( {\n\t\t\t\tisDragging: this.isDragging,\n\t\t\t\tisZooming: this.isZooming,\n\t\t\t} );\n\t\t}\n\t}\n\n\t/**\n\t * Handle a pointer-down event on the container element.\n\t *\n\t * Initiates a drag (pan) interaction. Captures the pointer on the\n\t * provided element and registers pointermove/pointerup/lostpointercapture\n\t * listeners for the duration of the drag.\n\t *\n\t * @param e The native PointerEvent.\n\t * @param el The DOM element to capture the pointer on.\n\t */\n\thandlePointerDown( e: PointerEvent, el: HTMLElement ): void {\n\t\t// Only handle primary button (left click / first touch).\n\t\tif ( e.button !== 0 ) {\n\t\t\treturn;\n\t\t}\n\t\t// Touch gestures are handled by touchstart/touchmove. Starting the\n\t\t// pointer drag path too can briefly toggle drag UI before pinch begins.\n\t\tif ( e.pointerType === 'touch' ) {\n\t\t\treturn;\n\t\t}\n\t\te.preventDefault();\n\n\t\t// Blur any focused handle so its focus ring doesn't linger,\n\t\t// but leave the canvas itself alone so keyboard control works after drag.\n\t\tconst ownerDoc = el.ownerDocument;\n\t\tif (\n\t\t\townerDoc?.activeElement instanceof HTMLElement &&\n\t\t\townerDoc.activeElement !== el\n\t\t) {\n\t\t\townerDoc.activeElement.blur();\n\t\t}\n\n\t\tel.focus();\n\n\t\t// Capture pointer so drag works across iframe boundaries.\n\t\tel.setPointerCapture( e.pointerId );\n\n\t\t// End a pending wheel gesture now, so its debounce timer cannot\n\t\t// fire mid-drag and end the drag's gesture along with it.\n\t\tif ( this.wheelGestureActive ) {\n\t\t\tclearTimeout( this.wheelGestureTimer );\n\t\t\tthis.wheelGestureActive = false;\n\t\t\tthis.options.onGestureEnd?.();\n\t\t}\n\n\t\tthis.setStatus( { isDragging: true } );\n\t\tthis.options.onGestureStart?.();\n\n\t\tconst currentState = this.options.getState();\n\t\tthis.drag = {\n\t\t\tstartX: e.clientX,\n\t\t\tstartY: e.clientY,\n\t\t\tstartPanX: currentState.pan.x,\n\t\t\tstartPanY: currentState.pan.y,\n\t\t};\n\n\t\tconst onPointerMove = ( moveEvent: Event ) => {\n\t\t\tconst drag = this.drag;\n\t\t\tif ( ! drag ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst pe = moveEvent as PointerEvent;\n\n\t\t\tcancelAnimationFrame( this.rafId );\n\t\t\tthis.rafId = requestAnimationFrame( () => {\n\t\t\t\tconst s = this.options.getState();\n\t\t\t\tconst imgSize = this.options.getImageSize();\n\t\t\t\tconst containerSize = this.options.getContainerSize();\n\t\t\t\tconst panSize = imgSize ?? containerSize;\n\t\t\t\tconst deltaX =\n\t\t\t\t\tpanSize.width > 0\n\t\t\t\t\t\t? ( pe.clientX - drag.startX ) / panSize.width\n\t\t\t\t\t\t: 0;\n\t\t\t\tconst deltaY =\n\t\t\t\t\tpanSize.height > 0\n\t\t\t\t\t\t? ( pe.clientY - drag.startY ) / panSize.height\n\t\t\t\t\t\t: 0;\n\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...s,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: drag.startPanX + deltaX,\n\t\t\t\t\t\t\ty: drag.startPanY + deltaY,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\t\ts.cropRect\n\t\t\t\t);\n\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t} );\n\t\t};\n\n\t\tconst removeListeners = () => {\n\t\t\tel.removeEventListener( 'pointermove', onPointerMove );\n\t\t\tel.removeEventListener( 'pointerup', onPointerUp );\n\t\t\tel.removeEventListener( 'lostpointercapture', onPointerUp );\n\t\t};\n\n\t\tconst onPointerUp = () => {\n\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\tthis.options.onGestureEnd?.();\n\t\t\tthis.drag = null;\n\t\t\tcancelAnimationFrame( this.rafId );\n\t\t\tremoveListeners();\n\t\t\tthis.pointerCleanup = null;\n\t\t};\n\n\t\tel.addEventListener( 'pointermove', onPointerMove );\n\t\tel.addEventListener( 'pointerup', onPointerUp );\n\t\tel.addEventListener( 'lostpointercapture', onPointerUp );\n\t\t// Expose cleanup to destroy() in case the consumer unmounts\n\t\t// mid-drag. The pending rAF is cancelled in destroy().\n\t\tthis.pointerCleanup = removeListeners;\n\t}\n\n\t/**\n\t * Handle a wheel event on the container element.\n\t *\n\t * Implements focal-point zoom: the point under the cursor stays\n\t * stationary on screen while the zoom level changes.\n\t *\n\t * Must be registered with `{ passive: false }` to allow preventDefault.\n\t *\n\t * @param e The native WheelEvent.\n\t */\n\thandleWheel( e: WheelEvent ): void {\n\t\te.preventDefault();\n\n\t\tif ( this.drag ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Debounced gesture boundaries for wheel zoom.\n\t\t// Start on first wheel event, end after 300ms of no events.\n\t\tif ( ! this.wheelGestureActive ) {\n\t\t\tthis.wheelGestureActive = true;\n\t\t\tthis.options.onGestureStart?.();\n\t\t}\n\t\tclearTimeout( this.wheelGestureTimer );\n\t\tthis.wheelGestureTimer = setTimeout( () => {\n\t\t\tthis.wheelGestureActive = false;\n\t\t\tthis.options.onGestureEnd?.();\n\t\t}, DOUBLE_TAP_TIME );\n\n\t\tconst s = this.options.getState();\n\t\tconst delta = -e.deltaY * this.zoomSpeed;\n\t\tconst newZoom = Math.min(\n\t\t\tthis.maxZoom,\n\t\t\tMath.max( this.minZoom, s.zoom + delta )\n\t\t);\n\n\t\tif ( newZoom === s.zoom ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Focal-point zoom: keep the point under the cursor stationary.\n\t\tconst containerSize = this.options.getContainerSize();\n\t\tconst imgSize = this.options.getImageSize();\n\t\tconst visSize = imgSize ?? containerSize;\n\t\tconst target = e.currentTarget;\n\t\tconst rect =\n\t\t\ttarget instanceof Element\n\t\t\t\t? target.getBoundingClientRect()\n\t\t\t\t: undefined;\n\t\tif ( visSize.width > 0 && visSize.height > 0 && rect ) {\n\t\t\tconst fx = e.clientX - rect.left - containerSize.width / 2;\n\t\t\tconst fy = e.clientY - rect.top - containerSize.height / 2;\n\n\t\t\tconst zoomRatio = 1 - newZoom / s.zoom;\n\t\t\tconst focalNormX = fx / visSize.width;\n\t\t\tconst focalNormY = fy / visSize.height;\n\t\t\tconst newCropX = s.pan.x + ( focalNormX - s.pan.x ) * zoomRatio;\n\t\t\tconst newCropY = s.pan.y + ( focalNormY - s.pan.y ) * zoomRatio;\n\n\t\t\tconst { pan: clampedCrop } = restrictPanZoom(\n\t\t\t\t{ ...s, zoom: newZoom, pan: { x: newCropX, y: newCropY } },\n\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\ts.cropRect\n\t\t\t);\n\t\t\tthis.options.actions.setZoomAtPoint( newZoom, clampedCrop );\n\t\t} else {\n\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t}\n\t}\n\n\t/**\n\t * Handle a touch-start event on the container element.\n\t *\n\t * Supports single-finger pan, two-finger pinch zoom, and\n\t * double-tap to toggle between fit and 2x zoom. Registers\n\t * touchmove/touchend/touchcancel on the provided document for the\n\t * duration of the gesture.\n\t *\n\t * @param e The native TouchEvent.\n\t * @param containerRect The bounding rect of the container element.\n\t * @param doc The document to register move/end listeners on.\n\t * Defaults to globalThis.document. Pass the iframe's\n\t * contentDocument when running inside an iframe.\n\t */\n\thandleTouchStart(\n\t\te: TouchEvent,\n\t\tcontainerRect: DOMRect,\n\t\tdoc: Document = document\n\t): void {\n\t\t// Second finger arriving during an existing gesture — snapshot\n\t\t// pinch start values. handleTouchMove will detect 2 touches and\n\t\t// handle pinch automatically.\n\t\tif ( this.touch && e.touches.length === 2 ) {\n\t\t\tconst s = this.options.getState();\n\t\t\tconst distance = getTouchDistance( e.touches[ 0 ], e.touches[ 1 ] );\n\t\t\tconst midX =\n\t\t\t\t( e.touches[ 0 ].clientX + e.touches[ 1 ].clientX ) / 2;\n\t\t\tconst midY =\n\t\t\t\t( e.touches[ 0 ].clientY + e.touches[ 1 ].clientY ) / 2;\n\t\t\tthis.touch.didPinch = true;\n\t\t\tthis.touch.startDistance = distance;\n\t\t\tthis.touch.startZoom = s.zoom;\n\t\t\tthis.touch.startPanX = s.pan.x;\n\t\t\tthis.touch.startPanY = s.pan.y;\n\t\t\tthis.touch.startMidX = midX;\n\t\t\tthis.touch.startMidY = midY;\n\t\t\tthis.touch.containerRect = containerRect;\n\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( e.touches.length === 1 ) {\n\t\t\tconst tapX = e.touches[ 0 ].clientX;\n\t\t\tconst tapY = e.touches[ 0 ].clientY;\n\t\t\tif ( this.tryDoubleTap( e, tapX, tapY, containerRect ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst currentState = this.options.getState();\n\n\t\t\t// Record touch state. Don't decide pan vs pinch yet —\n\t\t\t// that happens in handleTouchMove based on touches.length.\n\t\t\tthis.touch = {\n\t\t\t\tstartDistance: 0,\n\t\t\t\tstartZoom: currentState.zoom,\n\t\t\t\tlastTouchX: e.touches[ 0 ].clientX,\n\t\t\t\tlastTouchY: e.touches[ 0 ].clientY,\n\t\t\t\tstartPanX: currentState.pan.x,\n\t\t\t\tstartPanY: currentState.pan.y,\n\t\t\t\tcontainerRect,\n\t\t\t\tstartMidX: 0,\n\t\t\t\tstartMidY: 0,\n\t\t\t\tdidPinch: false,\n\t\t\t\tmoved: false,\n\t\t\t};\n\t\t\tthis.options.onGestureStart?.();\n\t\t} else if ( e.touches.length === 2 ) {\n\t\t\t// Both fingers landed simultaneously (rare but possible).\n\t\t\tconst currentState = this.options.getState();\n\t\t\tconst distance = getTouchDistance( e.touches[ 0 ], e.touches[ 1 ] );\n\t\t\tconst midX =\n\t\t\t\t( e.touches[ 0 ].clientX + e.touches[ 1 ].clientX ) / 2;\n\t\t\tconst midY =\n\t\t\t\t( e.touches[ 0 ].clientY + e.touches[ 1 ].clientY ) / 2;\n\t\t\tthis.touch = {\n\t\t\t\tstartDistance: distance,\n\t\t\t\tstartZoom: currentState.zoom,\n\t\t\t\tlastTouchX: 0,\n\t\t\t\tlastTouchY: 0,\n\t\t\t\tstartPanX: currentState.pan.x,\n\t\t\t\tstartPanY: currentState.pan.y,\n\t\t\t\tcontainerRect,\n\t\t\t\tstartMidX: midX,\n\t\t\t\tstartMidY: midY,\n\t\t\t\tdidPinch: true,\n\t\t\t\tmoved: false,\n\t\t\t};\n\t\t\tthis.options.onGestureStart?.();\n\t\t}\n\n\t\tconst onTouchEnd = () => {\n\t\t\tthis.touch = null;\n\t\t\tthis.touchCleanup = null;\n\t\t\tcancelAnimationFrame( this.rafId );\n\t\t\tdoc.removeEventListener( 'touchmove', this.handleTouchMove );\n\t\t\tdoc.removeEventListener( 'touchend', onTouchEnd );\n\t\t\tdoc.removeEventListener( 'touchcancel', onTouchEnd );\n\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\tthis.options.onGestureEnd?.();\n\t\t};\n\n\t\t// Clean up any previous touch listeners before registering new ones.\n\t\tthis.touchCleanup?.();\n\n\t\tdoc.addEventListener( 'touchmove', this.handleTouchMove, {\n\t\t\tpassive: false,\n\t\t} );\n\t\tdoc.addEventListener( 'touchend', onTouchEnd );\n\t\tdoc.addEventListener( 'touchcancel', onTouchEnd );\n\n\t\tthis.touchCleanup = onTouchEnd;\n\t}\n\n\t// Handle a touchmove event during an active touch gesture. Decides pinch\n\t// vs. pan based on current `moveEvent.touches.length`, so the gesture\n\t// can transition between modes without timing sensitivity (e.g. fingers\n\t// landing 0ms vs 200ms apart). Arrow-property binding so `this` stays\n\t// attached when used as an event listener.\n\tprivate handleTouchMove = ( moveEvent: TouchEvent ): void => {\n\t\tconst touch = this.touch;\n\t\tif ( ! touch ) {\n\t\t\treturn;\n\t\t}\n\t\tmoveEvent.preventDefault();\n\n\t\tcancelAnimationFrame( this.rafId );\n\t\tthis.rafId = requestAnimationFrame( () => {\n\t\t\tconst s = this.options.getState();\n\n\t\t\tif ( moveEvent.touches.length === 2 ) {\n\t\t\t\t// Two fingers → always pinch, regardless of how gesture\n\t\t\t\t// started. Initialize pinch state on first 2-finger move.\n\t\t\t\tif ( ! touch.didPinch ) {\n\t\t\t\t\ttouch.didPinch = true;\n\t\t\t\t\ttouch.startDistance = getTouchDistance(\n\t\t\t\t\t\tmoveEvent.touches[ 0 ],\n\t\t\t\t\t\tmoveEvent.touches[ 1 ]\n\t\t\t\t\t);\n\t\t\t\t\ttouch.startZoom = s.zoom;\n\t\t\t\t\ttouch.startPanX = s.pan.x;\n\t\t\t\t\ttouch.startPanY = s.pan.y;\n\t\t\t\t\ttouch.startMidX =\n\t\t\t\t\t\t( moveEvent.touches[ 0 ].clientX +\n\t\t\t\t\t\t\tmoveEvent.touches[ 1 ].clientX ) /\n\t\t\t\t\t\t2;\n\t\t\t\t\ttouch.startMidY =\n\t\t\t\t\t\t( moveEvent.touches[ 0 ].clientY +\n\t\t\t\t\t\t\tmoveEvent.touches[ 1 ].clientY ) /\n\t\t\t\t\t\t2;\n\t\t\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst latestContainerSize = this.options.getContainerSize();\n\t\t\t\tconst latestImageSize = this.options.getImageSize();\n\n\t\t\t\t// Pinch zoom with focal point at finger midpoint,\n\t\t\t\t// plus simultaneous pan from midpoint drift.\n\t\t\t\tconst t0 = moveEvent.touches[ 0 ];\n\t\t\t\tconst t1 = moveEvent.touches[ 1 ];\n\t\t\t\tconst currentDistance = getTouchDistance( t0, t1 );\n\t\t\t\tconst ratio = currentDistance / touch.startDistance;\n\t\t\t\tconst newZoom = Math.min(\n\t\t\t\t\tthis.maxZoom,\n\t\t\t\t\tMath.max( this.minZoom, touch.startZoom * ratio )\n\t\t\t\t);\n\n\t\t\t\tconst visSize = latestImageSize ?? latestContainerSize;\n\t\t\t\tconst rect = touch.containerRect;\n\t\t\t\tif ( visSize.width > 0 && visSize.height > 0 && rect ) {\n\t\t\t\t\t// Current midpoint.\n\t\t\t\t\tconst mx =\n\t\t\t\t\t\t( t0.clientX + t1.clientX ) / 2 -\n\t\t\t\t\t\trect.left -\n\t\t\t\t\t\tlatestContainerSize.width / 2;\n\t\t\t\t\tconst my =\n\t\t\t\t\t\t( t0.clientY + t1.clientY ) / 2 -\n\t\t\t\t\t\trect.top -\n\t\t\t\t\t\tlatestContainerSize.height / 2;\n\n\t\t\t\t\t// Pan from midpoint drift (fingers moving together).\n\t\t\t\t\tconst startMx =\n\t\t\t\t\t\ttouch.startMidX -\n\t\t\t\t\t\trect.left -\n\t\t\t\t\t\tlatestContainerSize.width / 2;\n\t\t\t\t\tconst startMy =\n\t\t\t\t\t\ttouch.startMidY -\n\t\t\t\t\t\trect.top -\n\t\t\t\t\t\tlatestContainerSize.height / 2;\n\t\t\t\t\tconst panDx =\n\t\t\t\t\t\tvisSize.width > 0\n\t\t\t\t\t\t\t? ( mx - startMx ) / visSize.width\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tconst panDy =\n\t\t\t\t\t\tvisSize.height > 0\n\t\t\t\t\t\t\t? ( my - startMy ) / visSize.height\n\t\t\t\t\t\t\t: 0;\n\n\t\t\t\t\t// Focal-point zoom correction. Keep this based on the\n\t\t\t\t\t// pinch-start state; using the current reducer state here\n\t\t\t\t\t// compounds prior touchmove frames and makes a fixed pinch\n\t\t\t\t\t// center drift after the image is already zoomed or panned.\n\t\t\t\t\tconst zoomRatio =\n\t\t\t\t\t\ttouch.startZoom !== 0\n\t\t\t\t\t\t\t? 1 - newZoom / touch.startZoom\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tconst startFocalNormX = startMx / visSize.width;\n\t\t\t\t\tconst startFocalNormY = startMy / visSize.height;\n\n\t\t\t\t\t// Combined: midpoint drift + zoom around the pinch-start\n\t\t\t\t\t// midpoint, so moving both fingers together pans while\n\t\t\t\t\t// symmetric pinches keep the start center stationary.\n\t\t\t\t\tconst newCropX =\n\t\t\t\t\t\ttouch.startPanX +\n\t\t\t\t\t\tpanDx +\n\t\t\t\t\t\t( startFocalNormX - touch.startPanX ) * zoomRatio;\n\t\t\t\t\tconst newCropY =\n\t\t\t\t\t\ttouch.startPanY +\n\t\t\t\t\t\tpanDy +\n\t\t\t\t\t\t( startFocalNormY - touch.startPanY ) * zoomRatio;\n\n\t\t\t\t\tconst { pan: clampedCrop } = restrictPanZoom(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\tzoom: newZoom,\n\t\t\t\t\t\t\tpan: { x: newCropX, y: newCropY },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\t\t\ts.cropRect\n\t\t\t\t\t);\n\t\t\t\t\tthis.options.actions.setZoomAtPoint( newZoom, clampedCrop );\n\t\t\t\t} else if ( newZoom !== s.zoom ) {\n\t\t\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t\t\t}\n\t\t\t} else if ( moveEvent.touches.length === 1 && ! touch.didPinch ) {\n\t\t\t\t// One finger and no pinch ever detected → pan.\n\t\t\t\t// If fingers went 2→1 (didPinch is true), we do NOT\n\t\t\t\t// switch to pan — avoids accidental pan after releasing\n\t\t\t\t// one finger from a pinch.\n\t\t\t\tif ( ! touch.moved ) {\n\t\t\t\t\ttouch.moved = true;\n\t\t\t\t\tthis.setStatus( { isDragging: true } );\n\t\t\t\t}\n\t\t\t\tconst panImageSize = this.options.getImageSize();\n\t\t\t\tconst panContainerSize = this.options.getContainerSize();\n\t\t\t\tconst panSize = panImageSize ?? panContainerSize;\n\t\t\t\tconst deltaX =\n\t\t\t\t\tpanSize.width > 0\n\t\t\t\t\t\t? ( moveEvent.touches[ 0 ].clientX -\n\t\t\t\t\t\t\t\ttouch.lastTouchX ) /\n\t\t\t\t\t\t\tpanSize.width\n\t\t\t\t\t\t: 0;\n\t\t\t\tconst deltaY =\n\t\t\t\t\tpanSize.height > 0\n\t\t\t\t\t\t? ( moveEvent.touches[ 0 ].clientY -\n\t\t\t\t\t\t\t\ttouch.lastTouchY ) /\n\t\t\t\t\t\t\tpanSize.height\n\t\t\t\t\t\t: 0;\n\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...s,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: touch.startPanX + deltaX,\n\t\t\t\t\t\t\ty: touch.startPanY + deltaY,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\t\ts.cropRect\n\t\t\t\t);\n\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t}\n\t\t} );\n\t};\n\n\t// Handle double-tap-to-toggle-zoom. On a second tap within the configured\n\t// time/distance threshold, toggles zoom between `minZoom` and\n\t// `doubleTapZoom` around the tap point and dispatches. Returns `true` if\n\t// the tap was handled as a double-tap (caller should early-return),\n\t// `false` otherwise (caller proceeds with normal single-tap handling).\n\t// Either way, records the tap for next time.\n\tprivate tryDoubleTap(\n\t\te: TouchEvent,\n\t\ttapX: number,\n\t\ttapY: number,\n\t\tcontainerRect: DOMRect\n\t): boolean {\n\t\tconst now = Date.now();\n\t\tconst lastTap = this.lastTap;\n\t\tif ( ! lastTap ) {\n\t\t\tthis.lastTap = { time: now, x: tapX, y: tapY };\n\t\t\treturn false;\n\t\t}\n\t\tconst timeDelta = now - lastTap.time;\n\t\tconst distDelta = Math.sqrt(\n\t\t\t( tapX - lastTap.x ) ** 2 + ( tapY - lastTap.y ) ** 2\n\t\t);\n\t\tconst isDoubleTap =\n\t\t\ttimeDelta < DOUBLE_TAP_TIME && distDelta < DOUBLE_TAP_DISTANCE;\n\t\tif ( ! isDoubleTap ) {\n\t\t\tthis.lastTap = { time: now, x: tapX, y: tapY };\n\t\t\treturn false;\n\t\t}\n\n\t\t// It's a double-tap — suppress browser zoom.\n\t\te.preventDefault();\n\t\tthis.lastTap = null;\n\n\t\tconst currentState = this.options.getState();\n\t\tconst containerSize = this.options.getContainerSize();\n\t\tconst imgSize = this.options.getImageSize();\n\n\t\t// Toggle: if past halfway to doubleTapZoom, go back to 1x.\n\t\tconst targetZoom =\n\t\t\tcurrentState.zoom > ( this.minZoom + this.doubleTapZoom ) / 2\n\t\t\t\t? this.minZoom\n\t\t\t\t: this.doubleTapZoom;\n\t\tconst visSize = imgSize ?? containerSize;\n\n\t\t// Enable zoom animation before dispatching.\n\t\tthis.setStatus( { isZooming: true } );\n\t\tclearTimeout( this.zoomTimer );\n\t\tthis.zoomTimer = setTimeout( () => {\n\t\t\tthis.setStatus( { isZooming: false } );\n\t\t}, ZOOM_ANIMATION_DURATION );\n\n\t\t// Double-tap bypasses the normal handleTouchStart gesture path so\n\t\t// onGestureStart/End are never called — fire them here so undo\n\t\t// receives a proper boundary around this discrete zoom action.\n\t\tthis.options.onGestureStart?.();\n\n\t\tif ( visSize.width > 0 && visSize.height > 0 ) {\n\t\t\tconst fx = tapX - containerRect.left - containerSize.width / 2;\n\t\t\tconst fy = tapY - containerRect.top - containerSize.height / 2;\n\n\t\t\tconst zoomRatio = 1 - targetZoom / currentState.zoom;\n\t\t\tconst focalNormX = fx / visSize.width;\n\t\t\tconst focalNormY = fy / visSize.height;\n\t\t\tconst newCropX =\n\t\t\t\tcurrentState.pan.x +\n\t\t\t\t( focalNormX - currentState.pan.x ) * zoomRatio;\n\t\t\tconst newCropY =\n\t\t\t\tcurrentState.pan.y +\n\t\t\t\t( focalNormY - currentState.pan.y ) * zoomRatio;\n\n\t\t\tconst { pan: clampedCrop } = restrictPanZoom(\n\t\t\t\t{\n\t\t\t\t\t...currentState,\n\t\t\t\t\tzoom: targetZoom,\n\t\t\t\t\tpan: { x: newCropX, y: newCropY },\n\t\t\t\t},\n\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\tcurrentState.cropRect\n\t\t\t);\n\t\t\tthis.options.actions.setZoomAtPoint( targetZoom, clampedCrop );\n\t\t} else {\n\t\t\tthis.options.actions.setZoom( targetZoom );\n\t\t}\n\n\t\tthis.options.onGestureEnd?.();\n\t\treturn true;\n\t}\n\n\t/**\n\t * Handle a keydown event on the container element.\n\t *\n\t * Supports arrow keys for panning, +/- for zoom, and r/R for rotation.\n\t *\n\t * @param e The native KeyboardEvent.\n\t */\n\thandleKeyDown( e: KeyboardEvent ): void {\n\t\tconst currentState = this.options.getState();\n\n\t\tswitch ( e.key ) {\n\t\t\tcase 'ArrowUp': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst keyboardStep = this.getKeyboardStep( e );\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x,\n\t\t\t\t\t\t\ty: currentState.pan.y + keyboardStep,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowDown': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst keyboardStep = this.getKeyboardStep( e );\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x,\n\t\t\t\t\t\t\ty: currentState.pan.y - keyboardStep,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowLeft': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst keyboardStep = this.getKeyboardStep( e );\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x + keyboardStep,\n\t\t\t\t\t\t\ty: currentState.pan.y,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowRight': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst keyboardStep = this.getKeyboardStep( e );\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x - keyboardStep,\n\t\t\t\t\t\t\ty: currentState.pan.y,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase '+':\n\t\t\tcase '=': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst newZoom = Math.min(\n\t\t\t\t\tthis.maxZoom,\n\t\t\t\t\tMath.max( this.minZoom, currentState.zoom + 0.5 )\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase '-':\n\t\t\tcase '_': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst newZoom = Math.min(\n\t\t\t\t\tthis.maxZoom,\n\t\t\t\t\tMath.max( this.minZoom, currentState.zoom - 0.5 )\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'r':\n\t\t\tcase 'R': {\n\t\t\t\tif ( e.metaKey || e.ctrlKey || e.altKey ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.options.actions.snapRotate90( e.shiftKey ? -1 : 1 );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'h':\n\t\t\tcase 'H': {\n\t\t\t\tif ( e.metaKey || e.ctrlKey || e.altKey || e.shiftKey ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.options.actions.toggleFlip?.( 'horizontal' );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'v':\n\t\t\tcase 'V': {\n\t\t\t\tif ( e.metaKey || e.ctrlKey || e.altKey || e.shiftKey ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.options.actions.toggleFlip?.( 'vertical' );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clean up all timers, animation frames, and active touch listeners.\n\t *\n\t * Must be called when the controller is no longer needed (e.g., on\n\t * component unmount or element removal).\n\t */\n\tdestroy(): void {\n\t\tcancelAnimationFrame( this.rafId );\n\t\tclearTimeout( this.zoomTimer );\n\t\tclearTimeout( this.wheelGestureTimer );\n\t\tthis.touchCleanup?.();\n\t\tthis.touchCleanup = null;\n\t\tthis.pointerCleanup?.();\n\t\tthis.pointerCleanup = null;\n\t\tthis.drag = null;\n\t\tthis.touch = null;\n\t\tthis.lastTap = null;\n\t\t// Reset the gesture bookkeeping too. The timers above are cancelled\n\t\t// rather than run, so these flags would otherwise stay set: a stale\n\t\t// `wheelGestureActive` suppresses the next wheel gesture's start,\n\t\t// and `setStatus` dedupes against `isDragging` / `isZooming`, so a\n\t\t// stale value swallows the next real change.\n\t\tthis.wheelGestureActive = false;\n\t\tthis.isDragging = false;\n\t\tthis.isZooming = false;\n\t}\n}\n"],"mappings":";;;;;;;;;AAWA,MAAM,kBAAkB;;AAExB,MAAM,sBAAsB;;AAE5B,MAAM,0BAA0B;;;;;;;AAQhC,SAAS,sBAAuB,OAG9B;CACD,OAAO,MAAM,QACV;EAAE,OAAO,MAAM,MAAM;EAAc,QAAQ,MAAM,MAAM;CAAc,IACrE;EAAE,OAAO;EAAG,QAAQ;CAAE;AAC1B;;;;;;;;AASA,SAAS,iBAAkB,IAAW,IAAoB;CACzD,MAAM,KAAK,GAAG,UAAU,GAAG;CAC3B,MAAM,KAAK,GAAG,UAAU,GAAG;CAC3B,OAAO,KAAK,KAAM,KAAK,KAAK,KAAK,EAAG;AACrC;;;;;;;;;;;;;;;;;;;AAuFA,IAAa,wBAAb,MAAmC;CAClC;;CAGA,aAAqB;CACrB,YAAoB;;CAGpB,OAKW;;CAGX,QAoBW;;CAGX,eAA8C;;;;;;;CAQ9C,iBAAgD;;CAGhD,UAIW;;CAGX;;CAGA;;CAGA,qBAA6B;;CAG7B,QAAgB;CAEhB,YAAa,SAAwC;EACpD,KAAK,UAAU;CAChB;;CAGA,IAAY,UAAkB;EAC7B,OAAO,KAAK,QAAQ,WAAWA,eAAAA;CAChC;;CAGA,IAAY,UAAkB;EAC7B,OAAO,KAAK,QAAQ,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perties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- // packages/media-editor/src/image-editor/core/math/rotation.ts
7
- /**
8
- * Normalizes a rotation value to the range [0, 360).
9
- *
10
- * Negative rotations are converted to their positive clockwise equivalent.
11
- * For example, -90 becomes 270, -45 becomes 315, and 450 becomes 90.
12
- *
13
- * @param degrees The rotation value in degrees.
14
- * @return The normalized rotation in the range [0, 360).
15
- */
16
- function normalizeRotation(degrees) {
17
- if (degrees >= 0) return degrees % 360;
18
- return (360 + degrees % 360) % 360;
19
- }
20
- /**
21
- * Converts an angle from degrees to radians.
22
- *
23
- * @param degrees The angle in degrees.
24
- * @return The angle in radians.
25
- */
26
- function degreesToRadians(degrees) {
27
- return degrees * Math.PI / 180;
28
- }
29
- exports.degreesToRadians = degreesToRadians;
30
- exports.normalizeRotation = normalizeRotation;
31
-
32
- //# sourceMappingURL=rotation.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rotation.cjs","names":[],"sources":["../../../../src/image-editor/core/math/rotation.ts"],"sourcesContent":["/**\n * Normalizes a rotation value to the range [0, 360).\n *\n * Negative rotations are converted to their positive clockwise equivalent.\n * For example, -90 becomes 270, -45 becomes 315, and 450 becomes 90.\n *\n * @param degrees The rotation value in degrees.\n * @return The normalized rotation in the range [0, 360).\n */\nexport function normalizeRotation( degrees: number ): number {\n\tif ( degrees >= 0 ) {\n\t\treturn degrees % 360;\n\t}\n\t// For negative rotations, convert to positive clockwise equivalent.\n\treturn ( 360 + ( degrees % 360 ) ) % 360;\n}\n\n/**\n * Converts an angle from degrees to radians.\n *\n * @param degrees The angle in degrees.\n * @return The angle in radians.\n */\nexport function degreesToRadians( degrees: number ): number {\n\treturn ( degrees * Math.PI ) / 180;\n}\n"],"mappings":";;;;;;;;;;;;;;;AASA,SAAgB,kBAAmB,SAA0B;CAC5D,IAAK,WAAW,GACf,OAAO,UAAU;CAGlB,QAAS,MAAQ,UAAU,OAAU;AACtC;;;;;;;AAQA,SAAgB,iBAAkB,SAA0B;CAC3D,OAAS,UAAU,KAAK,KAAO;AAChC"}
@@ -1,136 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- // packages/media-editor/src/image-editor/core/math/sanitize.ts
7
- /**
8
- * Magnitude beyond which any cropper-math input is treated as corrupt.
9
- * Picks a value well above any realistic image/rotation/zoom/pan but far
10
- * below `Number.MAX_VALUE`, so multiplications inside trig and matrix code
11
- * can't overflow to `Infinity`.
12
- */
13
- const MAX_SAFE_MAGNITUDE = 1e6;
14
- /**
15
- * Returns `value` if it's finite and within `[-MAX_SAFE_MAGNITUDE,
16
- * MAX_SAFE_MAGNITUDE]`, otherwise `fallback`. Stricter than `Number.isFinite`
17
- * because extreme finite magnitudes (e.g. `Number.MAX_VALUE`) overflow
18
- * downstream trig/matrix math even though the spec reports them as finite.
19
- *
20
- * Note: sub-normal denormals (e.g. `Number.MIN_VALUE`) are accepted by this
21
- * function — they don't overflow on their own. Protection against divisions
22
- * by sub-normal values lives in `sanitizeCropperState`'s zoom guard.
23
- *
24
- * @param value The candidate value.
25
- * @param fallback The replacement to return when `value` is unsafe.
26
- * @return Either `value` or `fallback`.
27
- */
28
- function safeBoundedNumber(value, fallback) {
29
- if (!Number.isFinite(value)) return fallback;
30
- if (Math.abs(value) > MAX_SAFE_MAGNITUDE) return fallback;
31
- return value;
32
- }
33
- /**
34
- * Returns `true` when `value` is finite and within `[-MAX_SAFE_MAGNITUDE,
35
- * MAX_SAFE_MAGNITUDE]`. The predicate companion to {@link safeBoundedNumber}
36
- * for callers that need to short-circuit rather than substitute a fallback.
37
- *
38
- * @param value The candidate value.
39
- * @return Whether `value` is safe to use in math.
40
- */
41
- function isSafeNumber(value) {
42
- return Number.isFinite(value) && Math.abs(value) <= MAX_SAFE_MAGNITUDE;
43
- }
44
- /**
45
- * Returns `true` when both dimensions are finite and within the safe
46
- * range `[Number.EPSILON, MAX_SAFE_MAGNITUDE]`. The lower bound matters
47
- * because sub-normal dimensions (e.g. `Number.MIN_VALUE`) pass `> 0` but
48
- * make `container / dim` overflow to `Infinity` downstream in
49
- * `getImageFit` / `createCamera`. Use this to short-circuit math that
50
- * would otherwise produce non-finite output.
51
- *
52
- * @param size The size to check.
53
- * @return Whether `size` is safe to use in math.
54
- */
55
- function isValidSize(size) {
56
- return Number.isFinite(size.width) && Number.isFinite(size.height) && size.width >= Number.EPSILON && size.height >= Number.EPSILON && size.width <= MAX_SAFE_MAGNITUDE && size.height <= MAX_SAFE_MAGNITUDE;
57
- }
58
- /**
59
- * Returns a copy of `rect` with every numeric field replaced by a safe
60
- * value via {@link safeBoundedNumber}. Returns the same reference when no
61
- * field needed substitution so callers can keep their reference-equality
62
- * short-circuits intact for clean inputs.
63
- *
64
- * @param rect The rect to sanitize.
65
- * @return A rect with all numeric fields finite.
66
- */
67
- function sanitizeRect(rect) {
68
- const x = safeBoundedNumber(rect.x, 0);
69
- const y = safeBoundedNumber(rect.y, 0);
70
- const width = safeBoundedNumber(rect.width, 0);
71
- const height = safeBoundedNumber(rect.height, 0);
72
- if (x === rect.x && y === rect.y && width === rect.width && height === rect.height) return rect;
73
- return {
74
- x,
75
- y,
76
- width,
77
- height
78
- };
79
- }
80
- /**
81
- * Returns a copy of `state` with the cropper-math numeric fields replaced
82
- * by safe defaults. Covers `pan`, `zoom`, `rotation`, the matching base
83
- * pose, and `cropRect`. The `state.image` numeric fields (naturalWidth /
84
- * naturalHeight) are intentionally NOT sanitized — image dimensions reach
85
- * the math layer as a separate `imageSize` argument, and cloning the
86
- * image object here would break the reducer's reference-equality
87
- * short-circuit.
88
- *
89
- * Returns the same `state` reference when no field needed substitution
90
- * so callers in hot paths (every pointermove via `restrictPanZoom`) can
91
- * keep their reference-equality optimizations. Sub-object references
92
- * (`pan`, `basePan`, `cropRect`) are also preserved when their fields
93
- * are individually clean.
94
- *
95
- * @param state The cropper state to sanitize.
96
- * @return A cropper state with the math-relevant numeric fields finite.
97
- */
98
- function sanitizeCropperState(state) {
99
- const panX = safeBoundedNumber(state.pan.x, 0);
100
- const panY = safeBoundedNumber(state.pan.y, 0);
101
- const basePanX = safeBoundedNumber(state.basePan.x, 0);
102
- const basePanY = safeBoundedNumber(state.basePan.y, 0);
103
- const rotation = safeBoundedNumber(state.rotation, 0);
104
- const baseRotation = safeBoundedNumber(state.baseRotation, 0);
105
- const rawZoom = safeBoundedNumber(state.zoom, 1);
106
- const zoom = rawZoom >= Number.EPSILON ? rawZoom : 1;
107
- const rawBaseZoom = safeBoundedNumber(state.baseZoom, 1);
108
- const baseZoom = rawBaseZoom >= Number.EPSILON ? rawBaseZoom : 1;
109
- const cropRect = sanitizeRect(state.cropRect);
110
- const panUnchanged = panX === state.pan.x && panY === state.pan.y;
111
- const basePanUnchanged = basePanX === state.basePan.x && basePanY === state.basePan.y;
112
- if (panUnchanged && basePanUnchanged && zoom === state.zoom && baseZoom === state.baseZoom && rotation === state.rotation && baseRotation === state.baseRotation && cropRect === state.cropRect) return state;
113
- return {
114
- ...state,
115
- pan: panUnchanged ? state.pan : {
116
- x: panX,
117
- y: panY
118
- },
119
- zoom,
120
- rotation,
121
- basePan: basePanUnchanged ? state.basePan : {
122
- x: basePanX,
123
- y: basePanY
124
- },
125
- baseZoom,
126
- baseRotation,
127
- cropRect
128
- };
129
- }
130
- exports.isSafeNumber = isSafeNumber;
131
- exports.isValidSize = isValidSize;
132
- exports.safeBoundedNumber = safeBoundedNumber;
133
- exports.sanitizeCropperState = sanitizeCropperState;
134
- exports.sanitizeRect = sanitizeRect;
135
-
136
- //# sourceMappingURL=sanitize.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitize.cjs","names":[],"sources":["../../../../src/image-editor/core/math/sanitize.ts"],"sourcesContent":["import type { CropperState, NormalizedRect, Size } from '../types';\n\n/**\n * Magnitude beyond which any cropper-math input is treated as corrupt.\n * Picks a value well above any realistic image/rotation/zoom/pan but far\n * below `Number.MAX_VALUE`, so multiplications inside trig and matrix code\n * can't overflow to `Infinity`.\n */\nconst MAX_SAFE_MAGNITUDE = 1e6;\n\n/**\n * Returns `value` if it's finite and within `[-MAX_SAFE_MAGNITUDE,\n * MAX_SAFE_MAGNITUDE]`, otherwise `fallback`. Stricter than `Number.isFinite`\n * because extreme finite magnitudes (e.g. `Number.MAX_VALUE`) overflow\n * downstream trig/matrix math even though the spec reports them as finite.\n *\n * Note: sub-normal denormals (e.g. `Number.MIN_VALUE`) are accepted by this\n * function — they don't overflow on their own. Protection against divisions\n * by sub-normal values lives in `sanitizeCropperState`'s zoom guard.\n *\n * @param value The candidate value.\n * @param fallback The replacement to return when `value` is unsafe.\n * @return Either `value` or `fallback`.\n */\nexport function safeBoundedNumber( value: number, fallback: number ): number {\n\tif ( ! Number.isFinite( value ) ) {\n\t\treturn fallback;\n\t}\n\tif ( Math.abs( value ) > MAX_SAFE_MAGNITUDE ) {\n\t\treturn fallback;\n\t}\n\treturn value;\n}\n\n/**\n * Returns `true` when `value` is finite and within `[-MAX_SAFE_MAGNITUDE,\n * MAX_SAFE_MAGNITUDE]`. The predicate companion to {@link safeBoundedNumber}\n * for callers that need to short-circuit rather than substitute a fallback.\n *\n * @param value The candidate value.\n * @return Whether `value` is safe to use in math.\n */\nexport function isSafeNumber( value: number ): boolean {\n\treturn Number.isFinite( value ) && Math.abs( value ) <= MAX_SAFE_MAGNITUDE;\n}\n\n/**\n * Returns `true` when both dimensions are finite and within the safe\n * range `[Number.EPSILON, MAX_SAFE_MAGNITUDE]`. The lower bound matters\n * because sub-normal dimensions (e.g. `Number.MIN_VALUE`) pass `> 0` but\n * make `container / dim` overflow to `Infinity` downstream in\n * `getImageFit` / `createCamera`. Use this to short-circuit math that\n * would otherwise produce non-finite output.\n *\n * @param size The size to check.\n * @return Whether `size` is safe to use in math.\n */\nexport function isValidSize( size: Size ): boolean {\n\treturn (\n\t\tNumber.isFinite( size.width ) &&\n\t\tNumber.isFinite( size.height ) &&\n\t\tsize.width >= Number.EPSILON &&\n\t\tsize.height >= Number.EPSILON &&\n\t\tsize.width <= MAX_SAFE_MAGNITUDE &&\n\t\tsize.height <= MAX_SAFE_MAGNITUDE\n\t);\n}\n\n/**\n * Returns a copy of `rect` with every numeric field replaced by a safe\n * value via {@link safeBoundedNumber}. Returns the same reference when no\n * field needed substitution so callers can keep their reference-equality\n * short-circuits intact for clean inputs.\n *\n * @param rect The rect to sanitize.\n * @return A rect with all numeric fields finite.\n */\nexport function sanitizeRect( rect: NormalizedRect ): NormalizedRect {\n\tconst x = safeBoundedNumber( rect.x, 0 );\n\tconst y = safeBoundedNumber( rect.y, 0 );\n\tconst width = safeBoundedNumber( rect.width, 0 );\n\tconst height = safeBoundedNumber( rect.height, 0 );\n\tif (\n\t\tx === rect.x &&\n\t\ty === rect.y &&\n\t\twidth === rect.width &&\n\t\theight === rect.height\n\t) {\n\t\treturn rect;\n\t}\n\treturn { x, y, width, height };\n}\n\n/**\n * Returns a copy of `state` with the cropper-math numeric fields replaced\n * by safe defaults. Covers `pan`, `zoom`, `rotation`, the matching base\n * pose, and `cropRect`. The `state.image` numeric fields (naturalWidth /\n * naturalHeight) are intentionally NOT sanitized — image dimensions reach\n * the math layer as a separate `imageSize` argument, and cloning the\n * image object here would break the reducer's reference-equality\n * short-circuit.\n *\n * Returns the same `state` reference when no field needed substitution\n * so callers in hot paths (every pointermove via `restrictPanZoom`) can\n * keep their reference-equality optimizations. Sub-object references\n * (`pan`, `basePan`, `cropRect`) are also preserved when their fields\n * are individually clean.\n *\n * @param state The cropper state to sanitize.\n * @return A cropper state with the math-relevant numeric fields finite.\n */\nexport function sanitizeCropperState( state: CropperState ): CropperState {\n\tconst panX = safeBoundedNumber( state.pan.x, 0 );\n\tconst panY = safeBoundedNumber( state.pan.y, 0 );\n\tconst basePanX = safeBoundedNumber( state.basePan.x, 0 );\n\tconst basePanY = safeBoundedNumber( state.basePan.y, 0 );\n\tconst rotation = safeBoundedNumber( state.rotation, 0 );\n\tconst baseRotation = safeBoundedNumber( state.baseRotation, 0 );\n\tconst rawZoom = safeBoundedNumber( state.zoom, 1 );\n\t// Zoom must be strictly positive AND large enough that 1/zoom doesn't\n\t// overflow. Sub-normals (e.g. Number.MIN_VALUE) pass `> 0` but make\n\t// division explode, so guard against them with Number.EPSILON.\n\tconst zoom = rawZoom >= Number.EPSILON ? rawZoom : 1;\n\tconst rawBaseZoom = safeBoundedNumber( state.baseZoom, 1 );\n\tconst baseZoom = rawBaseZoom >= Number.EPSILON ? rawBaseZoom : 1;\n\tconst cropRect = sanitizeRect( state.cropRect );\n\n\tconst panUnchanged = panX === state.pan.x && panY === state.pan.y;\n\tconst basePanUnchanged =\n\t\tbasePanX === state.basePan.x && basePanY === state.basePan.y;\n\n\tif (\n\t\tpanUnchanged &&\n\t\tbasePanUnchanged &&\n\t\tzoom === state.zoom &&\n\t\tbaseZoom === state.baseZoom &&\n\t\trotation === state.rotation &&\n\t\tbaseRotation === state.baseRotation &&\n\t\tcropRect === state.cropRect\n\t) {\n\t\treturn state;\n\t}\n\treturn {\n\t\t...state,\n\t\tpan: panUnchanged ? state.pan : { x: panX, y: panY },\n\t\tzoom,\n\t\trotation,\n\t\tbasePan: basePanUnchanged\n\t\t\t? state.basePan\n\t\t\t: { x: basePanX, y: basePanY },\n\t\tbaseZoom,\n\t\tbaseRotation,\n\t\tcropRect,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;AAQA,MAAM,qBAAqB;;;;;;;;;;;;;;;AAgB3B,SAAgB,kBAAmB,OAAe,UAA2B;CAC5E,IAAK,CAAE,OAAO,SAAU,KAAM,GAC7B,OAAO;CAER,IAAK,KAAK,IAAK,KAAM,IAAI,oBACxB,OAAO;CAER,OAAO;AACR;;;;;;;;;AAUA,SAAgB,aAAc,OAAyB;CACtD,OAAO,OAAO,SAAU,KAAM,KAAK,KAAK,IAAK,KAAM,KAAK;AACzD;;;;;;;;;;;;AAaA,SAAgB,YAAa,MAAsB;CAClD,OACC,OAAO,SA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ACnB,aAAa,MAAM,YACnB,iBAAiB,MAAM,gBACvB,aAAa,MAAM,UAEnB,OAAO;CAER,OAAO;EACN,GAAG;EACH,KAAK,eAAe,MAAM,MAAM;GAAE,GAAG;GAAM,GAAG;EAAK;EACnD;EACA;EACA,SAAS,mBACN,MAAM,UACN;GAAE,GAAG;GAAU,GAAG;EAAS;EAC9B;EACA;EACA;CACD;AACD"}
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- let __constants_ts = require("./constants.cjs");
7
- let __containment_ts = require("./containment.cjs");
8
- // packages/media-editor/src/image-editor/core/setter-helpers.ts
9
- /**
10
- * Build the reducer action that produces a "cursorless" zoom — zoom
11
- * anchored at the current crop-rect center, with pan clamped to keep
12
- * the image covering the crop.
13
- *
14
- * The slider, the `+`/`-` keys, and the toolbar buttons have no
15
- * natural focal point (unlike wheel/pinch zoom), so they default to
16
- * the crop center. Returns `null` when the clamped zoom matches the
17
- * current zoom (no-op).
18
- *
19
- * Extracted so multiple hooks (the pure `useCropperController` and the
20
- * composite `useMediaEditorState`) can share the math without
21
- * duplicating it.
22
- *
23
- * @param state The current cropper state.
24
- * @param requestedZoom The zoom value the caller asked for.
25
- * @return A `SET_ZOOM_AT_POINT` action, or `null` if no change is required.
26
- */
27
- function buildFocalPointZoomAction(state, requestedZoom) {
28
- const clampedZoom = Math.min(__constants_ts.MAX_ZOOM, Math.max((0, __containment_ts.getMinZoom)(state), requestedZoom));
29
- if (clampedZoom === state.zoom) return null;
30
- const { cropRect } = state;
31
- const focalNormX = cropRect.x + cropRect.width / 2 - .5;
32
- const focalNormY = cropRect.y + cropRect.height / 2 - .5;
33
- const zoomRatio = 1 - clampedZoom / state.zoom;
34
- const newPanX = state.pan.x + (focalNormX - state.pan.x) * zoomRatio;
35
- const newPanY = state.pan.y + (focalNormY - state.pan.y) * zoomRatio;
36
- const imageSize = state.image ? {
37
- width: state.image.naturalWidth,
38
- height: state.image.naturalHeight
39
- } : {
40
- width: 1,
41
- height: 1
42
- };
43
- const { pan: clampedPan } = (0, __containment_ts.restrictPanZoom)({
44
- ...state,
45
- zoom: clampedZoom,
46
- pan: {
47
- x: newPanX,
48
- y: newPanY
49
- }
50
- }, imageSize, state.cropRect);
51
- return {
52
- type: "SET_ZOOM_AT_POINT",
53
- payload: {
54
- zoom: clampedZoom,
55
- pan: clampedPan
56
- }
57
- };
58
- }
59
- exports.buildFocalPointZoomAction = buildFocalPointZoomAction;
60
-
61
- //# sourceMappingURL=setter-helpers.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setter-helpers.cjs","names":["MAX_ZOOM","getMinZoom","restrictPanZoom"],"sources":["../../../src/image-editor/core/setter-helpers.ts"],"sourcesContent":["import type { CropperState, NormalizedPoint, CropperAction } from './types';\nimport { MAX_ZOOM } from './constants';\nimport { getMinZoom, restrictPanZoom } from './containment';\n\n/**\n * Build the reducer action that produces a \"cursorless\" zoom — zoom\n * anchored at the current crop-rect center, with pan clamped to keep\n * the image covering the crop.\n *\n * The slider, the `+`/`-` keys, and the toolbar buttons have no\n * natural focal point (unlike wheel/pinch zoom), so they default to\n * the crop center. Returns `null` when the clamped zoom matches the\n * current zoom (no-op).\n *\n * Extracted so multiple hooks (the pure `useCropperController` and the\n * composite `useMediaEditorState`) can share the math without\n * duplicating it.\n *\n * @param state The current cropper state.\n * @param requestedZoom The zoom value the caller asked for.\n * @return A `SET_ZOOM_AT_POINT` action, or `null` if no change is required.\n */\nexport function buildFocalPointZoomAction(\n\tstate: CropperState,\n\trequestedZoom: number\n): CropperAction | null {\n\tconst clampedZoom = Math.min(\n\t\tMAX_ZOOM,\n\t\tMath.max( getMinZoom( state ), requestedZoom )\n\t);\n\tif ( clampedZoom === state.zoom ) {\n\t\treturn null;\n\t}\n\t// Crop center expressed in the same coord system as `state.pan`:\n\t// container-center-relative, normalized by image rendered size.\n\t// `cropRect` is image-top-left-origin (0–1), so subtract 0.5\n\t// to recenter.\n\tconst { cropRect } = state;\n\tconst focalNormX = cropRect.x + cropRect.width / 2 - 0.5;\n\tconst focalNormY = cropRect.y + cropRect.height / 2 - 0.5;\n\tconst zoomRatio = 1 - clampedZoom / state.zoom;\n\tconst newPanX = state.pan.x + ( focalNormX - state.pan.x ) * zoomRatio;\n\tconst newPanY = state.pan.y + ( focalNormY - state.pan.y ) * zoomRatio;\n\tconst imageSize: { width: number; height: number } = state.image\n\t\t? {\n\t\t\t\twidth: state.image.naturalWidth,\n\t\t\t\theight: state.image.naturalHeight,\n\t\t\t}\n\t\t: { width: 1, height: 1 };\n\tconst { pan: clampedPan }: { pan: NormalizedPoint } = restrictPanZoom(\n\t\t{\n\t\t\t...state,\n\t\t\tzoom: clampedZoom,\n\t\t\tpan: { x: newPanX, y: newPanY },\n\t\t},\n\t\timageSize,\n\t\tstate.cropRect\n\t);\n\treturn {\n\t\ttype: 'SET_ZOOM_AT_POINT',\n\t\tpayload: { zoom: clampedZoom, pan: clampedPan },\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,0BACf,OACA,eACuB;CACvB,MAAM,cAAc,KAAK,IACxBA,eAAAA,UACA,KAAK,KAAA,GAAKC,iBAAAA,WAAAA,CAAY,KAAM,GAAG,aAAc,CAC9C;CACA,IAAK,gBAAgB,MAAM,MAC1B,OAAO;CAMR,MAAM,EAAE,aAAa;CACrB,MAAM,aAAa,SAAS,IAAI,SAAS,QAAQ,IAAI;CACrD,MAAM,aAAa,SAAS,IAAI,SAAS,SAAS,IAAI;CACtD,MAAM,YAAY,IAAI,cAAc,MAAM;CAC1C,MAAM,UAAU,MAAM,IAAI,KAAM,aAAa,MAAM,IAAI,KAAM;CAC7D,MAAM,UAAU,MAAM,IAAI,KAAM,aAAa,MAAM,IAAI,KAAM;CAC7D,MAAM,YAA+C,MAAM,QACxD;EACA,OAAO,MAAM,MAAM;EACnB,QAAQ,MAAM,MAAM;CACrB,IACC;EAAE,OAAO;EAAG,QAAQ;CAAE;CACzB,MAAM,EAAE,KAAK,gBAAA,GAAyCC,iBAAAA,gBAAAA,CACrD;EACC,GAAG;EACH,MAAM;EACN,KAAK;GAAE,GAAG;GAAS,GAAG;EAAQ;CAC/B,GACA,WACA,MAAM,QACP;CACA,OAAO;EACN,MAAM;EACN,SAAS;GAAE,MAAM;GAAa,KAAK;EAAW;CAC/C;AACD"}
@@ -1,236 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, {
3
- __esModule: { value: true },
4
- [Symbol.toStringTag]: { value: "Module" }
5
- });
6
- let gl_matrix = require("gl-matrix");
7
- let __camera_ts = require("./camera.cjs");
8
- let __math_sanitize_ts = require("./math/sanitize.cjs");
9
- let __math_rotation_ts = require("./math/rotation.cjs");
10
- // packages/media-editor/src/image-editor/core/source-region.ts
11
- /**
12
- * Get the selected image region in source-pixel coordinates.
13
- *
14
- * Converts the current crop state (normalized visual space) to the actual
15
- * region of the original image that's selected. This is the bridge between
16
- * the cropper's internal coordinate system and external tools (image
17
- * processing libraries, AI APIs, server-side processing) that work in
18
- * source-pixel coordinates.
19
- *
20
- * The returned rectangle accounts for pan, zoom, and the crop rect position,
21
- * but expresses the crop in the unrotated image's coordinate space. Rotation
22
- * and flip are included as separate fields since they represent transforms,
23
- * not a region.
24
- *
25
- * @param state The current cropper state.
26
- * @param imageSize The natural dimensions of the source image.
27
- * @return The selected region in source pixels plus rotation/flip metadata.
28
- */
29
- function getSourceRegion(state, imageSize) {
30
- const safeState = (0, __math_sanitize_ts.sanitizeCropperState)(state);
31
- if (!(0, __math_sanitize_ts.isValidSize)(imageSize)) return {
32
- x: 0,
33
- y: 0,
34
- width: 0,
35
- height: 0,
36
- rotation: safeState.rotation,
37
- flip: { ...safeState.flip },
38
- zoom: safeState.zoom
39
- };
40
- const syntheticContainer = {
41
- width: 1e3,
42
- height: 1e3
43
- };
44
- const camera = (0, __camera_ts.createCamera)(safeState, syntheticContainer, imageSize);
45
- const inv = gl_matrix.mat2d.create();
46
- gl_matrix.mat2d.invert(inv, camera);
47
- const baseCamera = (0, __camera_ts.createCamera)({
48
- ...safeState,
49
- pan: {
50
- x: 0,
51
- y: 0
52
- },
53
- zoom: 1
54
- }, syntheticContainer, imageSize);
55
- const visibleBounds = (0, __camera_ts.getVisibleBounds)(baseCamera);
56
- const cropRect = safeState.cropRect;
57
- const cropCenterScreenX = visibleBounds.left + (cropRect.x + cropRect.width / 2) * visibleBounds.width;
58
- const cropCenterScreenY = visibleBounds.top + (cropRect.y + cropRect.height / 2) * visibleBounds.height;
59
- const srcCenter = gl_matrix.vec2.create();
60
- gl_matrix.vec2.transformMat2d(srcCenter, [cropCenterScreenX, cropCenterScreenY], inv);
61
- const snapRotation = Math.round(safeState.rotation / 90) * 90;
62
- const { width: rotW, height: rotH } = (0, __camera_ts.getRotatedBBox)(imageSize.width, imageSize.height, snapRotation);
63
- const sourceW = cropRect.width * rotW / safeState.zoom;
64
- const sourceH = cropRect.height * rotH / safeState.zoom;
65
- return {
66
- x: srcCenter[0] * imageSize.width - sourceW / 2,
67
- y: srcCenter[1] * imageSize.height - sourceH / 2,
68
- width: sourceW,
69
- height: sourceH,
70
- rotation: safeState.rotation,
71
- flip: { ...safeState.flip },
72
- zoom: safeState.zoom
73
- };
74
- }
75
- /**
76
- * Convert a source-pixel region back to the cropper's normalized crop rect.
77
- *
78
- * The math intentionally mirrors `getSourceRegion`: map the requested source
79
- * center through the current camera, then express that screen point inside the
80
- * same base visible bounds used to position crop overlays.
81
- *
82
- * @param state The current cropper state.
83
- * @param imageSize The natural dimensions of the source image.
84
- * @param region The source-pixel region to represent as a crop rect.
85
- * @return The normalized crop rect, or null when inputs cannot be mapped.
86
- */
87
- function getCropRectFromSourceRegion(state, imageSize, region) {
88
- if (!(0, __math_sanitize_ts.isValidSize)(imageSize) || region.width <= 0 || region.height <= 0) return null;
89
- const safeState = (0, __math_sanitize_ts.sanitizeCropperState)(state);
90
- const syntheticContainer = {
91
- width: 1e3,
92
- height: 1e3
93
- };
94
- const baseCamera = (0, __camera_ts.createCamera)({
95
- ...safeState,
96
- pan: {
97
- x: 0,
98
- y: 0
99
- },
100
- zoom: 1
101
- }, syntheticContainer, imageSize);
102
- const visibleBounds = (0, __camera_ts.getVisibleBounds)(baseCamera);
103
- if (visibleBounds.width <= 0 || visibleBounds.height <= 0) return null;
104
- const sourceCenter = gl_matrix.vec2.fromValues((region.x + region.width / 2) / imageSize.width, (region.y + region.height / 2) / imageSize.height);
105
- const screenCenter = gl_matrix.vec2.create();
106
- const camera = (0, __camera_ts.createCamera)(safeState, syntheticContainer, imageSize);
107
- gl_matrix.vec2.transformMat2d(screenCenter, sourceCenter, camera);
108
- const snapRotation = Math.round(safeState.rotation / 90) * 90;
109
- const { width: rotW, height: rotH } = (0, __camera_ts.getRotatedBBox)(imageSize.width, imageSize.height, snapRotation);
110
- if (rotW <= 0 || rotH <= 0) return null;
111
- const width = region.width * safeState.zoom / rotW;
112
- const height = region.height * safeState.zoom / rotH;
113
- const centerX = (screenCenter[0] - visibleBounds.left) / visibleBounds.width;
114
- const centerY = (screenCenter[1] - visibleBounds.top) / visibleBounds.height;
115
- return {
116
- x: centerX - width / 2,
117
- y: centerY - height / 2,
118
- width,
119
- height
120
- };
121
- }
122
- const CARDINAL_ROTATION_EPSILON = 1e-6;
123
- /**
124
- * Check whether a rotation is effectively at a 90-degree stop.
125
- *
126
- * @param rotation The rotation angle in degrees.
127
- * @return Whether the rotation is close enough to a cardinal angle.
128
- */
129
- function isCardinalRotation(rotation) {
130
- const normalizedRotation = (0, __math_rotation_ts.normalizeRotation)(rotation);
131
- const nearestCardinal = Math.round(normalizedRotation / 90) * 90;
132
- return Math.abs(normalizedRotation - nearestCardinal) < CARDINAL_ROTATION_EPSILON;
133
- }
134
- /**
135
- * Snap a crop rect so the selected source-region edges land on whole pixels.
136
- *
137
- * This is a display-time affordance for visible pixel grids; it does not alter
138
- * pan/zoom/rotation. Callers decide when snapping is appropriate.
139
- *
140
- * @param state The current cropper state.
141
- * @param imageSize The natural dimensions of the source image.
142
- * @param cropRect The candidate crop rect from resize math.
143
- * @param handle The active resize handle. Only edges moved by the handle snap.
144
- * @return A crop rect whose selected source-region edges are whole pixels.
145
- */
146
- function snapCropRectToSourcePixels(state, imageSize, cropRect, handle) {
147
- const safeState = (0, __math_sanitize_ts.sanitizeCropperState)(state);
148
- if (!isCardinalRotation(safeState.rotation)) return cropRect;
149
- return snapCropRectEdgesToSourcePixels(safeState, imageSize, cropRect, {
150
- left: handle.includes("w"),
151
- top: handle.includes("n"),
152
- right: handle.includes("e"),
153
- bottom: handle.includes("s")
154
- });
155
- }
156
- /**
157
- * Snap all source-region edges for a crop rect to the nearest whole pixels.
158
- *
159
- * @param state The current cropper state.
160
- * @param imageSize The natural dimensions of the source image.
161
- * @param cropRect The crop rect to align to the source-pixel grid.
162
- * @return A crop rect whose source-region edges are whole pixels.
163
- */
164
- function snapCropRectToSourcePixelGrid(state, imageSize, cropRect) {
165
- return snapCropRectEdgesToSourcePixels(state, imageSize, cropRect, {
166
- left: true,
167
- top: true,
168
- right: true,
169
- bottom: true
170
- });
171
- }
172
- function snapCropRectEdgesToSourcePixels(state, imageSize, cropRect, edges) {
173
- if (!(0, __math_sanitize_ts.isValidSize)(imageSize)) return cropRect;
174
- const stateWithCrop = (0, __math_sanitize_ts.sanitizeCropperState)({
175
- ...state,
176
- cropRect
177
- });
178
- const region = getSourceRegion(stateWithCrop, imageSize);
179
- const shouldSnapX = edges.left || edges.right;
180
- const shouldSnapY = edges.top || edges.bottom;
181
- const left = edges.left ? Math.round(region.x) : region.x;
182
- const top = edges.top ? Math.round(region.y) : region.y;
183
- const right = edges.right ? Math.round(region.x + region.width) : region.x + region.width;
184
- const bottom = edges.bottom ? Math.round(region.y + region.height) : region.y + region.height;
185
- if (right <= left || bottom <= top) return cropRect;
186
- const snappedCropRect = getCropRectFromSourceRegion(stateWithCrop, imageSize, {
187
- ...region,
188
- x: left,
189
- y: top,
190
- width: right - left,
191
- height: bottom - top
192
- });
193
- if (!snappedCropRect) return cropRect;
194
- return {
195
- x: shouldSnapX ? snappedCropRect.x : cropRect.x,
196
- y: shouldSnapY ? snappedCropRect.y : cropRect.y,
197
- width: shouldSnapX ? snappedCropRect.width : cropRect.width,
198
- height: shouldSnapY ? snappedCropRect.height : cropRect.height
199
- };
200
- }
201
- /**
202
- * Get the selected image region as percentages of the source image dimensions.
203
- *
204
- * Returns `{ x, y, width, height }` where each value is a percentage (0–100)
205
- * of the source image's natural width or height. This format is compatible
206
- * with the WordPress REST API attachments `/edit` endpoint and CSS-based
207
- * crop workflows.
208
- *
209
- * Internally delegates to `getSourceRegion` and divides by the image
210
- * dimensions, so accuracy is identical.
211
- *
212
- * @param state The current cropper state.
213
- * @param imageSize The natural dimensions of the source image.
214
- * @return The crop region as percentages (0–100).
215
- */
216
- function getSourceRegionPercent(state, imageSize) {
217
- if (!(0, __math_sanitize_ts.isValidSize)(imageSize)) return {
218
- x: 0,
219
- y: 0,
220
- width: 0,
221
- height: 0
222
- };
223
- const region = getSourceRegion(state, imageSize);
224
- return {
225
- x: region.x / imageSize.width * 100,
226
- y: region.y / imageSize.height * 100,
227
- width: region.width / imageSize.width * 100,
228
- height: region.height / imageSize.height * 100
229
- };
230
- }
231
- exports.getSourceRegion = getSourceRegion;
232
- exports.getSourceRegionPercent = getSourceRegionPercent;
233
- exports.snapCropRectToSourcePixelGrid = snapCropRectToSourcePixelGrid;
234
- exports.snapCropRectToSourcePixels = snapCropRectToSourcePixels;
235
-
236
- //# sourceMappingURL=source-region.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"source-region.cjs","names":["sanitizeCropperState","isValidSize","createCamera","mat2d","getVisibleBounds","vec2","getRotatedBBox","normalizeRotation"],"sources":["../../../src/image-editor/core/source-region.ts"],"sourcesContent":["import { mat2d, vec2 } from 'gl-matrix';\nimport type {\n\tCropperState,\n\tHandlePosition,\n\tNormalizedRect,\n\tSize,\n} from './types';\nimport { createCamera, getRotatedBBox, getVisibleBounds } from './camera';\nimport { isValidSize, sanitizeCropperState } from './math/sanitize';\nimport { normalizeRotation } from './math/rotation';\n\n/**\n * The selected image region in source-pixel coordinates.\n */\nexport interface SourceRegion {\n\t/** X offset in source pixels. */\n\tx: number;\n\t/** Y offset in source pixels. */\n\ty: number;\n\t/** Width in source pixels. */\n\twidth: number;\n\t/** Height in source pixels. */\n\theight: number;\n\t/** Rotation in degrees (0-360). */\n\trotation: number;\n\t/** Flip state. */\n\tflip: { horizontal: boolean; vertical: boolean };\n\t/** Zoom factor applied. */\n\tzoom: number;\n}\n\n/**\n * Get the selected image region in source-pixel coordinates.\n *\n * Converts the current crop state (normalized visual space) to the actual\n * region of the original image that's selected. This is the bridge between\n * the cropper's internal coordinate system and external tools (image\n * processing libraries, AI APIs, server-side processing) that work in\n * source-pixel coordinates.\n *\n * The returned rectangle accounts for pan, zoom, and the crop rect position,\n * but expresses the crop in the unrotated image's coordinate space. Rotation\n * and flip are included as separate fields since they represent transforms,\n * not a region.\n *\n * @param state The current cropper state.\n * @param imageSize The natural dimensions of the source image.\n * @return The selected region in source pixels plus rotation/flip metadata.\n */\nexport function getSourceRegion(\n\tstate: CropperState,\n\timageSize: Size\n): SourceRegion {\n\t// Sanitize before the zero-size short-circuit so the early return\n\t// doesn't leak raw non-finite state.rotation or state.zoom out\n\t// through the metadata fields. (state.flip is boolean and isn't\n\t// at risk of NaN propagation.)\n\tconst safeState = sanitizeCropperState( state );\n\n\tif ( ! isValidSize( imageSize ) ) {\n\t\treturn {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\trotation: safeState.rotation,\n\t\t\tflip: { ...safeState.flip },\n\t\t\tzoom: safeState.zoom,\n\t\t};\n\t}\n\n\t// Use a synthetic 1:1 container so the camera maps normalized coords\n\t// to a known pixel space. The container size cancels out.\n\tconst syntheticContainer: Size = { width: 1000, height: 1000 };\n\tconst camera = createCamera( safeState, syntheticContainer, imageSize );\n\n\t// Inverse camera maps screen pixels back to normalized [0,1] world coords.\n\tconst inv = mat2d.create();\n\tmat2d.invert( inv, camera );\n\n\t// The crop rect center in screen space. We need the base camera\n\t// (zoom=1, no pan) to locate the visual bounds, then place the\n\t// crop rect within them.\n\tconst baseCamera = createCamera(\n\t\t{ ...safeState, pan: { x: 0, y: 0 }, zoom: 1 },\n\t\tsyntheticContainer,\n\t\timageSize\n\t);\n\tconst visibleBounds = getVisibleBounds( baseCamera );\n\n\tconst cropRect = safeState.cropRect;\n\tconst cropCenterScreenX =\n\t\tvisibleBounds.left +\n\t\t( cropRect.x + cropRect.width / 2 ) * visibleBounds.width;\n\tconst cropCenterScreenY =\n\t\tvisibleBounds.top +\n\t\t( cropRect.y + cropRect.height / 2 ) * visibleBounds.height;\n\n\t// Transform crop center through inverse camera to get source position.\n\tconst srcCenter = vec2.create();\n\tvec2.transformMat2d(\n\t\tsrcCenter,\n\t\t[ cropCenterScreenX, cropCenterScreenY ],\n\t\tinv\n\t);\n\n\t// Crop rect size in the snap-rotation visual space, divided by zoom\n\t// for source-pixel dimensions. Matches the stencil's reference frame.\n\tconst snapRotation = Math.round( safeState.rotation / 90 ) * 90;\n\tconst { width: rotW, height: rotH } = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tsnapRotation\n\t);\n\tconst sourceW = ( cropRect.width * rotW ) / safeState.zoom;\n\tconst sourceH = ( cropRect.height * rotH ) / safeState.zoom;\n\n\treturn {\n\t\tx: srcCenter[ 0 ] * imageSize.width - sourceW / 2,\n\t\ty: srcCenter[ 1 ] * imageSize.height - sourceH / 2,\n\t\twidth: sourceW,\n\t\theight: sourceH,\n\t\trotation: safeState.rotation,\n\t\tflip: { ...safeState.flip },\n\t\tzoom: safeState.zoom,\n\t};\n}\n\n/**\n * Convert a source-pixel region back to the cropper's normalized crop rect.\n *\n * The math intentionally mirrors `getSourceRegion`: map the requested source\n * center through the current camera, then express that screen point inside the\n * same base visible bounds used to position crop overlays.\n *\n * @param state The current cropper state.\n * @param imageSize The natural dimensions of the source image.\n * @param region The source-pixel region to represent as a crop rect.\n * @return The normalized crop rect, or null when inputs cannot be mapped.\n */\nfunction getCropRectFromSourceRegion(\n\tstate: CropperState,\n\timageSize: Size,\n\tregion: SourceRegion\n): NormalizedRect | null {\n\tif (\n\t\t! isValidSize( imageSize ) ||\n\t\tregion.width <= 0 ||\n\t\tregion.height <= 0\n\t) {\n\t\treturn null;\n\t}\n\n\tconst safeState = sanitizeCropperState( state );\n\tconst syntheticContainer: Size = { width: 1000, height: 1000 };\n\tconst baseCamera = createCamera(\n\t\t{ ...safeState, pan: { x: 0, y: 0 }, zoom: 1 },\n\t\tsyntheticContainer,\n\t\timageSize\n\t);\n\tconst visibleBounds = getVisibleBounds( baseCamera );\n\tif ( visibleBounds.width <= 0 || visibleBounds.height <= 0 ) {\n\t\treturn null;\n\t}\n\n\tconst sourceCenter = vec2.fromValues(\n\t\t( region.x + region.width / 2 ) / imageSize.width,\n\t\t( region.y + region.height / 2 ) / imageSize.height\n\t);\n\tconst screenCenter = vec2.create();\n\tconst camera = createCamera( safeState, syntheticContainer, imageSize );\n\tvec2.transformMat2d( screenCenter, sourceCenter, camera );\n\n\tconst snapRotation = Math.round( safeState.rotation / 90 ) * 90;\n\tconst { width: rotW, height: rotH } = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tsnapRotation\n\t);\n\tif ( rotW <= 0 || rotH <= 0 ) {\n\t\treturn null;\n\t}\n\n\tconst width = ( region.width * safeState.zoom ) / rotW;\n\tconst height = ( region.height * safeState.zoom ) / rotH;\n\tconst centerX =\n\t\t( screenCenter[ 0 ] - visibleBounds.left ) / visibleBounds.width;\n\tconst centerY =\n\t\t( screenCenter[ 1 ] - visibleBounds.top ) / visibleBounds.height;\n\n\treturn {\n\t\tx: centerX - width / 2,\n\t\ty: centerY - height / 2,\n\t\twidth,\n\t\theight,\n\t};\n}\n\ninterface SourcePixelSnapEdges {\n\tleft: boolean;\n\ttop: boolean;\n\tright: boolean;\n\tbottom: boolean;\n}\n\nconst CARDINAL_ROTATION_EPSILON = 1e-6;\n\n/**\n * Check whether a rotation is effectively at a 90-degree stop.\n *\n * @param rotation The rotation angle in degrees.\n * @return Whether the rotation is close enough to a cardinal angle.\n */\nfunction isCardinalRotation( rotation: number ): boolean {\n\tconst normalizedRotation = normalizeRotation( rotation );\n\tconst nearestCardinal = Math.round( normalizedRotation / 90 ) * 90;\n\treturn (\n\t\tMath.abs( normalizedRotation - nearestCardinal ) <\n\t\tCARDINAL_ROTATION_EPSILON\n\t);\n}\n\n/**\n * Snap a crop rect so the selected source-region edges land on whole pixels.\n *\n * This is a display-time affordance for visible pixel grids; it does not alter\n * pan/zoom/rotation. Callers decide when snapping is appropriate.\n *\n * @param state The current cropper state.\n * @param imageSize The natural dimensions of the source image.\n * @param cropRect The candidate crop rect from resize math.\n * @param handle The active resize handle. Only edges moved by the handle snap.\n * @return A crop rect whose selected source-region edges are whole pixels.\n */\nexport function snapCropRectToSourcePixels(\n\tstate: CropperState,\n\timageSize: Size,\n\tcropRect: NormalizedRect,\n\thandle: HandlePosition\n): NormalizedRect {\n\tconst safeState = sanitizeCropperState( state );\n\tif ( ! isCardinalRotation( safeState.rotation ) ) {\n\t\treturn cropRect;\n\t}\n\n\treturn snapCropRectEdgesToSourcePixels( safeState, imageSize, cropRect, {\n\t\tleft: handle.includes( 'w' ),\n\t\ttop: handle.includes( 'n' ),\n\t\tright: handle.includes( 'e' ),\n\t\tbottom: handle.includes( 's' ),\n\t} );\n}\n\n/**\n * Snap all source-region edges for a crop rect to the nearest whole pixels.\n *\n * @param state The current cropper state.\n * @param imageSize The natural dimensions of the source image.\n * @param cropRect The crop rect to align to the source-pixel grid.\n * @return A crop rect whose source-region edges are whole pixels.\n */\nexport function snapCropRectToSourcePixelGrid(\n\tstate: CropperState,\n\timageSize: Size,\n\tcropRect: NormalizedRect\n): NormalizedRect {\n\treturn snapCropRectEdgesToSourcePixels( state, imageSize, cropRect, {\n\t\tleft: true,\n\t\ttop: true,\n\t\tright: true,\n\t\tbottom: true,\n\t} );\n}\n\nfunction snapCropRectEdgesToSourcePixels(\n\tstate: CropperState,\n\timageSize: Size,\n\tcropRect: NormalizedRect,\n\tedges: SourcePixelSnapEdges\n): NormalizedRect {\n\tif ( ! isValidSize( imageSize ) ) {\n\t\treturn cropRect;\n\t}\n\n\tconst stateWithCrop = sanitizeCropperState( { ...state, cropRect } );\n\tconst region = getSourceRegion( stateWithCrop, imageSize );\n\tconst shouldSnapX = edges.left || edges.right;\n\tconst shouldSnapY = edges.top || edges.bottom;\n\tconst left = edges.left ? Math.round( region.x ) : region.x;\n\tconst top = edges.top ? Math.round( region.y ) : region.y;\n\tconst right = edges.right\n\t\t? Math.round( region.x + region.width )\n\t\t: region.x + region.width;\n\tconst bottom = edges.bottom\n\t\t? Math.round( region.y + region.height )\n\t\t: region.y + region.height;\n\tif ( right <= left || bottom <= top ) {\n\t\treturn cropRect;\n\t}\n\n\tconst snappedCropRect = getCropRectFromSourceRegion(\n\t\tstateWithCrop,\n\t\timageSize,\n\t\t{\n\t\t\t...region,\n\t\t\tx: left,\n\t\t\ty: top,\n\t\t\twidth: right - left,\n\t\t\theight: bottom - top,\n\t\t}\n\t);\n\tif ( ! snappedCropRect ) {\n\t\treturn cropRect;\n\t}\n\n\treturn {\n\t\tx: shouldSnapX ? snappedCropRect.x : cropRect.x,\n\t\ty: shouldSnapY ? snappedCropRect.y : cropRect.y,\n\t\twidth: shouldSnapX ? snappedCropRect.width : cropRect.width,\n\t\theight: shouldSnapY ? snappedCropRect.height : cropRect.height,\n\t};\n}\n\n/**\n * The selected crop region expressed as percentages of the source image.\n */\nexport interface SourceRegionPercent {\n\t/** X offset as a percentage (0–100) of the source image width. */\n\tx: number;\n\t/** Y offset as a percentage (0–100) of the source image height. */\n\ty: number;\n\t/** Width as a percentage (0–100) of the source image width. */\n\twidth: number;\n\t/** Height as a percentage (0–100) of the source image height. */\n\theight: number;\n}\n\n/**\n * Get the selected image region as percentages of the source image dimensions.\n *\n * Returns `{ x, y, width, height }` where each value is a percentage (0–100)\n * of the source image's natural width or height. This format is compatible\n * with the WordPress REST API attachments `/edit` endpoint and CSS-based\n * crop workflows.\n *\n * Internally delegates to `getSourceRegion` and divides by the image\n * dimensions, so accuracy is identical.\n *\n * @param state The current cropper state.\n * @param imageSize The natural dimensions of the source image.\n * @return The crop region as percentages (0–100).\n */\nexport function getSourceRegionPercent(\n\tstate: CropperState,\n\timageSize: Size\n): SourceRegionPercent {\n\tif ( ! isValidSize( imageSize ) ) {\n\t\treturn { x: 0, y: 0, width: 0, height: 0 };\n\t}\n\tconst region = getSourceRegion( state, imageSize );\n\treturn {\n\t\tx: ( region.x / imageSize.width ) * 100,\n\t\ty: ( region.y / imageSize.height ) * 100,\n\t\twidth: ( region.width / imageSize.width ) * 100,\n\t\theight: ( region.height / imageSize.height ) * 100,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,gBACf,OACA,WACe;CAKf,MAAM,aAAA,GAAYA,mBAAAA,qBAAAA,CAAsB,KAAM;CAE9C,IAAK,EAAA,GAAEC,mBAAAA,YAAAA,CAAa,SAAU,GAC7B,OAAO;EACN,GAAG;EACH,GAAG;EACH,OAAO;EACP,QAAQ;EACR,UAAU,UAAU;EACpB,MAAM,EAAE,GAAG,UAAU,KAAK;EAC1B,MAAM,UAAU;CACjB;CAKD,MAAM,qBAA2B;EAAE,OAAO;EAAM,QAAQ;CAAK;CAC7D,MAAM,UAAA,GAASC,YAAAA,aAAAA,CAAc,WAAW,oBAAoB,SAAU;CAGtE,MAAM,MAAMC,UAAAA,MAAM,OAAO;CACzB,UAAA,MAAM,OAAQ,KAAK,MAAO;CAK1B,MAAM,cAAA,GAAaD,YAAAA,aAAAA,CAClB;EAAE,GAAG;EAAW,KAAK;GAAE,GAAG;GAAG,GAAG;EAAE;EAAG,MAAM;CAAE,GAC7C,oBACA,SACD;CACA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