import{r as e,h as t,H as s,g as i}from"./p-268dca3f.js";import{b as o}from"./p-9c90d370.js";import{g as r}from"./p-569a5c63.js";import{g as a}from"./p-46044fd3.js";import{d as n,u as c,c as l}from"./p-ee984234.js";const p=class{constructor(t){e(this,t),this.offsetDistance=n,this.offsetSkidding=0,this.open=!1,this.placement="auto",this._referenceElement=this.getReferenceElement(),this.guid="calcite-tooltip-"+a(),this.getId=()=>this.el.id||this.guid,this.addReferences=()=>{const{_referenceElement:e}=this;e&&(e.setAttribute("data-calcite-tooltip-reference",""),e.hasAttribute("aria-describedby")||e.setAttribute("aria-describedby",this.getId()))},this.removeReferences=()=>{const{_referenceElement:e}=this;e&&(e.removeAttribute("aria-describedby"),e.removeAttribute("data-calcite-tooltip-reference"))},this.show=()=>{this.open=!0},this.hide=()=>{this.open=!1}}offsetDistanceOffsetHandler(){this.reposition()}offsetSkiddingHandler(){this.reposition()}openHandler(e){e?this.createPopper():this.destroyPopper()}placementHandler(){this.reposition()}referenceElementHandler(){this.removeReferences(),this._referenceElement=this.getReferenceElement(),this.addReferences(),this.createPopper()}componentDidLoad(){this.addReferences(),this.createPopper()}disconnectedCallback(){this.removeReferences(),this.destroyPopper()}async reposition(){const{popper:e,el:t,placement:s}=this,i=this.getModifiers();e?c({el:t,modifiers:i,placement:s,popper:e}):this.createPopper()}getReferenceElement(){const{referenceElement:e}=this;return("string"==typeof e?document.getElementById(e):e)||null}getModifiers(){const{arrowEl:e,offsetDistance:t,offsetSkidding:s}=this;return[{name:"arrow",enabled:!0,options:{element:e}},{name:"offset",enabled:!0,options:{offset:[s,t]}}]}createPopper(){this.destroyPopper();const{el:e,open:t,placement:s,_referenceElement:i}=this,o=this.getModifiers();this.popper=l({el:e,modifiers:o,open:t,placement:s,referenceEl:i})}destroyPopper(){const{popper:e}=this;e&&e.destroy(),this.popper=null}render(){const{_referenceElement:e,open:i}=this;return t(s,{role:"tooltip","aria-hidden":e&&i?"false":"true",id:this.getId()},t("div",{class:"arrow",ref:e=>this.arrowEl=e}),t("div",{class:"container"},t("slot",null)))}get el(){return i(this)}static get watchers(){return{offsetDistance:["offsetDistanceOffsetHandler"],offsetSkidding:["offsetSkiddingHandler"],open:["openHandler"],placement:["placementHandler"],referenceElement:["referenceElementHandler"]}}};p.style=':host([hidden]){display:none}:host{display:block;position:absolute;z-index:999;top:-999999px;left:-999999px}:host([aria-hidden=false]){-webkit-box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16)}.arrow,.arrow::before{position:absolute;width:8px;height:8px;z-index:-1}.arrow::before{content:"";-webkit-box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);-webkit-transform:rotate(45deg);transform:rotate(45deg);background:var(--calcite-ui-foreground-1)}:host([data-popper-placement^=top])>.arrow{bottom:-4px}:host([data-popper-placement^=bottom])>.arrow{top:-4px}:host([data-popper-placement^=left])>.arrow{right:-4px}:host([data-popper-placement^=right])>.arrow{left:-4px}.container{position:relative;border-radius:var(--calcite-border-radius);background:var(--calcite-ui-foreground-1);max-width:300px;max-height:300px;display:-ms-flexbox;display:flex;-ms-flex-pack:start;justify-content:flex-start;-ms-flex-direction:column;flex-direction:column;font-weight:500;color:var(--calcite-ui-text-1);padding:12px 16px;overflow:hidden;font-size:0.8125rem;line-height:1.5}:host([theme=dark]) .container{background:var(--calcite-ui-foreground-2)}';const h=class{constructor(t){e(this,t),this.selector="[data-calcite-tooltip-reference]",this.toggle=(e,t=!0)=>{const s=e.target,{selector:i}=this,r=o(s.closest(i));r&&(r.open=t)},this.keyUpHandler=e=>{"Escape"===r(e.key)&&this.toggle(e,!1)}}render(){return t(s,{onkeyup:this.keyUpHandler})}mouseEnterShow(e){this.toggle(e,!0)}mouseLeaveHide(e){this.toggle(e,!1)}focusShow(e){this.toggle(e,!0)}blurHide(e){this.toggle(e,!1)}};export{p as calcite_tooltip,h as calcite_tooltip_manager}