import{__awaiter,__generator}from"tslib";var newBalOption=function(t,n){var i=Object.assign(Object.assign({},t),{disabled:false,invalid:false,selected:false,focused:false,hidden:false,multiline:false});if(n){i.disabled=n.disabled===undefined?i.disabled:n.disabled;i.invalid=n.invalid===undefined?i.invalid:n.invalid;i.selected=n.selected===undefined?i.selected:n.selected;i.focused=n.focused===undefined?i.focused:n.focused;i.hidden=n.hidden===undefined?i.hidden:n.hidden;i.multiline=n.multiline===undefined?i.multiline:n.multiline}return i};var mapOption=function(t){return newBalOption({value:t.value,label:t.label},t)};var DropdownOptionUtil=function(){function t(){}t.prototype.connectedCallback=function(t){this.component=t;this.optionChanged()};t.prototype.componentWillRender=function(){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(n){switch(n.label){case 0:if(!this.component.listEl)return[3,2];t=this.component;return[4,this.component.listEl.getValues()];case 1:t.nativeOptions=n.sent();n.label=2;case 2:return[2]}}))}))};t.prototype.hasPropOptions=function(){return this.component.options&&this.component.options.length>0};t.prototype.optionChanged=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:this.component.rawOptions=this.component.options.map(mapOption);return[4,this.component.valueUtil.updateInputContent()];case 1:t.sent();return[2]}}))}))};t.prototype.listenToOptionChange=function(t){return __awaiter(this,void 0,void 0,(function(){var t,n;return __generator(this,(function(i){switch(i.label){case 0:return[4,(t=this.component.listEl)===null||t===void 0?void 0:t.getSelectedValues()];case 1:n=i.sent()||[];this.component.valueUtil.updateRawValueBySelection(n);if(!this.component.multiple){this.component.popupUtil.collapseList();if(this.component.hasFocus){this.component.balBlur.emit(new FocusEvent("blur",{relatedTarget:this.component.el}));this.component.hasFocus=false}}return[2]}}))}))};return t}();export{DropdownOptionUtil as D,newBalOption as n};