/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../chunks/_rollupPluginBabelHelpers","../chunks/tslib.es6","./Error","./Promise","./promiseUtils","./Warning","./accessorSupport/decorators/property","./accessorSupport/decorators/subclass"],(function(o,e,r,t,l,n,a,s){"use strict";const d="not-loaded",i="loading",c="failed",u="loaded",p=t=>{let p=function(e){function t(...t){var n;return(n=e.call(this,...t)||this)._loadController=null,n.loadError=null,n.loadStatus="not-loaded",n._set("loadWarnings",[]),n.addResolvingPromise(new Promise((e=>{const t=n.load.bind(o._assertThisInitialized(n));n.load=a=>{const s=new Promise(((e,t)=>{const s=l.onAbortOrThrow(a,t);n.destroyed&&t(new r("load:instance-destroyed",`Instance of '${n.declaredClass||n.constructor.name}' is already destroyed`,{instance:o._assertThisInitialized(n)})),n._promiseProps.when(e,t).finally((()=>{s&&s.remove()}))}));if(n.loadStatus===d){n._set("loadStatus",i);const o=n._loadController=new AbortController;t({signal:o.signal}),l.onAbort(o.signal,(()=>{n._promiseProps.abort()}))}return e(),s}}))),n.when((()=>{n._set("loadStatus",u),n._loadController=null}),(o=>{n._set("loadStatus",c),n._set("loadError",o),n._loadController=null})),n}o._inheritsLoose(t,e);var n=t.prototype;return n.load=function(){return null},n.cancelLoad=function(){var o;return this.isFulfilled()||(this._set("loadError",new r("load:cancelled","Cancelled")),null==(o=this._loadController)||o.abort()),this},o._createClass(t,[{key:"loaded",get:function(){return this.loadStatus===u}},{key:"loadWarnings",get:function(){return this._get("loadWarnings")}}]),t}(t);return e.__decorate([a.property({readOnly:!0})],p.prototype,"loaded",null),e.__decorate([a.property({readOnly:!0})],p.prototype,"loadError",void 0),e.__decorate([a.property({clonable:!1})],p.prototype,"loadStatus",void 0),e.__decorate([a.property({type:[n],readOnly:!0})],p.prototype,"loadWarnings",null),p=e.__decorate([s.subclass("esri.core.Loadable")],p),p};let _=function(e){function r(){return e.apply(this,arguments)||this}return o._inheritsLoose(r,e),r}(p(t.EsriPromise));_=e.__decorate([s.subclass("esri.core.Loadable")],_),function(o){function e(o){return!(!o||!o.load)}o.LoadableMixin=p,o.isLoadable=e}(_||(_={}));return _}));
