import*as UI from"../ui/ui.js";export class ComboBoxOfCheckBoxes extends UI.Toolbar.ToolbarButton{constructor(t){super(t),this.options=new Array,this.headers=new Array,this.onOptionClicked=()=>{},this.turnIntoSelect(),this.addEventListener(UI.Toolbar.ToolbarButton.Events.Click,this.showLevelContextMenu.bind(this)),UI.ARIAUtils.markAsMenuButton(this.element)}addOption(t,e,o){this.options.push({title:t,value:e,default:o,enabled:o})}setOptionEnabled(t,e){const o=this.options[t];o&&(o.enabled=e,this.onOptionClicked())}addHeader(t,e){this.headers.push({title:t,callback:e})}setOnOptionClicked(t){this.onOptionClicked=t}getOptions(){return this.options}showLevelContextMenu(t){const e=t.data,o=new UI.ContextMenu.ContextMenu(e,!0,this.element.totalOffsetLeft(),this.element.totalOffsetTop()+this.element.offsetHeight);for(const{title:n,callback:s}of this.headers)o.headerSection().appendCheckboxItem(n,(()=>s()));for(const[n,{title:s,enabled:i}]of this.options.entries())o.defaultSection().appendCheckboxItem(s,(()=>{this.setOptionEnabled(n,!i)}),i);o.show()}}