/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import has from"../../../../core/has.js";import{createResolver as i}from"../../../../core/promiseUtils.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";let r=class extends e{constructor(t){super(t),this.computedOpacity=1,this.computedVisible=!0,this.opacity=1,this.visible=!0,this._fadeOutResolver=null,this._fadeInResolver=null}get transitioning(){return(this._fadeOutResolver||!this.visible?0:this.opacity)!==this.computedOpacity}endTransition(){this._fadeInResolver?.(),this._fadeOutResolver?.(),this._fadeInResolver=this._fadeOutResolver=null,this.computedOpacity=this.visible?this.opacity:0}fadeIn(){return this._fadeInResolver||(this.opacity=1,this.computedOpacity=0,this._fadeOutResolver?.(),this._fadeOutResolver=null,this._fadeInResolver=i()),this._fadeInResolver.promise}fadeOut(){return this._fadeOutResolver||(this.opacity=0,this._fadeInResolver?.(),this._fadeInResolver=null,this._fadeOutResolver=i()),this._fadeOutResolver.promise}transitionStep(t,e){const i=has("mapview-transitions-duration"),s=i?1/i:0;if(0===s)this.computedOpacity=this.opacity,this.computedVisible=this.visible;else{const e=this._fadeOutResolver||!this.visible?0:this.opacity,i=this.computedOpacity;if(i===e)this.computedVisible=this.visible;else{const o=t*s;this.computedOpacity=i>e?Math.max(e,i-o):Math.min(e,i+o),this.computedVisible=this.computedOpacity>0}}this.transitioning||(this._fadeInResolver?.(),this._fadeOutResolver?.(),this._fadeOutResolver=this._fadeInResolver=null)}};t([s()],r.prototype,"computedOpacity",void 0),t([s()],r.prototype,"computedVisible",void 0),t([s()],r.prototype,"opacity",void 0),t([s()],r.prototype,"visible",void 0),t([s()],r.prototype,"transitioning",null),t([s()],r.prototype,"_fadeOutResolver",void 0),t([s()],r.prototype,"_fadeInResolver",void 0),r=t([o("esri.views.2d.engine.transitions.FadeTransition")],r);export{r as FadeTransition};
