@deck.gl/test-utils 9.4.0-beta.1 → 9.4.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vitest.cjs CHANGED
@@ -886,8 +886,8 @@ var _Viewport = class _Viewport {
886
886
  }
887
887
  return PROJECTION_MODE.IDENTITY;
888
888
  }
889
- // Two viewports are equal if width and height are identical, and if
890
- // their view and projection matrices are (approximately) equal.
889
+ // Two viewports are equal if their dimensions, common-space scale, and
890
+ // view and projection matrices are (approximately) equal.
891
891
  equals(viewport) {
892
892
  if (!(viewport instanceof _Viewport)) {
893
893
  return false;
@@ -895,7 +895,7 @@ var _Viewport = class _Viewport {
895
895
  if (this === viewport) {
896
896
  return true;
897
897
  }
898
- return viewport.width === this.width && viewport.height === this.height && viewport.scale === this.scale && (0, import_core2.equals)(viewport.projectionMatrix, this.projectionMatrix) && (0, import_core2.equals)(viewport.viewMatrix, this.viewMatrix);
898
+ return viewport.width === this.width && viewport.height === this.height && viewport.scale === this.scale && viewport.projectionMode === this.projectionMode && viewport.resolution === this.resolution && (0, import_core2.equals)(viewport.distanceScales.unitsPerMeter, this.distanceScales.unitsPerMeter) && (0, import_core2.equals)(viewport.projectionMatrix, this.projectionMatrix) && (0, import_core2.equals)(viewport.viewMatrix, this.viewMatrix);
899
899
  }
900
900
  /**
901
901
  * Projects xyz (possibly latitude and longitude) to pixel coordinates in window
@@ -1232,6 +1232,10 @@ var _WebMercatorViewport = class _WebMercatorViewport extends Viewport {
1232
1232
  }
1233
1233
  return this._subViewports;
1234
1234
  }
1235
+ /** Returns whether two Web Mercator viewports use the same projection settings. */
1236
+ equals(viewport) {
1237
+ return viewport instanceof _WebMercatorViewport && viewport._pseudoMeters === this._pseudoMeters && super.equals(viewport);
1238
+ }
1235
1239
  projectPosition(xyz) {
1236
1240
  if (this._pseudoMeters) {
1237
1241
  return super.projectPosition(xyz);
@@ -2259,7 +2263,7 @@ var View = class {
2259
2263
  };
2260
2264
 
2261
2265
  // ../core/src/controllers/map-controller.ts
2262
- var import_core9 = require("@math.gl/core");
2266
+ var import_core7 = require("@math.gl/core");
2263
2267
 
2264
2268
  // ../core/src/transitions/transition.ts
2265
2269
  var Transition = class {
@@ -2571,185 +2575,7 @@ var TransitionInterpolator = class {
2571
2575
  };
2572
2576
 
2573
2577
  // ../core/src/transitions/linear-interpolator.ts
2574
- var import_core8 = require("@math.gl/core");
2575
-
2576
- // ../core/src/viewports/globe-viewport.ts
2577
2578
  var import_core6 = require("@math.gl/core");
2578
- var import_web_mercator3 = require("@math.gl/web-mercator");
2579
- var import_core7 = require("@math.gl/core");
2580
- var import_web_mercator4 = require("@math.gl/web-mercator");
2581
- var DEGREES_TO_RADIANS2 = Math.PI / 180;
2582
- var RADIANS_TO_DEGREES = 180 / Math.PI;
2583
- var EARTH_RADIUS = 6370972;
2584
- var GLOBE_RADIUS = 256;
2585
- function getDistanceScales2() {
2586
- const unitsPerMeter2 = GLOBE_RADIUS / EARTH_RADIUS;
2587
- const unitsPerDegree = Math.PI / 180 * GLOBE_RADIUS;
2588
- return {
2589
- unitsPerMeter: [unitsPerMeter2, unitsPerMeter2, unitsPerMeter2],
2590
- unitsPerMeter2: [0, 0, 0],
2591
- metersPerUnit: [1 / unitsPerMeter2, 1 / unitsPerMeter2, 1 / unitsPerMeter2],
2592
- unitsPerDegree: [unitsPerDegree, unitsPerDegree, unitsPerMeter2],
2593
- unitsPerDegree2: [0, 0, 0],
2594
- degreesPerUnit: [1 / unitsPerDegree, 1 / unitsPerDegree, 1 / unitsPerMeter2]
2595
- };
2596
- }
2597
- var GlobeViewport = class extends Viewport {
2598
- constructor(opts = {}) {
2599
- const {
2600
- longitude = 0,
2601
- bearing = 0,
2602
- pitch = 0,
2603
- zoom = 0,
2604
- // Matches Maplibre defaults
2605
- // https://github.com/maplibre/maplibre-gl-js/blob/f8ab4b48d59ab8fe7b068b102538793bbdd4c848/src/geo/projection/globe_transform.ts#L632-L633
2606
- nearZMultiplier = 0.5,
2607
- farZMultiplier = 1,
2608
- resolution = 10
2609
- } = opts;
2610
- let { latitude = 0, height, altitude = 1.5, fovy } = opts;
2611
- latitude = Math.max(Math.min(latitude, 90), -90);
2612
- height = height || 1;
2613
- if (fovy) {
2614
- altitude = (0, import_web_mercator3.fovyToAltitude)(fovy);
2615
- } else {
2616
- fovy = (0, import_web_mercator3.altitudeToFovy)(altitude);
2617
- }
2618
- const scaleLatitude = Math.max(Math.min(latitude, import_web_mercator4.MAX_LATITUDE), -import_web_mercator4.MAX_LATITUDE);
2619
- const scale = Math.pow(2, zoom - zoomAdjust(scaleLatitude));
2620
- const pitchRadians = pitch * DEGREES_TO_RADIANS2;
2621
- const nearZ = opts.nearZ ?? nearZMultiplier;
2622
- const farZ = opts.farZ ?? (altitude + GLOBE_RADIUS * 2 * scale / height / Math.max(Math.cos(pitchRadians), 0.1)) * farZMultiplier;
2623
- const viewMatrix = new import_core6.Matrix4().lookAt({ eye: [0, -altitude, 0], up: [0, 0, 1] }).rotateX(-pitchRadians).rotateY(-bearing * DEGREES_TO_RADIANS2).rotateX(latitude * DEGREES_TO_RADIANS2).rotateZ(-longitude * DEGREES_TO_RADIANS2).scale(scale / height);
2624
- super({
2625
- ...opts,
2626
- // x, y, width,
2627
- height,
2628
- // view matrix
2629
- viewMatrix,
2630
- longitude,
2631
- latitude,
2632
- zoom,
2633
- // projection matrix parameters
2634
- distanceScales: getDistanceScales2(),
2635
- fovy,
2636
- focalDistance: altitude,
2637
- near: nearZ,
2638
- far: farZ
2639
- });
2640
- this.scale = scale;
2641
- this.latitude = latitude;
2642
- this.longitude = longitude;
2643
- this.bearing = bearing;
2644
- this.pitch = pitch;
2645
- this.fovy = fovy;
2646
- this.resolution = resolution;
2647
- }
2648
- get projectionMode() {
2649
- return PROJECTION_MODE.GLOBE;
2650
- }
2651
- getDistanceScales() {
2652
- return this.distanceScales;
2653
- }
2654
- getBounds(options = {}) {
2655
- const unprojectOption = { targetZ: options.z || 0 };
2656
- const left = this.unproject([0, this.height / 2], unprojectOption);
2657
- const top = this.unproject([this.width / 2, 0], unprojectOption);
2658
- const right = this.unproject([this.width, this.height / 2], unprojectOption);
2659
- const bottom = this.unproject([this.width / 2, this.height], unprojectOption);
2660
- if (right[0] < this.longitude) right[0] += 360;
2661
- if (left[0] > this.longitude) left[0] -= 360;
2662
- return [
2663
- Math.min(left[0], right[0], top[0], bottom[0]),
2664
- Math.min(left[1], right[1], top[1], bottom[1]),
2665
- Math.max(left[0], right[0], top[0], bottom[0]),
2666
- Math.max(left[1], right[1], top[1], bottom[1])
2667
- ];
2668
- }
2669
- unproject(xyz, { topLeft = true, targetZ } = {}) {
2670
- const [x, y, z] = xyz;
2671
- const y2 = topLeft ? y : this.height - y;
2672
- const { pixelUnprojectionMatrix } = this;
2673
- let coord;
2674
- if (Number.isFinite(z)) {
2675
- coord = transformVector(pixelUnprojectionMatrix, [x, y2, z, 1]);
2676
- } else {
2677
- const coord0 = transformVector(pixelUnprojectionMatrix, [x, y2, -1, 1]);
2678
- const coord1 = transformVector(pixelUnprojectionMatrix, [x, y2, 1, 1]);
2679
- const lt = ((targetZ || 0) / EARTH_RADIUS + 1) * GLOBE_RADIUS;
2680
- const lSqr = import_core7.vec3.sqrLen(import_core7.vec3.sub([], coord0, coord1));
2681
- const l0Sqr = import_core7.vec3.sqrLen(coord0);
2682
- const l1Sqr = import_core7.vec3.sqrLen(coord1);
2683
- const sSqr = (4 * l0Sqr * l1Sqr - (lSqr - l0Sqr - l1Sqr) ** 2) / 16;
2684
- const dSqr = 4 * sSqr / lSqr;
2685
- const r0 = Math.sqrt(l0Sqr - dSqr);
2686
- const dr = Math.sqrt(Math.max(0, lt * lt - dSqr));
2687
- const t = (r0 - dr) / Math.sqrt(lSqr);
2688
- coord = import_core7.vec3.lerp([], coord0, coord1, t);
2689
- }
2690
- const [X, Y, Z] = this.unprojectPosition(coord);
2691
- if (Number.isFinite(z)) {
2692
- return [X, Y, Z];
2693
- }
2694
- return Number.isFinite(targetZ) ? [X, Y, targetZ] : [X, Y];
2695
- }
2696
- projectPosition(xyz) {
2697
- const [lng, lat, Z = 0] = xyz;
2698
- const lambda = lng * DEGREES_TO_RADIANS2;
2699
- const phi = lat * DEGREES_TO_RADIANS2;
2700
- const cosPhi = Math.cos(phi);
2701
- const D = (Z / EARTH_RADIUS + 1) * GLOBE_RADIUS;
2702
- return [Math.sin(lambda) * cosPhi * D, -Math.cos(lambda) * cosPhi * D, Math.sin(phi) * D];
2703
- }
2704
- unprojectPosition(xyz) {
2705
- const [x, y, z] = xyz;
2706
- const D = import_core7.vec3.len(xyz);
2707
- const phi = Math.asin(z / D);
2708
- const lambda = Math.atan2(x, -y);
2709
- const lng = lambda * RADIANS_TO_DEGREES;
2710
- const lat = phi * RADIANS_TO_DEGREES;
2711
- const Z = (D / GLOBE_RADIUS - 1) * EARTH_RADIUS;
2712
- return [lng, lat, Z];
2713
- }
2714
- projectFlat(xyz) {
2715
- return xyz;
2716
- }
2717
- unprojectFlat(xyz) {
2718
- return xyz;
2719
- }
2720
- /**
2721
- * Pan the globe using delta-based movement
2722
- * @param coords - the geographic coordinates where the pan started
2723
- * @param pixel - the current screen position
2724
- * @param startPixel - the screen position where the pan started
2725
- * @returns updated viewport options with new longitude/latitude
2726
- */
2727
- panByPosition([startLng, startLat, startZoom], pixel, startPixel) {
2728
- const scale = Math.pow(2, this.zoom - zoomAdjust(this.latitude));
2729
- const rotationSpeed = 0.25 / scale;
2730
- const longitude = startLng + rotationSpeed * (startPixel[0] - pixel[0]);
2731
- let latitude = startLat - rotationSpeed * (startPixel[1] - pixel[1]);
2732
- latitude = Math.max(Math.min(latitude, 90), -90);
2733
- const out = { longitude, latitude, zoom: startZoom - zoomAdjust(startLat) };
2734
- out.zoom += zoomAdjust(out.latitude);
2735
- return out;
2736
- }
2737
- };
2738
- GlobeViewport.displayName = "GlobeViewport";
2739
- function zoomAdjust(latitude, clampToPoles) {
2740
- if (clampToPoles) {
2741
- latitude = Math.max(Math.min(latitude, import_web_mercator4.MAX_LATITUDE), -import_web_mercator4.MAX_LATITUDE);
2742
- }
2743
- const scaleAdjust = Math.PI * Math.cos(latitude * Math.PI / 180);
2744
- return Math.log2(scaleAdjust);
2745
- }
2746
- function transformVector(matrix, vector) {
2747
- const result = import_core7.vec4.transformMat4([], vector, matrix);
2748
- import_core7.vec4.scale(result, result, 1 / result[3]);
2749
- return result;
2750
- }
2751
-
2752
- // ../core/src/transitions/linear-interpolator.ts
2753
2579
  var DEFAULT_PROPS = ["longitude", "latitude", "zoom", "bearing", "pitch"];
2754
2580
  var DEFAULT_REQUIRED_PROPS = ["longitude", "latitude", "zoom"];
2755
2581
  var LinearInterpolator = class extends TransitionInterpolator {
@@ -2776,28 +2602,23 @@ var LinearInterpolator = class extends TransitionInterpolator {
2776
2602
  const result = super.initializeProps(startProps, endProps);
2777
2603
  const { makeViewport, around } = this.opts;
2778
2604
  if (makeViewport && around) {
2779
- const TestViewport = makeViewport(startProps);
2780
- if (TestViewport instanceof GlobeViewport) {
2781
- log_default.warn("around not supported in GlobeView")();
2782
- } else {
2783
- const startViewport = makeViewport(startProps);
2784
- const endViewport = makeViewport(endProps);
2785
- const aroundPosition = startViewport.unproject(around);
2786
- result.start.around = around;
2787
- Object.assign(result.end, {
2788
- around: endViewport.project(aroundPosition),
2789
- aroundPosition,
2790
- width: endProps.width,
2791
- height: endProps.height
2792
- });
2793
- }
2605
+ const startViewport = makeViewport(startProps);
2606
+ const endViewport = makeViewport(endProps);
2607
+ const aroundPosition = startViewport.unproject(around);
2608
+ result.start.around = around;
2609
+ Object.assign(result.end, {
2610
+ around: endViewport.project(aroundPosition),
2611
+ aroundPosition,
2612
+ width: endProps.width,
2613
+ height: endProps.height
2614
+ });
2794
2615
  }
2795
2616
  return result;
2796
2617
  }
2797
2618
  interpolateProps(startProps, endProps, t) {
2798
2619
  const propsInTransition = {};
2799
2620
  for (const key of this._propsToExtract) {
2800
- propsInTransition[key] = (0, import_core8.lerp)(startProps[key] || 0, endProps[key] || 0, t);
2621
+ propsInTransition[key] = (0, import_core6.lerp)(startProps[key] || 0, endProps[key] || 0, t);
2801
2622
  }
2802
2623
  if (endProps.aroundPosition && this.opts.makeViewport) {
2803
2624
  const viewport = this.opts.makeViewport({ ...endProps, ...propsInTransition });
@@ -2806,7 +2627,7 @@ var LinearInterpolator = class extends TransitionInterpolator {
2806
2627
  viewport.panByPosition(
2807
2628
  endProps.aroundPosition,
2808
2629
  // anchor point in current screen coordinates
2809
- (0, import_core8.lerp)(startProps.around, endProps.around, t)
2630
+ (0, import_core6.lerp)(startProps.around, endProps.around, t)
2810
2631
  )
2811
2632
  );
2812
2633
  }
@@ -2815,6 +2636,7 @@ var LinearInterpolator = class extends TransitionInterpolator {
2815
2636
  };
2816
2637
 
2817
2638
  // ../core/src/controllers/controller.ts
2639
+ var import_web_mercator3 = require("@math.gl/web-mercator");
2818
2640
  var NO_TRANSITION_PROPS = {
2819
2641
  transitionDuration: 0
2820
2642
  };
@@ -2863,6 +2685,7 @@ var Controller = class {
2863
2685
  this.touchRotate = false;
2864
2686
  this.multiTouchDrag = null;
2865
2687
  this.trackpadGesture = false;
2688
+ this.zoomAround = "pointer";
2866
2689
  this.keyboard = true;
2867
2690
  this.transitionManager = new TransitionManager({
2868
2691
  ...opts,
@@ -2957,6 +2780,15 @@ var Controller = class {
2957
2780
  const { offsetCenter } = event;
2958
2781
  return [offsetCenter.x - x, offsetCenter.y - y];
2959
2782
  }
2783
+ /** Resolves the zoom anchor for pointer-based controls. */
2784
+ getZoomPosition(position) {
2785
+ if (this.zoomAround === "pointer") {
2786
+ return position;
2787
+ }
2788
+ const viewport = this.makeViewport(this.controllerState.getViewportProps());
2789
+ const [centerX, centerY] = (0, import_web_mercator3.worldToPixels)(viewport.center, viewport.pixelProjectionMatrix);
2790
+ return [centerX, centerY];
2791
+ }
2960
2792
  isPointInBounds(pos, event) {
2961
2793
  const { width, height } = this.props;
2962
2794
  if (event && event.handled) {
@@ -3014,6 +2846,7 @@ var Controller = class {
3014
2846
  touchRotate = false,
3015
2847
  multiTouchDrag = touchRotate ? "rotate" : null,
3016
2848
  trackpadGesture = false,
2849
+ zoomAround = "pointer",
3017
2850
  keyboard = true
3018
2851
  } = props;
3019
2852
  const isInteractive = Boolean(this.onViewStateChange);
@@ -3036,6 +2869,7 @@ var Controller = class {
3036
2869
  this.touchRotate = multiTouchDrag === "rotate";
3037
2870
  this.multiTouchDrag = multiTouchDrag;
3038
2871
  this.trackpadGesture = trackpadGesture;
2872
+ this.zoomAround = zoomAround;
3039
2873
  this.keyboard = keyboard;
3040
2874
  const constraintChanged = !oldProps || oldProps.height !== props.height || oldProps.width !== props.width || oldProps.maxBounds !== props.maxBounds || oldProps.maxBoundsPadding !== props.maxBoundsPadding;
3041
2875
  if (constraintChanged && props.maxBounds) {
@@ -3269,8 +3103,9 @@ var Controller = class {
3269
3103
  if (delta < 0 && scale !== 0) {
3270
3104
  scale = 1 / scale;
3271
3105
  }
3272
- const transitionProps = smooth ? { ...this._getTransitionProps({ around: pos }), transitionDuration: 250 } : NO_TRANSITION_PROPS;
3273
- const newControllerState = this.controllerState.zoom({ pos, scale });
3106
+ const zoomPosition = this.getZoomPosition(pos);
3107
+ const transitionProps = smooth ? { ...this._getTransitionProps({ around: zoomPosition }), transitionDuration: 250 } : NO_TRANSITION_PROPS;
3108
+ const newControllerState = this.controllerState.zoom({ pos: zoomPosition, scale });
3274
3109
  this.updateViewport(newControllerState, transitionProps, {
3275
3110
  isZooming: true,
3276
3111
  isPanning: true
@@ -3356,7 +3191,7 @@ var Controller = class {
3356
3191
  if (!this.isPointInBounds(pos, event)) {
3357
3192
  return false;
3358
3193
  }
3359
- const newControllerState = this.controllerState.zoomStart({ pos }, this._getConstraintContext("zoom", "start")).rotateStart({ pos }, this._getConstraintContext("rotate", "start"));
3194
+ const newControllerState = this.controllerState.zoomStart({ pos: this.getZoomPosition(pos) }, this._getConstraintContext("zoom", "start")).rotateStart({ pos }, this._getConstraintContext("rotate", "start"));
3360
3195
  pinchEventWorkaround._startPinchRotation = event.rotation;
3361
3196
  pinchEventWorkaround._lastPinchEvent = event;
3362
3197
  this.updateViewport(newControllerState, NO_TRANSITION_PROPS, { isDragging: true });
@@ -3375,7 +3210,7 @@ var Controller = class {
3375
3210
  const { scale } = event;
3376
3211
  const pos = this.getCenter(event);
3377
3212
  newControllerState = newControllerState.zoom(
3378
- { pos, scale },
3213
+ { pos: this.getZoomPosition(pos), scale },
3379
3214
  this._getConstraintContext("zoom", "update")
3380
3215
  );
3381
3216
  }
@@ -3403,15 +3238,16 @@ var Controller = class {
3403
3238
  const { _lastPinchEvent } = pinchEventWorkaround;
3404
3239
  if (this.touchZoom && inertia && _lastPinchEvent && event.scale !== _lastPinchEvent.scale) {
3405
3240
  const pos = this.getCenter(event);
3241
+ const zoomPosition = this.getZoomPosition(pos);
3406
3242
  let newControllerState = this.controllerState.rotateEnd();
3407
3243
  const z = Math.log2(event.scale);
3408
3244
  const velocityZ = (z - Math.log2(_lastPinchEvent.scale)) / (event.deltaTime - _lastPinchEvent.deltaTime);
3409
3245
  const endScale = Math.pow(2, z + velocityZ * inertia / 2);
3410
- newControllerState = newControllerState.zoom({ pos, scale: endScale }).zoomEnd();
3246
+ newControllerState = newControllerState.zoom({ pos: zoomPosition, scale: endScale }).zoomEnd();
3411
3247
  this.updateViewport(
3412
3248
  newControllerState,
3413
3249
  {
3414
- ...this._getTransitionProps({ around: pos }),
3250
+ ...this._getTransitionProps({ around: zoomPosition }),
3415
3251
  transitionDuration: inertia,
3416
3252
  transitionEasing: INERTIA_EASING
3417
3253
  },
@@ -3456,8 +3292,12 @@ var Controller = class {
3456
3292
  return false;
3457
3293
  }
3458
3294
  const isZoomOut = this.isFunctionKeyPressed(event);
3459
- const newControllerState = this.controllerState.zoom({ pos, scale: isZoomOut ? 0.5 : 2 });
3460
- this.updateViewport(newControllerState, this._getTransitionProps({ around: pos }), {
3295
+ const zoomPosition = this.getZoomPosition(pos);
3296
+ const newControllerState = this.controllerState.zoom({
3297
+ pos: zoomPosition,
3298
+ scale: isZoomOut ? 0.5 : 2
3299
+ });
3300
+ this.updateViewport(newControllerState, this._getTransitionProps({ around: zoomPosition }), {
3461
3301
  isZooming: true,
3462
3302
  isPanning: true
3463
3303
  });
@@ -3474,14 +3314,14 @@ var Controller = class {
3474
3314
  this._doubleClickDragAnchor = null;
3475
3315
  return false;
3476
3316
  }
3477
- this._doubleClickDragAnchor = pos;
3317
+ this._doubleClickDragAnchor = this.getZoomPosition(pos);
3478
3318
  let newControllerState = this.controllerState.zoomStart(
3479
- { pos },
3319
+ { pos: this._doubleClickDragAnchor },
3480
3320
  this._getConstraintContext("zoom", "start")
3481
3321
  );
3482
3322
  if (event.scale !== 1) {
3483
3323
  newControllerState = newControllerState.zoom(
3484
- { pos, scale: event.scale },
3324
+ { pos: this._doubleClickDragAnchor, scale: event.scale },
3485
3325
  this._getConstraintContext("zoom", "update")
3486
3326
  );
3487
3327
  }
@@ -3650,7 +3490,7 @@ function getMaxBoundsExtents(viewport, target, rect) {
3650
3490
  }
3651
3491
 
3652
3492
  // ../core/src/controllers/map-controller.ts
3653
- var import_web_mercator5 = require("@math.gl/web-mercator");
3493
+ var import_web_mercator4 = require("@math.gl/web-mercator");
3654
3494
  var PITCH_MOUSE_THRESHOLD = 5;
3655
3495
  var PITCH_ACCEL = 1.2;
3656
3496
  var WEB_MERCATOR_TILE_SIZE = 512;
@@ -3664,11 +3504,11 @@ function lngLatToWorld2([lng, lat]) {
3664
3504
  lat = Math.sign(lat) * 90;
3665
3505
  }
3666
3506
  if (Number.isFinite(lng)) {
3667
- const [x, y2] = (0, import_web_mercator5.lngLatToWorld)([lng, lat]);
3668
- return [x, (0, import_core9.clamp)(y2, 0, WEB_MERCATOR_TILE_SIZE)];
3507
+ const [x, y2] = (0, import_web_mercator4.lngLatToWorld)([lng, lat]);
3508
+ return [x, (0, import_core7.clamp)(y2, 0, WEB_MERCATOR_TILE_SIZE)];
3669
3509
  }
3670
- const [, y] = (0, import_web_mercator5.lngLatToWorld)([0, lat]);
3671
- return [lng, (0, import_core9.clamp)(y, 0, WEB_MERCATOR_TILE_SIZE)];
3510
+ const [, y] = (0, import_web_mercator4.lngLatToWorld)([0, lat]);
3511
+ return [lng, (0, import_core7.clamp)(y, 0, WEB_MERCATOR_TILE_SIZE)];
3672
3512
  }
3673
3513
  var MapState = class extends ViewState {
3674
3514
  constructor(options) {
@@ -3977,7 +3817,7 @@ var MapState = class extends ViewState {
3977
3817
  props.bearing = mod(bearing + 180, 360) - 180;
3978
3818
  }
3979
3819
  }
3980
- props.pitch = (0, import_core9.clamp)(pitch, minPitch, maxPitch);
3820
+ props.pitch = (0, import_core7.clamp)(pitch, minPitch, maxPitch);
3981
3821
  const constrainedZoom = this._constrainZoom(props.zoom, props);
3982
3822
  const shouldRubberBand = rubberBand && (constraintContext == null ? void 0 : constraintContext.mode) === "elastic";
3983
3823
  props.zoom = (constraintContext == null ? void 0 : constraintContext.mode) === "preserve" ? props.zoom : shouldRubberBand ? applyRubberBand(props.zoom, constrainedZoom, ZOOM_RUBBER_BAND_RANGE) : constrainedZoom;
@@ -4012,8 +3852,8 @@ var MapState = class extends ViewState {
4012
3852
  ];
4013
3853
  const center = lngLatToWorld2([props.longitude, props.latitude]);
4014
3854
  const constrainedCenter = [
4015
- (0, import_core9.clamp)(center[0], minimumCenter[0], maximumCenter[0]),
4016
- (0, import_core9.clamp)(center[1], minimumCenter[1], maximumCenter[1])
3855
+ (0, import_core7.clamp)(center[0], minimumCenter[0], maximumCenter[0]),
3856
+ (0, import_core7.clamp)(center[1], minimumCenter[1], maximumCenter[1])
4017
3857
  ];
4018
3858
  const displayedCenter = center.slice();
4019
3859
  if (maxBoundsRect.width >= 0) {
@@ -4023,7 +3863,7 @@ var MapState = class extends ViewState {
4023
3863
  displayedCenter[1] = (constraintContext == null ? void 0 : constraintContext.mode) === "preserve" ? center[1] : shouldRubberBand ? applyRubberBand(center[1], constrainedCenter[1], maxBoundsRect.height / 2 / scale) : constrainedCenter[1];
4024
3864
  }
4025
3865
  if (displayedCenter[0] !== center[0] || displayedCenter[1] !== center[1]) {
4026
- const [displayedLongitude, displayedLatitude] = (0, import_web_mercator5.worldToLngLat)(displayedCenter);
3866
+ const [displayedLongitude, displayedLatitude] = (0, import_web_mercator4.worldToLngLat)(displayedCenter);
4027
3867
  if (displayedCenter[0] !== center[0]) {
4028
3868
  props.longitude = displayedLongitude;
4029
3869
  }
@@ -4054,7 +3894,7 @@ var MapState = class extends ViewState {
4054
3894
  }
4055
3895
  if (minZoom > maxZoom) minZoom = maxZoom;
4056
3896
  }
4057
- return (0, import_core9.clamp)(zoom, minZoom, maxZoom);
3897
+ return (0, import_core7.clamp)(zoom, minZoom, maxZoom);
4058
3898
  }
4059
3899
  _zoomFromCenter(scale, constraintContext) {
4060
3900
  const { width, height } = this.getViewportProps();
@@ -4110,7 +3950,7 @@ var MapState = class extends ViewState {
4110
3950
  deltaScaleY = 1 - centerY / startY;
4111
3951
  }
4112
3952
  }
4113
- deltaScaleY = (0, import_core9.clamp)(deltaScaleY, -1, 1);
3953
+ deltaScaleY = (0, import_core7.clamp)(deltaScaleY, -1, 1);
4114
3954
  const { minPitch, maxPitch } = this.getViewportProps();
4115
3955
  const bearing = startBearing + 180 * deltaScaleX;
4116
3956
  let pitch = startPitch;