/*
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/maybe","../../../../core/promiseUtils"],(function(t,o,a,r){"use strict";let s=function(){function s(o){this.schedule=o,this._loadStatus=t.LoadStatus.LOADING,this.logger=null}var e=s.prototype;return e.destroy=function(){this.abortLoad()},e.load=function(o,s){return this._loadStatus===t.LoadStatus.LOADED?(o&&o(),a.unwrap(this._loader)):this._loadStatus===t.LoadStatus.FAILED?(s&&s(this._loadError),a.unwrap(this._loader)):(a.isNone(this._loader)&&(this._abortController=new AbortController,this._loader=this.doLoad(this._abortController.signal).then((()=>{this._abortController=null,this._loadStatus=t.LoadStatus.LOADED}),(o=>{throw this._loadError=o,this._abortController=null,this._loadStatus=t.LoadStatus.FAILED,!r.isAbortError(o)&&this.logger&&o.message&&this.logger.warn(o.message),o}))),this._loader.then(o,s).catch((()=>{})),this._loader)},e.abortLoad=function(){a.isSome(this._abortController)?this._abortController=a.abortMaybe(this._abortController):this._loadStatus===t.LoadStatus.LOADING&&(this._loadStatus=t.LoadStatus.FAILED),this._loader=null},o._createClass(s,[{key:"loadStatus",get:function(){return this._loadStatus}}]),s}();var e;t.LoadStatus=void 0,(e=t.LoadStatus||(t.LoadStatus={}))[e.LOADING=0]="LOADING",e[e.LOADED=1]="LOADED",e[e.FAILED=2]="FAILED",t.Loadable=s,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
