@wordpress/media-editor 0.8.1-next.v.202605131032.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/build/components/media-editor/index.cjs +34 -135
  2. package/build/components/media-editor/index.cjs.map +3 -3
  3. package/build/components/media-editor/use-crop-options.cjs +87 -0
  4. package/build/components/media-editor/use-crop-options.cjs.map +7 -0
  5. package/build/components/media-editor/use-save-media-editor.cjs +185 -0
  6. package/build/components/media-editor/use-save-media-editor.cjs.map +7 -0
  7. package/build/components/media-editor-canvas/index.cjs +32 -11
  8. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  9. package/build/components/media-editor-crop-panel/index.cjs +66 -83
  10. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  11. package/build/components/media-editor-modal/index.cjs +40 -11
  12. package/build/components/media-editor-modal/index.cjs.map +3 -3
  13. package/build/components/media-editor-toolbar/index.cjs +7 -3
  14. package/build/components/media-editor-toolbar/index.cjs.map +2 -2
  15. package/build/components/media-form/index.cjs +19 -1
  16. package/build/components/media-form/index.cjs.map +3 -3
  17. package/build/components/media-form/sidebar-datetime-view.cjs +53 -0
  18. package/build/components/media-form/sidebar-datetime-view.cjs.map +7 -0
  19. package/build/components/rotation-ruler/index.cjs +8 -2
  20. package/build/components/rotation-ruler/index.cjs.map +2 -2
  21. package/build/hooks/use-crop-gesture-handlers.cjs +41 -4
  22. package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
  23. package/build/image-editor/core/camera.cjs +29 -11
  24. package/build/image-editor/core/camera.cjs.map +2 -2
  25. package/build/image-editor/core/constants.cjs +6 -0
  26. package/build/image-editor/core/constants.cjs.map +2 -2
  27. package/build/image-editor/core/containment.cjs +71 -34
  28. package/build/image-editor/core/containment.cjs.map +2 -2
  29. package/build/image-editor/core/crop-rect.cjs +48 -0
  30. package/build/image-editor/core/crop-rect.cjs.map +7 -0
  31. package/build/image-editor/core/index.cjs +12 -0
  32. package/build/image-editor/core/index.cjs.map +2 -2
  33. package/build/image-editor/core/interaction-controller.cjs.map +2 -2
  34. package/build/image-editor/core/math/sanitize.cjs +92 -0
  35. package/build/image-editor/core/math/sanitize.cjs.map +7 -0
  36. package/build/image-editor/core/setter-helpers.cjs +64 -0
  37. package/build/image-editor/core/setter-helpers.cjs.map +7 -0
  38. package/build/image-editor/core/source-region.cjs +16 -14
  39. package/build/image-editor/core/source-region.cjs.map +2 -2
  40. package/build/image-editor/core/state.cjs +20 -10
  41. package/build/image-editor/core/state.cjs.map +2 -2
  42. package/build/image-editor/core/stencil-math.cjs +31 -20
  43. package/build/image-editor/core/stencil-math.cjs.map +2 -2
  44. package/build/image-editor/core/transform-style.cjs +12 -6
  45. package/build/image-editor/core/transform-style.cjs.map +2 -2
  46. package/build/image-editor/core/types.cjs.map +1 -1
  47. package/build/image-editor/index.cjs +12 -2
  48. package/build/image-editor/index.cjs.map +2 -2
  49. package/build/image-editor/react/components/cropper-provider.cjs +2 -2
  50. package/build/image-editor/react/components/cropper-provider.cjs.map +2 -2
  51. package/build/image-editor/react/components/cropper.cjs +121 -48
  52. package/build/image-editor/react/components/cropper.cjs.map +2 -2
  53. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +172 -0
  54. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +7 -0
  55. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +20 -10
  56. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
  57. package/build/image-editor/react/hooks/build-cropper-setters.cjs +71 -0
  58. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +7 -0
  59. package/build/image-editor/react/hooks/index.cjs +6 -3
  60. package/build/image-editor/react/hooks/index.cjs.map +2 -2
  61. package/build/image-editor/react/hooks/use-aria-announcer.cjs +3 -1
  62. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
  63. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +113 -0
  64. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +7 -0
  65. package/build/image-editor/react/hooks/use-interaction.cjs +1 -1
  66. package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
  67. package/build/state/composite-reducer.cjs +115 -0
  68. package/build/state/composite-reducer.cjs.map +7 -0
  69. package/build/state/index.cjs +48 -0
  70. package/build/state/index.cjs.map +7 -0
  71. package/build/state/media-editor-state-provider.cjs +58 -0
  72. package/build/state/media-editor-state-provider.cjs.map +7 -0
  73. package/build/state/types.cjs +34 -0
  74. package/build/state/types.cjs.map +7 -0
  75. package/build/state/use-media-editor-state.cjs +298 -0
  76. package/build/state/use-media-editor-state.cjs.map +7 -0
  77. package/build-module/components/media-editor/index.mjs +40 -140
  78. package/build-module/components/media-editor/index.mjs.map +2 -2
  79. package/build-module/components/media-editor/use-crop-options.mjs +61 -0
  80. package/build-module/components/media-editor/use-crop-options.mjs.map +7 -0
  81. package/build-module/components/media-editor/use-save-media-editor.mjs +151 -0
  82. package/build-module/components/media-editor/use-save-media-editor.mjs.map +7 -0
  83. package/build-module/components/media-editor-canvas/index.mjs +33 -12
  84. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  85. package/build-module/components/media-editor-crop-panel/index.mjs +68 -83
  86. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  87. package/build-module/components/media-editor-modal/index.mjs +40 -11
  88. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  89. package/build-module/components/media-editor-toolbar/index.mjs +7 -3
  90. package/build-module/components/media-editor-toolbar/index.mjs.map +2 -2
  91. package/build-module/components/media-form/index.mjs +9 -1
  92. package/build-module/components/media-form/index.mjs.map +2 -2
  93. package/build-module/components/media-form/sidebar-datetime-view.mjs +32 -0
  94. package/build-module/components/media-form/sidebar-datetime-view.mjs.map +7 -0
  95. package/build-module/components/rotation-ruler/index.mjs +8 -2
  96. package/build-module/components/rotation-ruler/index.mjs.map +2 -2
  97. package/build-module/hooks/use-crop-gesture-handlers.mjs +41 -4
  98. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
  99. package/build-module/image-editor/core/camera.mjs +34 -11
  100. package/build-module/image-editor/core/camera.mjs.map +2 -2
  101. package/build-module/image-editor/core/constants.mjs +4 -0
  102. package/build-module/image-editor/core/constants.mjs.map +2 -2
  103. package/build-module/image-editor/core/containment.mjs +75 -34
  104. package/build-module/image-editor/core/containment.mjs.map +2 -2
  105. package/build-module/image-editor/core/crop-rect.mjs +23 -0
  106. package/build-module/image-editor/core/crop-rect.mjs.map +7 -0
  107. package/build-module/image-editor/core/index.mjs +12 -0
  108. package/build-module/image-editor/core/index.mjs.map +2 -2
  109. package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
  110. package/build-module/image-editor/core/math/sanitize.mjs +63 -0
  111. package/build-module/image-editor/core/math/sanitize.mjs.map +7 -0
  112. package/build-module/image-editor/core/setter-helpers.mjs +39 -0
  113. package/build-module/image-editor/core/setter-helpers.mjs.map +7 -0
  114. package/build-module/image-editor/core/source-region.mjs +16 -14
  115. package/build-module/image-editor/core/source-region.mjs.map +2 -2
  116. package/build-module/image-editor/core/state.mjs +25 -11
  117. package/build-module/image-editor/core/state.mjs.map +2 -2
  118. package/build-module/image-editor/core/stencil-math.mjs +30 -19
  119. package/build-module/image-editor/core/stencil-math.mjs.map +2 -2
  120. package/build-module/image-editor/core/transform-style.mjs +12 -6
  121. package/build-module/image-editor/core/transform-style.mjs.map +2 -2
  122. package/build-module/image-editor/index.mjs +11 -2
  123. package/build-module/image-editor/index.mjs.map +2 -2
  124. package/build-module/image-editor/react/components/cropper-provider.mjs +3 -3
  125. package/build-module/image-editor/react/components/cropper-provider.mjs.map +2 -2
  126. package/build-module/image-editor/react/components/cropper.mjs +122 -49
  127. package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
  128. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +147 -0
  129. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +7 -0
  130. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +20 -10
  131. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
  132. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +46 -0
  133. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +7 -0
  134. package/build-module/image-editor/react/hooks/index.mjs +4 -2
  135. package/build-module/image-editor/react/hooks/index.mjs.map +2 -2
  136. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +3 -1
  137. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
  138. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +100 -0
  139. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +7 -0
  140. package/build-module/image-editor/react/hooks/use-interaction.mjs +1 -1
  141. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
  142. package/build-module/state/composite-reducer.mjs +94 -0
  143. package/build-module/state/composite-reducer.mjs.map +7 -0
  144. package/build-module/state/index.mjs +26 -0
  145. package/build-module/state/index.mjs.map +7 -0
  146. package/build-module/state/media-editor-state-provider.mjs +34 -0
  147. package/build-module/state/media-editor-state-provider.mjs.map +7 -0
  148. package/build-module/state/types.mjs +9 -0
  149. package/build-module/state/types.mjs.map +7 -0
  150. package/build-module/state/use-media-editor-state.mjs +289 -0
  151. package/build-module/state/use-media-editor-state.mjs.map +7 -0
  152. package/build-style/style-rtl.css +46 -9
  153. package/build-style/style.css +46 -9
  154. package/build-types/components/media-editor/index.d.ts +4 -7
  155. package/build-types/components/media-editor/index.d.ts.map +1 -1
  156. package/build-types/components/media-editor/use-crop-options.d.ts +37 -0
  157. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -0
  158. package/build-types/components/media-editor/use-save-media-editor.d.ts +29 -0
  159. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -0
  160. package/build-types/components/media-editor-canvas/index.d.ts +5 -10
  161. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  162. package/build-types/components/media-editor-crop-panel/index.d.ts +4 -16
  163. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  164. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  165. package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -1
  166. package/build-types/components/media-form/index.d.ts.map +1 -1
  167. package/build-types/components/media-form/sidebar-datetime-view.d.ts +10 -0
  168. package/build-types/components/media-form/sidebar-datetime-view.d.ts.map +1 -0
  169. package/build-types/components/rotation-ruler/index.d.ts.map +1 -1
  170. package/build-types/hooks/use-crop-gesture-handlers.d.ts +13 -14
  171. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
  172. package/build-types/image-editor/core/camera.d.ts.map +1 -1
  173. package/build-types/image-editor/core/constants.d.ts +18 -0
  174. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  175. package/build-types/image-editor/core/containment.d.ts +10 -0
  176. package/build-types/image-editor/core/containment.d.ts.map +1 -1
  177. package/build-types/image-editor/core/crop-rect.d.ts +19 -0
  178. package/build-types/image-editor/core/crop-rect.d.ts.map +1 -0
  179. package/build-types/image-editor/core/index.d.ts +3 -1
  180. package/build-types/image-editor/core/index.d.ts.map +1 -1
  181. package/build-types/image-editor/core/interaction-controller.d.ts +5 -1
  182. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
  183. package/build-types/image-editor/core/math/sanitize.d.ts +70 -0
  184. package/build-types/image-editor/core/math/sanitize.d.ts.map +1 -0
  185. package/build-types/image-editor/core/setter-helpers.d.ts +24 -0
  186. package/build-types/image-editor/core/setter-helpers.d.ts.map +1 -0
  187. package/build-types/image-editor/core/source-region.d.ts.map +1 -1
  188. package/build-types/image-editor/core/state.d.ts +12 -0
  189. package/build-types/image-editor/core/state.d.ts.map +1 -1
  190. package/build-types/image-editor/core/stencil-math.d.ts +23 -18
  191. package/build-types/image-editor/core/stencil-math.d.ts.map +1 -1
  192. package/build-types/image-editor/core/transform-style.d.ts.map +1 -1
  193. package/build-types/image-editor/core/types.d.ts +23 -4
  194. package/build-types/image-editor/core/types.d.ts.map +1 -1
  195. package/build-types/image-editor/index.d.ts +4 -4
  196. package/build-types/image-editor/index.d.ts.map +1 -1
  197. package/build-types/image-editor/react/components/cropper-provider.d.ts +11 -7
  198. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
  199. package/build-types/image-editor/react/components/cropper.d.ts +6 -4
  200. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  201. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +36 -0
  202. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +1 -0
  203. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +2 -1
  204. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
  205. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +47 -0
  206. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +1 -0
  207. package/build-types/image-editor/react/hooks/index.d.ts +4 -2
  208. package/build-types/image-editor/react/hooks/index.d.ts.map +1 -1
  209. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
  210. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +58 -0
  211. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +1 -0
  212. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
  213. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -1
  214. package/build-types/state/composite-reducer.d.ts +39 -0
  215. package/build-types/state/composite-reducer.d.ts.map +1 -0
  216. package/build-types/state/index.d.ts +7 -0
  217. package/build-types/state/index.d.ts.map +1 -0
  218. package/build-types/state/media-editor-state-provider.d.ts +34 -0
  219. package/build-types/state/media-editor-state-provider.d.ts.map +1 -0
  220. package/build-types/state/types.d.ts +104 -0
  221. package/build-types/state/types.d.ts.map +1 -0
  222. package/build-types/state/use-media-editor-state.d.ts +104 -0
  223. package/build-types/state/use-media-editor-state.d.ts.map +1 -0
  224. package/package.json +19 -17
  225. package/src/components/media-editor/index.tsx +52 -188
  226. package/src/components/media-editor/test/use-crop-options.tsx +164 -0
  227. package/src/components/media-editor/use-crop-options.ts +115 -0
  228. package/src/components/media-editor/use-save-media-editor.ts +214 -0
  229. package/src/components/media-editor-canvas/index.tsx +56 -24
  230. package/src/components/media-editor-crop-panel/index.tsx +25 -61
  231. package/src/components/media-editor-crop-panel/test/index.tsx +17 -43
  232. package/src/components/media-editor-modal/index.tsx +50 -12
  233. package/src/components/media-editor-modal/test/build-modifiers.test.ts +14 -0
  234. package/src/components/media-editor-modal/test/index.tsx +143 -0
  235. package/src/components/media-editor-toolbar/index.tsx +9 -5
  236. package/src/components/media-form/index.tsx +15 -1
  237. package/src/components/media-form/sidebar-datetime-view.tsx +47 -0
  238. package/src/components/media-form/test/sidebar-datetime-view.test.tsx +96 -0
  239. package/src/components/rotation-ruler/README.md +11 -25
  240. package/src/components/rotation-ruler/index.tsx +17 -2
  241. package/src/components/rotation-ruler/style.scss +49 -13
  242. package/src/hooks/use-crop-gesture-handlers.ts +66 -17
  243. package/src/image-editor/README.md +28 -129
  244. package/src/image-editor/core/camera.ts +51 -26
  245. package/src/image-editor/core/constants.ts +19 -0
  246. package/src/image-editor/core/containment.ts +102 -49
  247. package/src/image-editor/core/crop-rect.ts +45 -0
  248. package/src/image-editor/core/index.ts +16 -4
  249. package/src/image-editor/core/interaction-controller.ts +5 -1
  250. package/src/image-editor/core/math/sanitize.ts +158 -0
  251. package/src/image-editor/core/math/test/sanitize.ts +244 -0
  252. package/src/image-editor/core/setter-helpers.ts +66 -0
  253. package/src/image-editor/core/source-region.ts +21 -14
  254. package/src/image-editor/core/state.ts +67 -15
  255. package/src/image-editor/core/stencil-math.ts +55 -35
  256. package/src/image-editor/core/test/camera.ts +367 -1
  257. package/src/image-editor/core/test/state.ts +101 -8
  258. package/src/image-editor/core/test/stencil-math.ts +193 -0
  259. package/src/image-editor/core/transform-style.ts +21 -6
  260. package/src/image-editor/core/types.ts +24 -4
  261. package/src/image-editor/docs/architecture.md +48 -89
  262. package/src/image-editor/docs/recipes.md +123 -659
  263. package/src/image-editor/index.ts +12 -3
  264. package/src/image-editor/react/components/cropper-provider.tsx +16 -12
  265. package/src/image-editor/react/components/cropper.scss +23 -4
  266. package/src/image-editor/react/components/cropper.tsx +197 -90
  267. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +269 -0
  268. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +22 -9
  269. package/src/image-editor/react/components/test/cropper.tsx +55 -13
  270. package/src/image-editor/react/hooks/build-cropper-setters.ts +105 -0
  271. package/src/image-editor/react/hooks/index.ts +4 -2
  272. package/src/image-editor/react/hooks/test/{use-cropper-state.ts → use-cropper-reducer.ts} +142 -286
  273. package/src/image-editor/react/hooks/use-aria-announcer.ts +3 -1
  274. package/src/image-editor/react/hooks/use-cropper-reducer.ts +204 -0
  275. package/src/image-editor/react/hooks/use-interaction.ts +3 -2
  276. package/src/image-editor/stories/rectangle-crop.story.tsx +7 -17
  277. package/src/state/composite-reducer.ts +152 -0
  278. package/src/state/index.ts +20 -0
  279. package/src/state/media-editor-state-provider.tsx +70 -0
  280. package/src/state/test/use-media-editor-state.ts +402 -0
  281. package/src/state/types.ts +107 -0
  282. package/src/state/use-media-editor-state.ts +488 -0
  283. package/tsconfig.json +2 -0
  284. package/tsconfig.tsbuildinfo +1 -1
  285. package/build/image-editor/react/hooks/use-cropper-state.cjs +0 -277
  286. package/build/image-editor/react/hooks/use-cropper-state.cjs.map +0 -7
  287. package/build-module/image-editor/react/hooks/use-cropper-state.mjs +0 -262
  288. package/build-module/image-editor/react/hooks/use-cropper-state.mjs.map +0 -7
  289. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +0 -97
  290. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +0 -1
  291. package/src/image-editor/docs/roadmap.md +0 -66
  292. package/src/image-editor/react/hooks/use-cropper-state.ts +0 -457
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/image-editor/index.ts"],
4
- "sourcesContent": ["/**\n * Public image editor contract.\n *\n * Keep this barrel explicit so implementation details from `core/`,\n * `react/hooks/`, or `react/components/` do not become supported API by\n * accident. Internal modules may export additional helpers for local tests or\n * React wiring; consumers should import through this file.\n */\n\n// React surface.\nexport { useCropperState } from './react/hooks';\nexport { Cropper, CropperProvider, useCropper } from './react/components';\nexport type { UseCropperStateReturn } from './react/hooks';\nexport type { CropperProps } from './react/components';\n\n// State and extension types.\nexport type {\n\tCropperState,\n\tTransformOperation,\n\tNormalizedPoint,\n\tNormalizedRect,\n\tSize,\n\tFlip,\n\tStencilProps,\n} from './core';\n\n// Deterministic cropper helpers.\nexport {\n\tDEFAULT_STATE,\n\tDEFAULT_ASPECT_RATIOS,\n\tORIGINAL_ASPECT_RATIO,\n\tgetSourceRegion,\n\tgetSourceRegionPercent,\n\tapplyOperationToState,\n\tstateFromPipeline,\n\texportCroppedImage,\n\tapplyToCanvas,\n} from './core';\nexport type {\n\tAspectRatioPreset,\n\tSourceRegion,\n\tSourceRegionPercent,\n} from './core';\n"],
5
- "mappings": ";AAUA,SAAS,uBAAuB;AAChC,SAAS,SAAS,iBAAiB,kBAAkB;AAgBrD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;",
4
+ "sourcesContent": ["/**\n * Public image editor contract.\n *\n * Keep this barrel explicit so implementation details from `core/`,\n * `react/hooks/`, or `react/components/` do not become supported API by\n * accident. Internal modules may export additional helpers for local tests or\n * React wiring; consumers should import through this file.\n */\n\n// React surface.\nexport { useCropperReducer, buildCropperSetters } from './react/hooks';\nexport { Cropper, CropperProvider, useCropper } from './react/components';\nexport type { CropperController, CropperSetters } from './react/hooks';\nexport type { CropperProps } from './react/components';\n\n// State and extension types.\nexport type {\n\tCropperState,\n\tCropperAction,\n\tTransformOperation,\n\tNormalizedPoint,\n\tNormalizedRect,\n\tSize,\n\tFlip,\n\tStencilProps,\n\tHandlePosition,\n} from './core';\n\n// Deterministic cropper helpers. The reducer + containment + state\n// equality helpers are exported so consumers can build composite\n// stores that delegate cropper actions (see `useMediaEditorState` for\n// the media editor's composite store).\nexport {\n\tDEFAULT_STATE,\n\tDEFAULT_ASPECT_RATIOS,\n\tORIGINAL_ASPECT_RATIO,\n\tcropperReducer,\n\tenforceContainment,\n\tareCropperStatesEqual,\n\tcomputeInscribedRect,\n\tgetSourceRegion,\n\tgetSourceRegionPercent,\n\tapplyOperationToState,\n\tstateFromPipeline,\n\texportCroppedImage,\n\tapplyToCanvas,\n} from './core';\nexport type {\n\tAspectRatioPreset,\n\tSourceRegion,\n\tSourceRegionPercent,\n} from './core';\n"],
5
+ "mappings": ";AAUA,SAAS,mBAAmB,2BAA2B;AACvD,SAAS,SAAS,iBAAiB,kBAAkB;AAqBrD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;",
6
6
  "names": []
7
7
  }
@@ -1,15 +1,15 @@
1
1
  // packages/media-editor/src/image-editor/react/components/cropper-provider.tsx
2
2
  import { createContext, useContext } from "@wordpress/element";
3
3
  import {
4
- useCropperState
5
- } from "../hooks/use-cropper-state.mjs";
4
+ useCropperReducer
5
+ } from "../hooks/use-cropper-reducer.mjs";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  var CropperContext = createContext(null);
8
8
  function CropperProvider({
9
9
  initialState,
10
10
  children
11
11
  }) {
12
- const cropperReturn = useCropperState(initialState);
12
+ const cropperReturn = useCropperReducer(initialState);
13
13
  return /* @__PURE__ */ jsx(CropperContext.Provider, { value: cropperReturn, children });
14
14
  }
15
15
  function useCropper() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/image-editor/react/components/cropper-provider.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseCropperState,\n\ttype UseCropperStateReturn,\n} from '../hooks/use-cropper-state';\nimport type { CropperState } from '../../core/types';\n\n/**\n * The context value type for the CropperProvider.\n * Contains the full return value of useCropperState.\n */\ntype CropperContextValue = UseCropperStateReturn | null;\n\nconst CropperContext = createContext< CropperContextValue >( null );\n\n/**\n * Props for the CropperProvider component.\n */\ninterface CropperProviderProps {\n\t/** Optional partial initial state to merge with defaults. */\n\tinitialState?: Partial< CropperState >;\n\t/** Child components. */\n\tchildren: React.ReactNode;\n}\n\n/**\n * Convenience context provider that wraps useCropperState.\n *\n * Provides the full cropper state and action creators to all\n * descendant components via React context.\n *\n * @param props Provider props.\n * @param props.initialState\n * @param props.children\n * @return The provider element wrapping children.\n */\nexport function CropperProvider( {\n\tinitialState,\n\tchildren,\n}: CropperProviderProps ) {\n\tconst cropperReturn = useCropperState( initialState );\n\n\treturn (\n\t\t<CropperContext.Provider value={ cropperReturn }>\n\t\t\t{ children }\n\t\t</CropperContext.Provider>\n\t);\n}\n\n/**\n * Hook to consume the CropperProvider context.\n *\n * Must be used within a CropperProvider. Throws if used outside\n * of the provider tree.\n *\n * @return The cropper state and action creators.\n */\nexport function useCropper(): UseCropperStateReturn {\n\tconst context = useContext( CropperContext );\n\n\tif ( ! context ) {\n\t\tthrow new Error( 'useCropper must be used within a CropperProvider.' );\n\t}\n\n\treturn context;\n}\n"],
5
- "mappings": ";AAGA,SAAS,eAAe,kBAAkB;AAK1C;AAAA,EACC;AAAA,OAEM;AAuCL;AA9BF,IAAM,iBAAiB,cAAsC,IAAK;AAuB3D,SAAS,gBAAiB;AAAA,EAChC;AAAA,EACA;AACD,GAA0B;AACzB,QAAM,gBAAgB,gBAAiB,YAAa;AAEpD,SACC,oBAAC,eAAe,UAAf,EAAwB,OAAQ,eAC9B,UACH;AAEF;AAUO,SAAS,aAAoC;AACnD,QAAM,UAAU,WAAY,cAAe;AAE3C,MAAK,CAAE,SAAU;AAChB,UAAM,IAAI,MAAO,mDAAoD;AAAA,EACtE;AAEA,SAAO;AACR;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseCropperReducer,\n\ttype CropperController,\n} from '../hooks/use-cropper-reducer';\nimport type { CropperState } from '../../core/types';\n\n/**\n * The context value type for the CropperProvider.\n * Contains the cropper controller from useCropperReducer.\n */\ntype CropperContextValue = CropperController | null;\n\nconst CropperContext = createContext< CropperContextValue >( null );\n\n/**\n * Props for the CropperProvider component.\n */\ninterface CropperProviderProps {\n\t/** Optional partial initial state to merge with defaults. */\n\tinitialState?: Partial< CropperState >;\n\t/** Child components. */\n\tchildren: React.ReactNode;\n}\n\n/**\n * Convenience context provider that wraps `useCropperReducer`.\n *\n * Provides the pure cropper controller (state + setters, NO undo\n * history) to all descendant components via React context.\n *\n * History is a higher-layer concern owned by composite stores\n * (see `useMediaEditorState` in media-editor/state for the media\n * editor's composite controller with undo/redo).\n *\n * @param props\n * @param props.initialState\n * @param props.children\n * @return The provider element wrapping children.\n */\nexport function CropperProvider( {\n\tinitialState,\n\tchildren,\n}: CropperProviderProps ) {\n\tconst cropperReturn = useCropperReducer( initialState );\n\n\treturn (\n\t\t<CropperContext.Provider value={ cropperReturn }>\n\t\t\t{ children }\n\t\t</CropperContext.Provider>\n\t);\n}\n\n/**\n * Hook to consume the CropperProvider context.\n *\n * Must be used within a CropperProvider. Throws if used outside\n * of the provider tree.\n *\n * @return The cropper controller.\n */\nexport function useCropper(): CropperController {\n\tconst context = useContext( CropperContext );\n\n\tif ( ! context ) {\n\t\tthrow new Error( 'useCropper must be used within a CropperProvider.' );\n\t}\n\n\treturn context;\n}\n"],
5
+ "mappings": ";AAGA,SAAS,eAAe,kBAAkB;AAK1C;AAAA,EACC;AAAA,OAEM;AA2CL;AAlCF,IAAM,iBAAiB,cAAsC,IAAK;AA2B3D,SAAS,gBAAiB;AAAA,EAChC;AAAA,EACA;AACD,GAA0B;AACzB,QAAM,gBAAgB,kBAAmB,YAAa;AAEtD,SACC,oBAAC,eAAe,UAAf,EAAwB,OAAQ,eAC9B,UACH;AAEF;AAUO,SAAS,aAAgC;AAC/C,QAAM,UAAU,WAAY,cAAe;AAE3C,MAAK,CAAE,SAAU;AAChB,UAAM,IAAI,MAAO,mDAAoD;AAAA,EACtE;AAEA,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -11,36 +11,22 @@ import {
11
11
  forwardRef
12
12
  } from "@wordpress/element";
13
13
  import { __ } from "@wordpress/i18n";
14
- import { getImageFit } from "../../core/camera.mjs";
15
- import { getImageCropBounds } from "../../core/containment.mjs";
14
+ import { getImageFit, getRotatedBBox } from "../../core/camera.mjs";
15
+ import { getImageCropBounds, getMinZoom } from "../../core/containment.mjs";
16
+ import { MIN_CROP_PIXELS } from "../../core/constants.mjs";
17
+ import { computeInscribedRect } from "../../core/crop-rect.mjs";
16
18
  import { useInteraction } from "../hooks/use-interaction.mjs";
17
19
  import { useTransformStyle } from "../hooks/use-transform-style.mjs";
18
20
  import { useAriaAnnouncer } from "../hooks/use-aria-announcer.mjs";
19
21
  import { RectangleStencil } from "./stencils/rectangle-stencil.mjs";
20
22
  import { DimmingOverlay } from "./overlays/dimming-overlay.mjs";
21
23
  import { GridOverlay } from "./overlays/grid-overlay.mjs";
24
+ import { DimensionsOverlay } from "./overlays/dimensions-overlay.mjs";
25
+ import { getSourceRegion } from "../../core/source-region.mjs";
22
26
  import { ViewportProvider, useViewport } from "./viewport-provider.mjs";
23
27
  import { VISUALLY_HIDDEN_STYLE } from "../visually-hidden-style.mjs";
24
28
  import { jsx, jsxs } from "react/jsx-runtime";
25
29
  var CROP_RECT_EPSILON = 1e-6;
26
- function computeInscribedRect(aspectRatio, visualSize) {
27
- let w = 1;
28
- let h = 1;
29
- if (aspectRatio && aspectRatio > 0 && visualSize.width > 0) {
30
- const normalizedRatio = aspectRatio * visualSize.height / visualSize.width;
31
- if (normalizedRatio <= 1) {
32
- w = normalizedRatio;
33
- } else {
34
- h = 1 / normalizedRatio;
35
- }
36
- }
37
- return {
38
- x: (1 - w) / 2,
39
- y: (1 - h) / 2,
40
- width: w,
41
- height: h
42
- };
43
- }
44
30
  function CropperInner({
45
31
  src,
46
32
  controller,
@@ -48,6 +34,7 @@ function CropperInner({
48
34
  showGrid = false,
49
35
  isPlacementActive = false,
50
36
  showDimming = true,
37
+ showDimensions = true,
51
38
  minZoom,
52
39
  maxZoom,
53
40
  aspectRatio,
@@ -59,7 +46,14 @@ function CropperInner({
59
46
  onGestureEnd,
60
47
  className
61
48
  }, ref) {
62
- const { state, setImage, setCropRect, settleCrop } = controller;
49
+ const {
50
+ state,
51
+ setImage,
52
+ setCropRect,
53
+ settleCrop,
54
+ setVisualSize,
55
+ adjustCropRectForViewport
56
+ } = controller;
63
57
  const {
64
58
  viewport: viewportState,
65
59
  setViewportPan,
@@ -80,11 +74,12 @@ function CropperInner({
80
74
  }, [focusOnMount]);
81
75
  const handleCropAreaFocus = useCallback(
82
76
  (event) => {
83
- if (event.target === event.currentTarget) {
77
+ const target = event.target;
78
+ if (target === event.currentTarget) {
84
79
  setIsCropAreaFocused(true);
85
- if (event.relatedTarget !== null && event.currentTarget.matches(":focus-visible")) {
86
- setIsFocusVisible(true);
87
- }
80
+ }
81
+ if (event.relatedTarget !== null && target.matches(":focus-visible")) {
82
+ setIsFocusVisible(true);
88
83
  }
89
84
  },
90
85
  []
@@ -93,6 +88,10 @@ function CropperInner({
93
88
  (event) => {
94
89
  if (event.target === event.currentTarget) {
95
90
  setIsCropAreaFocused(false);
91
+ }
92
+ if (!event.currentTarget.contains(
93
+ event.relatedTarget
94
+ )) {
96
95
  setIsFocusVisible(false);
97
96
  }
98
97
  },
@@ -133,6 +132,27 @@ function CropperInner({
133
132
  ),
134
133
  [canvasSize, naturalWidth, naturalHeight, state.rotation]
135
134
  );
135
+ const minCropSize = useMemo(() => {
136
+ if (naturalWidth <= 0 || naturalHeight <= 0) {
137
+ return void 0;
138
+ }
139
+ const snapRotation = Math.round(state.rotation / 90) * 90;
140
+ const bbox = getRotatedBBox(
141
+ naturalWidth,
142
+ naturalHeight,
143
+ snapRotation
144
+ );
145
+ return {
146
+ width: Math.min(1, MIN_CROP_PIXELS * state.zoom / bbox.width),
147
+ height: Math.min(
148
+ 1,
149
+ MIN_CROP_PIXELS * state.zoom / bbox.height
150
+ )
151
+ };
152
+ }, [naturalWidth, naturalHeight, state.rotation, state.zoom]);
153
+ useEffect(() => {
154
+ setVisualSize(visualSize);
155
+ }, [visualSize, setVisualSize]);
136
156
  useEffect(() => {
137
157
  if (freeformCrop || visualSize.width === 0 || visualSize.height === 0 || !aspectRatio || aspectRatio <= 0) {
138
158
  return;
@@ -142,8 +162,14 @@ function CropperInner({
142
162
  if (Math.abs(current.x - rect.x) < CROP_RECT_EPSILON && Math.abs(current.y - rect.y) < CROP_RECT_EPSILON && Math.abs(current.width - rect.width) < CROP_RECT_EPSILON && Math.abs(current.height - rect.height) < CROP_RECT_EPSILON) {
143
163
  return;
144
164
  }
145
- setCropRect(rect);
146
- }, [freeformCrop, aspectRatio, visualSize, setCropRect, state.cropRect]);
165
+ adjustCropRectForViewport(rect);
166
+ }, [
167
+ freeformCrop,
168
+ aspectRatio,
169
+ visualSize,
170
+ adjustCropRectForViewport,
171
+ state.cropRect
172
+ ]);
147
173
  const prevAspectRatioRef = useRef(aspectRatio);
148
174
  useEffect(() => {
149
175
  if (prevAspectRatioRef.current === aspectRatio) {
@@ -153,17 +179,32 @@ function CropperInner({
153
179
  if (!freeformCrop || visualSize.width === 0 || visualSize.height === 0 || !aspectRatio || aspectRatio <= 0) {
154
180
  return;
155
181
  }
156
- setCropRect(computeInscribedRect(aspectRatio, visualSize));
157
- }, [aspectRatio, freeformCrop, visualSize, setCropRect]);
182
+ const rect = computeInscribedRect(aspectRatio, visualSize);
183
+ const current = state.cropRect;
184
+ if (Math.abs(current.x - rect.x) < CROP_RECT_EPSILON && Math.abs(current.y - rect.y) < CROP_RECT_EPSILON && Math.abs(current.width - rect.width) < CROP_RECT_EPSILON && Math.abs(current.height - rect.height) < CROP_RECT_EPSILON) {
185
+ return;
186
+ }
187
+ adjustCropRectForViewport(rect);
188
+ }, [
189
+ aspectRatio,
190
+ freeformCrop,
191
+ visualSize,
192
+ adjustCropRectForViewport,
193
+ state.cropRect
194
+ ]);
158
195
  const cropBounds = useMemo(() => {
159
196
  if (!state.image || elementSize.width === 0) {
160
197
  return void 0;
161
198
  }
162
199
  return getImageCropBounds(state, elementSize, visualSize);
163
200
  }, [state, elementSize, visualSize]);
201
+ const effectiveMinZoom = minZoom !== void 0 ? minZoom : getMinZoom(state);
164
202
  const [isResizing, setIsResizing] = useState(false);
165
203
  const isResizingRef = useRef(false);
166
204
  const isSettlingRef = useRef(false);
205
+ const [activeHandle, setActiveHandle] = useState(
206
+ null
207
+ );
167
208
  const {
168
209
  handlers,
169
210
  onWheelNative,
@@ -171,22 +212,24 @@ function CropperInner({
171
212
  isZooming,
172
213
  isPlacementActive: isInteractionPlacementActive
173
214
  } = useInteraction(state, controller, canvasSize, visualSize, {
174
- minZoom,
215
+ minZoom: effectiveMinZoom,
175
216
  maxZoom,
176
217
  onGestureStart,
177
218
  onGestureEnd
178
219
  });
179
220
  const canvasHandlers = {
180
221
  ...handlers,
181
- onPointerDown: (event) => {
182
- handlers.onPointerDown?.(event);
222
+ onPointerDownCapture: () => {
183
223
  setIsFocusVisible(false);
184
224
  },
185
- onKeyDown: (event) => {
186
- if (event.target === event.currentTarget && !["Shift", "Control", "Alt", "Meta"].includes(event.key)) {
225
+ onKeyDownCapture: (event) => {
226
+ if (!["Shift", "Control", "Alt", "Meta"].includes(event.key)) {
187
227
  setIsFocusVisible(true);
188
228
  }
189
- handlers.onKeyDown?.(event);
229
+ },
230
+ onPointerDown: (event) => {
231
+ handlers.onPointerDown?.(event);
232
+ setIsFocusVisible(false);
190
233
  }
191
234
  };
192
235
  useEffect(() => {
@@ -256,7 +299,7 @@ function CropperInner({
256
299
  [setCropRect, setViewportPan, canvasSize, visualSize]
257
300
  );
258
301
  const [settling, setSettling] = useState(false);
259
- const settleTimerRef = useRef();
302
+ const settleTimerRef = useRef(void 0);
260
303
  useEffect(() => {
261
304
  return () => {
262
305
  clearTimeout(settleTimerRef.current);
@@ -264,22 +307,37 @@ function CropperInner({
264
307
  }, []);
265
308
  const isInteractiveGrid = showGrid === "interactive";
266
309
  const showInteractiveGrid = isInteractiveGrid && (isInteractionPlacementActive || isResizing || isPlacementActive);
310
+ const outputSize = useMemo(() => {
311
+ if (!showDimensions || !activeHandle || !state.image) {
312
+ return null;
313
+ }
314
+ const region = getSourceRegion(state, {
315
+ width: state.image.naturalWidth,
316
+ height: state.image.naturalHeight
317
+ });
318
+ return { width: region.width, height: region.height };
319
+ }, [showDimensions, activeHandle, state]);
267
320
  const handleEscape = useCallback(() => {
268
321
  setIsFocusVisible(true);
269
322
  canvasRef.current?.focus({ preventScroll: true });
270
323
  }, []);
271
- const handleResizeStart = useCallback(() => {
272
- isResizingRef.current = true;
273
- setIsResizing(true);
274
- clearTimeout(settleTimerRef.current);
275
- isSettlingRef.current = false;
276
- setSettling(false);
277
- resetViewport();
278
- onGestureStart?.();
279
- }, [onGestureStart, resetViewport]);
324
+ const handleResizeStart = useCallback(
325
+ (handle) => {
326
+ isResizingRef.current = true;
327
+ setIsResizing(true);
328
+ setActiveHandle(handle ?? null);
329
+ clearTimeout(settleTimerRef.current);
330
+ isSettlingRef.current = false;
331
+ setSettling(false);
332
+ resetViewport();
333
+ onGestureStart?.();
334
+ },
335
+ [onGestureStart, resetViewport]
336
+ );
280
337
  const handleResizeEnd = useCallback(() => {
281
338
  isResizingRef.current = false;
282
339
  setIsResizing(false);
340
+ setActiveHandle(null);
283
341
  isSettlingRef.current = true;
284
342
  setSettling(true);
285
343
  resetViewport();
@@ -355,9 +413,12 @@ function CropperInner({
355
413
  isInteractiveGrid && "wp-media-editor-image-editor__canvas--grid-interactive",
356
414
  showInteractiveGrid && "wp-media-editor-image-editor__canvas--show-grid",
357
415
  settling && "wp-media-editor-image-editor__canvas--settling",
358
- // Show the keyboard focus outline only when the canvas
359
- // itself (not a child handle) has keyboard focus.
360
- isFocusVisible && isCropAreaFocused && "wp-media-editor-image-editor__canvas--focus-visible"
416
+ // Marks the cropper as in keyboard-interaction mode.
417
+ // CSS uses :focus on the canvas to show the stencil
418
+ // outline and :focus on a handle to show its ring,
419
+ // so the class applies whenever any cropper element
420
+ // has keyboard focus.
421
+ isFocusVisible && "wp-media-editor-image-editor__canvas--focus-visible"
361
422
  ),
362
423
  tabIndex: 0,
363
424
  role: "group",
@@ -417,7 +478,8 @@ function CropperInner({
417
478
  aspectRatio,
418
479
  freeformCrop,
419
480
  stencilTransition: settleStencilTransition,
420
- cropBounds
481
+ cropBounds,
482
+ minCropSize
421
483
  }
422
484
  ),
423
485
  (showGrid === true || isInteractiveGrid) && /* @__PURE__ */ jsx(
@@ -427,6 +489,17 @@ function CropperInner({
427
489
  containerSize: canvasSize,
428
490
  imageSize: visualSize
429
491
  }
492
+ ),
493
+ activeHandle && outputSize && /* @__PURE__ */ jsx(
494
+ DimensionsOverlay,
495
+ {
496
+ cropRect: state.cropRect,
497
+ containerSize: canvasSize,
498
+ imageSize: visualSize,
499
+ activeHandle,
500
+ outputWidth: outputSize.width,
501
+ outputHeight: outputSize.height
502
+ }
430
503
  )
431
504
  ]
432
505
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/image-editor/react/components/cropper.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\n\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseCallback,\n\tuseMemo,\n\tuseRef,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseId,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tCropperState,\n\tStencilProps,\n\tSize,\n\tNormalizedRect,\n} from '../../core/types';\nimport type { UseCropperStateReturn } from '../hooks/use-cropper-state';\nimport { getImageFit } from '../../core/camera';\nimport { getImageCropBounds } from '../../core/containment';\nimport { useInteraction } from '../hooks/use-interaction';\nimport { useTransformStyle } from '../hooks/use-transform-style';\nimport { useAriaAnnouncer } from '../hooks/use-aria-announcer';\nimport { RectangleStencil } from './stencils/rectangle-stencil';\nimport { DimmingOverlay } from './overlays/dimming-overlay';\nimport { GridOverlay } from './overlays/grid-overlay';\nimport { ViewportProvider, useViewport } from './viewport-provider';\nimport { VISUALLY_HIDDEN_STYLE } from '../visually-hidden-style';\n\n/** Threshold for comparing normalized crop rect values. */\nconst CROP_RECT_EPSILON = 1e-6;\n\n// Largest rect of the given pixel aspect ratio that fits inside the visual\n// bounds, centered in [0,1] \u00D7 [0,1] normalized space. Returns a full-frame\n// rect (1\u00D71) if `aspectRatio` is unset or non-positive.\nfunction computeInscribedRect(\n\taspectRatio: number | undefined,\n\tvisualSize: Size\n): NormalizedRect {\n\tlet w = 1;\n\tlet h = 1;\n\tif ( aspectRatio && aspectRatio > 0 && visualSize.width > 0 ) {\n\t\t// normalizedRatio = w/h in normalized space that produces the\n\t\t// desired pixel aspect ratio.\n\t\t// pixelW = w * visualW, pixelH = h * visualH\n\t\t// pixelW / pixelH = aspectRatio\n\t\t// => w / h = aspectRatio * visualH / visualW\n\t\tconst normalizedRatio =\n\t\t\t( aspectRatio * visualSize.height ) / visualSize.width;\n\t\tif ( normalizedRatio <= 1 ) {\n\t\t\tw = normalizedRatio;\n\t\t} else {\n\t\t\th = 1 / normalizedRatio;\n\t\t}\n\t}\n\treturn {\n\t\tx: ( 1 - w ) / 2,\n\t\ty: ( 1 - h ) / 2,\n\t\twidth: w,\n\t\theight: h,\n\t};\n}\n\n/**\n * Props for the Cropper component.\n */\nexport interface CropperProps {\n\t/** Image source URL. */\n\tsrc: string;\n\t/** The full state/setter object from `useCropperState`. */\n\tcontroller: UseCropperStateReturn;\n\t/** Stencil component for the crop area. Defaults to RectangleStencil. */\n\tstencil?: React.ComponentType< StencilProps >;\n\t/** Show the rule-of-thirds grid overlay, or only during interactions. */\n\tshowGrid?: boolean | 'interactive';\n\t/** Whether external placement activity should keep the grid visible. */\n\tisPlacementActive?: boolean;\n\t/** Show the dimming overlay outside the crop area. */\n\tshowDimming?: boolean;\n\t/** Minimum zoom level. */\n\tminZoom?: number;\n\t/** Maximum zoom level. */\n\tmaxZoom?: number;\n\t/** Fixed aspect ratio (width / height) in pixel space for the crop area. */\n\taspectRatio?: number;\n\t/**\n\t * Enable freeform crop mode with resizable handles.\n\t * When false (default), the crop area is fixed and centered.\n\t * When true, the crop area has resize handles and can be freely repositioned.\n\t */\n\tfreeformCrop?: boolean;\n\t/** Focus the crop area when the cropper mounts. */\n\tfocusOnMount?: boolean;\n\t/** Callback fired when the image is loaded. */\n\tonImageLoaded?: ( size: Size ) => void;\n\t/**\n\t * Callback fired on every state change. Fires at pointermove rate\n\t * during drags, so keep the handler light \u2014 no heavy work, no\n\t * expensive parent re-renders. For commit-style events (drag end,\n\t * settled crop), use `onGestureEnd` instead.\n\t *\n\t * Useful for lightweight syncing with external tools, analytics,\n\t * or AI agents. Receives the full state so consumers can derive\n\t * whatever they need.\n\t */\n\tonStateChange?: ( state: CropperState ) => void;\n\t/** Fires when a continuous gesture begins (pan drag, handle resize, pinch zoom). */\n\tonGestureStart?: () => void;\n\t/** Fires when a continuous gesture ends (pointerup, resize settle). */\n\tonGestureEnd?: () => void;\n\t/** Additional className for the container. */\n\tclassName?: string;\n}\n\n/**\n * The main image cropper component.\n *\n * Renders an image within a container with interactive crop overlays.\n * Creates the camera once per render via getImageFit, then passes\n * derived values to stencil, overlays, and interaction hooks.\n *\n * The component fills its parent container (100% width and height).\n * Wrap it in a sized container to control its dimensions.\n *\n * @param root0 Component props implementing CropperProps.\n * @param root0.src Image source URL.\n * @param root0.controller The full state/setter object from `useCropperState`.\n * @param root0.stencil Custom stencil component.\n * @param root0.showGrid Grid overlay mode: false | true | 'interactive'.\n * @param root0.isPlacementActive Keep grid visible during external placement activity.\n * @param root0.showDimming Show dimming overlay outside crop.\n * @param root0.minZoom Minimum zoom level.\n * @param root0.maxZoom Maximum zoom level.\n * @param root0.aspectRatio Fixed aspect ratio (width/height).\n * @param root0.freeformCrop Enable resize handles.\n * @param root0.focusOnMount Focus the crop area on mount.\n * @param root0.onImageLoaded Image load callback.\n * @param root0.onStateChange Every-frame state callback.\n * @param root0.onGestureStart Gesture boundary start.\n * @param root0.onGestureEnd Gesture boundary end.\n * @param root0.className Additional CSS class.\n * @param ref Forwarded ref for the container div.\n */\nfunction CropperInner(\n\t{\n\t\tsrc,\n\t\tcontroller,\n\t\tstencil: StencilComponent = RectangleStencil,\n\t\tshowGrid = false,\n\t\tisPlacementActive = false,\n\t\tshowDimming = true,\n\t\tminZoom,\n\t\tmaxZoom,\n\t\taspectRatio,\n\t\tfreeformCrop = false,\n\t\tfocusOnMount = false,\n\t\tonImageLoaded,\n\t\tonStateChange,\n\t\tonGestureStart,\n\t\tonGestureEnd,\n\t\tclassName,\n\t}: CropperProps,\n\tref: React.ForwardedRef< HTMLDivElement >\n) {\n\tconst { state, setImage, setCropRect, settleCrop } = controller;\n\tconst {\n\t\tviewport: viewportState,\n\t\tsetViewportPan,\n\t\tresetViewport,\n\t} = useViewport();\n\t// Canvas measurement via ResizeObserver. The canvas is the inner\n\t// positioning context for image/stencil/handles \u2014 inset from the root\n\t// by the handle gutter, so crop math operates on the reduced box.\n\tconst canvasRef = useRef< HTMLDivElement >( null );\n\tconst cropAreaDescriptionId = useId();\n\tconst [ isCropAreaFocused, setIsCropAreaFocused ] =\n\t\tuseState( focusOnMount );\n\tconst [ isFocusVisible, setIsFocusVisible ] = useState( false );\n\tconst [ canvasSize, setCanvasSize ] = useState< Size >( {\n\t\twidth: 0,\n\t\theight: 0,\n\t} );\n\n\tuseLayoutEffect( () => {\n\t\tif ( focusOnMount ) {\n\t\t\tcanvasRef.current?.focus( { preventScroll: true } );\n\t\t}\n\t}, [ focusOnMount ] );\n\n\tconst handleCropAreaFocus = useCallback(\n\t\t( event: React.FocusEvent< HTMLDivElement > ) => {\n\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\tsetIsCropAreaFocused( true );\n\t\t\t\t// Show the outline only when focus arrived via keyboard\n\t\t\t\t// navigation. relatedTarget is null for pointer-initiated and\n\t\t\t\t// cross-window focus, so it reliably excludes those cases\n\t\t\t\t// without needing a separate ref or flag.\n\t\t\t\tif (\n\t\t\t\t\tevent.relatedTarget !== null &&\n\t\t\t\t\tevent.currentTarget.matches( ':focus-visible' )\n\t\t\t\t) {\n\t\t\t\t\tsetIsFocusVisible( true );\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[]\n\t);\n\n\tconst handleCropAreaBlur = useCallback(\n\t\t( event: React.FocusEvent< HTMLDivElement > ) => {\n\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\tsetIsCropAreaFocused( false );\n\t\t\t\tsetIsFocusVisible( false );\n\t\t\t}\n\t\t},\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\tconst element = canvasRef.current;\n\t\tif ( ! element ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new ResizeObserver( ( entries ) => {\n\t\t\tfor ( const entry of entries ) {\n\t\t\t\tconst { width, height } = entry.contentRect;\n\t\t\t\tsetCanvasSize( ( prev ) => {\n\t\t\t\t\tif ( prev.width === width && prev.height === height ) {\n\t\t\t\t\t\treturn prev;\n\t\t\t\t\t}\n\t\t\t\t\treturn { width, height };\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t\tobserver.observe( element );\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [] );\n\n\t// Notify consumer of state changes.\n\tuseEffect( () => {\n\t\tonStateChange?.( state );\n\t}, [ state, onStateChange ] );\n\n\t// ARIA live region: announce significant state changes for screen readers.\n\tconst ariaMessage = useAriaAnnouncer( state );\n\n\t// Compute fitted image dimensions and visual bounds from camera math.\n\tconst naturalWidth = state.image?.naturalWidth ?? 0;\n\tconst naturalHeight = state.image?.naturalHeight ?? 0;\n\tconst { elementSize, visualSize } = useMemo(\n\t\t() =>\n\t\t\tgetImageFit(\n\t\t\t\tcanvasSize,\n\t\t\t\t{ width: naturalWidth, height: naturalHeight },\n\t\t\t\tstate.rotation\n\t\t\t),\n\t\t[ canvasSize, naturalWidth, naturalHeight, state.rotation ]\n\t);\n\n\t// In fixed-crop mode, auto-size the crop rect only when a fixed aspect\n\t// ratio is selected. With \"Free\" selected, turning freeform handles off\n\t// should preserve the user's current unconstrained crop.\n\tuseEffect( () => {\n\t\tif (\n\t\t\tfreeformCrop ||\n\t\t\tvisualSize.width === 0 ||\n\t\t\tvisualSize.height === 0 ||\n\t\t\t! aspectRatio ||\n\t\t\taspectRatio <= 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst rect = computeInscribedRect( aspectRatio, visualSize );\n\t\tconst current = state.cropRect;\n\t\tif (\n\t\t\tMath.abs( current.x - rect.x ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.y - rect.y ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.width - rect.width ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.height - rect.height ) < CROP_RECT_EPSILON\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tsetCropRect( rect );\n\t}, [ freeformCrop, aspectRatio, visualSize, setCropRect, state.cropRect ] );\n\n\t// In freeform mode, when aspectRatio changes, reshape the crop to the\n\t// largest inscribed rect of the new ratio.\n\tconst prevAspectRatioRef = useRef( aspectRatio );\n\tuseEffect( () => {\n\t\tif ( prevAspectRatioRef.current === aspectRatio ) {\n\t\t\treturn;\n\t\t}\n\t\tprevAspectRatioRef.current = aspectRatio;\n\n\t\tif (\n\t\t\t! freeformCrop ||\n\t\t\tvisualSize.width === 0 ||\n\t\t\tvisualSize.height === 0 ||\n\t\t\t! aspectRatio ||\n\t\t\taspectRatio <= 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tsetCropRect( computeInscribedRect( aspectRatio, visualSize ) );\n\t}, [ aspectRatio, freeformCrop, visualSize, setCropRect ] );\n\n\t// Compute the crop handle bounds from the actual image footprint.\n\t// Depends on the full state object because getImageCropBounds reads\n\t// crop, zoom, rotation, flip, and image. React Compiler requires\n\t// the complete dependency; the computation is lightweight (a few\n\t// trig ops + 4 corner transforms).\n\tconst cropBounds = useMemo( () => {\n\t\tif ( ! state.image || elementSize.width === 0 ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn getImageCropBounds( state, elementSize, visualSize );\n\t}, [ state, elementSize, visualSize ] );\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst isResizingRef = useRef( false );\n\tconst isSettlingRef = useRef( false );\n\n\t// Use the interaction hook for mouse, touch, and keyboard events.\n\tconst {\n\t\thandlers,\n\t\tonWheelNative,\n\t\tisDragging,\n\t\tisZooming,\n\t\tisPlacementActive: isInteractionPlacementActive,\n\t} = useInteraction( state, controller, canvasSize, visualSize, {\n\t\tminZoom,\n\t\tmaxZoom,\n\t\tonGestureStart,\n\t\tonGestureEnd,\n\t} );\n\n\t// Compose focus-visibility tracking into the canvas event handlers.\n\t// Kept as a spread rather than explicit props to avoid triggering\n\t// jsx-a11y/no-noninteractive-element-interactions on role=\"group\".\n\tconst canvasHandlers = {\n\t\t...handlers,\n\t\tonPointerDown: ( event: React.PointerEvent< HTMLDivElement > ) => {\n\t\t\thandlers.onPointerDown?.( event );\n\t\t\t// Called after handlers so it lands last in the React batch \u2014\n\t\t\t// el.focus() inside the handler fires onFocus, which may\n\t\t\t// otherwise set isFocusVisible back to true.\n\t\t\tsetIsFocusVisible( false );\n\t\t},\n\t\tonKeyDown: ( event: React.KeyboardEvent< HTMLDivElement > ) => {\n\t\t\t// Guard against keydowns bubbling up from child handles\n\t\t\t// (e.g. Tab between handles, unhandled keys). Modifier-only\n\t\t\t// keypresses are excluded \u2014 they precede another key rather\n\t\t\t// than indicating deliberate keyboard interaction on their own.\n\t\t\tif (\n\t\t\t\tevent.target === event.currentTarget &&\n\t\t\t\t! [ 'Shift', 'Control', 'Alt', 'Meta' ].includes( event.key )\n\t\t\t) {\n\t\t\t\tsetIsFocusVisible( true );\n\t\t\t}\n\t\t\thandlers.onKeyDown?.( event );\n\t\t},\n\t};\n\n\t// Register wheel handler natively with { passive: false } so\n\t// preventDefault works. React's onWheel registers as passive. Bound\n\t// to the canvas (not the root) so pointer geometry inside the handler\n\t// resolves against the canvas box.\n\tuseEffect( () => {\n\t\tconst el = canvasRef.current;\n\t\tif ( ! el ) {\n\t\t\treturn;\n\t\t}\n\t\tconst handleWheel = ( event: WheelEvent ) => {\n\t\t\t// Block wheel zoom while resizing or settling \u2014 the stage CSS\n\t\t\t// transform changes getBoundingClientRect() during this window,\n\t\t\t// so focal-point math would resolve against the wrong center.\n\t\t\tif ( isResizingRef.current || isSettlingRef.current ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonWheelNative( event );\n\t\t};\n\t\tel.addEventListener( 'wheel', handleWheel, {\n\t\t\tpassive: false,\n\t\t} );\n\t\treturn () => {\n\t\t\tel.removeEventListener( 'wheel', handleWheel );\n\t\t};\n\t}, [ onWheelNative ] );\n\n\t// Use the transform style hook for the image CSS transform.\n\tconst transformString = useTransformStyle( state, visualSize );\n\n\t/**\n\t * Handle the image load event.\n\t */\n\tconst handleImageLoad = useCallback(\n\t\t( event: React.SyntheticEvent< HTMLImageElement > ) => {\n\t\t\tconst img = event.currentTarget;\n\t\t\tconst size: Size = {\n\t\t\t\twidth: img.naturalWidth,\n\t\t\t\theight: img.naturalHeight,\n\t\t\t};\n\n\t\t\tsetImage( {\n\t\t\t\tsrc,\n\t\t\t\tnaturalWidth: size.width,\n\t\t\t\tnaturalHeight: size.height,\n\t\t\t} );\n\n\t\t\tonImageLoaded?.( size );\n\t\t},\n\t\t[ src, setImage, onImageLoaded ]\n\t);\n\n\tconst handleCropChange = useCallback(\n\t\t( rect: NormalizedRect ) => {\n\t\t\tsetCropRect( rect );\n\t\t\t// During a resize drag, pan the viewport so the handle stays\n\t\t\t// visible even when the crop extends beyond the canvas edge.\n\t\t\tif (\n\t\t\t\tisResizingRef.current &&\n\t\t\t\tvisualSize.width > 0 &&\n\t\t\t\tvisualSize.height > 0\n\t\t\t) {\n\t\t\t\tconst offsetX = ( canvasSize.width - visualSize.width ) / 2;\n\t\t\t\tconst offsetY = ( canvasSize.height - visualSize.height ) / 2;\n\t\t\t\tconst rightOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\toffsetX +\n\t\t\t\t\t\t( rect.x + rect.width ) * visualSize.width -\n\t\t\t\t\t\tcanvasSize.width\n\t\t\t\t);\n\t\t\t\tconst leftOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\t-( offsetX + rect.x * visualSize.width )\n\t\t\t\t);\n\t\t\t\tconst bottomOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\toffsetY +\n\t\t\t\t\t\t( rect.y + rect.height ) * visualSize.height -\n\t\t\t\t\t\tcanvasSize.height\n\t\t\t\t);\n\t\t\t\tconst topOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\t-( offsetY + rect.y * visualSize.height )\n\t\t\t\t);\n\t\t\t\tsetViewportPan( {\n\t\t\t\t\tx: -rightOverflow + leftOverflow,\n\t\t\t\t\ty: -bottomOverflow + topOverflow,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ setCropRect, setViewportPan, canvasSize, visualSize ]\n\t);\n\n\t// Settling animation: brief linear transition after resize end.\n\tconst [ settling, setSettling ] = useState( false );\n\tconst settleTimerRef = useRef< ReturnType< typeof setTimeout > >();\n\n\t// Clear the pending settle timer on unmount so it can't fire a\n\t// state update on an unmounted component.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( settleTimerRef.current );\n\t\t};\n\t}, [] );\n\n\tconst isInteractiveGrid = showGrid === 'interactive';\n\tconst showInteractiveGrid =\n\t\tisInteractiveGrid &&\n\t\t( isInteractionPlacementActive || isResizing || isPlacementActive );\n\n\t/**\n\t * Handle Escape on a resize handle \u2014 return focus to the canvas so\n\t * arrow keys pan the image rather than resize.\n\t */\n\tconst handleEscape = useCallback( () => {\n\t\t// Escape is always a keyboard action, so show the outline immediately\n\t\t// rather than relying on the focus handler's :focus-visible check.\n\t\tsetIsFocusVisible( true );\n\t\tcanvasRef.current?.focus( { preventScroll: true } );\n\t}, [] );\n\n\tconst handleResizeStart = useCallback( () => {\n\t\tisResizingRef.current = true;\n\t\tsetIsResizing( true );\n\t\t// Clear any in-flight settle so transitions don't apply during the\n\t\t// new drag (rapid successive resizes would otherwise inherit the\n\t\t// previous settle animation).\n\t\tclearTimeout( settleTimerRef.current );\n\t\tisSettlingRef.current = false;\n\t\tsetSettling( false );\n\t\tresetViewport();\n\t\tonGestureStart?.();\n\t}, [ onGestureStart, resetViewport ] );\n\n\t/**\n\t * Handle resize end \u2014 settle the crop rect (re-center, fill height)\n\t * and reset the viewport pan back to neutral.\n\t */\n\tconst handleResizeEnd = useCallback( () => {\n\t\tisResizingRef.current = false;\n\t\tsetIsResizing( false );\n\t\tisSettlingRef.current = true;\n\t\tsetSettling( true );\n\t\t// Reset viewport pan first so it transitions back to zero in sync\n\t\t// with the settle animation on the image.\n\t\tresetViewport();\n\t\tsettleCrop();\n\t\tonGestureEnd?.();\n\t\tclearTimeout( settleTimerRef.current );\n\t\tsettleTimerRef.current = setTimeout( () => {\n\t\t\tisSettlingRef.current = false;\n\t\t\tsetSettling( false );\n\t\t}, 200 );\n\t}, [ settleCrop, onGestureEnd, resetViewport ] );\n\n\tlet imageTransition: string | undefined;\n\tif ( settling ) {\n\t\timageTransition = 'transform 200ms ease-out';\n\t} else if ( isZooming ) {\n\t\timageTransition = 'transform 150ms linear';\n\t}\n\tconst settleStencilTransition = settling\n\t\t? 'left 200ms ease-out, top 200ms ease-out, width 200ms ease-out, height 200ms ease-out'\n\t\t: undefined;\n\n\t// Compute the image's CSS style.\n\tconst imageStyle = useMemo( (): React.CSSProperties => {\n\t\tif ( elementSize.width === 0 || elementSize.height === 0 ) {\n\t\t\treturn {};\n\t\t}\n\t\tconst centerX = ( canvasSize.width - elementSize.width ) / 2;\n\t\tconst centerY = ( canvasSize.height - elementSize.height ) / 2;\n\t\treturn {\n\t\t\twidth: elementSize.width,\n\t\t\theight: elementSize.height,\n\t\t\tmaxWidth: elementSize.width,\n\t\t\tmaxHeight: elementSize.height,\n\t\t\tleft: centerX,\n\t\t\ttop: centerY,\n\t\t\ttransform: transformString,\n\t\t\ttransition: imageTransition,\n\t\t};\n\t}, [ canvasSize, elementSize, transformString, imageTransition ] );\n\n\t// Viewport pan CSS transform for the stage div. Applied during resize\n\t// drags to keep handles visible when the crop extends past the canvas edge.\n\t// Transitions back to zero during the settle animation.\n\t// will-change promotes the stage to its own compositor layer while the\n\t// transform is active, keeping per-frame pan updates off the main thread.\n\tconst settleTransition = settling ? 'transform 200ms ease-out' : undefined;\n\tconst willChange = isResizing || settling ? 'transform' : undefined;\n\tlet stageStyle: React.CSSProperties | undefined;\n\tif ( viewportState.pan.x !== 0 || viewportState.pan.y !== 0 ) {\n\t\tstageStyle = {\n\t\t\ttransform: `translate(${ viewportState.pan.x }px, ${ viewportState.pan.y }px)`,\n\t\t\ttransition: settleTransition,\n\t\t\twillChange,\n\t\t};\n\t} else if ( settling ) {\n\t\tstageStyle = { transition: settleTransition, willChange };\n\t}\n\n\t// Forward the root element to the consumer's ref.\n\tconst setContainerRef = useCallback(\n\t\t( element: HTMLDivElement | null ) => {\n\t\t\tif ( typeof ref === 'function' ) {\n\t\t\t\tref( element );\n\t\t\t} else if ( ref ) {\n\t\t\t\t(\n\t\t\t\t\tref as React.MutableRefObject< HTMLDivElement | null >\n\t\t\t\t ).current = element;\n\t\t\t}\n\t\t},\n\t\t[ ref ]\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tref={ setContainerRef }\n\t\t\tclassName={ clsx(\n\t\t\t\t'wp-media-editor-image-editor',\n\t\t\t\tisDragging && 'wp-media-editor-image-editor--dragging',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t{ /*\n\t\t\t * The canvas is the interactive, inset surface. Handles and\n\t\t\t * the ARIA role/tabIndex live here so pointer geometry\n\t\t\t * (getBoundingClientRect on e.currentTarget) resolves against\n\t\t\t * the same box that crop math uses. The root stays as the\n\t\t\t * clipping shell for the dimming overlay's box-shadow.\n\t\t\t *\n\t\t\t * Not role=\"application\" \u2014 that disables the screen reader's\n\t\t\t * normal keyboard interception, too heavy-handed for a single\n\t\t\t * widget. Screen reader users get the ARIA live region below\n\t\t\t * as the announcement channel.\n\t\t\t */ }\n\t\t\t<div\n\t\t\t\tref={ canvasRef }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'wp-media-editor-image-editor__canvas',\n\t\t\t\t\tisInteractiveGrid &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--grid-interactive',\n\t\t\t\t\tshowInteractiveGrid &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--show-grid',\n\t\t\t\t\tsettling &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--settling',\n\t\t\t\t\t// Show the keyboard focus outline only when the canvas\n\t\t\t\t\t// itself (not a child handle) has keyboard focus.\n\t\t\t\t\tisFocusVisible &&\n\t\t\t\t\t\tisCropAreaFocused &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--focus-visible'\n\t\t\t\t) }\n\t\t\t\ttabIndex={ 0 }\n\t\t\t\trole=\"group\"\n\t\t\t\taria-label={ __( 'Crop area' ) }\n\t\t\t\taria-describedby={\n\t\t\t\t\tisCropAreaFocused ? cropAreaDescriptionId : undefined\n\t\t\t\t}\n\t\t\t\tonFocus={ handleCropAreaFocus }\n\t\t\t\tonBlur={ handleCropAreaBlur }\n\t\t\t\t{ ...canvasHandlers }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tid={ cropAreaDescriptionId }\n\t\t\t\t\tstyle={ VISUALLY_HIDDEN_STYLE }\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'When this area is focused, use arrow keys to move the image and plus or minus to zoom. Tab to resize handles and controls.'\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t{ /*\n\t\t\t\t * The stage is an inner full-size div that receives the\n\t\t\t\t * viewport pan CSS transform. Keeping the transform here\n\t\t\t\t * (rather than on the canvas) means the canvas always stays\n\t\t\t\t * at its natural position, so the root div's background is\n\t\t\t\t * never exposed when the stage is panned during a resize drag.\n\t\t\t\t */ }\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"wp-media-editor-image-editor__stage\"\n\t\t\t\t\tdata-testid=\"cropper-stage\"\n\t\t\t\t\tstyle={ stageStyle }\n\t\t\t\t>\n\t\t\t\t\t{ /* The image layer */ }\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName=\"wp-media-editor-image-editor__image\"\n\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tonLoad={ handleImageLoad }\n\t\t\t\t\t\tstyle={ imageStyle }\n\t\t\t\t\t\tdraggable={ false }\n\t\t\t\t\t/>\n\n\t\t\t\t\t{ /* Dimming overlay outside the crop area */ }\n\t\t\t\t\t{ showDimming && (\n\t\t\t\t\t\t<DimmingOverlay\n\t\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\t\t\ttransition={ settleStencilTransition }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ /* The stencil (crop area with handles) */ }\n\t\t\t\t\t<StencilComponent\n\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\t\tonCropChange={ handleCropChange }\n\t\t\t\t\t\tonResizeStart={ handleResizeStart }\n\t\t\t\t\t\tonResizeEnd={ handleResizeEnd }\n\t\t\t\t\t\tonEscape={ handleEscape }\n\t\t\t\t\t\taspectRatio={ aspectRatio }\n\t\t\t\t\t\tfreeformCrop={ freeformCrop }\n\t\t\t\t\t\tstencilTransition={ settleStencilTransition }\n\t\t\t\t\t\tcropBounds={ cropBounds }\n\t\t\t\t\t/>\n\n\t\t\t\t\t{ /* Rule-of-thirds grid */ }\n\t\t\t\t\t{ ( showGrid === true || isInteractiveGrid ) && (\n\t\t\t\t\t\t<GridOverlay\n\t\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\n\t\t\t\t{ /* ARIA live region for screen reader announcements */ }\n\t\t\t\t<div\n\t\t\t\t\taria-live=\"polite\"\n\t\t\t\t\taria-atomic=\"true\"\n\t\t\t\t\tclassName=\"wp-media-editor-image-editor__aria-live\"\n\t\t\t\t\tstyle={ VISUALLY_HIDDEN_STYLE }\n\t\t\t\t>\n\t\t\t\t\t{ ariaMessage }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nconst CropperInnerWithRef = forwardRef< HTMLDivElement, CropperProps >(\n\tCropperInner\n);\n\nexport const Cropper = forwardRef< HTMLDivElement, CropperProps >(\n\t( props, ref ) => (\n\t\t<ViewportProvider>\n\t\t\t<CropperInnerWithRef { ...props } ref={ ref } />\n\t\t</ViewportProvider>\n\t)\n);\n"],
5
- "mappings": ";AAIA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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;AAAA,sBACA,KAAI;AAAA,sBACJ,QAAS;AAAA,sBACT,OAAQ;AAAA,sBACR,WAAY;AAAA;AAAA,kBACb;AAAA,kBAGE,eACD;AAAA,oBAAC;AAAA;AAAA,sBACA,UAAW,MAAM;AAAA,sBACjB,eAAgB;AAAA,sBAChB,WAAY;AAAA,sBACZ,YAAa;AAAA;AAAA,kBACd;AAAA,kBAID;AAAA,oBAAC;AAAA;AAAA,sBACA,UAAW,MAAM;AAAA,sBACjB,eAAgB;AAAA,sBAChB,WAAY;AAAA,sBACZ,cAAe;AAAA,sBACf,eAAgB;AAAA,sBAChB,aAAc;AAAA,sBACd,UAAW;AAAA,sBACX;AAAA,sBACA;AAAA,sBACA,mBAAoB;AAAA,sBACpB;AAAA;AAAA,kBACD;AAAA,mBAGI,aAAa,QAAQ,sBACxB;AAAA,oBAAC;AAAA;AAAA,sBACA,UAAW,MAAM;AAAA,sBACjB,eAAgB;AAAA,sBAChB,WAAY;AAAA;AAAA,kBACb;AAAA;AAAA;AAAA,YAEF;AAAA,YAGA;AAAA,cAAC;AAAA;AAAA,gBACA,aAAU;AAAA,gBACV,eAAY;AAAA,gBACZ,WAAU;AAAA,gBACV,OAAQ;AAAA,gBAEN;AAAA;AAAA,YACH;AAAA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;AAEA,IAAM,sBAAsB;AAAA,EAC3B;AACD;AAEO,IAAM,UAAU;AAAA,EACtB,CAAE,OAAO,QACR,oBAAC,oBACA,8BAAC,uBAAsB,GAAG,OAAQ,KAAY,GAC/C;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\n\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseCallback,\n\tuseMemo,\n\tuseRef,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseId,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tCropperState,\n\tHandlePosition,\n\tStencilProps,\n\tSize,\n\tNormalizedRect,\n} from '../../core/types';\nimport type { CropperController } from '../hooks/use-cropper-reducer';\nimport { getImageFit, getRotatedBBox } from '../../core/camera';\nimport { getImageCropBounds, getMinZoom } from '../../core/containment';\nimport { MIN_CROP_PIXELS } from '../../core/constants';\nimport { computeInscribedRect } from '../../core/crop-rect';\nimport { useInteraction } from '../hooks/use-interaction';\nimport { useTransformStyle } from '../hooks/use-transform-style';\nimport { useAriaAnnouncer } from '../hooks/use-aria-announcer';\nimport { RectangleStencil } from './stencils/rectangle-stencil';\nimport { DimmingOverlay } from './overlays/dimming-overlay';\nimport { GridOverlay } from './overlays/grid-overlay';\nimport { DimensionsOverlay } from './overlays/dimensions-overlay';\nimport { getSourceRegion } from '../../core/source-region';\nimport { ViewportProvider, useViewport } from './viewport-provider';\nimport { VISUALLY_HIDDEN_STYLE } from '../visually-hidden-style';\n\n/** Threshold for comparing normalized crop rect values. */\nconst CROP_RECT_EPSILON = 1e-6;\n\n/**\n * Props for the Cropper component.\n */\nexport interface CropperProps {\n\t/** Image source URL. */\n\tsrc: string;\n\t/** The cropper controller from `useCropperReducer` or a composite store. */\n\tcontroller: CropperController;\n\t/** Stencil component for the crop area. Defaults to RectangleStencil. */\n\tstencil?: React.ComponentType< StencilProps >;\n\t/** Show the rule-of-thirds grid overlay, or only during interactions. */\n\tshowGrid?: boolean | 'interactive';\n\t/** Whether external placement activity should keep the grid visible. */\n\tisPlacementActive?: boolean;\n\t/** Show the dimming overlay outside the crop area. */\n\tshowDimming?: boolean;\n\t/** Show the live output dimensions tooltip during a resize. */\n\tshowDimensions?: boolean;\n\t/** Minimum zoom level override. Defaults to the coverage-aware minimum. */\n\tminZoom?: number;\n\t/** Maximum zoom level. */\n\tmaxZoom?: number;\n\t/** Fixed aspect ratio (width / height) in pixel space for the crop area. */\n\taspectRatio?: number;\n\t/**\n\t * Enable freeform crop mode with resizable handles.\n\t * When false (default), the crop area is fixed and centered.\n\t * When true, the crop area has resize handles and can be freely repositioned.\n\t */\n\tfreeformCrop?: boolean;\n\t/** Focus the crop area when the cropper mounts. */\n\tfocusOnMount?: boolean;\n\t/** Callback fired when the image is loaded. */\n\tonImageLoaded?: ( size: Size ) => void;\n\t/**\n\t * Callback fired on every state change. Fires at pointermove rate\n\t * during drags, so keep the handler light \u2014 no heavy work, no\n\t * expensive parent re-renders. For commit-style events (drag end,\n\t * settled crop), use `onGestureEnd` instead.\n\t *\n\t * Useful for lightweight syncing with external tools, analytics,\n\t * or AI agents. Receives the full state so consumers can derive\n\t * whatever they need.\n\t */\n\tonStateChange?: ( state: CropperState ) => void;\n\t/** Fires when a continuous gesture begins (pan drag, handle resize, pinch zoom). */\n\tonGestureStart?: () => void;\n\t/** Fires when a continuous gesture ends (pointerup, resize settle). */\n\tonGestureEnd?: () => void;\n\t/** Additional className for the container. */\n\tclassName?: string;\n}\n\n/**\n * The main image cropper component.\n *\n * Renders an image within a container with interactive crop overlays.\n * Creates the camera once per render via getImageFit, then passes\n * derived values to stencil, overlays, and interaction hooks.\n *\n * The component fills its parent container (100% width and height).\n * Wrap it in a sized container to control its dimensions.\n *\n * @param root0 Component props implementing CropperProps.\n * @param root0.src Image source URL.\n * @param root0.controller The cropper controller from `useCropperReducer` or a composite store.\n * @param root0.stencil Custom stencil component.\n * @param root0.showGrid Grid overlay mode: false | true | 'interactive'.\n * @param root0.isPlacementActive Keep grid visible during external placement activity.\n * @param root0.showDimming Show dimming overlay outside crop.\n * @param root0.showDimensions Show live dimensions tooltip during resize.\n * @param root0.minZoom Minimum zoom level override.\n * @param root0.maxZoom Maximum zoom level.\n * @param root0.aspectRatio Fixed aspect ratio (width/height).\n * @param root0.freeformCrop Enable resize handles.\n * @param root0.focusOnMount Focus the crop area on mount.\n * @param root0.onImageLoaded Image load callback.\n * @param root0.onStateChange Every-frame state callback.\n * @param root0.onGestureStart Gesture boundary start.\n * @param root0.onGestureEnd Gesture boundary end.\n * @param root0.className Additional CSS class.\n * @param ref Forwarded ref for the container div.\n */\nfunction CropperInner(\n\t{\n\t\tsrc,\n\t\tcontroller,\n\t\tstencil: StencilComponent = RectangleStencil,\n\t\tshowGrid = false,\n\t\tisPlacementActive = false,\n\t\tshowDimming = true,\n\t\tshowDimensions = true,\n\t\tminZoom,\n\t\tmaxZoom,\n\t\taspectRatio,\n\t\tfreeformCrop = false,\n\t\tfocusOnMount = false,\n\t\tonImageLoaded,\n\t\tonStateChange,\n\t\tonGestureStart,\n\t\tonGestureEnd,\n\t\tclassName,\n\t}: CropperProps,\n\tref: React.ForwardedRef< HTMLDivElement >\n) {\n\tconst {\n\t\tstate,\n\t\tsetImage,\n\t\tsetCropRect,\n\t\tsettleCrop,\n\t\tsetVisualSize,\n\t\tadjustCropRectForViewport,\n\t} = controller;\n\tconst {\n\t\tviewport: viewportState,\n\t\tsetViewportPan,\n\t\tresetViewport,\n\t} = useViewport();\n\t// Canvas measurement via ResizeObserver. The canvas is the inner\n\t// positioning context for image/stencil/handles \u2014 inset from the root\n\t// by the handle gutter, so crop math operates on the reduced box.\n\tconst canvasRef = useRef< HTMLDivElement >( null );\n\tconst cropAreaDescriptionId = useId();\n\tconst [ isCropAreaFocused, setIsCropAreaFocused ] =\n\t\tuseState( focusOnMount );\n\tconst [ isFocusVisible, setIsFocusVisible ] = useState( false );\n\tconst [ canvasSize, setCanvasSize ] = useState< Size >( {\n\t\twidth: 0,\n\t\theight: 0,\n\t} );\n\n\tuseLayoutEffect( () => {\n\t\tif ( focusOnMount ) {\n\t\t\tcanvasRef.current?.focus( { preventScroll: true } );\n\t\t}\n\t}, [ focusOnMount ] );\n\n\tconst handleCropAreaFocus = useCallback(\n\t\t( event: React.FocusEvent< HTMLDivElement > ) => {\n\t\t\tconst target = event.target as HTMLElement;\n\t\t\tif ( target === event.currentTarget ) {\n\t\t\t\tsetIsCropAreaFocused( true );\n\t\t\t}\n\t\t\t// Show the outline only when focus arrived via keyboard\n\t\t\t// navigation. relatedTarget is null for pointer-initiated and\n\t\t\t// cross-window focus, so it reliably excludes those cases\n\t\t\t// without needing a separate ref or flag. Applies to focus\n\t\t\t// arriving on the canvas itself or on a descendant handle.\n\t\t\tif (\n\t\t\t\tevent.relatedTarget !== null &&\n\t\t\t\ttarget.matches( ':focus-visible' )\n\t\t\t) {\n\t\t\t\tsetIsFocusVisible( true );\n\t\t\t}\n\t\t},\n\t\t[]\n\t);\n\n\tconst handleCropAreaBlur = useCallback(\n\t\t( event: React.FocusEvent< HTMLDivElement > ) => {\n\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\tsetIsCropAreaFocused( false );\n\t\t\t}\n\t\t\t// Reset keyboard-active styling only when focus leaves the\n\t\t\t// cropper entirely. Moves between the canvas and a handle (or\n\t\t\t// between handles) keep the keyboard-active state intact.\n\t\t\tif (\n\t\t\t\t! event.currentTarget.contains(\n\t\t\t\t\tevent.relatedTarget as Node | null\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tsetIsFocusVisible( false );\n\t\t\t}\n\t\t},\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\tconst element = canvasRef.current;\n\t\tif ( ! element ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new ResizeObserver( ( entries ) => {\n\t\t\tfor ( const entry of entries ) {\n\t\t\t\tconst { width, height } = entry.contentRect;\n\t\t\t\tsetCanvasSize( ( prev ) => {\n\t\t\t\t\tif ( prev.width === width && prev.height === height ) {\n\t\t\t\t\t\treturn prev;\n\t\t\t\t\t}\n\t\t\t\t\treturn { width, height };\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t\tobserver.observe( element );\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [] );\n\n\t// Notify consumer of state changes.\n\tuseEffect( () => {\n\t\tonStateChange?.( state );\n\t}, [ state, onStateChange ] );\n\n\t// ARIA live region: announce significant state changes for screen readers.\n\tconst ariaMessage = useAriaAnnouncer( state );\n\n\t// Compute fitted image dimensions and visual bounds from camera math.\n\tconst naturalWidth = state.image?.naturalWidth ?? 0;\n\tconst naturalHeight = state.image?.naturalHeight ?? 0;\n\tconst { elementSize, visualSize } = useMemo(\n\t\t() =>\n\t\t\tgetImageFit(\n\t\t\t\tcanvasSize,\n\t\t\t\t{ width: naturalWidth, height: naturalHeight },\n\t\t\t\tstate.rotation\n\t\t\t),\n\t\t[ canvasSize, naturalWidth, naturalHeight, state.rotation ]\n\t);\n\n\t// Per-axis minimum crop size in normalized space, expressing a\n\t// pixel floor on the captured source region. cropRect is normalized\n\t// in the viewport's snap-rotation bbox; the captured source-pixel\n\t// width is `cropRect.width * bbox.width / zoom`, so the normalized\n\t// floor scales with `zoom` to keep the source-pixel floor constant.\n\t// Without this, SETTLE_CROP zooms in proportional to the shrink and\n\t// successive drags can crop arbitrarily small.\n\tconst minCropSize: Size | undefined = useMemo( () => {\n\t\tif ( naturalWidth <= 0 || naturalHeight <= 0 ) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst snapRotation = Math.round( state.rotation / 90 ) * 90;\n\t\tconst bbox = getRotatedBBox(\n\t\t\tnaturalWidth,\n\t\t\tnaturalHeight,\n\t\t\tsnapRotation\n\t\t);\n\t\treturn {\n\t\t\twidth: Math.min( 1, ( MIN_CROP_PIXELS * state.zoom ) / bbox.width ),\n\t\t\theight: Math.min(\n\t\t\t\t1,\n\t\t\t\t( MIN_CROP_PIXELS * state.zoom ) / bbox.height\n\t\t\t),\n\t\t};\n\t}, [ naturalWidth, naturalHeight, state.rotation, state.zoom ] );\n\n\t// Report the rendered image size to the controller. Composite\n\t// controllers need it to compute aspect-ratio reshapes from the\n\t// reducer (the dropdown dispatches without DOM access); pure\n\t// controllers ignore it.\n\tuseEffect( () => {\n\t\tsetVisualSize( visualSize );\n\t}, [ visualSize, setVisualSize ] );\n\n\t// In fixed-crop mode, auto-size the crop rect only when a fixed\n\t// aspect ratio is selected. With \"Free\" selected, turning freeform\n\t// handles off should preserve the user's current unconstrained\n\t// crop. Uses `adjustCropRectForViewport` so window-resize-driven\n\t// reshapes don't create undo entries (composite controller); the\n\t// dedup at lines below avoids redundant dispatches when the\n\t// reducer has already updated the cropRect for an aspect change.\n\tuseEffect( () => {\n\t\tif (\n\t\t\tfreeformCrop ||\n\t\t\tvisualSize.width === 0 ||\n\t\t\tvisualSize.height === 0 ||\n\t\t\t! aspectRatio ||\n\t\t\taspectRatio <= 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst rect = computeInscribedRect( aspectRatio, visualSize );\n\t\tconst current = state.cropRect;\n\t\tif (\n\t\t\tMath.abs( current.x - rect.x ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.y - rect.y ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.width - rect.width ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.height - rect.height ) < CROP_RECT_EPSILON\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tadjustCropRectForViewport( rect );\n\t}, [\n\t\tfreeformCrop,\n\t\taspectRatio,\n\t\tvisualSize,\n\t\tadjustCropRectForViewport,\n\t\tstate.cropRect,\n\t] );\n\n\t// In freeform mode, when aspectRatio changes, reshape the crop to\n\t// the largest inscribed rect of the new ratio. Bails out when the\n\t// cropRect already matches the inscribed rect \u2014 composite stores\n\t// reshape atomically inside the reducer, so this effect is a\n\t// no-op there.\n\tconst prevAspectRatioRef = useRef( aspectRatio );\n\tuseEffect( () => {\n\t\tif ( prevAspectRatioRef.current === aspectRatio ) {\n\t\t\treturn;\n\t\t}\n\t\tprevAspectRatioRef.current = aspectRatio;\n\n\t\tif (\n\t\t\t! freeformCrop ||\n\t\t\tvisualSize.width === 0 ||\n\t\t\tvisualSize.height === 0 ||\n\t\t\t! aspectRatio ||\n\t\t\taspectRatio <= 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst rect = computeInscribedRect( aspectRatio, visualSize );\n\t\tconst current = state.cropRect;\n\t\tif (\n\t\t\tMath.abs( current.x - rect.x ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.y - rect.y ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.width - rect.width ) < CROP_RECT_EPSILON &&\n\t\t\tMath.abs( current.height - rect.height ) < CROP_RECT_EPSILON\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tadjustCropRectForViewport( rect );\n\t}, [\n\t\taspectRatio,\n\t\tfreeformCrop,\n\t\tvisualSize,\n\t\tadjustCropRectForViewport,\n\t\tstate.cropRect,\n\t] );\n\n\t// Compute the crop handle bounds from the actual image footprint.\n\t// Depends on the full state object because getImageCropBounds reads\n\t// crop, zoom, rotation, flip, and image. React Compiler requires\n\t// the complete dependency; the computation is lightweight (a few\n\t// trig ops + 4 corner transforms).\n\tconst cropBounds = useMemo( () => {\n\t\tif ( ! state.image || elementSize.width === 0 ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn getImageCropBounds( state, elementSize, visualSize );\n\t}, [ state, elementSize, visualSize ] );\n\tconst effectiveMinZoom =\n\t\tminZoom !== undefined ? minZoom : getMinZoom( state );\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst isResizingRef = useRef( false );\n\tconst isSettlingRef = useRef( false );\n\t// Direction of the handle the user is currently resizing \u2014 pointer or\n\t// keyboard. `null` outside of an active resize. Drives the live\n\t// dimensions tooltip overlay.\n\tconst [ activeHandle, setActiveHandle ] = useState< HandlePosition | null >(\n\t\tnull\n\t);\n\n\t// Use the interaction hook for mouse, touch, and keyboard events.\n\tconst {\n\t\thandlers,\n\t\tonWheelNative,\n\t\tisDragging,\n\t\tisZooming,\n\t\tisPlacementActive: isInteractionPlacementActive,\n\t} = useInteraction( state, controller, canvasSize, visualSize, {\n\t\tminZoom: effectiveMinZoom,\n\t\tmaxZoom,\n\t\tonGestureStart,\n\t\tonGestureEnd,\n\t} );\n\n\t// Compose focus-visibility tracking into the canvas event handlers.\n\t// Kept as a spread rather than explicit props to avoid triggering\n\t// jsx-a11y/no-noninteractive-element-interactions on role=\"group\".\n\t//\n\t// The pointer/key tracking lives in the capture phase so it runs\n\t// before any child handler \u2014 handles call stopPropagation in their\n\t// own onPointerDown / onKeyDown, which would otherwise prevent the\n\t// keyboard-active state from updating when the user interacts with\n\t// a handle directly.\n\tconst canvasHandlers = {\n\t\t...handlers,\n\t\tonPointerDownCapture: () => {\n\t\t\tsetIsFocusVisible( false );\n\t\t},\n\t\tonKeyDownCapture: ( event: React.KeyboardEvent< HTMLDivElement > ) => {\n\t\t\t// Modifier-only keypresses precede another key rather than\n\t\t\t// indicating deliberate keyboard interaction on their own.\n\t\t\tif (\n\t\t\t\t! [ 'Shift', 'Control', 'Alt', 'Meta' ].includes( event.key )\n\t\t\t) {\n\t\t\t\tsetIsFocusVisible( true );\n\t\t\t}\n\t\t},\n\t\tonPointerDown: ( event: React.PointerEvent< HTMLDivElement > ) => {\n\t\t\thandlers.onPointerDown?.( event );\n\t\t\t// Re-assert false after handlers run \u2014 el.focus() inside the\n\t\t\t// handler fires onFocus, which may otherwise set it back to true.\n\t\t\tsetIsFocusVisible( false );\n\t\t},\n\t};\n\n\t// Register wheel handler natively with { passive: false } so\n\t// preventDefault works. React's onWheel registers as passive. Bound\n\t// to the canvas (not the root) so pointer geometry inside the handler\n\t// resolves against the canvas box.\n\tuseEffect( () => {\n\t\tconst el = canvasRef.current;\n\t\tif ( ! el ) {\n\t\t\treturn;\n\t\t}\n\t\tconst handleWheel = ( event: WheelEvent ) => {\n\t\t\t// Block wheel zoom while resizing or settling \u2014 the stage CSS\n\t\t\t// transform changes getBoundingClientRect() during this window,\n\t\t\t// so focal-point math would resolve against the wrong center.\n\t\t\tif ( isResizingRef.current || isSettlingRef.current ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonWheelNative( event );\n\t\t};\n\t\tel.addEventListener( 'wheel', handleWheel, {\n\t\t\tpassive: false,\n\t\t} );\n\t\treturn () => {\n\t\t\tel.removeEventListener( 'wheel', handleWheel );\n\t\t};\n\t}, [ onWheelNative ] );\n\n\t// Use the transform style hook for the image CSS transform.\n\tconst transformString = useTransformStyle( state, visualSize );\n\n\t/**\n\t * Handle the image load event.\n\t */\n\tconst handleImageLoad = useCallback(\n\t\t( event: React.SyntheticEvent< HTMLImageElement > ) => {\n\t\t\tconst img = event.currentTarget;\n\t\t\tconst size: Size = {\n\t\t\t\twidth: img.naturalWidth,\n\t\t\t\theight: img.naturalHeight,\n\t\t\t};\n\n\t\t\tsetImage( {\n\t\t\t\tsrc,\n\t\t\t\tnaturalWidth: size.width,\n\t\t\t\tnaturalHeight: size.height,\n\t\t\t} );\n\n\t\t\tonImageLoaded?.( size );\n\t\t},\n\t\t[ src, setImage, onImageLoaded ]\n\t);\n\n\tconst handleCropChange = useCallback(\n\t\t( rect: NormalizedRect ) => {\n\t\t\tsetCropRect( rect );\n\t\t\t// During a resize drag, pan the viewport so the handle stays\n\t\t\t// visible even when the crop extends beyond the canvas edge.\n\t\t\tif (\n\t\t\t\tisResizingRef.current &&\n\t\t\t\tvisualSize.width > 0 &&\n\t\t\t\tvisualSize.height > 0\n\t\t\t) {\n\t\t\t\tconst offsetX = ( canvasSize.width - visualSize.width ) / 2;\n\t\t\t\tconst offsetY = ( canvasSize.height - visualSize.height ) / 2;\n\t\t\t\tconst rightOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\toffsetX +\n\t\t\t\t\t\t( rect.x + rect.width ) * visualSize.width -\n\t\t\t\t\t\tcanvasSize.width\n\t\t\t\t);\n\t\t\t\tconst leftOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\t-( offsetX + rect.x * visualSize.width )\n\t\t\t\t);\n\t\t\t\tconst bottomOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\toffsetY +\n\t\t\t\t\t\t( rect.y + rect.height ) * visualSize.height -\n\t\t\t\t\t\tcanvasSize.height\n\t\t\t\t);\n\t\t\t\tconst topOverflow = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\t-( offsetY + rect.y * visualSize.height )\n\t\t\t\t);\n\t\t\t\tsetViewportPan( {\n\t\t\t\t\tx: -rightOverflow + leftOverflow,\n\t\t\t\t\ty: -bottomOverflow + topOverflow,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ setCropRect, setViewportPan, canvasSize, visualSize ]\n\t);\n\n\t// Settling animation: brief linear transition after resize end.\n\tconst [ settling, setSettling ] = useState( false );\n\tconst settleTimerRef = useRef<\n\t\tReturnType< typeof setTimeout > | undefined\n\t>( undefined );\n\n\t// Clear the pending settle timer on unmount so it can't fire a\n\t// state update on an unmounted component.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( settleTimerRef.current );\n\t\t};\n\t}, [] );\n\n\tconst isInteractiveGrid = showGrid === 'interactive';\n\tconst showInteractiveGrid =\n\t\tisInteractiveGrid &&\n\t\t( isInteractionPlacementActive || isResizing || isPlacementActive );\n\n\t// Output crop size in source pixels \u2014 drives the live tooltip\n\t// overlay. Only computed during pointer drags, so the per-frame\n\t// state churn during pan/zoom doesn't pay for it.\n\tconst outputSize = useMemo( () => {\n\t\tif ( ! showDimensions || ! activeHandle || ! state.image ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst region = getSourceRegion( state, {\n\t\t\twidth: state.image.naturalWidth,\n\t\t\theight: state.image.naturalHeight,\n\t\t} );\n\t\treturn { width: region.width, height: region.height };\n\t}, [ showDimensions, activeHandle, state ] );\n\n\t/**\n\t * Handle Escape on a resize handle \u2014 return focus to the canvas so\n\t * arrow keys pan the image rather than resize.\n\t */\n\tconst handleEscape = useCallback( () => {\n\t\t// Escape is always a keyboard action, so show the outline immediately\n\t\t// rather than relying on the focus handler's :focus-visible check.\n\t\tsetIsFocusVisible( true );\n\t\tcanvasRef.current?.focus( { preventScroll: true } );\n\t}, [] );\n\n\tconst handleResizeStart = useCallback(\n\t\t( handle?: HandlePosition ) => {\n\t\t\tisResizingRef.current = true;\n\t\t\tsetIsResizing( true );\n\t\t\tsetActiveHandle( handle ?? null );\n\t\t\t// Clear any in-flight settle so transitions don't apply during the\n\t\t\t// new drag (rapid successive resizes would otherwise inherit the\n\t\t\t// previous settle animation).\n\t\t\tclearTimeout( settleTimerRef.current );\n\t\t\tisSettlingRef.current = false;\n\t\t\tsetSettling( false );\n\t\t\tresetViewport();\n\t\t\tonGestureStart?.();\n\t\t},\n\t\t[ onGestureStart, resetViewport ]\n\t);\n\n\t/**\n\t * Handle resize end \u2014 settle the crop rect (re-center, fill height)\n\t * and reset the viewport pan back to neutral.\n\t */\n\tconst handleResizeEnd = useCallback( () => {\n\t\tisResizingRef.current = false;\n\t\tsetIsResizing( false );\n\t\tsetActiveHandle( null );\n\t\tisSettlingRef.current = true;\n\t\tsetSettling( true );\n\t\t// Reset viewport pan first so it transitions back to zero in sync\n\t\t// with the settle animation on the image.\n\t\tresetViewport();\n\t\tsettleCrop();\n\t\tonGestureEnd?.();\n\t\tclearTimeout( settleTimerRef.current );\n\t\tsettleTimerRef.current = setTimeout( () => {\n\t\t\tisSettlingRef.current = false;\n\t\t\tsetSettling( false );\n\t\t}, 200 );\n\t}, [ settleCrop, onGestureEnd, resetViewport ] );\n\n\tlet imageTransition: string | undefined;\n\tif ( settling ) {\n\t\timageTransition = 'transform 200ms ease-out';\n\t} else if ( isZooming ) {\n\t\timageTransition = 'transform 150ms linear';\n\t}\n\tconst settleStencilTransition = settling\n\t\t? 'left 200ms ease-out, top 200ms ease-out, width 200ms ease-out, height 200ms ease-out'\n\t\t: undefined;\n\n\t// Compute the image's CSS style.\n\tconst imageStyle = useMemo( (): React.CSSProperties => {\n\t\tif ( elementSize.width === 0 || elementSize.height === 0 ) {\n\t\t\treturn {};\n\t\t}\n\t\tconst centerX = ( canvasSize.width - elementSize.width ) / 2;\n\t\tconst centerY = ( canvasSize.height - elementSize.height ) / 2;\n\t\treturn {\n\t\t\twidth: elementSize.width,\n\t\t\theight: elementSize.height,\n\t\t\tmaxWidth: elementSize.width,\n\t\t\tmaxHeight: elementSize.height,\n\t\t\tleft: centerX,\n\t\t\ttop: centerY,\n\t\t\ttransform: transformString,\n\t\t\ttransition: imageTransition,\n\t\t};\n\t}, [ canvasSize, elementSize, transformString, imageTransition ] );\n\n\t// Viewport pan CSS transform for the stage div. Applied during resize\n\t// drags to keep handles visible when the crop extends past the canvas edge.\n\t// Transitions back to zero during the settle animation.\n\t// will-change promotes the stage to its own compositor layer while the\n\t// transform is active, keeping per-frame pan updates off the main thread.\n\tconst settleTransition = settling ? 'transform 200ms ease-out' : undefined;\n\tconst willChange = isResizing || settling ? 'transform' : undefined;\n\tlet stageStyle: React.CSSProperties | undefined;\n\tif ( viewportState.pan.x !== 0 || viewportState.pan.y !== 0 ) {\n\t\tstageStyle = {\n\t\t\ttransform: `translate(${ viewportState.pan.x }px, ${ viewportState.pan.y }px)`,\n\t\t\ttransition: settleTransition,\n\t\t\twillChange,\n\t\t};\n\t} else if ( settling ) {\n\t\tstageStyle = { transition: settleTransition, willChange };\n\t}\n\n\t// Forward the root element to the consumer's ref.\n\tconst setContainerRef = useCallback(\n\t\t( element: HTMLDivElement | null ) => {\n\t\t\tif ( typeof ref === 'function' ) {\n\t\t\t\tref( element );\n\t\t\t} else if ( ref ) {\n\t\t\t\t(\n\t\t\t\t\tref as React.MutableRefObject< HTMLDivElement | null >\n\t\t\t\t ).current = element;\n\t\t\t}\n\t\t},\n\t\t[ ref ]\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tref={ setContainerRef }\n\t\t\tclassName={ clsx(\n\t\t\t\t'wp-media-editor-image-editor',\n\t\t\t\tisDragging && 'wp-media-editor-image-editor--dragging',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t{ /*\n\t\t\t * The canvas is the interactive, inset surface. Handles and\n\t\t\t * the ARIA role/tabIndex live here so pointer geometry\n\t\t\t * (getBoundingClientRect on e.currentTarget) resolves against\n\t\t\t * the same box that crop math uses. The root stays as the\n\t\t\t * clipping shell for the dimming overlay's box-shadow.\n\t\t\t *\n\t\t\t * Not role=\"application\" \u2014 that disables the screen reader's\n\t\t\t * normal keyboard interception, too heavy-handed for a single\n\t\t\t * widget. Screen reader users get the ARIA live region below\n\t\t\t * as the announcement channel.\n\t\t\t */ }\n\t\t\t<div\n\t\t\t\tref={ canvasRef }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'wp-media-editor-image-editor__canvas',\n\t\t\t\t\tisInteractiveGrid &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--grid-interactive',\n\t\t\t\t\tshowInteractiveGrid &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--show-grid',\n\t\t\t\t\tsettling &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--settling',\n\t\t\t\t\t// Marks the cropper as in keyboard-interaction mode.\n\t\t\t\t\t// CSS uses :focus on the canvas to show the stencil\n\t\t\t\t\t// outline and :focus on a handle to show its ring,\n\t\t\t\t\t// so the class applies whenever any cropper element\n\t\t\t\t\t// has keyboard focus.\n\t\t\t\t\tisFocusVisible &&\n\t\t\t\t\t\t'wp-media-editor-image-editor__canvas--focus-visible'\n\t\t\t\t) }\n\t\t\t\ttabIndex={ 0 }\n\t\t\t\trole=\"group\"\n\t\t\t\taria-label={ __( 'Crop area' ) }\n\t\t\t\taria-describedby={\n\t\t\t\t\tisCropAreaFocused ? cropAreaDescriptionId : undefined\n\t\t\t\t}\n\t\t\t\tonFocus={ handleCropAreaFocus }\n\t\t\t\tonBlur={ handleCropAreaBlur }\n\t\t\t\t{ ...canvasHandlers }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tid={ cropAreaDescriptionId }\n\t\t\t\t\tstyle={ VISUALLY_HIDDEN_STYLE }\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'When this area is focused, use arrow keys to move the image and plus or minus to zoom. Tab to resize handles and controls.'\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t{ /*\n\t\t\t\t * The stage is an inner full-size div that receives the\n\t\t\t\t * viewport pan CSS transform. Keeping the transform here\n\t\t\t\t * (rather than on the canvas) means the canvas always stays\n\t\t\t\t * at its natural position, so the root div's background is\n\t\t\t\t * never exposed when the stage is panned during a resize drag.\n\t\t\t\t */ }\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"wp-media-editor-image-editor__stage\"\n\t\t\t\t\tdata-testid=\"cropper-stage\"\n\t\t\t\t\tstyle={ stageStyle }\n\t\t\t\t>\n\t\t\t\t\t{ /* The image layer */ }\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName=\"wp-media-editor-image-editor__image\"\n\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tonLoad={ handleImageLoad }\n\t\t\t\t\t\tstyle={ imageStyle }\n\t\t\t\t\t\tdraggable={ false }\n\t\t\t\t\t/>\n\n\t\t\t\t\t{ /* Dimming overlay outside the crop area */ }\n\t\t\t\t\t{ showDimming && (\n\t\t\t\t\t\t<DimmingOverlay\n\t\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\t\t\ttransition={ settleStencilTransition }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ /* The stencil (crop area with handles) */ }\n\t\t\t\t\t<StencilComponent\n\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\t\tonCropChange={ handleCropChange }\n\t\t\t\t\t\tonResizeStart={ handleResizeStart }\n\t\t\t\t\t\tonResizeEnd={ handleResizeEnd }\n\t\t\t\t\t\tonEscape={ handleEscape }\n\t\t\t\t\t\taspectRatio={ aspectRatio }\n\t\t\t\t\t\tfreeformCrop={ freeformCrop }\n\t\t\t\t\t\tstencilTransition={ settleStencilTransition }\n\t\t\t\t\t\tcropBounds={ cropBounds }\n\t\t\t\t\t\tminCropSize={ minCropSize }\n\t\t\t\t\t/>\n\n\t\t\t\t\t{ /* Rule-of-thirds grid */ }\n\t\t\t\t\t{ ( showGrid === true || isInteractiveGrid ) && (\n\t\t\t\t\t\t<GridOverlay\n\t\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ /* Live dimensions tooltip pinned to the dragged handle. */ }\n\t\t\t\t\t{ activeHandle && outputSize && (\n\t\t\t\t\t\t<DimensionsOverlay\n\t\t\t\t\t\t\tcropRect={ state.cropRect }\n\t\t\t\t\t\t\tcontainerSize={ canvasSize }\n\t\t\t\t\t\t\timageSize={ visualSize }\n\t\t\t\t\t\t\tactiveHandle={ activeHandle }\n\t\t\t\t\t\t\toutputWidth={ outputSize.width }\n\t\t\t\t\t\t\toutputHeight={ outputSize.height }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\n\t\t\t\t{ /* ARIA live region for screen reader announcements */ }\n\t\t\t\t<div\n\t\t\t\t\taria-live=\"polite\"\n\t\t\t\t\taria-atomic=\"true\"\n\t\t\t\t\tclassName=\"wp-media-editor-image-editor__aria-live\"\n\t\t\t\t\tstyle={ VISUALLY_HIDDEN_STYLE }\n\t\t\t\t>\n\t\t\t\t\t{ ariaMessage }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nconst CropperInnerWithRef = forwardRef< HTMLDivElement, CropperProps >(\n\tCropperInner\n);\n\nexport const Cropper = forwardRef< HTMLDivElement, CropperProps >(\n\t( props, ref ) => (\n\t\t<ViewportProvider>\n\t\t\t<CropperInnerWithRef { ...props } ref={ ref } />\n\t\t</ViewportProvider>\n\t)\n);\n"],
5
+ "mappings": ";AAIA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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