text: import{r as i,c as t,h as s,g as a}from"./p-f58ba550.js";import{h as o}from"./p-f86f6644.js";import{u as l,l as e}from"./p-74222c65.js";import{M as h}from"./p-de179682.js";let n=0;const r=class{constructor(s){i(this,s),this.slShow=t(this,"sl-show",7),this.slAfterShow=t(this,"sl-after-show",7),this.slHide=t(this,"sl-hide",7),this.slAfterHide=t(this,"sl-after-hide",7),this.slOverlayDismiss=t(this,"sl-overlay-dismiss",7),this.componentId="dialog-"+ ++n,this.hasFooter=!1,this.isVisible=!1,this.open=!1,this.label="",this.noHeader=!1}handleOpenChange(){this.open?this.show():this.hide()}connectedCallback(){this.handleCloseClick=this.handleCloseClick.bind(this),this.handleTransitionEnd=this.handleTransitionEnd.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleOverlayClick=this.handleOverlayClick.bind(this),this.handleSlotChange=this.handleSlotChange.bind(this),this.modal=new h(this.host,{onFocusOut:()=>this.panel.focus()})}componentDidLoad(){this.open&&this.show()}disconnectedCallback(){l(this.host)}async show(){this.open||(this.slShow.emit().defaultPrevented?this.open=!1:(this.isVisible=!0,this.open=!0,this.modal.activate(),e(this.host)))}async hide(){this.open&&(this.slHide.emit().defaultPrevented?this.open=!0:(this.open=!1,this.modal.deactivate(),l(this.host)))}handleCloseClick(){this.hide()}handleKeyDown(i){"Escape"===i.key&&this.hide()}handleOverlayClick(){this.slOverlayDismiss.emit().defaultPrevented||this.hide()}handleSlotChange(){this.hasFooter=o(this.host,"footer")}handleTransitionEnd(i){"opacity"===i.propertyName&&i.target.classList.contains("dialog__panel")&&(this.isVisible=this.open,this.open?this.slAfterShow.emit():this.slAfterHide.emit(),this.open&&this.panel.focus())}render(){return s("div",{ref:i=>this.dialog=i,part:"base",class:{dialog:!0,"dialog--open":this.open,"dialog--visible":this.isVisible,"dialog--has-footer":this.hasFooter},onKeyDown:this.handleKeyDown,onTransitionEnd:this.handleTransitionEnd},s("div",{part:"overlay",class:"dialog__overlay",onClick:this.handleOverlayClick}),s("div",{ref:i=>this.panel=i,part:"panel",class:"dialog__panel",role:"dialog","aria-modal":"true","aria-hidden":!this.open,"aria-label":this.noHeader?this.label:null,"aria-labelledby":this.noHeader?null:this.componentId+"-title",tabIndex:0},!this.noHeader&&s("header",{part:"header",class:"dialog__header"},s("span",{part:"title",class:"dialog__title",id:this.componentId+"-title"},s("slot",{name:"label"},this.label||String.fromCharCode(65279))),s("sl-icon-button",{part:"close-button",class:"dialog__close",name:"x",onClick:this.handleCloseClick})),s("div",{part:"body",class:"dialog__body"},s("slot",null)),s("footer",{part:"footer",class:"dialog__footer"},s("slot",{name:"footer",onSlotchange:this.handleSlotChange}))))}get host(){return a(this)}static get watchers(){return{open:["handleOpenChange"]}}};r.style=":host{position:relative;box-sizing:border-box}:host *,:host *:before,:host *:after{box-sizing:inherit}:host{--width:31rem;display:contents}.dialog{display:flex;align-items:center;justify-content:center;position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--sl-z-index-dialog)}.dialog:not(.dialog--visible){position:absolute;width:1px;height:1px;clip:rect(0 0 0 0);clip-path:inset(50%);overflow:hidden;pointer-events:none;visibility:hidden}.dialog__panel{display:flex;flex-direction:column;z-index:2;width:var(--width);max-width:calc(100% - var(--sl-spacing-xx-large));max-height:calc(100% - var(--sl-spacing-xx-large));background-color:var(--sl-panel-background-color);border-radius:var(--sl-border-radius-medium);box-shadow:var(--sl-shadow-x-large);opacity:0;transform:scale(0.8);transition:var(--sl-transition-medium) opacity, var(--sl-transition-medium) transform}.dialog__panel:focus{outline:none}@media screen and (max-width: 420px){.dialog__panel{max-height:80vh}}.dialog--open .dialog__panel{display:flex;opacity:1;transform:scale(1)}.dialog__header{flex:0 0 auto;display:flex}.dialog__title{flex:1 1 auto;font-size:var(--sl-font-size-large);line-height:var(--sl-line-height-dense);padding:var(--sl-spacing-large)}.dialog__close{flex:0 0 auto;display:flex;align-items:center;font-size:var(--sl-font-size-x-large);padding:0 var(--sl-spacing-large)}.dialog__body{flex:1 1 auto;padding:var(--sl-spacing-large);overflow:auto;-webkit-overflow-scrolling:touch}.dialog__footer{flex:0 0 auto;text-align:right;padding:var(--sl-spacing-large)}.dialog__footer ::slotted(sl-button:not(:first-of-type)){margin-left:var(--sl-spacing-x-small)}.dialog:not(.dialog--has-footer) .dialog__footer{display:none}.dialog__overlay{position:fixed;top:0;right:0;bottom:0;left:0;background-color:var(--sl-overlay-background-color);opacity:0;transition:var(--sl-transition-medium) opacity}.dialog--open .dialog__overlay{opacity:1}";export{r as sl_dialog}