/*
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","../../../Graphic","../../../core/Accessor","../../../core/HandleOwner","../../../core/reactiveUtils","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../support/featureUtils"],(function(e,t,r,o,n,a,s,c,i,l,p,d){"use strict";let u=function(t){function r(e){var r;return(r=t.call(this,e)||this)._loadingPromise=null,r.created=null,r.creator=null,r.destroyer=null,r.graphic=null,r.handles.add(a.watch((()=>r.creator),(e=>{r._destroyContent(),r._createContent(e)}),a.initial)),r}e._inheritsLoose(r,t);var o=r.prototype;return o.destroy=function(){this._destroyContent()},o._destroyContent=function(){const{created:e,graphic:t,destroyer:r}=this;e&&(d.graphicCallback(r,{graphic:t}).catch((()=>null)),this._set("created",null))},o._createContent=function(){var t=e._asyncToGenerator((function*(e){const{graphic:t}=this,r=d.graphicCallback(e,{graphic:t}).catch((()=>null));this._loadingPromise=r,this.notifyChange("state");const o=yield r;r===this._loadingPromise&&(this._loadingPromise=null,this.notifyChange("state"),this._set("created",o))}));function r(e){return t.apply(this,arguments)}return r}(),e._createClass(r,[{key:"state",get:function(){return this._loadingPromise?"loading":"ready"}}]),r}(n.HandleOwnerMixin(o));t.__decorate([s.property({readOnly:!0})],u.prototype,"created",void 0),t.__decorate([s.property()],u.prototype,"creator",void 0),t.__decorate([s.property()],u.prototype,"destroyer",void 0),t.__decorate([s.property({type:r})],u.prototype,"graphic",void 0),t.__decorate([s.property({readOnly:!0})],u.prototype,"state",null),u=t.__decorate([p.subclass("esri.widgets.Feature.FeatureContent.FeatureContentViewModel")],u);return u}));
