/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as t}from"tslib";import{EventedAccessor as o}from"../../core/Evented.js";import e from"../../core/Logger.js";import{after as i,isAbortError as l}from"../../core/promiseUtils.js";import{property as r,subclass as a}from"../../core/accessorSupport/decorators.js";const s={first:!0},n={first:!1};let p=class extends o{constructor(t){super(t),this._animationController=null,this.disabled=!1,this.layout="horizontal",this.loop=!1,this.playRate=1e3,this.values=null}destroy(){this._pause()}get state(){return this._animationController?"playing":"ready"}next(){this.emit("next")}pause(){this.emit("pause"),this._pause()}play(){this.emit("play"),this._play()}previous(){this.emit("previous")}_pause(){this._animationController?.abort(),this._animationController=null}_play(){this._pause(),this._animationController=new AbortController,this._animate(s)}async _animate(t){if(this.emit("animate",t),this._animationController){try{await i(this.playRate,null,this._animationController.signal)}catch(o){return l(o)||e.getLogger(this).error(o),void this._pause()}this._animate(n)}}};t([r()],p.prototype,"_animationController",void 0),t([r({nonNullable:!0})],p.prototype,"disabled",void 0),t([r({nonNullable:!0})],p.prototype,"layout",void 0),t([r({nonNullable:!0})],p.prototype,"loop",void 0),t([r({nonNullable:!0})],p.prototype,"playRate",void 0),t([r({readOnly:!0})],p.prototype,"state",null),t([r()],p.prototype,"values",void 0),t([r()],p.prototype,"next",null),t([r()],p.prototype,"pause",null),t([r()],p.prototype,"play",null),t([r()],p.prototype,"previous",null),p=t([a("esri.widgets.ValuePicker.ValuePickerViewModel")],p);const u=p;export{u as default};
