/*
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","../../../core/Evented","../../../core/has","../../../core/maybe","../../../core/promiseUtils"],(function(e,t,s,i,n,r){"use strict";const o=1/i("mapview-transitions-duration");let a=function(e){function s(){var t;return(t=e.apply(this,arguments)||this)._fadeOutResolver=null,t._fadeInResolver=null,t._clips=null,t.computedVisible=!0,t.computedOpacity=1,t.fadeTransitionEnabled=!1,t.inFadeTransition=!1,t._isReady=!1,t._opacity=1,t._stage=null,t._visible=!0,t}t._inheritsLoose(s,e);var i=s.prototype;return i._getTransforms=function(){return n.isNone(this._transforms)&&(this._transforms=this._createTransforms()),this._transforms},i.fadeIn=function(){return this._fadeInResolver||(this._fadeOutResolver&&(this._fadeOutResolver(),this._fadeOutResolver=null),this.computedOpacity=0,this.fadeTransitionEnabled=!0,this._fadeInResolver=r.createResolver(),this.requestRender()),this._fadeInResolver.promise},i.fadeOut=function(){return this._fadeOutResolver||(this._fadeInResolver&&(this._fadeInResolver(),this._fadeInResolver=null),this.fadeTransitionEnabled=!0,this._fadeOutResolver=r.createResolver(),this.requestRender()),this._fadeOutResolver.promise},i.beforeRender=function(e){this.updateTransitionProperties(e.deltaTime,e.state.scale)},i.afterRender=function(e){this._fadeInResolver&&this.computedOpacity===this.opacity?(this._fadeInResolver(),this._fadeInResolver=null):this._fadeOutResolver&&0===this.computedOpacity&&(this._fadeOutResolver(),this._fadeOutResolver=null)},i.remove=function(){var e;null==(e=this.parent)||e.removeChild(this)},i.setTransform=function(e){},i.processRender=function(e){this.stage&&this.computedVisible&&this.doRender(e)},i.requestRender=function(){this.stage&&this.stage.requestRender()},i.processDetach=function(){this._fadeInResolver&&(this._fadeInResolver(),this._fadeInResolver=null),this._fadeOutResolver&&(this._fadeOutResolver(),this._fadeOutResolver=null),this.onDetach(),this.emit("detach")},i.updateTransitionProperties=function(e,t){if(this.fadeTransitionEnabled){const t=this._fadeOutResolver||!this.visible?0:this.opacity,s=this.computedOpacity;if(s===t)this.computedVisible=this.visible;else{const i=e*o;this.computedOpacity=s>t?Math.max(t,s-i):Math.min(t,s+i),this.computedVisible=this.computedOpacity>0;const n=t===this.computedOpacity;this.inFadeTransition=!n,n||this.requestRender()}}else this.computedOpacity=this.opacity,this.computedVisible=this.visible},i.onAttach=function(){},i.onDetach=function(){},i.doRender=function(e){},i.ready=function(){this._isReady||(this._isReady=!0,this.emit("isReady"),this.requestRender())},t._createClass(s,[{key:"clips",get:function(){return this._clips},set:function(e){this._clips=e,this.requestRender()}},{key:"isReady",get:function(){return this._isReady}},{key:"opacity",get:function(){return this._opacity},set:function(e){this._opacity!==e&&(this._opacity=Math.min(1,Math.max(e,0)),this.requestRender())}},{key:"stage",get:function(){return this._stage},set:function(e){if(this._stage===e)return;const t=this._stage;this._stage=e,e?this._stage.untrashDisplayObject(this)||(this.onAttach(),this.emit("attach")):t.trashDisplayObject(this)}},{key:"transforms",get:function(){return this._getTransforms()}},{key:"visible",get:function(){return this._visible},set:function(e){this._visible!==e&&(this._visible=e,this.requestRender())}}]),s}(s);e.DisplayObject=a,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
