/*
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/promiseUtils","../core/unitUtils","../core/accessorSupport/decorators/aliasOf","../core/arrayUtils","../core/has","../core/accessorSupport/ensureType","../core/accessorSupport/decorators/property","../core/accessorSupport/decorators/subclass","./Widget","./AreaMeasurement2D/AreaMeasurement2DViewModel","./support/decorators/accessibleHandler","./support/decorators/messageBundle","./support/jsxFactory","./support/widgetUtils"],(function(e,t,s,i,a,r,n,o,l,u,c,d,p,m,_,v){"use strict";const b="esri-area-measurement-2d",y={buttonDisabled:"esri-button--disabled",widgetIcon:"esri-icon-measure-area",base:`${b} esri-widget esri-widget--panel`,container:`${b}__container`,hint:`${b}__hint`,hintText:`${b}__hint-text`,panelError:`${b}__panel--error`,measurement:`${b}__measurement`,measurementItem:`${b}__measurement-item`,measurementItemDisabled:`${b}__measurement-item--disabled`,measurementItemTitle:`${b}__measurement-item-title`,measurementItemValue:`${b}__measurement-item-value`,settings:`${b}__settings`,units:`${b}__units`,unitsLabel:`${b}__units-label`,unitsSelect:`${b}__units-select esri-select`,unitsSelectWrapper:`${b}__units-select-wrapper`,actionSection:`${b}__actions`,newMeasurementButton:`${b}__clear-button esri-button esri-button--primary`};let g=function(t){function a(e,s){var i;return(i=t.call(this,e,s)||this).active=null,i.iconClass=y.widgetIcon,i.label=void 0,i.messages=null,i.messagesUnits=null,i.unit=null,i.unitOptions=null,i.view=null,i.viewModel=new d,i}e._inheritsLoose(a,t);var r=a.prototype;return r.render=function(){const{id:e,viewModel:t,visible:s}=this,{active:a,supported:r,measurementLabel:n,state:o,unit:l,unitOptions:u}=t,c="disabled"===o,d="ready"===o,p="measuring"===o||"measured"===o,{messages:m,messagesUnits:v}=this,b=a&&d?_.tsx("section",{key:"hint",class:y.hint},_.tsx("p",{class:y.hintText},m.hint)):null,g=r?null:_.tsx("section",{key:"unsupported",class:y.panelError},_.tsx("p",null,m.unsupported)),w=(e,t,s)=>t?_.tsx("div",{key:`${s}-enabled`,class:y.measurementItem},_.tsx("span",{class:y.measurementItemTitle},e),_.tsx("span",{class:y.measurementItemValue},t)):_.tsx("div",{key:`${s}-disabled`,class:this.classes(y.measurementItem,y.measurementItemDisabled),"aria-disabled":"true"},_.tsx("span",{class:y.measurementItemTitle},e)),h=p?_.tsx("section",{key:"measurement",class:y.measurement},w(m.area,n.area,"area"),w(m.perimeter,n.perimeter,"perimeter")):null,x=`${e}__units`,M=_.tsx("section",{key:"units",class:y.units},_.tsx("label",{class:y.unitsLabel,for:x},m.unit),_.tsx("div",{class:y.unitsSelectWrapper},_.tsx("select",{class:y.unitsSelect,id:x,onchange:this._changeUnit,bind:this,value:l},u.map((e=>{var t;return _.tsx("option",{key:e,value:e},i.isMeasurementSystem(e)?v.systems[e]:null==(t=v.units[e])?void 0:t.pluralCapitalized)}))))),$=p?_.tsx("div",{key:"settings",class:y.settings},M):null,f=!r||a&&!p?null:_.tsx("div",{class:y.actionSection},_.tsx("button",{disabled:c,class:this.classes(y.newMeasurementButton,c&&y.buttonDisabled),bind:this,onclick:this._newMeasurement,title:m.newMeasurement,type:"button","aria-label":m.newMeasurement},m.newMeasurement)),I=s?_.tsx("div",{class:y.container},g,b,$,h,f):null;return _.tsx("div",{class:y.base},I)},r._newMeasurement=function(){s.ignoreAbortErrors(this.viewModel.start())},r._changeUnit=function(e){const t=e.target,s=t.options[t.selectedIndex];s&&(this.viewModel.unit=s.value)},a}(c);t.__decorate([a.aliasOf("viewModel.active")],g.prototype,"active",void 0),t.__decorate([l.property()],g.prototype,"iconClass",void 0),t.__decorate([l.property({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],g.prototype,"label",void 0),t.__decorate([l.property(),m.messageBundle("esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D")],g.prototype,"messages",void 0),t.__decorate([l.property(),m.messageBundle("esri/core/t9n/Units")],g.prototype,"messagesUnits",void 0),t.__decorate([l.property()],g.prototype,"uiStrings",void 0),t.__decorate([a.aliasOf("viewModel.unit")],g.prototype,"unit",void 0),t.__decorate([a.aliasOf("viewModel.unitOptions")],g.prototype,"unitOptions",void 0),t.__decorate([a.aliasOf("viewModel.view")],g.prototype,"view",void 0),t.__decorate([l.property({type:d})],g.prototype,"viewModel",void 0),t.__decorate([a.aliasOf("viewModel.visible")],g.prototype,"visible",void 0),t.__decorate([p.accessibleHandler()],g.prototype,"_newMeasurement",null),t.__decorate([p.accessibleHandler()],g.prototype,"_changeUnit",null),g=t.__decorate([u.subclass("esri.widgets.AreaMeasurement2D")],g);return g}));
