/*!
 * KoliBri - The accessible HTML-Standard
 */
import{r as i,h as t,g as s}from"./index-Brmny3Vg.js";import{d as a}from"./component-names-Dy77vq43.js";import{g as o,b as l,s as e}from"./common-DEEjER7G.js";import{v as d}from"./label-Cg7TG_7b.js";import{c as r}from"./clsx-COFh-Vc8.js";import{c as h}from"./dev.utils-HhhlYW_9.js";import{d as n,K as c}from"./events-BhfZTW2e.js";import{h as f}from"./tooltip-open-tracking-D3tCiiGP.js";import{w as v}from"./validation-VhuthteS.js";import"./level-CfQolHx4.js";import"./normalizers-pgU77mXp.js";import"./_Uint8Array-kJHDjtoP.js";import"./isArray-CcrBs4JM.js";const u=(i,t,s)=>{o(i,"_width",t,Object.assign({defaultValue:"100%"},s))};const b=["blank","card"];const m=(i,t)=>{l(i,"_variant",(i=>typeof i==="string"&&b.includes(i)),new Set(b),t)};const _=class{constructor(t){i(this,t);this.cardHeadingId=h("dialog-heading");this.isModal=true;this._cardOn={onClose:()=>void this.close()};this.handleCancelEvent=i=>{var t,s;f(i);if(i.defaultPrevented)return;(s=(t=this.state._on)===null||t===void 0?void 0:t.onCancel)===null||s===void 0?void 0:s.call(t,i);if(i.defaultPrevented)return;if(this.host&&!n(this.host,c.cancel)){i.preventDefault()}};this._level=0;this._width="100%";this._variant="blank";this.state={_label:"",_width:"100%"}}disconnectedCallback(){void this.close()}handleNativeCloseEvent(i){var t;if(i.target!==this.refDialog){return}if(typeof((t=this.state._on)===null||t===void 0?void 0:t.onClose)==="function"){this.state._on.onClose()}if(this.host){n(this.host,c.close)}}async show(i=false){var t,s,a,o,l;if((t=this.refDialog)===null||t===void 0?void 0:t.open){return}this.isModal=i;if(i){(a=(s=this.refDialog)===null||s===void 0?void 0:s.showModal)===null||a===void 0?void 0:a.call(s)}else{(l=(o=this.refDialog)===null||o===void 0?void 0:o.show)===null||l===void 0?void 0:l.call(o)}}showModal(){return this.show(true)}openModal(){return this.showModal()}async close(){var i,t;(t=(i=this.refDialog)===null||i===void 0?void 0:i.close)===null||t===void 0?void 0:t.call(i)}closeModal(){return this.close()}render(){return t("dialog",{key:"740fd9b18343e873a7961173848be648bbd0ff8a","aria-label":this.state._variant==="blank"?this.state._label:undefined,"aria-labelledby":this.state._variant==="card"?this.cardHeadingId:undefined,"aria-modal":this.isModal?"true":"false",class:r("kol-dialog","kol-modal",{"kol-dialog__blank":this.state._variant==="blank","kol-dialog__card":this.state._variant==="card","kol-modal__blank":this.state._variant==="blank","kol-modal__card":this.state._variant==="card"}),onCancel:this.handleCancelEvent,onClose:this.handleNativeCloseEvent.bind(this),ref:i=>{this.refDialog=i},style:{width:this.state._width}},this.state._variant==="blank"&&t("slot",{key:"183bbb7224ca0ec06bbd84e354fa7b58882a4879"}),this.state._variant==="card"&&t(a,{key:"e0270ea31e33d61760aa8fca356c08f88a56fffe",_hasCloser:true,_headingId:this.cardHeadingId,_label:this.state._label,_level:this._level,_on:this._cardOn},t("slot",{key:"a18c03fd1f0cdcc25a8bddfffd5b0753fc81cdb5"})))}validateLabel(i){d(this,i,{required:true})}validateLevel(i){v(this,i)}validateOn(i){if(typeof i==="object"&&i!==null){const t={};if(typeof i.onCancel==="function"){t.onCancel=i.onCancel}if(typeof i.onClose==="function"){t.onClose=i.onClose}e(this,"_on",t)}}validateWidth(i){u(this,i)}validateVariant(i){m(this,i)}componentWillLoad(){this.validateLabel(this._label);this.validateLevel(this._level);this.validateOn(this._on);this.validateWidth(this._width);this.validateVariant(this._variant)}get host(){return s(this)}static get watchers(){return{_label:["validateLabel"],_level:["validateLevel"],_on:["validateOn"],_width:["validateWidth"],_variant:["validateVariant"]}}};export{_ as kol_dialog_wc};
//# sourceMappingURL=kol-dialog-wc.entry.js.map