/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","../chunks/_rollupPluginBabelHelpers","../chunks/tslib.es6","../core/promiseUtils","../core/accessorSupport/decorators/aliasOf","../core/arrayUtils","../core/has","../core/accessorSupport/ensureType","../core/accessorSupport/decorators/property","../core/accessorSupport/decorators/subclass","./Widget","./Slice/SliceViewModel","./support/Heading","./support/widgetUtils","./support/decorators/messageBundle","./support/jsxFactory"],(function(e,t,s,i,l,r,o,n,c,a,d,u,p,_,y,v){"use strict";const h="esri-slice",b={buttonDisabled:"esri-button--disabled",layerIncludeButton:"esri-slice__cross",widgetIcon:"esri-icon-slice",base:`${h} esri-widget esri-widget--panel`,layerList:`${h}__settings`,layerListHeading:"esri-slice__settings-title",layerItem:`${h}__layer-item`,layerItemTitle:`${h}__layer-item__title`,container:`${h}__container`,actionSection:"esri-slice__actions",hint:`${h}__hint`,hintText:`${h}__hint-text`,panelError:`${h}__panel--error`,newSliceButton:`${h}__clear-button esri-button esri-button--primary`,excludeButton:`${h}__exclude-button esri-button esri-button--secondary`,cancelButton:`${h}__cancel-button esri-button esri-button--secondary`};let x=function(s){function l(e,t){var i;return(i=s.call(this,e,t)||this).headingLevel=3,i.iconClass=b.widgetIcon,i.label=void 0,i.messages=null,i.view=null,i.viewModel=new u,i}t._inheritsLoose(l,s);var r=l.prototype;return r.loadDependencies=function(){return Promise.all([new Promise(((t,s)=>e(["../chunks/calcite-button"],t,s))),new Promise(((t,s)=>e(["../chunks/calcite-icon"],t,s)))])},r.render=function(){const e=this.viewModel.supported,t=this.viewModel.active,s="disabled"===this.viewModel.state,i="ready"===this.viewModel.state,l="slicing"===this.viewModel.state||"sliced"===this.viewModel.state,r="exclude"===this.viewModel.layersMode,{messages:o}=this,n=s&&b.buttonDisabled,c=t&&!l||r?null:v.tsx("button",{disabled:s,class:this.classes(b.newSliceButton,n),bind:this,onclick:this._onNewSliceClick,key:"esri-slice__clear",type:"button"},o.newSlice),a=l&&!r?v.tsx("button",{class:this.classes(b.excludeButton,n),bind:this,onclick:()=>{this.viewModel.enterExcludeLayerMode()},key:"esri-slice__exclude",type:"button"},o.excludeLayer):null,d=t&&r?v.tsx("button",{class:this.classes(b.cancelButton,n),bind:this,onclick:()=>{this.viewModel.exitExcludeLayerMode()},key:"esri-slice__cancel-exclude",type:"button"},o.cancel):null;let u=null;t&&(r?u=o.excludeHint:i&&(u=o.hint));const _=u?v.tsx("div",{class:b.hint,key:"esri-slice__hint"},v.tsx("p",{class:b.hintText},u)):null,y=this.excludedLayers?this.excludedLayers.toArray().map((e=>this._renderLayerItem({uid:e.uid,title:e.title,onClick:()=>(this.excludedLayers.remove(e),!1)}))):[];this.excludeGroundSurface&&y.push(this._renderLayerItem({uid:"ground",title:o.ground,onClick:()=>(this.excludeGroundSurface=!1,!1)}));const h=!r&&l&&y.length>0?v.tsx("div",{class:b.layerList,key:"esri-slice__settings"},v.tsx(p.Heading,{class:b.layerListHeading,level:this.headingLevel},o.excludedLayers),v.tsx("ul",null,y)):null,x=v.tsx("div",{class:b.panelError,key:"esri-slice__unsupported"},v.tsx("p",null,o.unsupported)),w=v.tsx("div",{class:b.actionSection},a,d,c),g=this.visible?v.tsx("div",{class:b.container},e?[_,h,w]:x):null;return v.tsx("div",{class:b.base,role:"presentation"},g)},r._renderLayerItem=function(e){return v.tsx("li",{class:b.layerItem,key:e.uid},v.tsx("calcite-button",{appearance:"transparent",class:b.layerIncludeButton,"icon-start":"x",scale:"s",title:this.messages.includeLayer,bind:this,onclick:e.onClick}),v.tsx("div",{class:b.layerItemTitle},e.title))},r._onNewSliceClick=function(){i.ignoreAbortErrors(this.viewModel.start())},t._createClass(l,[{key:"analysis",get:function(){return this.viewModel.analysis},set:function(e){this.viewModel.analysis=e}}]),l}(d);s.__decorate([l.aliasOf("viewModel.active")],x.prototype,"active",void 0),s.__decorate([c.property({constructOnly:!0,nonNullable:!0})],x.prototype,"analysis",null),s.__decorate([l.aliasOf("viewModel.excludedLayers")],x.prototype,"excludedLayers",void 0),s.__decorate([l.aliasOf("viewModel.excludeGroundSurface")],x.prototype,"excludeGroundSurface",void 0),s.__decorate([c.property()],x.prototype,"headingLevel",void 0),s.__decorate([c.property()],x.prototype,"iconClass",void 0),s.__decorate([c.property({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],x.prototype,"label",void 0),s.__decorate([c.property(),y.messageBundle("esri/widgets/Slice/t9n/Slice")],x.prototype,"messages",void 0),s.__decorate([l.aliasOf("viewModel.view")],x.prototype,"view",void 0),s.__decorate([c.property({type:u})],x.prototype,"viewModel",void 0),s.__decorate([l.aliasOf("viewModel.visible")],x.prototype,"visible",void 0),x=s.__decorate([a.subclass("esri.widgets.Slice")],x);return x}));
