/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../analysis/LineOfSightAnalysis.js";import{deprecateWidget as i}from"../core/deprecate.js";import"../core/has.js";import s from"../core/Logger.js";import{ignoreAbortErrors as n}from"../core/promiseUtils.js";import{property as o,subclass as r}from"../core/accessorSupport/decorators.js";import l from"./Widget.js";import a from"./LineOfSight/LineOfSightViewModel.js";import{loadCalciteComponents as d}from"./support/componentsUtils.js";import{globalCss as u}from"./support/globalCss.js";import{messageBundle as p,tsx as h}from"./support/widget.js";const c="esri-line-of-sight",g={base:c,actions:`${c}__actions`,container:`${c}__container`,error:`${c}__error`,hint:`${c}__hint`,hintText:`${c}__hint-text`,newAnalysisButton:`${c}__new-analysis-button`},m={newAnalysisButton:`${c}__new-button`,doneButton:`${c}__done-button`};let _=class extends l{constructor(e,t){super(e,t),this.messages=null,this.viewModel=new a({suppressDeprecationWarning:!0}),this._onNewAnalysis=()=>{n(this.viewModel.start())},this._onDone=()=>{this.viewModel.stop()},this._onContinue=()=>{this.viewModel.continue()},i(s.getLogger(this),"Line Of Sight","arcgis-line-of-sight",{version:"4.33"})}loadDependencies(){return d({button:()=>import("@esri/calcite-components/dist/components/calcite-button")})}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get icon(){return"line-of-sight"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}render(){return h("div",{class:this.classes(g.base,u.widget,u.panel),role:"presentation"},this._renderContainerNode())}_renderContainerNode(){if(!this.visible)return null;if(!this.viewModel.supported)return this._renderUnsupportedMessage();let e=null;const t=[this._renderNewAnalysisButton()];return"creating"===this.viewModel.state?(e=this._renderHint(),t.unshift(this._renderDoneButton())):"created"===this.viewModel.state&&this.viewModel.targets.length>0&&t.unshift(this._renderContinueButton()),h("div",{class:g.container},e,h("div",{class:g.actions},t))}_renderUnsupportedMessage(){return h("div",{class:g.error,key:"esri-line-of-sight__unsupported"},h("p",null,this.messages.unsupported))}_renderHint(){return h("div",{class:g.hint,key:"esri-line-of-sight__hint"},h("p",{class:g.hintText},this.messages.hint))}_renderNewAnalysisButton(){return this._renderButton({className:g.newAnalysisButton,id:m.newAnalysisButton,label:this.messages.newAnalysis,onClick:this._onNewAnalysis,primary:!0})}_renderDoneButton(){return this._renderButton({id:m.doneButton,label:this.messages.done,onClick:this._onDone,primary:!1})}_renderContinueButton(){return this._renderButton({id:m.newAnalysisButton,label:this.messages.continueAnalysis,onClick:this._onContinue,primary:!1})}_renderButton({className:e,id:t,label:i,onClick:s,primary:n}){const o="disabled"===this.viewModel.state;return h("calcite-button",{appearance:n?"solid":"outline-fill",class:e,"data-id":t,disabled:o,key:t,onclick:s},i)}get test(){}};e([o()],_.prototype,"active",null),e([o({type:t,nonNullable:!0})],_.prototype,"analysis",null),e([o()],_.prototype,"icon",null),e([o()],_.prototype,"label",null),e([o(),p("esri/widgets/LineOfSight/t9n/LineOfSight")],_.prototype,"messages",void 0),e([o()],_.prototype,"view",null),e([o({type:a})],_.prototype,"viewModel",void 0),e([o()],_.prototype,"visible",null),_=e([r("esri.widgets.LineOfSight")],_);const v=_;export{v as default};
