dune-react 0.0.43 → 0.0.45

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 (56) hide show
  1. package/dist/_virtual/_commonjsHelpers.js +6 -0
  2. package/dist/_virtual/index.js +4 -0
  3. package/dist/components/puck-base/media.d.ts +1 -0
  4. package/dist/components/puck-base/media.js +272 -129
  5. package/dist/components/puck-block/gallery-sections/static-grid/static-grid.js +14 -10
  6. package/dist/components/puck-block/testimonial-sections/bento-testimonial/component.js +7 -6
  7. package/dist/components/puck-core/core/props/index.js +7 -0
  8. package/dist/components/puck-core/core/with-editable.js +4 -5
  9. package/dist/components/shadcn/slider.js +1 -1
  10. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/algorithms/flipImageAlgorithm.js +44 -0
  11. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/algorithms/moveCoordinatesAlgorithm.js +8 -0
  12. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/algorithms/resizeCoordinatesAlgorithm.js +291 -0
  13. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/algorithms/rotateImageAlgorithm.js +38 -0
  14. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/algorithms/transformImageAlgorithm.js +84 -0
  15. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/animation/index.js +78 -0
  16. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/boundary/index.js +31 -0
  17. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/canvas/index.js +94 -0
  18. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/constants/index.js +8 -0
  19. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultAreaPositionRestrictions.js +51 -0
  20. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultAreaSizeRestrictions.js +30 -0
  21. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultBoundary.js +10 -0
  22. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultPosition.js +12 -0
  23. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultPositionRestrictions.js +17 -0
  24. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultSize.js +31 -0
  25. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultSizeRestrictions.js +16 -0
  26. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultStencilConstraints.js +13 -0
  27. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultVisibleArea.js +49 -0
  28. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/index.js +84 -0
  29. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/extensions/stencil-size/index.js +107 -0
  30. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/image/index.js +350 -0
  31. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/instance/AbstractCropperInstance.js +494 -0
  32. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/approximateSize.js +30 -0
  33. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/fitCoordinates.js +30 -0
  34. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/fitVisibleArea.js +26 -0
  35. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/helpers.js +125 -0
  36. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/imageTransforms.js +83 -0
  37. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/interactions.js +19 -0
  38. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/normalize.js +83 -0
  39. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/sizeRestrictions.js +58 -0
  40. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/service/utils.js +313 -0
  41. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/copyState.js +7 -0
  42. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/createState.js +41 -0
  43. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/moveCoordinates.js +15 -0
  44. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/reconcileState.js +44 -0
  45. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/resizeCoordinates.js +22 -0
  46. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/setBoundary.js +31 -0
  47. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/setCoordinates.js +83 -0
  48. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/setVisibleArea.js +18 -0
  49. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/state/transformImage.js +18 -0
  50. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/types/index.js +16 -0
  51. package/dist/node_modules/.pnpm/advanced-cropper@0.17.1/node_modules/advanced-cropper/utils/index.js +268 -0
  52. package/dist/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js +63 -0
  53. package/dist/node_modules/.pnpm/react-advanced-cropper@0.20.1_react@19.2.4/node_modules/react-advanced-cropper/dist/index.esm-bundler.js +1715 -0
  54. package/dist/node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.js +181 -0
  55. package/dist/style.css +406 -0
  56. package/package.json +21 -20
@@ -0,0 +1,1715 @@
1
+ import { __rest, __assign, __spreadArray, __read, __extends, __awaiter, __generator } from "../../../../tslib@2.8.1/node_modules/tslib/tslib.es6.js";
2
+ import React__default, { forwardRef, useImperativeHandle, useRef, useState, useMemo, useLayoutEffect, createRef, useEffect, Component } from "react";
3
+ import cn from "../../../../classnames@2.5.1/node_modules/classnames/index.js";
4
+ import { aspectRatio, defaultSize, fixedStencilConstraints, fixedStencil, sizeRestrictions } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/extensions/stencil-size/index.js";
5
+ import { withDefaultSizeRestrictions, createDefaultSettings } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/index.js";
6
+ import { getBackgroundStyle, getPreviewStyle, loadImage } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/image/index.js";
7
+ import { createImage, getImageStyle, getStyleTransforms } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/image/index.js";
8
+ import { drawCroppedArea } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/canvas/index.js";
9
+ import { prepareSource, updateCanvas } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/canvas/index.js";
10
+ import { isUndefined, isFunction, getDirectionNames, isCardinalDirection, isObject, deepCompare, isNumber, distance, debounce, isGreater, promiseTimeout, getOptions } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/utils/index.js";
11
+ import { deepClone, emptyCoordinates, isArray, isBlob, isBoolean, isCrossOriginURL, isDataUrl, isLocal, isLower, isNaN, isNumeric, isRoughlyEqual, isString, parseNumber, sign } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/utils/index.js";
12
+ import { getStencilCoordinates, isInitializedState, getAreaSizeRestrictions, getAreaPositionRestrictions, getPositionRestrictions } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/service/helpers.js";
13
+ import { getAspectRatio, getCoefficient, getDefaultCoordinates, getDefaultTransforms, getDefaultVisibleArea, getMinimumSize, getRoundedCoordinates, getSizeRestrictions, getTransformedImageSize, isConsistentState } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/service/helpers.js";
14
+ import { createAspectRatio, ratio, applyScale, fitToSizeRestrictions, applyMove, diff, getCenter, moveToPositionRestrictions, mergePositionRestrictions, coordinatesToPositionRestrictions } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/service/utils.js";
15
+ import { applyDirections, aspectRatioIntersection, fitToPositionRestrictions, getBrokenRatio, getCloserSize, getIntersections, getOppositeSide, inverseMove, isConsistentPosition, isConsistentSize, maxScale, minScale, positionToSizeRestrictions, resizeToSizeRestrictions, rotatePoint, rotateSize, sizeDistance } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/service/utils.js";
16
+ import { copyState } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/state/copyState.js";
17
+ import { Animation } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/animation/index.js";
18
+ import { getEmptyInteractions } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/service/interactions.js";
19
+ import { hasInteractions } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/service/interactions.js";
20
+ import { AbstractCropperInstance } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/instance/AbstractCropperInstance.js";
21
+ import { touchesToImageTransform, wheelEventToImageTransform } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/service/imageTransforms.js";
22
+ import { stretchPreviewBoundary, stretchCropperBoundary } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/boundary/index.js";
23
+ import { fillBoundary } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultBoundary.js";
24
+ import { defaultStencilConstraints } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/defaults/defaultStencilConstraints.js";
25
+ import { ImageRestriction } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/types/index.js";
26
+ import { Priority } from "../../../../advanced-cropper@0.17.1/node_modules/advanced-cropper/types/index.js";
27
+ function hybridStencilAutoZoomAlgorithm(state, settings) {
28
+ if (isInitializedState(state)) {
29
+ var result = copyState(state);
30
+ var stencil = {
31
+ width: 0,
32
+ height: 0
33
+ };
34
+ if (ratio(result.boundary) > ratio(result.coordinates)) {
35
+ stencil.height = result.boundary.height * 0.8;
36
+ stencil.width = stencil.height * ratio(result.coordinates);
37
+ } else {
38
+ stencil.width = result.boundary.width * 0.8;
39
+ stencil.height = stencil.width * ratio(result.coordinates);
40
+ }
41
+ result.visibleArea = applyScale(result.visibleArea, result.coordinates.width * result.boundary.width / (result.visibleArea.width * stencil.width));
42
+ var scale = fitToSizeRestrictions(result.visibleArea, getAreaSizeRestrictions(result, settings));
43
+ result.visibleArea = applyScale(result.visibleArea, scale);
44
+ if (scale !== 1) {
45
+ stencil.height /= scale;
46
+ stencil.width /= scale;
47
+ }
48
+ result.visibleArea = applyMove(result.visibleArea, diff(getCenter(result.coordinates), getCenter(result.visibleArea)));
49
+ result.visibleArea = moveToPositionRestrictions(result.visibleArea, getAreaPositionRestrictions(result, settings));
50
+ result.coordinates = moveToPositionRestrictions(result.coordinates, mergePositionRestrictions(coordinatesToPositionRestrictions(result.visibleArea), getPositionRestrictions(result, settings)));
51
+ return result;
52
+ }
53
+ return state;
54
+ }
55
+ function hybridStencilAutoZoom(state, settings, action) {
56
+ if (action.immediately) {
57
+ return hybridStencilAutoZoomAlgorithm(state, settings);
58
+ }
59
+ return state;
60
+ }
61
+ function deprecationWarning(text) {
62
+ if (process.env.NODE_ENV === "development") {
63
+ console.warn("Deprecation warning: ".concat(text));
64
+ }
65
+ }
66
+ function useDeprecationWarning() {
67
+ var fired = useRef([]);
68
+ return function(message) {
69
+ if (fired.current.indexOf(message) === -1) {
70
+ deprecationWarning(message);
71
+ fired.current.push(message);
72
+ }
73
+ };
74
+ }
75
+ function createCropper(render) {
76
+ return forwardRef(render);
77
+ }
78
+ function useFirstMountState() {
79
+ var isFirst = useRef(true);
80
+ if (isFirst.current) {
81
+ isFirst.current = false;
82
+ return true;
83
+ }
84
+ return isFirst.current;
85
+ }
86
+ var useUpdateEffect = function(effect, deps) {
87
+ var isFirstMount = useFirstMountState();
88
+ useEffect(function() {
89
+ if (!isFirstMount) {
90
+ return effect();
91
+ }
92
+ }, deps);
93
+ };
94
+ function useStateWithCallback(initialState) {
95
+ var _a = __read(useState(initialState), 2), state = _a[0], setState = _a[1];
96
+ var _b = __read(useState(null), 2), callback = _b[0], setCallback = _b[1];
97
+ var previousState = useRef(initialState);
98
+ useUpdateEffect(function() {
99
+ if (callback) {
100
+ callback(state, previousState.current);
101
+ }
102
+ }, [callback]);
103
+ return [
104
+ state,
105
+ function(value, callback2) {
106
+ previousState.current = state;
107
+ setState(value);
108
+ setCallback(function() {
109
+ return callback2;
110
+ });
111
+ }
112
+ ];
113
+ }
114
+ var CropperInstance = (
115
+ /** @class */
116
+ function(_super) {
117
+ __extends(CropperInstance2, _super);
118
+ function CropperInstance2(props, onChange) {
119
+ var _this = _super.call(this) || this;
120
+ _this.props = props;
121
+ _this.notify = onChange;
122
+ _this.data = {
123
+ state: null,
124
+ transitions: false,
125
+ interactions: getEmptyInteractions()
126
+ };
127
+ return _this;
128
+ }
129
+ CropperInstance2.prototype.getProps = function() {
130
+ return this.props();
131
+ };
132
+ CropperInstance2.prototype.setData = function(data) {
133
+ this.data = data;
134
+ this.notify();
135
+ };
136
+ CropperInstance2.prototype.getData = function() {
137
+ return this.data;
138
+ };
139
+ return CropperInstance2;
140
+ }(AbstractCropperInstance)
141
+ );
142
+ function useForceRerender() {
143
+ var _a = __read(useState({}), 2);
144
+ _a[0];
145
+ var setTick = _a[1];
146
+ return function() {
147
+ setTick({});
148
+ };
149
+ }
150
+ function usePersistentFunction(props) {
151
+ var propsRef = useRef(props);
152
+ propsRef.current = props;
153
+ return function() {
154
+ var args = [];
155
+ for (var _i = 0; _i < arguments.length; _i++) {
156
+ args[_i] = arguments[_i];
157
+ }
158
+ return propsRef.current.apply(propsRef, __spreadArray([], __read(args), false));
159
+ };
160
+ }
161
+ function useCropperInstance(props) {
162
+ var rerender = useForceRerender();
163
+ var getProps = usePersistentFunction(function() {
164
+ var _a = props(), settings = _a.settings, parameters = __rest(_a, ["settings"]);
165
+ var extendedSettings = __assign({ imageRestriction: ImageRestriction.fitArea, transformImage: {
166
+ adjustStencil: true
167
+ } }, settings);
168
+ var extendedParameters = __assign({ transitions: true }, parameters);
169
+ return __assign({ settings: __assign(__assign({}, extendedSettings), createDefaultSettings(extendedSettings)) }, extendedParameters);
170
+ });
171
+ var cropper = useRef(new CropperInstance(getProps, rerender));
172
+ return cropper.current;
173
+ }
174
+ function useCropperImage(options) {
175
+ var src = options.src, onLoadingStart = options.onLoadingStart, onLoadingEnd = options.onLoadingEnd, onError = options.onError, onLoad = options.onLoad, crossOrigin = options.crossOrigin, checkOrientation = options.checkOrientation, canvas = options.canvas, unloadTime = options.unloadTime;
176
+ var _a = __read(useState(null), 2), image = _a[0], setImage = _a[1];
177
+ var _b = __read(useState(false), 2), loading = _b[0], setLoading = _b[1];
178
+ var _c = __read(useStateWithCallback(false), 2), loaded = _c[0], setLoaded = _c[1];
179
+ var currentSrc = useRef(null);
180
+ useEffect(function() {
181
+ if (currentSrc.current !== src) {
182
+ currentSrc.current = src || null;
183
+ setLoaded(false);
184
+ if (src) {
185
+ setLoading(true);
186
+ onLoadingStart === null || onLoadingStart === void 0 ? void 0 : onLoadingStart();
187
+ var promises = [
188
+ loadImage(src, {
189
+ crossOrigin: isUndefined(crossOrigin) ? canvas : crossOrigin,
190
+ checkOrientation
191
+ })
192
+ ];
193
+ if (loaded && unloadTime) {
194
+ promises.push(promiseTimeout(unloadTime));
195
+ }
196
+ Promise.all(promises).then(function(responses) {
197
+ var _a2 = __read(responses, 1), image2 = _a2[0];
198
+ if (currentSrc.current === src) {
199
+ setImage(image2);
200
+ }
201
+ }).catch(function() {
202
+ if (currentSrc.current === src) {
203
+ onError === null || onError === void 0 ? void 0 : onError();
204
+ }
205
+ }).finally(function() {
206
+ if (currentSrc.current === src) {
207
+ onLoadingEnd === null || onLoadingEnd === void 0 ? void 0 : onLoadingEnd();
208
+ setLoading(false);
209
+ }
210
+ });
211
+ } else {
212
+ if (unloadTime) {
213
+ promiseTimeout(unloadTime).then(function() {
214
+ if (currentSrc.current === src) {
215
+ setImage(null);
216
+ }
217
+ });
218
+ } else {
219
+ setImage(null);
220
+ }
221
+ }
222
+ }
223
+ }, [src, image]);
224
+ useEffect(function() {
225
+ if (image) {
226
+ setLoaded(true, function() {
227
+ onLoad === null || onLoad === void 0 ? void 0 : onLoad(image);
228
+ });
229
+ }
230
+ }, [image]);
231
+ return {
232
+ isLoading: function() {
233
+ return loading;
234
+ },
235
+ isLoaded: function() {
236
+ return loaded;
237
+ },
238
+ getImage: function() {
239
+ return image;
240
+ },
241
+ setImage
242
+ };
243
+ }
244
+ var useWindowResize = function(callback) {
245
+ var callbackRef = useRef(callback);
246
+ var internalCallback = function() {
247
+ if (callbackRef.current) {
248
+ callbackRef.current();
249
+ }
250
+ };
251
+ useEffect(function() {
252
+ callbackRef.current = callback;
253
+ }, [callback]);
254
+ useEffect(function() {
255
+ window.addEventListener("resize", internalCallback);
256
+ window.addEventListener("orientationchange", internalCallback);
257
+ return function() {
258
+ window.removeEventListener("resize", internalCallback);
259
+ window.removeEventListener("orientationchange", internalCallback);
260
+ };
261
+ }, []);
262
+ };
263
+ function useCropperAutoReconcile(cropper, enabled) {
264
+ if (enabled === void 0) {
265
+ enabled = true;
266
+ }
267
+ var _a = __read(useState(enabled), 2), active = _a[0], setActive = _a[1];
268
+ useLayoutEffect(function() {
269
+ if (active && !cropper.hasInteractions()) {
270
+ cropper.reconcileState();
271
+ }
272
+ });
273
+ return {
274
+ pause: function() {
275
+ setActive(false);
276
+ },
277
+ resume: function() {
278
+ setActive(true);
279
+ }
280
+ };
281
+ }
282
+ function useAbstractCropper(props) {
283
+ var _this = this;
284
+ var _a = props(), src = _a.src, onReady = _a.onReady, onError = _a.onError, onUpdate = _a.onUpdate, _b = _a.canvas, canvas = _b === void 0 ? true : _b, _c = _a.unloadTime, unloadTime = _c === void 0 ? 500 : _c, _d = _a.crossOrigin, crossOrigin = _d === void 0 ? true : _d, _e = _a.checkOrientation, checkOrientation = _e === void 0 ? true : _e, _f = _a.autoReconcileState, autoReconcileState = _f === void 0 ? true : _f;
285
+ var imageRef = useRef(null);
286
+ var boundaryRef = useRef(null);
287
+ var canvasRef = useRef(null);
288
+ var cropperRef = useRef(null);
289
+ var _g = __read(useStateWithCallback(null), 2), currentImage = _g[0], setCurrentImage = _g[1];
290
+ var cropper = useCropperInstance(function() {
291
+ return __assign(__assign({}, props()), { getInstance: function() {
292
+ return cropperRef.current;
293
+ } });
294
+ });
295
+ var cropperImage = useCropperImage({
296
+ src,
297
+ crossOrigin,
298
+ checkOrientation,
299
+ unloadTime,
300
+ canvas,
301
+ onError: function() {
302
+ if (cropperRef.current) {
303
+ onError === null || onError === void 0 ? void 0 : onError(cropperRef.current);
304
+ }
305
+ }
306
+ });
307
+ var autoReconcile = useCropperAutoReconcile(cropper, autoReconcileState);
308
+ var resetCropper = function() {
309
+ return __awaiter(_this, void 0, void 0, function() {
310
+ var image_1, boundary_1;
311
+ var _a2;
312
+ return __generator(this, function(_b2) {
313
+ switch (_b2.label) {
314
+ case 0:
315
+ if (!boundaryRef.current) return [3, 2];
316
+ autoReconcile.pause();
317
+ image_1 = cropperImage.getImage();
318
+ return [4, (_a2 = boundaryRef.current) === null || _a2 === void 0 ? void 0 : _a2.stretchTo(image_1)];
319
+ case 1:
320
+ boundary_1 = _b2.sent();
321
+ setCurrentImage(image_1, function() {
322
+ if (boundary_1 && image_1) {
323
+ cropper.reset(boundary_1, image_1);
324
+ } else {
325
+ cropper.clear();
326
+ }
327
+ });
328
+ autoReconcile.resume();
329
+ _b2.label = 2;
330
+ case 2:
331
+ return [
332
+ 2
333
+ /*return*/
334
+ ];
335
+ }
336
+ });
337
+ });
338
+ };
339
+ var refreshCropper = function() {
340
+ return __awaiter(_this, void 0, void 0, function() {
341
+ var image, boundary, state;
342
+ var _a2;
343
+ return __generator(this, function(_b2) {
344
+ switch (_b2.label) {
345
+ case 0:
346
+ if (!boundaryRef.current) return [3, 2];
347
+ autoReconcile.pause();
348
+ image = cropperImage.getImage();
349
+ return [4, (_a2 = boundaryRef.current) === null || _a2 === void 0 ? void 0 : _a2.stretchTo(image)];
350
+ case 1:
351
+ boundary = _b2.sent();
352
+ if (boundary && image) {
353
+ state = cropper.getState();
354
+ if (state) {
355
+ if (boundary.width !== state.boundary.width || boundary.height !== state.boundary.height) {
356
+ cropper.setBoundary(boundary);
357
+ cropper.reconcileState();
358
+ }
359
+ } else {
360
+ cropper.reset(boundary, image);
361
+ }
362
+ } else {
363
+ cropper.clear();
364
+ }
365
+ autoReconcile.resume();
366
+ _b2.label = 2;
367
+ case 2:
368
+ return [
369
+ 2
370
+ /*return*/
371
+ ];
372
+ }
373
+ });
374
+ });
375
+ };
376
+ var cropperInterface = {
377
+ reset: function() {
378
+ return resetCropper();
379
+ },
380
+ refresh: function() {
381
+ return refreshCropper();
382
+ },
383
+ setImage: function(image) {
384
+ return setCurrentImage(image);
385
+ },
386
+ reconcileState: cropper.reconcileState,
387
+ moveCoordinates: cropper.moveCoordinates,
388
+ moveCoordinatesEnd: cropper.moveCoordinatesEnd,
389
+ resizeCoordinates: cropper.resizeCoordinates,
390
+ clear: cropper.clear,
391
+ resizeCoordinatesEnd: cropper.resizeCoordinatesEnd,
392
+ moveImage: cropper.moveImage,
393
+ flipImage: cropper.flipImage,
394
+ zoomImage: cropper.zoomImage,
395
+ rotateImage: cropper.rotateImage,
396
+ transformImage: cropper.transformImage,
397
+ transformImageEnd: cropper.transformImageEnd,
398
+ setCoordinates: cropper.setCoordinates,
399
+ setVisibleArea: cropper.setVisibleArea,
400
+ startTransitions: cropper.startTransitions,
401
+ setState: cropper.setState,
402
+ hasInteractions: cropper.hasInteractions,
403
+ getStencilCoordinates: cropper.getStencilCoordinates,
404
+ getCoordinates: cropper.getCoordinates,
405
+ getVisibleArea: cropper.getVisibleArea,
406
+ getTransforms: cropper.getTransforms,
407
+ getTransitions: cropper.getTransitions,
408
+ getInteractions: cropper.getInteractions,
409
+ getSettings: cropper.getSettings,
410
+ getState: cropper.getState,
411
+ getDefaultState: function() {
412
+ var state = cropper.getState();
413
+ var image = cropperImage.getImage();
414
+ if (state && image) {
415
+ return cropper.createDefaultState(state.boundary, image);
416
+ } else {
417
+ return null;
418
+ }
419
+ },
420
+ getCanvas: function(options) {
421
+ var state = cropper.getState();
422
+ if (imageRef.current && canvasRef.current && state) {
423
+ return canvasRef.current.draw(state, imageRef.current, options);
424
+ } else {
425
+ return null;
426
+ }
427
+ },
428
+ getImage: function() {
429
+ return currentImage ? __assign({}, currentImage) : null;
430
+ },
431
+ isLoading: cropperImage.isLoading,
432
+ isLoaded: cropperImage.isLoaded
433
+ };
434
+ useWindowResize(function() {
435
+ refreshCropper();
436
+ });
437
+ useUpdateEffect(function() {
438
+ resetCropper();
439
+ }, [cropperImage.getImage()]);
440
+ useUpdateEffect(function() {
441
+ if (cropperRef.current && currentImage) {
442
+ onReady === null || onReady === void 0 ? void 0 : onReady(cropperRef.current);
443
+ }
444
+ }, [currentImage]);
445
+ useUpdateEffect(function() {
446
+ if (cropperRef.current) {
447
+ onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(cropperRef.current);
448
+ }
449
+ }, [cropperImage.isLoaded(), cropperImage.isLoading()]);
450
+ useImperativeHandle(cropperRef, function() {
451
+ return cropperInterface;
452
+ });
453
+ return {
454
+ cropper: cropperInterface,
455
+ refs: {
456
+ image: imageRef,
457
+ boundary: boundaryRef,
458
+ canvas: canvasRef
459
+ },
460
+ image: currentImage
461
+ };
462
+ }
463
+ var StretchableBoundary = forwardRef(function(_a, ref) {
464
+ var className = _a.className, style = _a.style, stretcherClassName = _a.stretcherClassName, contentClassName = _a.contentClassName, _b = _a.stretchAlgorithm, stretchAlgorithm = _b === void 0 ? stretchCropperBoundary : _b, _c = _a.sizeAlgorithm, sizeAlgorithm = _c === void 0 ? fillBoundary : _c, children = _a.children;
465
+ var stretcherRef = useRef(null);
466
+ var boundaryRef = useRef(null);
467
+ useImperativeHandle(ref, function() {
468
+ return {
469
+ reset: function() {
470
+ var stretcher = stretcherRef.current;
471
+ if (stretcher) {
472
+ stretcher.style.height = "";
473
+ stretcher.style.width = "";
474
+ }
475
+ },
476
+ stretchTo: function(size) {
477
+ var stretcher = stretcherRef.current;
478
+ var boundary = boundaryRef.current;
479
+ if ((size === null || size === void 0 ? void 0 : size.width) && (size === null || size === void 0 ? void 0 : size.height) && stretcher && boundary) {
480
+ stretchAlgorithm(boundary, stretcher, size);
481
+ var result = sizeAlgorithm(boundary, size);
482
+ return Promise.resolve(result.width && result.height ? result : null);
483
+ } else {
484
+ if (stretcher) {
485
+ stretcher.style.height = "";
486
+ stretcher.style.width = "";
487
+ }
488
+ return Promise.resolve(null);
489
+ }
490
+ }
491
+ };
492
+ });
493
+ return React__default.createElement(
494
+ "div",
495
+ { ref: boundaryRef, style, className: cn("advanced-cropper-boundary", className) },
496
+ React__default.createElement("div", { ref: stretcherRef, className: cn(["advanced-cropper-boundary__stretcher", stretcherClassName]) }),
497
+ React__default.createElement("div", { className: cn(["advanced-cropper-boundary__content", contentClassName]) }, children)
498
+ );
499
+ });
500
+ StretchableBoundary.displayName = "StretchableBoundary";
501
+ var CropperFade = function(_a) {
502
+ var visible = _a.visible, className = _a.className, style = _a.style, children = _a.children;
503
+ return React__default.createElement("div", { style, className: cn(className, "advanced-cropper-fade", Boolean(visible) && "advanced-cropper-fade--visible") }, children);
504
+ };
505
+ var CropperWrapper = function(_a) {
506
+ var cropper = _a.cropper, children = _a.children, className = _a.className, style = _a.style;
507
+ var state = cropper ? cropper.getState() : null;
508
+ var loaded = cropper ? cropper.isLoaded() : false;
509
+ return React__default.createElement(
510
+ "div",
511
+ { className: cn(className, "advanced-cropper-wrapper"), style },
512
+ React__default.createElement(CropperFade, { visible: state && loaded, className: "advanced-cropper-wrapper__fade" }, children)
513
+ );
514
+ };
515
+ function preventDefault(e) {
516
+ e.preventDefault();
517
+ }
518
+ var CropperBackgroundImage = forwardRef(function(_a, ref) {
519
+ var className = _a.className, style = _a.style, cropper = _a.cropper, _b = _a.crossOrigin, crossOrigin = _b === void 0 ? true : _b;
520
+ var state = cropper.getState();
521
+ var transitions = cropper.getTransitions();
522
+ var image = cropper.getImage();
523
+ var transformStyles = image && state ? getBackgroundStyle(image, state, transitions) : {};
524
+ var src = image ? image.src : void 0;
525
+ return src ? React__default.createElement("img", { key: src, ref, className: cn("advanced-cropper-background-image", className), src, crossOrigin: crossOrigin === true ? "anonymous" : crossOrigin || void 0, style: __assign(__assign({}, transformStyles), style), onMouseDown: preventDefault }) : null;
526
+ });
527
+ CropperBackgroundImage.displayName = "CropperBackgroundImage";
528
+ var CropperCanvas = forwardRef(function(_, ref) {
529
+ var canvasRef = useRef(null);
530
+ var spareCanvasRef = useRef(null);
531
+ useImperativeHandle(ref, function() {
532
+ return {
533
+ draw: function(state, image, options) {
534
+ if (options === void 0) {
535
+ options = {};
536
+ }
537
+ if (image && canvasRef.current && spareCanvasRef.current) {
538
+ return drawCroppedArea(state, image, canvasRef.current, spareCanvasRef.current, options);
539
+ } else {
540
+ return null;
541
+ }
542
+ }
543
+ };
544
+ });
545
+ return React__default.createElement(
546
+ React__default.Fragment,
547
+ null,
548
+ React__default.createElement("canvas", { className: "advanced-cropper-canvas", ref: canvasRef }),
549
+ React__default.createElement("canvas", { className: "advanced-cropper-canvas", ref: spareCanvasRef })
550
+ );
551
+ });
552
+ CropperCanvas.displayName = "CropperCanvas";
553
+ var DraggableElement = (
554
+ /** @class */
555
+ function(_super) {
556
+ __extends(DraggableElement2, _super);
557
+ function DraggableElement2(props) {
558
+ var _this = _super.call(this, props) || this;
559
+ _this.processMove = function(e, newTouches) {
560
+ var _a;
561
+ var container = _this.container.current;
562
+ if (container && _this.touches.length) {
563
+ var _b = container.getBoundingClientRect(), left = _b.left, top_1 = _b.top;
564
+ if (_this.touches.length === 1 && newTouches.length === 1) {
565
+ if (_this.props.onMove) {
566
+ var movingToAnchor = {
567
+ left: Math.abs(newTouches[0].clientX - _this.anchor.left - left) < Math.abs(_this.touches[0].clientX - _this.anchor.left - left),
568
+ top: Math.abs(newTouches[0].clientY - _this.anchor.top - top_1) < Math.abs(_this.touches[0].clientY - _this.anchor.top - top_1)
569
+ };
570
+ var direction = {
571
+ left: 0,
572
+ top: 0
573
+ };
574
+ if (!_this.props.useAnchor || !movingToAnchor.left) {
575
+ direction.left = newTouches[0].clientX - _this.touches[0].clientX;
576
+ }
577
+ if (!_this.props.useAnchor || !movingToAnchor.top) {
578
+ direction.top = newTouches[0].clientY - _this.touches[0].clientY;
579
+ }
580
+ (_a = _this.props) === null || _a === void 0 ? void 0 : _a.onMove(direction, e);
581
+ _this.touches = __spreadArray([], __read(newTouches), false);
582
+ }
583
+ }
584
+ }
585
+ };
586
+ _this.processEnd = function() {
587
+ var _a = _this.props, onMoveEnd = _a.onMoveEnd, onLeave = _a.onLeave;
588
+ if (!_this.props.disabled && _this.touches.length) {
589
+ onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd();
590
+ }
591
+ if (_this.hovered) {
592
+ onLeave === null || onLeave === void 0 ? void 0 : onLeave();
593
+ _this.hovered = false;
594
+ }
595
+ _this.touches = [];
596
+ };
597
+ _this.initAnchor = function(touch) {
598
+ var container = _this.container.current;
599
+ if (container) {
600
+ var _a = container.getBoundingClientRect(), left = _a.left, top_2 = _a.top;
601
+ _this.anchor = {
602
+ left: touch.clientX - left,
603
+ top: touch.clientY - top_2
604
+ };
605
+ }
606
+ };
607
+ _this.onMouseOver = function() {
608
+ var _a = _this.props, onEnter = _a.onEnter, disabled = _a.disabled;
609
+ if (!_this.hovered && !disabled) {
610
+ _this.hovered = true;
611
+ onEnter === null || onEnter === void 0 ? void 0 : onEnter();
612
+ }
613
+ };
614
+ _this.onMouseLeave = function() {
615
+ var onLeave = _this.props.onLeave;
616
+ if (_this.hovered && !_this.touches.length) {
617
+ _this.hovered = false;
618
+ onLeave === null || onLeave === void 0 ? void 0 : onLeave();
619
+ }
620
+ };
621
+ _this.onTouchStart = function(e) {
622
+ var _a = _this.props, onEnter = _a.onEnter, onMoveStart = _a.onMoveStart, disabled = _a.disabled;
623
+ if (e.cancelable) {
624
+ _this.touches = Array.from(e.touches);
625
+ var shouldStartMove = !disabled && e.touches.length === 1;
626
+ if (shouldStartMove) {
627
+ _this.touches = Array.from(e.touches);
628
+ onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart();
629
+ }
630
+ if (!_this.hovered && !disabled) {
631
+ _this.hovered = true;
632
+ onEnter === null || onEnter === void 0 ? void 0 : onEnter();
633
+ }
634
+ if (_this.started || shouldStartMove) {
635
+ e.preventDefault();
636
+ e.stopPropagation();
637
+ }
638
+ }
639
+ };
640
+ _this.onTouchEnd = function() {
641
+ _this.started = false;
642
+ _this.processEnd();
643
+ };
644
+ _this.onTouchMove = function(e) {
645
+ if (_this.touches.length >= 1) {
646
+ if (_this.started) {
647
+ _this.processMove(e, Array.from(e.touches));
648
+ e.preventDefault();
649
+ e.stopPropagation();
650
+ } else if (distance({ left: _this.touches[0].clientX, top: _this.touches[0].clientY }, { left: e.touches[0].clientX, top: e.touches[0].clientY }) > (_this.props.activationDistance || 0)) {
651
+ _this.initAnchor({
652
+ clientX: e.touches[0].clientX,
653
+ clientY: e.touches[0].clientY
654
+ });
655
+ _this.started = true;
656
+ }
657
+ }
658
+ };
659
+ _this.onMouseDown = function(e) {
660
+ var _a = _this.props, onMoveStart = _a.onMoveStart, disabled = _a.disabled;
661
+ if (!disabled && e.button === 0) {
662
+ var touch = {
663
+ clientX: e.clientX,
664
+ clientY: e.clientY
665
+ };
666
+ _this.touches = [touch];
667
+ _this.initAnchor(touch);
668
+ e.stopPropagation();
669
+ onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart();
670
+ }
671
+ };
672
+ _this.onMouseMove = function(e) {
673
+ if (!_this.props.disabled && _this.touches.length) {
674
+ _this.processMove(e, [
675
+ {
676
+ clientX: e.clientX,
677
+ clientY: e.clientY
678
+ }
679
+ ]);
680
+ if (e.preventDefault && e.cancelable) {
681
+ e.preventDefault();
682
+ }
683
+ e.stopPropagation();
684
+ }
685
+ };
686
+ _this.onMouseUp = function() {
687
+ _this.processEnd();
688
+ };
689
+ _this.touches = [];
690
+ _this.hovered = false;
691
+ _this.started = false;
692
+ _this.anchor = {
693
+ left: 0,
694
+ top: 0
695
+ };
696
+ _this.container = createRef();
697
+ return _this;
698
+ }
699
+ DraggableElement2.prototype.componentWillUnmount = function() {
700
+ window.removeEventListener("mouseup", this.onMouseUp);
701
+ window.removeEventListener("mousemove", this.onMouseMove);
702
+ window.removeEventListener("touchmove", this.onTouchMove);
703
+ window.removeEventListener("touchend", this.onTouchEnd);
704
+ var container = this.container.current;
705
+ if (container) {
706
+ container.removeEventListener("touchstart", this.onTouchStart);
707
+ container.removeEventListener("mousedown", this.onMouseDown);
708
+ }
709
+ };
710
+ DraggableElement2.prototype.componentDidMount = function() {
711
+ window.addEventListener("mouseup", this.onMouseUp, { passive: false });
712
+ window.addEventListener("mousemove", this.onMouseMove, { passive: false });
713
+ window.addEventListener("touchmove", this.onTouchMove, { passive: false });
714
+ window.addEventListener("touchend", this.onTouchEnd, { passive: false });
715
+ var container = this.container.current;
716
+ if (container) {
717
+ container.addEventListener("touchstart", this.onTouchStart, {
718
+ passive: false
719
+ });
720
+ container.addEventListener("mousedown", this.onMouseDown, {
721
+ passive: false
722
+ });
723
+ }
724
+ };
725
+ DraggableElement2.prototype.componentDidUpdate = function(prevProps) {
726
+ if (this.props.disabled && !prevProps.disabled) {
727
+ this.touches = [];
728
+ }
729
+ };
730
+ DraggableElement2.prototype.render = function() {
731
+ var _a = this.props, children = _a.children, className = _a.className;
732
+ return React__default.createElement("div", { className: cn("advanced-cropper-draggable-element", className), ref: this.container, onMouseOver: this.onMouseOver, onMouseLeave: this.onMouseLeave }, children);
733
+ };
734
+ DraggableElement2.defaultProps = {
735
+ disabled: false,
736
+ activationDistance: 30,
737
+ useAnchor: true,
738
+ rerender: true
739
+ };
740
+ return DraggableElement2;
741
+ }(Component)
742
+ );
743
+ var LineWrapper = function(_a) {
744
+ var position = _a.position, className = _a.className, disabled = _a.disabled, onDrag = _a.onDrag, onDragEnd = _a.onDragEnd, onLeave = _a.onLeave, onEnter = _a.onEnter, children = _a.children;
745
+ return React__default.createElement(
746
+ DraggableElement,
747
+ { className: cn([
748
+ "advanced-cropper-line-wrapper",
749
+ position && "advanced-cropper-line-wrapper--".concat(position),
750
+ disabled && "advanced-cropper-line-wrapper--disabled",
751
+ className
752
+ ]), disabled, onMove: onDrag, onMoveEnd: onDragEnd, onLeave, onEnter, activationDistance: 0 },
753
+ React__default.createElement("div", { className: cn([
754
+ "advanced-cropper-line-wrapper__content",
755
+ position && "advanced-cropper-line-wrapper__content--".concat(position)
756
+ ]) }, children)
757
+ );
758
+ };
759
+ var SimpleLine = function(_a) {
760
+ var _b, _c;
761
+ var position = _a.position, hoverClassName = _a.hoverClassName, wrapperClassName = _a.wrapperClassName, defaultClassName = _a.defaultClassName, disabled = _a.disabled, onMove = _a.onMove, onMoveEnd = _a.onMoveEnd;
762
+ var _d = __read(useState(false), 2), hover = _d[0], setHover = _d[1];
763
+ var onEnter = function() {
764
+ setHover(true);
765
+ };
766
+ var onLeave = function() {
767
+ setHover(false);
768
+ };
769
+ return React__default.createElement(
770
+ LineWrapper,
771
+ { className: cn("advanced-cropper-simple-line-wrapper", wrapperClassName, (_b = {}, _b["advanced-cropper-simple-line-wrapper--".concat(position)] = !!position, _b)), position, disabled, onDrag: onMove, onDragEnd: onMoveEnd, onLeave, onEnter },
772
+ React__default.createElement("div", { className: cn("advanced-cropper-simple-line", hover && "advanced-cropper-simple-line--hover", defaultClassName, hover && hoverClassName, (_c = {}, _c["advanced-cropper-simple-line--".concat(position)] = !!position, _c)) })
773
+ );
774
+ };
775
+ var HandlerWrapper = function(_a) {
776
+ var horizontalPosition = _a.horizontalPosition, verticalPosition = _a.verticalPosition, className = _a.className, disabled = _a.disabled, onDrag = _a.onDrag, onDragEnd = _a.onDragEnd, onLeave = _a.onLeave, onEnter = _a.onEnter, children = _a.children, style = _a.style;
777
+ var position = horizontalPosition || verticalPosition ? getDirectionNames(horizontalPosition, verticalPosition).snakeCase : null;
778
+ return React__default.createElement(
779
+ "div",
780
+ { style, className: cn(className, "advanced-cropper-handler-wrapper", position && "advanced-cropper-handler-wrapper--".concat(position), disabled && "advanced-cropper-handler-wrapper--disabled") },
781
+ React__default.createElement(DraggableElement, { className: "advanced-cropper-handler-wrapper__draggable", disabled, onMove: onDrag, onMoveEnd: onDragEnd, onLeave, onEnter, activationDistance: 0 }, children)
782
+ );
783
+ };
784
+ var SimpleHandler = function(_a) {
785
+ var _b;
786
+ var verticalPosition = _a.verticalPosition, horizontalPosition = _a.horizontalPosition, hoverClassName = _a.hoverClassName, wrapperClassName = _a.wrapperClassName, defaultClassName = _a.defaultClassName, wrapperStyle = _a.wrapperStyle, disabled = _a.disabled, onMove = _a.onMove, onMoveEnd = _a.onMoveEnd;
787
+ var _c = __read(useState(false), 2), hover = _c[0], setHover = _c[1];
788
+ var onEnter = function() {
789
+ setHover(true);
790
+ };
791
+ var onLeave = function() {
792
+ setHover(false);
793
+ };
794
+ return React__default.createElement(
795
+ HandlerWrapper,
796
+ { style: wrapperStyle, className: cn("advanced-cropper-simple-handler-wrapper", wrapperClassName, verticalPosition && "advanced-cropper-simple-handler-wrapper--".concat(verticalPosition), horizontalPosition && "advanced-cropper-simple-handler-wrapper--".concat(horizontalPosition), horizontalPosition && verticalPosition && "advanced-cropper-simple-handler-wrapper--".concat(horizontalPosition, "-").concat(verticalPosition), hover && "advanced-cropper-simple-handler-wrapper--hover"), verticalPosition, horizontalPosition, disabled, onDrag: onMove, onDragEnd: onMoveEnd, onLeave, onEnter },
797
+ React__default.createElement("div", { className: cn("advanced-cropper-simple-handler", hover && "advanced-cropper-simple-handler--hover", defaultClassName, hover && hoverClassName, (_b = {}, _b["advanced-cropper-simple-handler--".concat(verticalPosition)] = !!verticalPosition, _b["advanced-cropper-simple-handler--".concat(horizontalPosition)] = !!horizontalPosition, _b["advanced-cropper-simple-handler--".concat(horizontalPosition, "-").concat(verticalPosition)] = horizontalPosition && verticalPosition, _b)) })
798
+ );
799
+ };
800
+ var HORIZONTAL_DIRECTIONS = ["east", "west", null];
801
+ var VERTICAL_DIRECTIONS = ["south", "north", null];
802
+ var BoundingBox = function(_a) {
803
+ var style = _a.style, className = _a.className, children = _a.children, onResize = _a.onResize, onResizeEnd = _a.onResizeEnd, _b = _a.handlerComponent, handlerComponent = _b === void 0 ? SimpleHandler : _b, _c = _a.handlers, handlers = _c === void 0 ? {
804
+ eastNorth: true,
805
+ north: true,
806
+ westNorth: true,
807
+ west: true,
808
+ westSouth: true,
809
+ south: true,
810
+ eastSouth: true,
811
+ east: true
812
+ } : _c, _d = _a.handlerClassNames, handlerClassNames = _d === void 0 ? {} : _d, _e = _a.handlerWrapperClassNames, handlerWrapperClassNames = _e === void 0 ? {} : _e, _f = _a.lines, lines = _f === void 0 ? {
813
+ west: true,
814
+ north: true,
815
+ east: true,
816
+ south: true
817
+ } : _f, _g = _a.lineComponent, lineComponent = _g === void 0 ? SimpleLine : _g, _h = _a.lineClassNames, lineClassNames = _h === void 0 ? {} : _h, _j = _a.lineWrapperClassNames, lineWrapperClassNames = _j === void 0 ? {} : _j, _k = _a.disabled, disabled = _k === void 0 ? false : _k, _l = _a.reference, reference = _l === void 0 ? null : _l;
818
+ var _m = __read(useState(null), 2), lastReference = _m[0], setLastReference = _m[1];
819
+ var points = useMemo(function() {
820
+ var result = [];
821
+ HORIZONTAL_DIRECTIONS.forEach(function(hDirection) {
822
+ VERTICAL_DIRECTIONS.forEach(function(vDirection) {
823
+ if (hDirection !== vDirection) {
824
+ var _a2 = getDirectionNames(hDirection, vDirection), snakeCase = _a2.snakeCase, camelCase = _a2.camelCase;
825
+ if (snakeCase && camelCase) {
826
+ result.push({
827
+ name: camelCase,
828
+ className: snakeCase,
829
+ verticalPosition: vDirection,
830
+ horizontalPosition: hDirection
831
+ });
832
+ }
833
+ }
834
+ });
835
+ });
836
+ return result;
837
+ }, []);
838
+ var lineNodes = useMemo(function() {
839
+ var result = [];
840
+ points.forEach(function(point) {
841
+ if (isCardinalDirection(point.name) && (isObject(lines) ? lines[point.name] : lines)) {
842
+ result.push({
843
+ name: point.name,
844
+ component: lineComponent,
845
+ className: cn(lineClassNames.default, lineClassNames[point.name], disabled && lineClassNames.disabled),
846
+ wrapperClassName: cn("advanced-cropper-bounding-box__line", "advanced-cropper-bounding-box__line--".concat(point.name), lineWrapperClassNames.default, lineWrapperClassNames[point.name], disabled && lineWrapperClassNames.disabled),
847
+ hoverClassName: lineClassNames.hover,
848
+ verticalPosition: point.verticalPosition,
849
+ horizontalPosition: point.horizontalPosition,
850
+ disabled
851
+ });
852
+ }
853
+ });
854
+ return result;
855
+ }, [points, lines, lineComponent, lineClassNames, lineWrapperClassNames, disabled]);
856
+ var handlerNodes = useMemo(function() {
857
+ var result = [];
858
+ points.forEach(function(point) {
859
+ if (isObject(handlers) ? handlers[point.name] : handlers) {
860
+ result.push({
861
+ name: point.name,
862
+ component: handlerComponent,
863
+ className: cn(handlerClassNames.default, handlerClassNames[point.name]),
864
+ containerClassName: cn("advanced-cropper-bounding-box__handler-wrapper", "advanced-cropper-bounding-box__handler-wrapper--".concat(point.className)),
865
+ wrapperClassName: cn("advanced-cropper-bounding-box__handler", "advanced-cropper-bounding-box__handler--".concat(point.className), handlerWrapperClassNames.default, handlerWrapperClassNames[point.name]),
866
+ hoverClassName: handlerClassNames.hover,
867
+ verticalPosition: point.verticalPosition,
868
+ horizontalPosition: point.horizontalPosition,
869
+ disabled
870
+ });
871
+ }
872
+ });
873
+ return result;
874
+ }, [points, handlers, handlerComponent, handlerClassNames, handlerWrapperClassNames, disabled]);
875
+ var onHandlerMove = function(horizontalPosition, verticalPosition) {
876
+ return function(_a2, nativeEvent) {
877
+ var left = _a2.left, top = _a2.top;
878
+ var directions = {
879
+ left,
880
+ top
881
+ };
882
+ var respectDirection;
883
+ if (!verticalPosition && horizontalPosition) {
884
+ respectDirection = "width";
885
+ } else if (verticalPosition && !horizontalPosition) {
886
+ respectDirection = "height";
887
+ }
888
+ if (!disabled) {
889
+ if (onResize) {
890
+ var anchor = getDirectionNames(horizontalPosition, verticalPosition).camelCase;
891
+ if (anchor) {
892
+ onResize(anchor, directions, {
893
+ reference: lastReference || reference,
894
+ preserveAspectRatio: nativeEvent && nativeEvent.shiftKey,
895
+ respectDirection,
896
+ compensate: true
897
+ });
898
+ }
899
+ }
900
+ if (!lastReference) {
901
+ setLastReference(reference);
902
+ }
903
+ }
904
+ };
905
+ };
906
+ var onHandlerMoveEnd = function() {
907
+ onResizeEnd === null || onResizeEnd === void 0 ? void 0 : onResizeEnd();
908
+ setLastReference(null);
909
+ };
910
+ return React__default.createElement(
911
+ "div",
912
+ { className: cn("advanced-cropper-bounding-box", className), style },
913
+ children,
914
+ React__default.createElement("div", null, lineNodes.map(function(line) {
915
+ return React__default.createElement(line.component, { key: line.name, defaultClassName: line.className, hoverClassName: line.hoverClassName, wrapperClassName: line.wrapperClassName, position: line.name, disabled: line.disabled, onMove: onHandlerMove(line.horizontalPosition, line.verticalPosition), onMoveEnd: onHandlerMoveEnd });
916
+ })),
917
+ React__default.createElement("div", null, handlerNodes.map(function(handler) {
918
+ var handlerElement = React__default.createElement(handler.component, { defaultClassName: handler.className, hoverClassName: handler.hoverClassName, wrapperClassName: handler.wrapperClassName, horizontalPosition: handler.horizontalPosition, verticalPosition: handler.verticalPosition, disabled: handler.disabled, onMove: onHandlerMove(handler.horizontalPosition, handler.verticalPosition), onMoveEnd: onHandlerMoveEnd });
919
+ return React__default.createElement("div", { key: handler.name, className: handler.containerClassName }, handlerElement);
920
+ }))
921
+ );
922
+ };
923
+ var StencilOverlay = function(_a) {
924
+ var className = _a.className, children = _a.children;
925
+ return React__default.createElement("div", { className: cn("advanced-cropper-stencil-overlay", className) }, children);
926
+ };
927
+ function useTransition(transitions) {
928
+ if (transitions === void 0) {
929
+ transitions = null;
930
+ }
931
+ var animation = useRef(new Animation());
932
+ var _a = __read(useState(false), 2), active = _a[0], setActive = _a[1];
933
+ return [
934
+ function(callback) {
935
+ if (transitions && transitions.active) {
936
+ animation.current.start(__assign(__assign({}, transitions), { onStart: function() {
937
+ setActive(true);
938
+ }, onProgress: function(progress) {
939
+ callback(progress);
940
+ }, onStop: function() {
941
+ setActive(false);
942
+ } }));
943
+ } else if (!animation.current.active) {
944
+ callback(1);
945
+ }
946
+ },
947
+ active
948
+ ];
949
+ }
950
+ var ArtificialTransition = function(_a) {
951
+ var className = _a.className, transitions = _a.transitions, children = _a.children, values = __rest(_a, ["className", "transitions", "children"]);
952
+ var root = useRef(null);
953
+ var transitionValues = useRef(values);
954
+ var _b = __read(useState(values), 2), rememberedValues = _b[0], setRememberedValues = _b[1];
955
+ var _c = __read(useTransition(transitions), 2), runTransitions = _c[0], transitionsActive = _c[1];
956
+ useLayoutEffect(function() {
957
+ if (!deepCompare(rememberedValues, values)) {
958
+ setRememberedValues(values);
959
+ var startValues_1 = transitionsActive ? __assign({}, transitionValues.current) : rememberedValues;
960
+ runTransitions(function(progress) {
961
+ var properties = ["left", "top", "height", "width"];
962
+ properties.forEach(function(property) {
963
+ var desiredValue = values[property];
964
+ var startValue = startValues_1[property];
965
+ transitionValues.current[property] = isNumber(startValue) && isNumber(desiredValue) ? startValue + (desiredValue - startValue) * progress : desiredValue;
966
+ });
967
+ if (root.current) {
968
+ root.current.style.width = "".concat(transitionValues.current.width, "px");
969
+ root.current.style.height = "".concat(transitionValues.current.height, "px");
970
+ root.current.style.transform = "translate3d(".concat(transitionValues.current.left, "px, ").concat(transitionValues.current.top, "px, 0px)");
971
+ }
972
+ });
973
+ }
974
+ }, [rememberedValues, transitionsActive, values.width, values.height, values.top, values.left]);
975
+ var currentValues = transitionsActive ? transitionValues.current : values;
976
+ var rootStyle = {
977
+ left: 0,
978
+ top: 0,
979
+ width: "".concat(currentValues.width, "px"),
980
+ height: "".concat(currentValues.height, "px"),
981
+ transform: "translate3d(".concat(currentValues.left, "px, ").concat(currentValues.top, "px, 0px)")
982
+ };
983
+ return React__default.createElement("div", { ref: root, className: cn("advanced-cropper-artificial-transition", className), style: rootStyle }, children);
984
+ };
985
+ var StencilWrapper = function(_a) {
986
+ var className = _a.className, transitions = _a.transitions, width = _a.width, height = _a.height, left = _a.left, top = _a.top, children = _a.children;
987
+ return React__default.createElement(ArtificialTransition, { className: cn("advanced-cropper-stencil-wrapper", className), transitions, width, height, top, left }, children);
988
+ };
989
+ var StencilGrid = function(_a) {
990
+ var _b = _a.columns, columns = _b === void 0 ? 3 : _b, _c = _a.rows, rows = _c === void 0 ? 3 : _c, _d = _a.visible, visible = _d === void 0 ? false : _d, className = _a.className;
991
+ var nodes = [];
992
+ var _e = __read(useState(columns), 2), currentColumns = _e[0], setCurrentColumns = _e[1];
993
+ var _f = __read(useState(rows), 2), currentRows = _f[0], setCurrentRows = _f[1];
994
+ useUpdateEffect(function() {
995
+ if (visible) {
996
+ setCurrentRows(rows);
997
+ setCurrentColumns(columns);
998
+ }
999
+ }, [visible, columns, rows]);
1000
+ for (var i = 0; i < currentRows; i++) {
1001
+ var cells = [];
1002
+ for (var j = 0; j < currentColumns; j++) {
1003
+ cells.push(React__default.createElement("div", { key: j, className: cn("advanced-cropper-stencil-grid__cell", i === 0 && "advanced-cropper-stencil-grid__cell--top", i === currentRows - 1 && "advanced-cropper-stencil-grid__cell--bottom", j === 0 && "advanced-cropper-stencil-grid__cell--left", j === currentColumns - 1 && "advanced-cropper-stencil-grid__cell--right") }));
1004
+ }
1005
+ nodes.push(React__default.createElement("div", { key: i, className: "advanced-cropper-stencil-grid__row" }, cells));
1006
+ }
1007
+ return React__default.createElement("div", { className: cn("advanced-cropper-stencil-grid", visible && "advanced-cropper-stencil-grid--visible", className) }, nodes);
1008
+ };
1009
+ var RectangleStencil = forwardRef(function(_a, ref) {
1010
+ var cropper = _a.cropper, coordinates = _a.coordinates, aspectRatio2 = _a.aspectRatio, minAspectRatio = _a.minAspectRatio, maxAspectRatio = _a.maxAspectRatio, _b = _a.handlerComponent, handlerComponent = _b === void 0 ? SimpleHandler : _b, _c = _a.handlers, handlers = _c === void 0 ? {
1011
+ eastNorth: true,
1012
+ north: true,
1013
+ westNorth: true,
1014
+ west: true,
1015
+ westSouth: true,
1016
+ south: true,
1017
+ eastSouth: true,
1018
+ east: true
1019
+ } : _c, _d = _a.handlerClassNames, handlerClassNames = _d === void 0 ? {} : _d, _e = _a.handlerWrapperClassNames, handlerWrapperClassNames = _e === void 0 ? {} : _e, _f = _a.lines, lines = _f === void 0 ? {
1020
+ west: true,
1021
+ north: true,
1022
+ east: true,
1023
+ south: true
1024
+ } : _f, _g = _a.lineComponent, lineComponent = _g === void 0 ? SimpleLine : _g, _h = _a.lineClassNames, lineClassNames = _h === void 0 ? {} : _h, _j = _a.lineWrapperClassNames, lineWrapperClassNames = _j === void 0 ? {} : _j, _k = _a.resizable, resizable = _k === void 0 ? true : _k, _l = _a.movable, movable = _l === void 0 ? true : _l, grid = _a.grid, gridClassName = _a.gridClassName, className = _a.className, movingClassName = _a.movingClassName, resizingClassName = _a.resizingClassName, previewClassName = _a.previewClassName, boundingBoxClassName = _a.boundingBoxClassName, overlayClassName = _a.overlayClassName, draggableAreaClassName = _a.draggableAreaClassName, disabled = _a.disabled;
1025
+ var state = cropper.getState();
1026
+ var transitions = cropper.getTransitions();
1027
+ var interactions = cropper.getInteractions();
1028
+ var resizeAllowed = resizable && !disabled;
1029
+ var moveAllowed = movable && !disabled;
1030
+ useImperativeHandle(ref, function() {
1031
+ return {
1032
+ aspectRatio: createAspectRatio(aspectRatio2 || {
1033
+ minimum: minAspectRatio,
1034
+ maximum: maxAspectRatio
1035
+ })
1036
+ };
1037
+ });
1038
+ var onMove = function(directions) {
1039
+ if (cropper && moveAllowed) {
1040
+ cropper.moveCoordinates(directions);
1041
+ }
1042
+ };
1043
+ var onMoveEnd = function() {
1044
+ if (cropper) {
1045
+ cropper.moveCoordinatesEnd();
1046
+ }
1047
+ };
1048
+ var onResize = function(anchor, directions, options) {
1049
+ if (cropper && resizeAllowed) {
1050
+ cropper.resizeCoordinates(anchor, directions, options);
1051
+ }
1052
+ };
1053
+ var onResizeEnd = function() {
1054
+ if (cropper) {
1055
+ cropper.resizeCoordinatesEnd();
1056
+ }
1057
+ };
1058
+ var _m = coordinates ? isFunction(coordinates) ? coordinates(state) : coordinates : getStencilCoordinates(state), width = _m.width, height = _m.height, left = _m.left, top = _m.top;
1059
+ return state && React__default.createElement(
1060
+ StencilWrapper,
1061
+ { className: cn("advanced-cropper-rectangle-stencil", className, interactions.moveCoordinates && movingClassName, interactions.resizeCoordinates && resizingClassName, {
1062
+ "advanced-cropper-rectangle-stencil--movable": moveAllowed,
1063
+ "advanced-cropper-rectangle-stencil--moving": interactions.moveCoordinates,
1064
+ "advanced-cropper-rectangle-stencil--resizable": resizeAllowed,
1065
+ "advanced-cropper-rectangle-stencil--resizing": interactions.resizeCoordinates,
1066
+ "advanced-cropper-rectangle-stencil--disabled": disabled
1067
+ }), width, height, left, top, transitions },
1068
+ React__default.createElement(
1069
+ BoundingBox,
1070
+ { reference: state.coordinates, className: cn(boundingBoxClassName, "advanced-cropper-rectangle-stencil__bounding-box"), handlers, handlerComponent, handlerClassNames, handlerWrapperClassNames, lines, lineComponent, lineClassNames, lineWrapperClassNames, onResize, onResizeEnd, disabled: !resizeAllowed },
1071
+ React__default.createElement(
1072
+ DraggableElement,
1073
+ { disabled: !moveAllowed, onMove, onMoveEnd, className: cn("advanced-cropper-rectangle-stencil__draggable-area", draggableAreaClassName) },
1074
+ React__default.createElement(
1075
+ StencilOverlay,
1076
+ { className: cn("advanced-cropper-rectangle-stencil__overlay", overlayClassName) },
1077
+ grid && React__default.createElement(StencilGrid, { visible: cropper.hasInteractions(), columns: interactions.transformImage.rotate ? 9 : 3, rows: interactions.transformImage.rotate ? 9 : 3, className: cn("advanced-cropper-rectangle-stencil__grid", gridClassName) }),
1078
+ React__default.createElement("div", { className: cn("advanced-cropper-rectangle-stencil__preview", previewClassName) })
1079
+ )
1080
+ )
1081
+ )
1082
+ );
1083
+ });
1084
+ RectangleStencil.displayName = "RectangleStencil";
1085
+ function useRotateImageOptions(rotateImage) {
1086
+ return useMemo(function() {
1087
+ return getOptions(rotateImage, {
1088
+ touch: true
1089
+ }, {
1090
+ touch: false
1091
+ });
1092
+ }, [rotateImage]);
1093
+ }
1094
+ function useScaleImageOptions(scaleImage) {
1095
+ return useMemo(function() {
1096
+ return getOptions(scaleImage, {
1097
+ touch: true,
1098
+ wheel: {
1099
+ ratio: 0.1
1100
+ }
1101
+ }, {
1102
+ touch: false,
1103
+ wheel: false
1104
+ });
1105
+ }, [scaleImage]);
1106
+ }
1107
+ function useMoveImageOptions(moveImage) {
1108
+ return useMemo(function() {
1109
+ return getOptions(moveImage, {
1110
+ touch: true,
1111
+ mouse: true
1112
+ }, {
1113
+ touch: false,
1114
+ mouse: false
1115
+ });
1116
+ }, [moveImage]);
1117
+ }
1118
+ var TransformableImageEvent = (
1119
+ /** @class */
1120
+ function() {
1121
+ function TransformableImageEvent2(_a) {
1122
+ var active = _a.active;
1123
+ this.active = active;
1124
+ this.defaultPrevented = false;
1125
+ }
1126
+ TransformableImageEvent2.prototype.preventDefault = function() {
1127
+ this.defaultPrevented = true;
1128
+ };
1129
+ return TransformableImageEvent2;
1130
+ }()
1131
+ );
1132
+ var TransformableImage = (
1133
+ /** @class */
1134
+ function(_super) {
1135
+ __extends(TransformableImage2, _super);
1136
+ function TransformableImage2(props) {
1137
+ var _this = _super.call(this, props) || this;
1138
+ _this.processMove = function(newTouches) {
1139
+ var _a = _this.props, onTransform = _a.onTransform, touchScale = _a.touchScale, touchMove = _a.touchMove, touchRotate = _a.touchRotate;
1140
+ var container = _this.container.current;
1141
+ if (container && onTransform) {
1142
+ onTransform(touchesToImageTransform(newTouches, _this.touches, container, {
1143
+ scale: touchScale,
1144
+ rotate: touchRotate,
1145
+ move: touchMove
1146
+ }));
1147
+ _this.touches = newTouches;
1148
+ }
1149
+ };
1150
+ _this.processEnd = function() {
1151
+ var onTransformEnd = _this.props.onTransformEnd;
1152
+ if (_this.transforming) {
1153
+ _this.transforming = false;
1154
+ if (onTransformEnd) {
1155
+ onTransformEnd();
1156
+ }
1157
+ }
1158
+ };
1159
+ _this.processStart = function() {
1160
+ _this.transforming = true;
1161
+ _this.debouncedProcessEnd.clear();
1162
+ };
1163
+ _this.processEvent = function(nativeEvent) {
1164
+ var _a = _this.props, onEvent = _a.onEvent, disabled = _a.disabled, _b = _a.preventDefault, preventDefault2 = _b === void 0 ? true : _b;
1165
+ var transformEvent = new TransformableImageEvent({ active: _this.transforming });
1166
+ if (onEvent) {
1167
+ onEvent(transformEvent, nativeEvent);
1168
+ } else if (preventDefault2) {
1169
+ nativeEvent.preventDefault();
1170
+ nativeEvent.stopPropagation();
1171
+ }
1172
+ return !disabled && !transformEvent.defaultPrevented;
1173
+ };
1174
+ _this.onWheel = function(event) {
1175
+ var _a = _this.props, onTransform = _a.onTransform, wheelScale = _a.wheelScale;
1176
+ var container = _this.container.current;
1177
+ if (wheelScale) {
1178
+ if (_this.processEvent(event)) {
1179
+ _this.processStart();
1180
+ if (onTransform && container) {
1181
+ onTransform(wheelEventToImageTransform(event, container, wheelScale === true ? 0.1 : wheelScale.ratio));
1182
+ }
1183
+ if (!_this.touches.length) {
1184
+ _this.debouncedProcessEnd();
1185
+ }
1186
+ }
1187
+ }
1188
+ };
1189
+ _this.onTouchStart = function(event) {
1190
+ var _a = _this.props, touchMove = _a.touchMove, touchScale = _a.touchScale, touchRotate = _a.touchRotate;
1191
+ if (event.cancelable && (touchMove || (touchScale || touchRotate) && event.touches.length > 1)) {
1192
+ if (_this.processEvent(event)) {
1193
+ var container = _this.container.current;
1194
+ if (container) {
1195
+ var _b = container.getBoundingClientRect(), left_1 = _b.left, top_1 = _b.top, bottom_1 = _b.bottom, right_1 = _b.right;
1196
+ _this.touches = Array.from(event.touches).filter(function(touch) {
1197
+ return touch.clientX > left_1 && touch.clientX < right_1 && touch.clientY > top_1 && touch.clientY < bottom_1;
1198
+ });
1199
+ }
1200
+ }
1201
+ }
1202
+ };
1203
+ _this.onTouchEnd = function(event) {
1204
+ if (event.touches.length === 0) {
1205
+ _this.touches = [];
1206
+ _this.processEnd();
1207
+ }
1208
+ };
1209
+ _this.onTouchMove = function(event) {
1210
+ if (_this.touches.length) {
1211
+ var touches = __spreadArray([], __read(event.touches), false).filter(function(touch) {
1212
+ return !touch.identifier || _this.touches.find(function(anotherTouch) {
1213
+ return anotherTouch.identifier === touch.identifier;
1214
+ });
1215
+ });
1216
+ if (_this.processEvent(event)) {
1217
+ _this.processMove(touches);
1218
+ _this.processStart();
1219
+ }
1220
+ }
1221
+ };
1222
+ _this.onMouseDown = function(event) {
1223
+ var mouseMove = _this.props.mouseMove;
1224
+ if (mouseMove && "buttons" in event && event.buttons === 1) {
1225
+ if (_this.processEvent(event)) {
1226
+ var touch = {
1227
+ clientX: event.clientX,
1228
+ clientY: event.clientY
1229
+ };
1230
+ _this.touches = [touch];
1231
+ _this.processStart();
1232
+ }
1233
+ }
1234
+ };
1235
+ _this.onMouseMove = function(event) {
1236
+ if (_this.touches.length) {
1237
+ if (_this.processEvent(event)) {
1238
+ _this.processMove([
1239
+ {
1240
+ clientX: event.clientX,
1241
+ clientY: event.clientY
1242
+ }
1243
+ ]);
1244
+ }
1245
+ }
1246
+ };
1247
+ _this.onMouseUp = function() {
1248
+ _this.touches = [];
1249
+ _this.processEnd();
1250
+ };
1251
+ _this.transforming = false;
1252
+ _this.touches = [];
1253
+ _this.anchor = {
1254
+ left: 0,
1255
+ top: 0
1256
+ };
1257
+ _this.container = createRef();
1258
+ _this.debouncedProcessEnd = debounce(_this.processEnd, props.timeout);
1259
+ return _this;
1260
+ }
1261
+ TransformableImage2.prototype.shouldComponentUpdate = function() {
1262
+ return true;
1263
+ };
1264
+ TransformableImage2.prototype.componentWillUnmount = function() {
1265
+ window.removeEventListener("mouseup", this.onMouseUp);
1266
+ window.removeEventListener("mousemove", this.onMouseMove);
1267
+ window.removeEventListener("touchmove", this.onTouchMove);
1268
+ window.removeEventListener("touchend", this.onTouchEnd);
1269
+ var container = this.container.current;
1270
+ if (container) {
1271
+ container.removeEventListener("touchstart", this.onTouchStart);
1272
+ container.removeEventListener("mousedown", this.onMouseDown);
1273
+ container.removeEventListener("wheel", this.onWheel);
1274
+ }
1275
+ };
1276
+ TransformableImage2.prototype.componentDidMount = function() {
1277
+ window.addEventListener("mouseup", this.onMouseUp, { passive: false });
1278
+ window.addEventListener("mousemove", this.onMouseMove, { passive: false });
1279
+ window.addEventListener("touchmove", this.onTouchMove, { passive: false });
1280
+ window.addEventListener("touchend", this.onTouchEnd, { passive: false });
1281
+ var container = this.container.current;
1282
+ if (container) {
1283
+ container.addEventListener("touchstart", this.onTouchStart, {
1284
+ passive: false
1285
+ });
1286
+ container.addEventListener("mousedown", this.onMouseDown, {
1287
+ passive: false
1288
+ });
1289
+ container.addEventListener("wheel", this.onWheel, {
1290
+ passive: false
1291
+ });
1292
+ }
1293
+ };
1294
+ TransformableImage2.prototype.render = function() {
1295
+ var _a = this.props, className = _a.className, children = _a.children, style = _a.style;
1296
+ return React__default.createElement("div", { className, style, ref: this.container }, children);
1297
+ };
1298
+ TransformableImage2.defaultProps = {
1299
+ touchMove: true,
1300
+ mouseMove: true,
1301
+ touchScale: true,
1302
+ touchRotate: false,
1303
+ wheelScale: true,
1304
+ timeout: 500
1305
+ };
1306
+ return TransformableImage2;
1307
+ }(Component)
1308
+ );
1309
+ var CropperBackgroundWrapper = function(_a) {
1310
+ var _b = _a.scaleImage, scaleImage = _b === void 0 ? true : _b, _c = _a.moveImage, moveImage = _c === void 0 ? true : _c, _d = _a.rotateImage, rotateImage = _d === void 0 ? false : _d, children = _a.children, className = _a.className, style = _a.style, cropper = _a.cropper, timeout = _a.timeout, disabled = _a.disabled;
1311
+ var transitions = cropper.getTransitions();
1312
+ var rotateImageOptions = useRotateImageOptions(rotateImage);
1313
+ var scaleImageOptions = useScaleImageOptions(scaleImage);
1314
+ var moveImageOptions = useMoveImageOptions(moveImage);
1315
+ return React__default.createElement(TransformableImage, { className, style, onTransform: cropper.transformImage, onTransformEnd: cropper.transformImageEnd, touchMove: moveImageOptions.touch, mouseMove: moveImageOptions.mouse, touchScale: scaleImageOptions.touch, wheelScale: scaleImageOptions.wheel, touchRotate: rotateImageOptions.touch, disabled: transitions.active || disabled, preventDefault: !disabled, timeout }, children);
1316
+ };
1317
+ var AbstractCropperComponent = function(props, ref) {
1318
+ var style = props.style, className = props.className, _a = props.stencilComponent, stencilComponent = _a === void 0 ? RectangleStencil : _a, _b = props.stencilConstraints, stencilConstraints = _b === void 0 ? defaultStencilConstraints : _b, _c = props.stencilProps, stencilProps = _c === void 0 ? {} : _c, _d = props.wrapperComponent, wrapperComponent = _d === void 0 ? CropperWrapper : _d, _e = props.wrapperProps, wrapperProps = _e === void 0 ? {} : _e, _f = props.backgroundComponent, backgroundComponent = _f === void 0 ? CropperBackgroundImage : _f, _g = props.backgroundProps, backgroundProps = _g === void 0 ? {} : _g, backgroundClassName = props.backgroundClassName, _h = props.backgroundWrapperComponent, backgroundWrapperComponent = _h === void 0 ? CropperBackgroundWrapper : _h, _j = props.backgroundWrapperProps, backgroundWrapperProps = _j === void 0 ? {} : _j, _k = props.boundaryComponent, boundaryComponent = _k === void 0 ? StretchableBoundary : _k, boundaryProps = props.boundaryProps, boundaryClassName = props.boundaryClassName, _l = props.canvas, canvas = _l === void 0 ? true : _l, _m = props.crossOrigin, crossOrigin = _m === void 0 ? true : _m, disabled = props.disabled, settings = props.settings, parameters = __rest(props, ["style", "className", "stencilComponent", "stencilConstraints", "stencilProps", "wrapperComponent", "wrapperProps", "backgroundComponent", "backgroundProps", "backgroundClassName", "backgroundWrapperComponent", "backgroundWrapperProps", "boundaryComponent", "boundaryProps", "boundaryClassName", "canvas", "crossOrigin", "disabled", "settings"]);
1319
+ var stencilRef = useRef(null);
1320
+ var _o = useAbstractCropper(function() {
1321
+ return __assign(__assign({}, parameters), { crossOrigin, stencilProps, canvas, settings: __assign(__assign({}, settings), stencilConstraints(settings, __assign(__assign({}, stencilProps), stencilRef.current))) });
1322
+ }), cropper = _o.cropper, image = _o.image, refs = _o.refs;
1323
+ var StencilComponent = stencilComponent;
1324
+ var WrapperComponent = wrapperComponent;
1325
+ var BackgroundWrapperComponent = backgroundWrapperComponent;
1326
+ var BackgroundComponent = backgroundComponent;
1327
+ var BoundaryComponent = boundaryComponent;
1328
+ useImperativeHandle(ref, function() {
1329
+ return cropper;
1330
+ });
1331
+ var deprecatedWrapperProps = {
1332
+ loading: cropper.isLoading(),
1333
+ loaded: cropper.isLoaded()
1334
+ };
1335
+ return React__default.createElement(
1336
+ WrapperComponent,
1337
+ __assign({}, wrapperProps, { disabled, className: cn("advanced-cropper", className), cropper, style }, deprecatedWrapperProps),
1338
+ React__default.createElement(
1339
+ BoundaryComponent,
1340
+ __assign({}, boundaryProps, { ref: refs.boundary, className: cn("advanced-cropper__boundary", boundaryClassName) }),
1341
+ React__default.createElement(
1342
+ BackgroundWrapperComponent,
1343
+ __assign({}, backgroundWrapperProps, { disabled, cropper, className: "advanced-cropper__background-wrapper" }),
1344
+ cropper.getState() && React__default.createElement(BackgroundComponent, __assign({}, backgroundProps, { ref: refs.image, crossOrigin, cropper, className: cn("advanced-cropper__background", backgroundClassName) })),
1345
+ React__default.createElement(StencilComponent, __assign({}, stencilProps, { disabled, ref: stencilRef, cropper, image }))
1346
+ ),
1347
+ canvas && React__default.createElement(CropperCanvas, { ref: refs.canvas })
1348
+ )
1349
+ );
1350
+ };
1351
+ var AbstractCropper = createCropper(AbstractCropperComponent);
1352
+ var defaultSettings = [
1353
+ "transformImage",
1354
+ "moveCoordinates",
1355
+ "resizeCoordinates",
1356
+ "defaultCoordinates",
1357
+ "defaultVisibleArea",
1358
+ "areaPositionRestrictions",
1359
+ "areaSizeRestrictions",
1360
+ "sizeRestrictions",
1361
+ "positionRestrictions",
1362
+ "aspectRatio",
1363
+ "minWidth",
1364
+ "minHeight",
1365
+ "maxWidth",
1366
+ "maxHeight",
1367
+ "defaultSize",
1368
+ "defaultPosition",
1369
+ "defaultTransforms",
1370
+ "imageRestriction",
1371
+ "priority"
1372
+ ];
1373
+ function useAbstractCropperProps(props, settings) {
1374
+ if (settings === void 0) {
1375
+ settings = defaultSettings;
1376
+ }
1377
+ var result = { settings: {}, props: {} };
1378
+ Object.keys(props).forEach(function(key) {
1379
+ if (settings.some(function(setting) {
1380
+ return setting === key;
1381
+ })) {
1382
+ result.settings[key] = props[key];
1383
+ } else {
1384
+ result.props[key] = props[key];
1385
+ }
1386
+ });
1387
+ return result;
1388
+ }
1389
+ var FixedCropper = forwardRef(function(props, ref) {
1390
+ var cropperProps = useAbstractCropperProps(props, __spreadArray(__spreadArray([], __read(defaultSettings), false), ["stencilSize"], false));
1391
+ return React__default.createElement(AbstractCropper, __assign({ postProcess: fixedStencil, stencilConstraints: fixedStencilConstraints }, cropperProps.props, { settings: __assign(__assign({ defaultSize, aspectRatio, sizeRestrictions: withDefaultSizeRestrictions(sizeRestrictions) }, cropperProps.settings), { transformImage: __assign(__assign({}, cropperProps.settings.transformImage), { adjustStencil: false }) }), ref }));
1392
+ });
1393
+ FixedCropper.displayName = "FixedCropper";
1394
+ var Cropper = forwardRef(function(props, ref) {
1395
+ var cropperProps = useAbstractCropperProps(props);
1396
+ var intrinsicProps = cropperProps.props;
1397
+ var _a = cropperProps.settings, stencilSize = _a.stencilSize, autoZoom = _a.autoZoom, actualSettings = __rest(_a, ["stencilSize", "autoZoom"]);
1398
+ var deprecationWarning2 = useDeprecationWarning();
1399
+ if (!isUndefined(autoZoom)) {
1400
+ if (intrinsicProps.postProcess || stencilSize) {
1401
+ deprecationWarning2("prop 'autoZoom' is deprecated now and will be removed, use 'postProcess' prop to pass your auto zoom function.");
1402
+ } else {
1403
+ deprecationWarning2("prop 'autoZoom' is deprecated now and will be removed, use 'postProcess' prop to pass your auto zoom function. The 'postProcess' automatically set to 'hybridAutoZoom'");
1404
+ intrinsicProps.postProcess = hybridStencilAutoZoom;
1405
+ }
1406
+ }
1407
+ if (!isUndefined(stencilSize)) {
1408
+ deprecationWarning2("prop 'stencilSize' is deprecated for <Cropper/> component now and will be removed, use <FixedCropper/> component instead.");
1409
+ return React__default.createElement(FixedCropper, __assign({ ref, stencilSize }, actualSettings, intrinsicProps));
1410
+ }
1411
+ return React__default.createElement(AbstractCropper, __assign({}, intrinsicProps, { ref, settings: actualSettings }));
1412
+ });
1413
+ Cropper.displayName = "CropperComponent";
1414
+ var CircleStencil = forwardRef(function(_a, ref) {
1415
+ var cropper = _a.cropper, coordinates = _a.coordinates, _b = _a.handlerComponent, handlerComponent = _b === void 0 ? SimpleHandler : _b, _c = _a.handlers, handlers = _c === void 0 ? {
1416
+ eastNorth: true,
1417
+ westNorth: true,
1418
+ westSouth: true,
1419
+ eastSouth: true
1420
+ } : _c, _d = _a.handlerClassNames, handlerClassNames = _d === void 0 ? {} : _d, _e = _a.handlerWrapperClassNames, handlerWrapperClassNames = _e === void 0 ? {} : _e, _f = _a.lines, lines = _f === void 0 ? {
1421
+ west: true,
1422
+ north: true,
1423
+ east: true,
1424
+ south: true
1425
+ } : _f, _g = _a.lineComponent, lineComponent = _g === void 0 ? SimpleLine : _g, _h = _a.lineClassNames, lineClassNames = _h === void 0 ? {} : _h, _j = _a.lineWrapperClassNames, lineWrapperClassNames = _j === void 0 ? {} : _j, _k = _a.resizable, resizable = _k === void 0 ? true : _k, _l = _a.movable, movable = _l === void 0 ? true : _l, grid = _a.grid, gridClassName = _a.gridClassName, className = _a.className, movingClassName = _a.movingClassName, resizingClassName = _a.resizingClassName, previewClassName = _a.previewClassName, boundingBoxClassName = _a.boundingBoxClassName, overlayClassName = _a.overlayClassName, draggableAreaClassName = _a.draggableAreaClassName, disabled = _a.disabled;
1426
+ var state = cropper.getState();
1427
+ var transitions = cropper.getTransitions();
1428
+ var interactions = cropper.getInteractions();
1429
+ var resizeAllowed = resizable && !disabled;
1430
+ var moveAllowed = movable && !disabled;
1431
+ useImperativeHandle(ref, function() {
1432
+ return {
1433
+ aspectRatio: 1,
1434
+ boundingBox: "circle"
1435
+ };
1436
+ });
1437
+ var onMove = function(directions) {
1438
+ if (cropper && moveAllowed) {
1439
+ cropper.moveCoordinates(directions);
1440
+ }
1441
+ };
1442
+ var onMoveEnd = function() {
1443
+ if (cropper) {
1444
+ cropper.moveCoordinatesEnd();
1445
+ }
1446
+ };
1447
+ var onResize = function(anchor, directions, options) {
1448
+ if (cropper && resizeAllowed) {
1449
+ cropper.resizeCoordinates(anchor, directions, options);
1450
+ }
1451
+ };
1452
+ var onResizeEnd = function() {
1453
+ if (cropper) {
1454
+ cropper.resizeCoordinatesEnd();
1455
+ }
1456
+ };
1457
+ var _m = coordinates ? isFunction(coordinates) ? coordinates(state) : coordinates : getStencilCoordinates(state), width = _m.width, height = _m.height, left = _m.left, top = _m.top;
1458
+ return state && React__default.createElement(
1459
+ StencilWrapper,
1460
+ { className: cn("advanced-cropper-circle-stencil", className, interactions.moveCoordinates && movingClassName, interactions.resizeCoordinates && resizingClassName, {
1461
+ "advanced-cropper-circle-stencil--movable": moveAllowed,
1462
+ "advanced-cropper-circle-stencil--moving": interactions.moveCoordinates,
1463
+ "advanced-cropper-circle-stencil--resizable": resizeAllowed,
1464
+ "advanced-cropper-circle-stencil--resizing": interactions.resizeCoordinates,
1465
+ "advanced-cropper-circle-stencil--disabled": disabled
1466
+ }), width, height, left, top, transitions },
1467
+ React__default.createElement(
1468
+ BoundingBox,
1469
+ { reference: state.coordinates, className: cn(boundingBoxClassName, "advanced-cropper-circle-stencil__bounding-box"), handlers, handlerComponent, handlerClassNames, handlerWrapperClassNames, lines, lineComponent, lineClassNames, lineWrapperClassNames, onResize, onResizeEnd, disabled: !resizeAllowed },
1470
+ React__default.createElement(
1471
+ DraggableElement,
1472
+ { disabled: !moveAllowed, onMove, onMoveEnd, className: cn("advanced-cropper-circle-stencil__draggable-area", draggableAreaClassName) },
1473
+ React__default.createElement(
1474
+ StencilOverlay,
1475
+ { className: cn("advanced-cropper-circle-stencil__overlay", overlayClassName) },
1476
+ grid && React__default.createElement(StencilGrid, { visible: cropper.hasInteractions(), columns: interactions.transformImage.rotate ? 9 : 3, rows: interactions.transformImage.rotate ? 9 : 3, className: cn("advanced-cropper-circle-stencil__grid", gridClassName) }),
1477
+ React__default.createElement("div", { className: cn("advanced-cropper-circle-stencil__preview", previewClassName) })
1478
+ )
1479
+ )
1480
+ )
1481
+ );
1482
+ });
1483
+ CircleStencil.displayName = "CircleStencil";
1484
+ var CropperSource = forwardRef(function(_a, ref) {
1485
+ var src = _a.src, _b = _a.crossOrigin, crossOrigin = _b === void 0 ? true : _b, props = __rest(_a, ["src", "crossOrigin"]);
1486
+ return src ? React__default.createElement("img", __assign({ key: src, ref, src, className: cn("advanced-cropper-source"), crossOrigin: crossOrigin === true ? "anonymous" : crossOrigin || void 0 }, props)) : null;
1487
+ });
1488
+ CropperSource.displayName = "CropperSource";
1489
+ var CropperPreviewWrapper = function(_a) {
1490
+ var children = _a.children, cropper = _a.cropper, className = _a.className, style = _a.style;
1491
+ return React__default.createElement(
1492
+ "div",
1493
+ { className: cn(className, "cropper-preview-wrapper"), style },
1494
+ React__default.createElement(CropperFade, { visible: cropper === null || cropper === void 0 ? void 0 : cropper.isLoaded(), className: "cropper-preview-wrapper__fade" }, children)
1495
+ );
1496
+ };
1497
+ var CropperPreviewBackground = function(_a) {
1498
+ var className = _a.className, cropper = _a.cropper, _b = _a.crossOrigin, crossOrigin = _b === void 0 ? true : _b, size = _a.size, style = _a.style;
1499
+ var state = cropper.getState();
1500
+ var transitions = cropper.getTransitions();
1501
+ var image = cropper.getImage();
1502
+ var transformStyles = size && image && (state === null || state === void 0 ? void 0 : state.coordinates) ? getPreviewStyle(image, state, size, transitions) : {};
1503
+ var src = image ? image.src : void 0;
1504
+ return src ? React__default.createElement("img", { key: src, className: cn("advanced-cropper-background-image", className), src, crossOrigin: crossOrigin === true ? "anonymous" : crossOrigin || void 0, style: __assign(__assign({}, transformStyles), style), onMouseDown: preventDefault }) : null;
1505
+ };
1506
+ forwardRef(function(_a, ref) {
1507
+ var _b, _c, _d, _e;
1508
+ var className = _a.className, contentClassName = _a.contentClassName, _f = _a.state, state = _f === void 0 ? null : _f, _g = _a.image, image = _g === void 0 ? null : _g, _h = _a.transitions, transitions = _h === void 0 ? null : _h, _j = _a.backgroundComponent, backgroundComponent = _j === void 0 ? CropperPreviewBackground : _j, backgroundProps = _a.backgroundProps, backgroundClassName = _a.backgroundClassName, _k = _a.boundaryComponent, boundaryComponent = _k === void 0 ? StretchableBoundary : _k, boundaryProps = _a.boundaryProps, boundaryClassName = _a.boundaryClassName, _l = _a.wrapperComponent, wrapperComponent = _l === void 0 ? CropperPreviewWrapper : _l, wrapperProps = _a.wrapperProps, _m = _a.loaded, loaded = _m === void 0 ? true : _m, _o = _a.loading, loading = _o === void 0 ? false : _o, style = _a.style, cropper = _a.cropper;
1509
+ var rerender = useForceRerender();
1510
+ var boundaryRef = useRef(null);
1511
+ var internalInstance = useRef(null);
1512
+ var instance = cropper || (internalInstance.current ? internalInstance : {
1513
+ current: {
1514
+ getState: function() {
1515
+ return state;
1516
+ },
1517
+ getTransitions: function() {
1518
+ return transitions;
1519
+ },
1520
+ getImage: function() {
1521
+ return image;
1522
+ },
1523
+ isLoaded: function() {
1524
+ return loaded;
1525
+ },
1526
+ isLoading: function() {
1527
+ return loading;
1528
+ }
1529
+ }
1530
+ });
1531
+ var _p = __read(useState(null), 2), size = _p[0], setSize = _p[1];
1532
+ var coordinates = (_c = (_b = instance.current) === null || _b === void 0 ? void 0 : _b.getState()) === null || _c === void 0 ? void 0 : _c.coordinates;
1533
+ var src = (_e = (_d = instance.current) === null || _d === void 0 ? void 0 : _d.getImage()) === null || _e === void 0 ? void 0 : _e.src;
1534
+ var contentStyle = size ? {
1535
+ width: "".concat(size.width, "px"),
1536
+ height: "".concat(size.height, "px")
1537
+ } : {};
1538
+ var refresh = function() {
1539
+ var _a2, _b2;
1540
+ var coordinates2 = (_b2 = (_a2 = instance.current) === null || _a2 === void 0 ? void 0 : _a2.getState()) === null || _b2 === void 0 ? void 0 : _b2.coordinates;
1541
+ if (boundaryRef.current && coordinates2) {
1542
+ boundaryRef.current.stretchTo(coordinates2).then(function(size2) {
1543
+ if (size2 && coordinates2) {
1544
+ if (isGreater(ratio(coordinates2), ratio(size2))) {
1545
+ setSize({
1546
+ width: size2.width,
1547
+ height: size2.width / ratio(coordinates2)
1548
+ });
1549
+ } else {
1550
+ setSize({
1551
+ width: size2.height * ratio(coordinates2),
1552
+ height: size2.height
1553
+ });
1554
+ }
1555
+ } else {
1556
+ setSize(null);
1557
+ }
1558
+ });
1559
+ }
1560
+ rerender();
1561
+ };
1562
+ useWindowResize(refresh);
1563
+ useLayoutEffect(refresh, [coordinates === null || coordinates === void 0 ? void 0 : coordinates.height, coordinates === null || coordinates === void 0 ? void 0 : coordinates.width]);
1564
+ useImperativeHandle(ref, function() {
1565
+ return {
1566
+ refresh,
1567
+ update: function(cropper2) {
1568
+ if (cropper2) {
1569
+ internalInstance.current = cropper2;
1570
+ } else {
1571
+ internalInstance.current = null;
1572
+ }
1573
+ refresh();
1574
+ }
1575
+ };
1576
+ });
1577
+ var WrapperComponent = wrapperComponent;
1578
+ var BackgroundComponent = backgroundComponent;
1579
+ var BoundaryComponent = boundaryComponent;
1580
+ return React__default.createElement(
1581
+ WrapperComponent,
1582
+ __assign({}, wrapperProps, { className: cn(className, "advanced-cropper-preview"), cropper: instance.current, style }),
1583
+ React__default.createElement(
1584
+ BoundaryComponent,
1585
+ __assign({ ref: boundaryRef, stretchAlgorithm: stretchPreviewBoundary }, boundaryProps, { className: cn("advanced-cropper-preview__boundary", boundaryClassName) }),
1586
+ React__default.createElement("div", { className: cn(contentClassName, "advanced-cropper-preview__content"), style: contentStyle }, instance.current && React__default.createElement(BackgroundComponent, __assign({}, backgroundProps, { cropper: instance.current, size, className: cn(backgroundClassName, "advanced-cropper-preview__image", src && "advanced-cropper-preview__image--visible") })))
1587
+ )
1588
+ );
1589
+ });
1590
+ export {
1591
+ AbstractCropperInstance,
1592
+ Animation,
1593
+ BoundingBox,
1594
+ CircleStencil,
1595
+ Cropper,
1596
+ CropperBackgroundImage,
1597
+ CropperBackgroundWrapper,
1598
+ CropperCanvas,
1599
+ CropperFade,
1600
+ CropperPreviewBackground,
1601
+ CropperPreviewWrapper,
1602
+ CropperSource,
1603
+ CropperWrapper,
1604
+ DraggableElement as DraggableArea,
1605
+ DraggableElement,
1606
+ FixedCropper,
1607
+ ImageRestriction,
1608
+ Priority,
1609
+ RectangleStencil,
1610
+ SimpleHandler,
1611
+ SimpleLine,
1612
+ StencilGrid,
1613
+ StencilOverlay,
1614
+ StencilWrapper,
1615
+ StretchableBoundary,
1616
+ TransformableImage,
1617
+ TransformableImageEvent,
1618
+ applyDirections,
1619
+ applyMove,
1620
+ applyScale,
1621
+ aspectRatioIntersection,
1622
+ coordinatesToPositionRestrictions,
1623
+ copyState,
1624
+ createAspectRatio,
1625
+ createDefaultSettings,
1626
+ createImage,
1627
+ debounce,
1628
+ deepClone,
1629
+ deepCompare,
1630
+ defaultStencilConstraints,
1631
+ diff,
1632
+ distance,
1633
+ drawCroppedArea,
1634
+ emptyCoordinates,
1635
+ fillBoundary,
1636
+ fitToPositionRestrictions,
1637
+ fitToSizeRestrictions,
1638
+ getAreaPositionRestrictions,
1639
+ getAreaSizeRestrictions,
1640
+ getAspectRatio,
1641
+ getBackgroundStyle,
1642
+ getBrokenRatio,
1643
+ getCenter,
1644
+ getCloserSize,
1645
+ getCoefficient,
1646
+ getDefaultCoordinates,
1647
+ getDefaultTransforms,
1648
+ getDefaultVisibleArea,
1649
+ getDirectionNames,
1650
+ getEmptyInteractions,
1651
+ getImageStyle,
1652
+ getIntersections,
1653
+ getMinimumSize,
1654
+ getOppositeSide,
1655
+ getOptions,
1656
+ getPositionRestrictions,
1657
+ getPreviewStyle,
1658
+ getRoundedCoordinates,
1659
+ getSizeRestrictions,
1660
+ getStencilCoordinates,
1661
+ getStyleTransforms,
1662
+ getTransformedImageSize,
1663
+ hasInteractions,
1664
+ inverseMove,
1665
+ isArray,
1666
+ isBlob,
1667
+ isBoolean,
1668
+ isCardinalDirection,
1669
+ isConsistentPosition,
1670
+ isConsistentSize,
1671
+ isConsistentState,
1672
+ isCrossOriginURL,
1673
+ isDataUrl,
1674
+ isFunction,
1675
+ isGreater,
1676
+ isInitializedState,
1677
+ isLocal,
1678
+ isLower,
1679
+ isNaN,
1680
+ isNumber,
1681
+ isNumeric,
1682
+ isObject,
1683
+ isRoughlyEqual,
1684
+ isString,
1685
+ isUndefined,
1686
+ loadImage,
1687
+ maxScale,
1688
+ mergePositionRestrictions,
1689
+ minScale,
1690
+ moveToPositionRestrictions,
1691
+ parseNumber,
1692
+ positionToSizeRestrictions,
1693
+ prepareSource,
1694
+ promiseTimeout,
1695
+ ratio,
1696
+ resizeToSizeRestrictions,
1697
+ rotatePoint,
1698
+ rotateSize,
1699
+ sign,
1700
+ sizeDistance,
1701
+ stretchCropperBoundary,
1702
+ stretchPreviewBoundary,
1703
+ touchesToImageTransform,
1704
+ updateCanvas,
1705
+ useAbstractCropper,
1706
+ useCropperImage,
1707
+ useCropperInstance,
1708
+ useMoveImageOptions,
1709
+ useRotateImageOptions,
1710
+ useScaleImageOptions,
1711
+ useUpdateEffect,
1712
+ useWindowResize,
1713
+ wheelEventToImageTransform,
1714
+ withDefaultSizeRestrictions
1715
+ };