/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../core/mathUtils","../../../../core/maybe","../../../../chunks/vec3","../../../../chunks/vec3f64","../../../../geometry/support/ray","./common","../../support/intersectionUtils"],(function(t,e,n,r,i,o,a,c){"use strict";function s(t,e,i=a.defaultApplyOptions){const s=u(t,e,i);if(0===s)return!1;const l=t.renderCoordsHelper,p=l.getAltitude(e.eye)+s,y=a.interactionDirectionTowardsConstraintMinimization(e,i.interactionDirection,d(t,e,Math.sign(s),T),f),m=r.copy(C,e.viewForward),A=l.intersectInfiniteManifold(o.wrap(e.eye,y),p,g);return e.eye=n.isSome(A)?A:l.setAltitude(g,p,e.eye),e.center=c.closestPointOnRay(g,e.eye,m,e.center),!0}function u(t,n,r=a.defaultApplyOptions){if(!l(t,r))return 0;const i=y(t.state.constraints.altitude,m);p(t,r,i);const o=t.renderCoordsHelper.getAltitude(n.eye),c=e.clamp(o,i.min,i.max)-o;return Math.abs(c)<=1e-6?0:c}function l(t,e){const n=t.state.constraints.altitude;return!(!t.state.isGlobal||!n)&&(e.interactionType!==a.InteractionType.TUMBLE||!a.hasConstraintType(e.selection,a.ConstraintTypes.TILT))}function p(t,e,n){const r=e.interactionType;if(r===a.InteractionType.NONE)return;const{min:i,max:o}=n,{interactionStartCamera:c,interactionFactor:s}=e,l=r===a.InteractionType.TUMBLE||r===a.InteractionType.ZOOM,p=u(t,c),d=0===p?0:t.renderCoordsHelper.getAltitude(c.eye);n.min=i,n.max=o;const y=.05*d;a.adjustRangeForInteraction(p,d,l,s,y,n)}function d(t,e,n,i){return t.renderCoordsHelper.worldUpAtPosition(e.eye,i),r.scale(i,i,n),i}function y(t,e){return e.min=t.min,e.max=t.max,e}const m={min:0,max:0},f=i.create(),T=i.create(),C=i.create(),g=i.create();t.applyAltitudeConstraint=s,t.getAltitudeConstraintError=u,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
