/*
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/time"],(function(t,i,o){"use strict";let e=function(){function t(t){t&&this.update(t)}var e=t.prototype;return e.update=function(t){t&&(this.definition?this.definition.copyFrom(t):this.definition=t.clone()),this._updatePrecomputedVariables(),this._updatePixelFlow()},e._updatePrecomputedVariables=function(){const t=this.definition,i=t.compared,o=i.sourceZoom,e=i.targetZoom;this._zoomSign=o>e?1:-1,this._panPixelsAtSource=i.pan*t.source.pixelsPerPanAtZoom(o);const n=(t.source.pixelsPerRotateAtZoom(o)+t.target.pixelsPerRotateAtZoom(e))/2;this._rotatePixels=i.rotate*n},e._updatePixelFlow=function(){const t=this.definition.compared.sourceZoom,i=this.definition.compared.targetZoom,{hasZoom:e,hasPan:n,hasRotate:s}=this.definition;let a=0,h=0;e&&(n&&(a=(i/t-1)/(-1/(this._zoomSign*this.definition.halfWindowSize)*Math.LN2*this._panPixelsAtSource)),s&&(h=this._zoomSign*(Math.log(t/i)/Math.LN2)*this.definition.halfWindowSize/this._rotatePixels)),this._zoomPixelFlow=0,this._panPixelFlow=0,this._rotatePixelFlow=0;const l=this.definition.desiredPixelFlow;if(e&&n&&s){const t=a+h+a*h;this._zoomPixelFlow=a*h/t*l,this._panPixelFlow=h/t*l,this._rotatePixelFlow=a/t*l}else if(e&&n){const t=1+a;this._zoomPixelFlow=a/t*l,this._panPixelFlow=1/t*l}else if(e&&s){const t=1+h;this._zoomPixelFlow=h/t*l,this._rotatePixelFlow=1/t*l}else if(n&&s){const t=this._panPixelsAtSource/this._rotatePixels,i=1+t;this._panPixelFlow=t/i*l,this._rotatePixelFlow=1/i*l}else n?this._panPixelFlow=l:e?this._zoomPixelFlow=l:s&&(this._rotatePixelFlow=l);this._time=s?this.rotateTime:e?this.zoomTime:n?this.panTime:o.Seconds(0)},e._interpolateComponentsZoom=function(t){if(0===t||1===t)return t;if(this.definition.hasZoom){const i=this.definition.compared.sourceZoom,o=this.definition.compared.targetZoom;return(i*(i/o)**-t-i)/(o-i)}return t},e._interpolateComponentsPan=function(t){if(0===t||1===t)return t;if(this.definition.hasPan&&this.definition.hasZoom){const i=-1/(this._zoomSign*this.definition.halfWindowSize)*this._zoomPixelFlow;return 1/this._panPixelsAtSource*(this._panPixelFlow*(2**(i*t*this._time)-1))/(i*Math.LN2)}return t},e._interpolateComponentsRotate=function(t){return t},e.interpolateComponentsAt=function(t,i){t=Math.min(Math.max(t,0),1);const o=this._interpolateComponentsZoom(t),e=this._interpolateComponentsPan(t),n=this._interpolateComponentsRotate(t);return i?(i.zoom=o,i.pan=e,i.rotate=n):i={zoom:o,pan:e,rotate:n},i},i._createClass(t,[{key:"time",get:function(){return this._time}},{key:"rotateTime",get:function(){return this.definition.hasRotate?o.Seconds(this._rotatePixels/this._rotatePixelFlow):o.Seconds(0)}},{key:"zoomTime",get:function(){return this.definition.hasZoom?o.Seconds(this._zoomSign*(Math.log(this.definition.compared.sourceZoom/this.definition.compared.targetZoom)/Math.LN2)*this.definition.halfWindowSize/this._zoomPixelFlow):o.Seconds(0)}},{key:"panTime",get:function(){if(this.definition.hasPan){if(this.definition.hasZoom){const t=-1/(this._zoomSign*this.definition.halfWindowSize)*Math.LN2,i=t*this._panPixelsAtSource;return o.Seconds(Math.log(i*(this._zoomPixelFlow/this._panPixelFlow)+1)/(t*this._zoomPixelFlow))}return o.Seconds(this._panPixelsAtSource/this._panPixelFlow)}return o.Seconds(0)}}]),t}();t.Segment=e,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
