/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../core/Accessor","../../../core/Logger","../../../core/mathUtils","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../../../geometry/support/Ellipsoid","../../ViewingMode","../support/mathUtils"],(function(t,e,i,o,n,r,a,s,c,l,u,d,p,m){"use strict";const _=n.getLogger("esri.views.3d.state.Constraints");function h(t){return{min:-2e5,max:4*t.radius}}t.Constraints=function(t){function i(e){var i;return(i=t.call(this,e)||this).collision=new v,i.distance=1/0,i.minimumPoiDistance=4,i}e._inheritsLoose(i,t);var o=i.prototype;return o.clampAltitude=function(t){return this.altitude?r.clamp(t,this.altitude.min,this.altitude.max):t},o.clampTilt=function(t,e){if(!this.tilt)return e;const i=this.tilt(t);return r.clamp(e,i.min,i.max)},o.clampDistance=function(t){return Math.min(t,this.distance)},o.createDefaultTilt=function(){return this.mode===p.ViewingMode.Local?this._createDefaultTiltLocal():this._createDefaultTiltGlobal()},o.createConstantMaxTilt=function(t){return(e,i=f)=>(i.min=g.min,i.max=t,i)},o._createDefaultTiltLocal=function(){const t=this.collision.enabled?m.makePiecewiseLinearFunction([[4e3,g.max],[1e4,r.deg2rad(88)],[6e6,r.deg2rad(88)]]):()=>g.max;return(e,i=f)=>(i.min=g.min,i.max=t(e),i)},o._createDefaultTiltGlobal=function(){const t=this.collision.enabled?m.makePiecewiseLinearFunction([[4e3,g.max],[5e4,r.deg2rad(88)],[6e6,r.deg2rad(88)],[2e7,g.min]]):m.makePiecewiseLinearFunction([[3e5,g.max],[3e6,r.deg2rad(88)],[6e6,r.deg2rad(88)],[2e7,g.min]]);return(e,i=f)=>(i.min=g.min,i.max=t(e),i)},e._createClass(i,[{key:"altitude",get:function(){return this.mode===p.ViewingMode.Local?null:this._get("altitude")||null},set:function(t){this.mode!==p.ViewingMode.Local?this._set("altitude",t):_.warn("Altitude constraint is ignored in local scenes")}}]),i}(o),i.__decorate([a.property()],t.Constraints.prototype,"altitude",null),i.__decorate([a.property({readOnly:!0})],t.Constraints.prototype,"collision",void 0),i.__decorate([a.property()],t.Constraints.prototype,"distance",void 0),i.__decorate([a.property({readOnly:!0})],t.Constraints.prototype,"minimumPoiDistance",void 0),i.__decorate([a.property()],t.Constraints.prototype,"tilt",void 0),i.__decorate([a.property({constructOnly:!0})],t.Constraints.prototype,"mode",void 0),t.Constraints=i.__decorate([u.subclass("esri.views.3d.state.Constraints")],t.Constraints);const y=h(d.earth),g={min:r.deg2rad(.5),max:r.deg2rad(179.5)},f={min:0,max:0};let v=function(t){function i(){var e;return(e=t.apply(this,arguments)||this).enabled=!0,e.elevationMargin=5,e}return e._inheritsLoose(i,t),i}(o);i.__decorate([a.property({type:Boolean})],v.prototype,"enabled",void 0),i.__decorate([a.property({type:Number})],v.prototype,"elevationMargin",void 0),v=i.__decorate([u.subclass("esri.views.3d.state.Constraints.CollisionConstraint")],v),t.TiltDefault=g,t.earthAltitudeConstraint=y,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
