import{LitElement as e,html as t,css as i}from"../../../lit/index.js";import"../../simple-modal/lib/simple-modal-template.js";import"./hax-picker.js";import{HaxComponentStyles as s}from"./hax-ui-styles.js";class HaxAppPicker extends e{static get styles(){return[...s,i`
        :host {
          display: none;
        }
      `]}constructor(){super(),this.windowControllers=new AbortController,this.title="Select an option"}connectedCallback(){super.connectedCallback(),globalThis.addEventListener("simple-modal-show",this.modalToggle.bind(this),{signal:this.windowControllers.signal})}disconnectedCallback(){this.windowControllers.abort(),super.disconnectedCallback()}modalToggle(e){"hax-picker"==e.detail.id&&e.detail.elements.content.children[0].buildOptions(this.elements,this.type,this.title,this.pickerType,this.target)}static get properties(){return{title:{type:String}}}presentOptions(e,t="element",i="Select an option",s="gizmo",l=window){this.elements=e,this.type=t,this.title=i,this.pickerType=s,this.target=l,setTimeout((()=>{this.shadowRoot.querySelector('[modal-id="hax-picker"]').openModal(l)}),0)}render(){return t`
      <simple-modal-template
        .title="${this.title}"
        modal-id="hax-picker"
        mode="hax-ui"
      >
        <hax-picker slot="content"></hax-picker>
      </simple-modal-template>
    `}static get tag(){return"hax-app-picker"}firstUpdated(){this.dispatchEvent(new CustomEvent("hax-register-core-piece",{bubbles:!0,cancelable:!0,composed:!0,detail:{piece:"haxAppPicker",object:this}}))}}customElements.define(HaxAppPicker.tag,HaxAppPicker);export{HaxAppPicker};