import{a as x}from"./chunk.CGQ2BPPZ.js";import{a as m,c as f}from"./chunk.B2NUKX6G.js";import{a as w}from"./chunk.KLRPP4NQ.js";import{a as k}from"./chunk.VAM5SM3O.js";import{a as l}from"./chunk.UFTAQNZB.js";import{a as h}from"./chunk.NYKJXI3Q.js";import{a as b,b as o,d as n,h as c}from"./chunk.XJAJO727.js";import{b as g,e as a}from"./chunk.OBAEIKIV.js";import{b as d,c as p,e as u}from"./chunk.W4QBFD6E.js";import{e as i}from"./chunk.6EV4YU6C.js";var e=class extends c{constructor(){super(...arguments);this.localize=new k(this);this.hasSlotController=new x(this,"[default]","content");this.size="lg";this.content="";this.placement="top";this.disabled=!1;this.open=!1;this.trigger="click focus";this.closeTrigger="click focus escape";this.hoist=!1;this.handleMouseInteraction=()=>{this.interactionType="mouse"};this.handleKeyboardInteraction=()=>{this.interactionType="keyboard"}}connectedCallback(){super.connectedCallback(),this.handleBlur=this.handleBlur.bind(this),this.handleClick=this.handleClick.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMouseOver=this.handleMouseOver.bind(this),this.handleMouseOut=this.handleMouseOut.bind(this),document.addEventListener("mousedown",this.handleMouseInteraction),document.addEventListener("keydown",this.handleKeyboardInteraction),this.handleDocumentClick=this.handleDocumentClick.bind(this),document.addEventListener("click",this.handleDocumentClick),this.updateComplete.then(()=>{this.addEventListener("blur",this.handleBlur,!0),this.addEventListener("focus",this.handleFocus,!0),this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("mouseover",this.handleMouseOver),this.addEventListener("mouseout",this.handleMouseOut)})}firstUpdated(){this.body.hidden=!this.open,this.formatDefaultSlot(this.defaultSlot),this.open&&(this.popup.active=!0,this.popup.reposition())}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("blur",this.handleBlur,!0),this.removeEventListener("focus",this.handleFocus,!0),this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("mouseover",this.handleMouseOver),this.removeEventListener("mouseout",this.handleMouseOut),document.removeEventListener("mousedown",this.handleMouseInteraction),document.removeEventListener("keydown",this.handleKeyboardInteraction),document.removeEventListener("click",this.handleDocumentClick)}get hasCustomTrigger(){return this.hasSlotController.test("[default]")}formatDefaultSlot(t){if(!t)return;t.assignedNodes({flatten:!0}).forEach(r=>{var y,v;r.nodeType===Node.TEXT_NODE&&!((y=r==null?void 0:r.textContent)!=null&&y.trim())&&((v=r==null?void 0:r.parentNode)==null||v.removeChild(r))})}handleBlur(){this.hasCloseTrigger("focus")&&this.hide()}handleClick(){this.open&&this.hasCloseTrigger("click")?this.hide():this.hasTrigger("click")&&this.show()}handleFocus(){this.hasTrigger("focus")&&this.interactionType==="keyboard"&&this.show()}handleKeyDown(t){this.open&&t.key==="Escape"&&this.hasCloseTrigger("escape")&&(t.stopPropagation(),this.hide())}handleMouseOver(){if(this.hasTrigger("hover")){let t=p(getComputedStyle(this).getPropertyValue("--show-delay"));clearTimeout(this.hoverTimeout),this.hoverTimeout=window.setTimeout(()=>this.show(),t)}}handleMouseOut(){if(this.hasCloseTrigger("hover")){let t=p(getComputedStyle(this).getPropertyValue("--hide-delay"));clearTimeout(this.hoverTimeout),this.hoverTimeout=window.setTimeout(()=>this.hide(),t)}}handleDocumentClick(t){if(!this.open||this.interactionType==="keyboard")return;let s=t.composedPath();this.hasCloseTrigger("focus")&&!s.includes(this)&&!s.includes(this.popup)&&this.hide()}hasTrigger(t){return this.trigger.split(" ").includes(t)}hasCloseTrigger(t){return this.closeTrigger.split(" ").includes(t)}async handleOpenChange(){if(this.open){if(this.disabled)return;this.emit("sd-show"),await u(this.body),this.body.hidden=!1,this.popup.active=!0;let{keyframes:t,options:s}=f(this,"tooltip.show",{dir:this.localize.dir()});await d(this.popup.popup,t,s),this.emit("sd-after-show")}else{this.emit("sd-hide"),await u(this.body);let{keyframes:t,options:s}=f(this,"tooltip.hide",{dir:this.localize.dir()});await d(this.popup.popup,t,s),this.popup.active=!1,this.body.hidden=!0,this.emit("sd-after-hide")}}async handleOptionsChange(){this.hasUpdated&&(await this.updateComplete,this.popup.reposition())}handleDisabledChange(){this.disabled&&this.open&&this.hide()}async show(){if(!this.open)return this.open=!0,w(this,"sd-after-show")}async hide(){if(this.open)return this.open=!1,this.trigger==="click"||this.trigger==="click focus"?this.focus():this.blur(),w(this,"sd-after-hide")}render(){let t=this.placement.endsWith("-start"),s=this.placement.endsWith("-end");return a`<sd-popup part="base" exportparts="
          popup:base__popup,
          arrow:base__arrow
        " class="${l(this.open&&"tooltip--open")}" placement="${this.placement}" distance="10" skidding="${{start:2,end:-2,default:0}[t?"start":s?"end":"default"]*(this.size==="sm"?-1:1)}" strategy="${this.hoist?"fixed":"absolute"}" flip shift arrow auto-size="vertical" arrow-padding="0">${this.hasCustomTrigger?a`<slot slot="anchor"></slot>`:a`<button slot="anchor" aria-describedby="tooltip" class="${l("flex sd-interactive rounded-full",this.size==="lg"?"text-xl":"text-base")}" ?disabled="${this.disabled}" aria-expanded="${this.open}" aria-controls="tooltip"><sd-icon library="_internal" name="info-circle" label="Tooltip" class="${l(this.disabled&&"sd-interactive--disabled")}"></sd-icon></button>`}<slot name="content" part="body" id="tooltip" class="sd-tooltip-color-background sd-tooltip-color-text py-3 px-4 block rounded-none text-sm text-left" role="tooltip" aria-label="${this.content}" aria-live="${this.open?"polite":"off"}">${this.content}</slot></sd-popup>`}};e.styles=[...c.styles,g`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */@layer properties;@layer theme,base,components,utilities;
:host{--hide-delay:0ms;--show-delay:150ms;display:contents}sd-popup{--arrow-color:rgba(var(--sd-tooltip-color-background));--arrow-size:10px}sd-popup::part(popup){pointer-events:none;z-index:10;--tw-shadow:var(--sd-shadow);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}sd-popup::part(arrow){--tw-shadow:var(--sd-shadow);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}sd-popup[placement^=top]::part(popup){transform-origin:bottom}sd-popup[placement^=bottom]::part(popup){transform-origin:top}#tooltip{max-width:var(--max-width)}::slotted([slot=content]){overflow:auto;max-width:var(--auto-size-available-width)!important;max-height:var(--auto-size-available-height)!important}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}`],i([n("slot:not([name])")],e.prototype,"defaultSlot",2),i([n("#tooltip")],e.prototype,"body",2),i([n("sd-popup")],e.prototype,"popup",2),i([o({type:String,reflect:!0})],e.prototype,"size",2),i([o({type:String,reflect:!0})],e.prototype,"content",2),i([o({type:String,reflect:!0})],e.prototype,"placement",2),i([o({type:Boolean,reflect:!0})],e.prototype,"disabled",2),i([o({type:Boolean,reflect:!0})],e.prototype,"open",2),i([o({type:String,reflect:!0})],e.prototype,"trigger",2),i([o({type:String,attribute:"close-trigger",reflect:!0})],e.prototype,"closeTrigger",2),i([o({type:Boolean,reflect:!0})],e.prototype,"hoist",2),i([h("open",{waitUntilFirstUpdate:!0})],e.prototype,"handleOpenChange",1),i([h(["content","hoist","placement"])],e.prototype,"handleOptionsChange",1),i([h("disabled")],e.prototype,"handleDisabledChange",1),e=i([b("sd-tooltip")],e);m("tooltip.show",{keyframes:[{opacity:0},{opacity:1}],options:{duration:"var(--sd-duration-fast, 150)",easing:"ease-in-out"}});m("tooltip.hide",{keyframes:[{opacity:1},{opacity:0}],options:{duration:"var(--sd-duration-fast, 150)",easing:"ease-in-out"}});export{e as a};
