/*
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/accessorSupport/decorators/aliasOf","../core/arrayUtils","../core/has","../core/accessorSupport/decorators/cast","../core/accessorSupport/decorators/property","../core/accessorSupport/decorators/subclass","./Widget","./BuildingExplorer/BuildingExplorerViewModel","./BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree","./BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker","./BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker","./support/Heading","./support/widgetUtils","./support/decorators/messageBundle","./support/jsxFactory"],(function(e,i,s,t,r,l,o,n,a,d,c,p,g,u,v,_,h){"use strict";const y={levels:!0,phases:!0,disciplines:!0},m="esri-building-explorer",b={esriWidget:"esri-widget",esriWidgetDisabled:"esri-widget--disabled",esriIconLoadingIndicator:"esri-icon-loading-indicator",esriRotating:"esri-rotating",widgetIcon:"esri-icon-organization",base:`${m} esri-widget--panel`,panelError:`${m}__panel--error`,loadingContainer:`${m}__loading-container`,content:`${m}__content`,section:`${m}__section`,levels:`${m}__levels`,phases:`${m}__phases`,disciplines:`${m}__disciplines`};let w=function(i){function s(e,s){var t;return(t=i.call(this,e,s)||this)._defaultViewModel=new d,t.viewModel=t._defaultViewModel,t.view=null,t.layers=null,t.visibleElements={...y},t.headingLevel=3,t.iconClass=b.widgetIcon,t.label=void 0,t.messages=null,t.messagesCommon=null,t.toggleSiblingsVisibility=!1,t}e._inheritsLoose(s,i);var t=s.prototype;return t.destroy=function(){this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()},t._castVisibleElements=function(e){return{...y,...e}},t.render=function(){const e=this.viewModel,i="disabled"===e.state||!e.isSupported;return h.tsx("div",{key:this,class:v.classes(b.esriWidget,b.base,{[b.esriWidgetDisabled]:i}),"aria-label":this.messages.widgetLabel},this._renderContent())},t._renderContent=function(){const e=this.viewModel,i=this.messages;if(!e.isSupported)return h.tsx("p",{class:b.panelError},i.unsupported);if(!e.layers.length)return h.tsx("p",{class:b.panelError},i.noData);switch(e.state){case"loading":return this._renderLoadingIndicator();case"ready":return h.tsx("div",{key:"content",class:b.content},this._renderLevelPickerSection(),this._renderPhasePickerSection(),this._renderDisciplinesSection());case"failed":return h.tsx("p",{class:b.panelError},i.failed);default:return null}},t._renderLoadingIndicator=function(){const e=this.messagesCommon.loading;return h.tsx("div",{key:"loading-container",role:"presentation",class:b.loadingContainer,"aria-label":e,title:e},h.tsx("span",{"aria-hidden":"true",class:v.classes(b.esriIconLoadingIndicator,b.esriRotating)}))},t._renderLevelPickerSection=function(){var e;const i=this.viewModel.level,s="ready"===i.state,t=i.allowedValues.length>1;if(!this.visibleElements.levels||!s||!t)return null;const r=null==(e=this.messages)?void 0:e.level;return h.tsx("div",{key:"levels",class:v.classes(b.section,b.levels)},h.tsx(u.Heading,{level:this.headingLevel},null==r?void 0:r.title),h.tsx(p,{vm:i,messages:r}))},t._renderPhasePickerSection=function(){const e=this.viewModel.phase,i="ready"===e.state,s=e.allowedValues.length>1;if(!this.visibleElements.phases||!i||!s)return null;const t=this.messages.phase;return h.tsx("div",{key:"phases",class:v.classes(b.section,b.phases)},h.tsx(u.Heading,{level:this.headingLevel},t.title),h.tsx(g,{vm:e,messages:t}))},t._renderDisciplinesSection=function(){var e;const i=this.viewModel.disciplines,s="ready"===i.state,t=i.root.hasChildren;if(!this.visibleElements.disciplines||!s||!t)return null;const r=null==(e=this.messages)?void 0:e.disciplines;return h.tsx("div",{key:"disciplines",class:v.classes(b.section,b.disciplines)},h.tsx(u.Heading,{level:this.headingLevel},r.title),h.tsx(c,{vm:i,messages:r,toggleSiblingsVisibility:this.toggleSiblingsVisibility}))},s}(a);i.__decorate([o.property({type:d})],w.prototype,"viewModel",void 0),i.__decorate([s.aliasOf("viewModel.view")],w.prototype,"view",void 0),i.__decorate([s.aliasOf("viewModel.layers")],w.prototype,"layers",void 0),i.__decorate([o.property()],w.prototype,"visibleElements",void 0),i.__decorate([l.cast("visibleElements")],w.prototype,"_castVisibleElements",null),i.__decorate([o.property()],w.prototype,"headingLevel",void 0),i.__decorate([o.property()],w.prototype,"iconClass",void 0),i.__decorate([s.aliasOf("messages.widgetLabel",{overridable:!0})],w.prototype,"label",void 0),i.__decorate([o.property(),_.messageBundle("esri/widgets/BuildingExplorer/t9n/BuildingExplorer")],w.prototype,"messages",void 0),i.__decorate([o.property(),_.messageBundle("esri/t9n/common")],w.prototype,"messagesCommon",void 0),i.__decorate([o.property({nonNullable:!0})],w.prototype,"toggleSiblingsVisibility",void 0),i.__decorate([o.property()],w.prototype,"uiStrings",void 0),w=i.__decorate([n.subclass("esri.widgets.BuildingExplorer")],w);return w}));
