/*
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","../../core/reactiveUtils","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","../Widget","./FeatureContent","./FeatureFields","./FeatureMedia","./FeatureExpression/FeatureExpressionViewModel","../support/widgetUtils","../support/jsxFactory"],(function(e,t,n,i,o,s,r,d,l,a,c,u,p,g,h){"use strict";const v={iconLoading:"esri-icon-loading-indicator esri-rotating",base:"esri-feature-expression",loadingSpinnerContainer:"esri-feature__loading-container",spinner:"esri-feature__loading-spinner"};let w=function(t){function i(e,n){var i;return(i=t.call(this,e,n)||this).viewModel=new p,i}e._inheritsLoose(i,t);var o=i.prototype;return o.initialize=function(){this.own(n.watch((()=>{var e;return null==(e=this.viewModel)?void 0:e.contentElementViewModel}),(()=>this._setupExpressionWidget()),n.initial))},o.destroy=function(){this._destroyContentWidget()},o.renderLoading=function(){return h.tsx("div",{key:"loading-container",class:v.loadingSpinnerContainer},h.tsx("span",{class:this.classes(v.iconLoading,v.spinner)}))},o.render=function(){var e;const{state:t}=this.viewModel;return h.tsx("div",{class:v.base},"loading"===t?this.renderLoading():"disabled"===t?null:null==(e=this._contentWidget)?void 0:e.render())},o._destroyContentWidget=function(){const{_contentWidget:e}=this;e&&(e.viewModel=null,e.destroy()),this._contentWidget=null},o._setupExpressionWidget=function(){const{contentElementViewModel:e,contentElement:t}=this.viewModel,n=null==t?void 0:t.type;this._destroyContentWidget();const i=e?"fields"===n?new c({viewModel:e}):"media"===n?new u({viewModel:e}):"text"===n?new a({viewModel:e}):null:null;this._contentWidget=i,this.scheduleRender()},i}(l);t.__decorate([i.property({type:p})],w.prototype,"viewModel",void 0),w=t.__decorate([d.subclass("esri.widgets.Feature.FeatureExpression")],w);return w}));
