/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import{property as t,subclass as o}from"../../core/accessorSupport/decorators.js";import{loadCalciteComponents as l}from"../support/componentsUtils.js";import{tsx as s}from"../support/widget.js";import i from"./ValuePickerBaseComponent.js";const r="esri-value-picker__combobox";let a=class extends i{constructor(e,t){super(e,t),this.items=null,this.placeholder=null,this.type="combobox"}loadDependencies(){return l({combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item")})}get canNext(){return!(!this.items||!this.viewModel)&&this.items.findIndex(({value:e})=>e===this.viewModel.values?.[0])!==this.items.length-1}get canPlay(){return null!=this.viewModel&&!!this.items?.length}get canPrevious(){const{items:e,viewModel:t}=this;return!(!e||!t)&&0!==e.findIndex(({value:e})=>e===t.values?.[0])}get label(){return super.label}set label(e){super.label=e}render(){const{viewModel:e}=this;if(null==e)return s("div",null);const t=e.values?.[0];return s("div",{class:r},s("calcite-combobox",{disabled:e.disabled,label:this.label,maxItems:10,overlayPositioning:"fixed",placeholder:this.placeholder??void 0,selectionMode:"single",topLayerDisabled:this.topLayerDisabled,onCalciteComboboxChange:t=>{Array.isArray(t.currentTarget.value)||(null!=e.values?e.values[0]!==t.currentTarget.value&&(e.values=[t.currentTarget.value]):e.values=[t.currentTarget.value])}},this.items?.map(({value:e,label:o},l)=>s("calcite-combobox-item",{heading:o,key:l,selected:e===t,value:e}))))}animate(e){this._step(1,e)}next(){this._step(1)}previous(){this._step(-1)}_step(e,t=!1){const{viewModel:o,items:l}=this;if(!l?.length||!o)return;if(!o.values)return void(o.values=[l[0].value]);const s=l.findIndex(({value:e})=>e===o.values[0]);if(-1===s)return void(o.values=[l[0].value]);const i=s+e;i<0||i>=l.length?o.loop||t?o.values=[l[1===e?0:l.length-1].value]:"playing"===o.state&&o.pause():o.values=[l[i].value]}};e([t()],a.prototype,"canNext",null),e([t()],a.prototype,"canPlay",null),e([t()],a.prototype,"canPrevious",null),e([t()],a.prototype,"items",void 0),e([t()],a.prototype,"placeholder",void 0),e([t()],a.prototype,"type",void 0),a=e([o("esri.widgets.ValuePicker.ValuePickerCombobox")],a);const n=a;export{n as default};
