/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{instructions as t}from"./instructions.js";function n(t){return t instanceof i?t:"object"==typeof t&&"type"in t?c[t.type].hydrate(t):new o(t)}class i{constructor(t){this.inputs=t}encode(){const t=[];for(const n of this.inputs)t.push(...n.encode());return t.push(...this.instructions),t}}class o extends i{constructor(t){super([]),this.value=t}simplify(){return this}get instructions(){if(Array.isArray(this.value)){const[n,i,o,s]=this.value;return null!=s?t.vector4.encode([n,i||0,o||0,s]):t.vector3.encode([n,i||0,o||0])}return t.scalar.encode(this.value)}}class s extends i{constructor(t,n){super([n]),this._config=t,this._parent=n}static hydrate(t){return new s(t,n(t.parent))}simplify(){if(this._config.relativeTranslation||this._config.absoluteScale)return this;const t=this._parent.simplify();if(!(t instanceof o))return this;const[n,i,r,e]=t.value,c=this._config.translation.from[0],a=this._config.translation.from[1],f=this._config.rotation.from,h=this._config.scale.from;if(c===this._config.translation.to[0]&&a===this._config.translation.to[1]&&f===this._config.rotation.to&&h===this._config.scale.to){const t=r+f,s=e*h,u=Math.sin(r),l=Math.cos(r);return new o([l*e*c-u*e*a+n,u*e*c+l*e*a+i,t,s])}return new s(this._config,t)}get instructions(){return t.animatedTransform.encode(this._config)}}class r extends i{constructor(t,n){super([n]),this._config=t,this._parent=n}static hydrate(t){return new r(t,n(t.parent))}simplify(){const t=this._parent.simplify();if(!(t instanceof o))return this;const[n,i,s,e]=t.value,c=this._config.color.from[0],a=this._config.color.from[1],f=this._config.color.from[2];let h=this._config.color.from[3];const u=this._config.opacity.from;return c===this._config.color.to[0]&&a===this._config.color.to[1]&&f===this._config.color.to[2]&&h===this._config.color.to[3]&&u===this._config.opacity.to?(h*=u,new o([n*c,i*a,s*f,e*h])):new r(this._config,t)}get instructions(){return t.animatedColor.encode(this._config)}}class e extends i{constructor(t,n){super([n]),this._config=t,this._parent=n}static hydrate(t){return new e(t,n(t.parent))}simplify(){const t=this._parent.simplify();return t instanceof o?new e(this._config,t):this}get instructions(){return t.animatedShift.encode(this._config)}}const c={AnimatedTransform:s,AnimatedColor:r,AnimatedShift:e};export{i as AAnimationInfo,r as AnimatedColor,e as AnimatedShift,s as AnimatedTransform,o as Constant,n as hydrate};
