/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t}from"tslib";import o from"../../core/Accessor.js";import{deprecateUnnecessaryViewModel as e}from"../../core/deprecate.js";import i from"../../core/Logger.js";import{initial as r,watch as a}from"../../core/reactiveUtils.js";import{property as s,subclass as n}from"../../core/accessorSupport/decorators.js";import{getGoToDuration as p}from"../../views/2d/navigation/duration.js";import{canShowNorth as d}from"./utils.js";import{GoTo as h}from"../support/GoTo.js";let c=class extends(h(o)){constructor(t){super(t),this.orientation={x:0,y:0,z:0},this.view=null,this._updateForCamera=this._updateForCamera.bind(this),this._updateForRotation=this._updateForRotation.bind(this),this._updateRotationWatcher=this._updateRotationWatcher.bind(this),t?.suppressDeprecationWarning||e(i.getLogger(this),"Compass","arcgis-compass",{version:"5.1"})}normalizeCtorArgs(t){const{suppressDeprecationWarning:o,...e}=t??{};return e}initialize(){this._watchForView(r)}destroy(){this.view=null}get canShowNorth(){return d(this.view)}get state(){return!this.view?.ready||"2d"===this.view.type&&!this.view.constraints.rotationEnabled?"disabled":this.canShowNorth?"compass":"rotation"}reset(){this.view?.ready&&("2d"===this.view?.type?this.callGoTo({target:{rotation:0},options:{animationMode:"always",duration:p()}}):this.callGoTo({target:{heading:0}}))}_updateForRotation(t){null!=t&&this._set("orientation",{z:t})}_updateForCamera(t){if(!t)return;const o=-t.heading;this._set("orientation",{x:0,y:0,z:o})}_updateRotationWatcher(t){this.removeAllHandles(),this._watchForView(),t&&this.addHandles("2d"===t.type?a(()=>t?.rotation,this._updateForRotation,r):a(()=>t?.camera,this._updateForCamera,r))}_watchForView(t){this.addHandles(a(()=>this.view,this._updateRotationWatcher,t))}};t([s({readOnly:!0})],c.prototype,"canShowNorth",null),t([s({readOnly:!0})],c.prototype,"orientation",void 0),t([s({readOnly:!0})],c.prototype,"state",null),t([s()],c.prototype,"view",void 0),c=t([n("esri.widgets.Compass.CompassViewModel")],c);const l=c;export{l as default};
