"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("../../common/utils/index.cjs"),l=require("vue"),c=require("../tooltip/tooltip.cjs"),m=require("../tooltip/tooltip-constants.cjs"),d={name:"dt-tooltip-directive",install(p){let a;const s=document.createElement("div");document.body.appendChild(s);const n="top";l.createApp({name:"DtTooltipDirectiveApp",components:{DtTooltip:c.default},data(){return{tooltips:[]}},created(){a=l.getCurrentInstance()},methods:{addOrUpdateTooltip(e,t){const i=this.tooltips.findIndex(o=>o.id===e);i!==-1?this.tooltips.splice(i,1,{id:e,...t}):this.tooltips.push({id:e,...t})},removeTooltip(e){this.tooltips=this.tooltips.filter(t=>t.id!==e)}},render(){return l.h("div",this.tooltips.map(({id:e,...t})=>l.h(c.default,{key:e,...t,sticky:t.sticky!==void 0?t.sticky:!0,delay:t.delay!==void 0?t.delay:process.env.NODE_ENV!=="test",externalAnchor:`[data-dt-tooltip-id="${e}"]`})))}}).mount(s),p.directive("dt-tooltip",{beforeMount(e,t){u(e,t)},updated(e,t){t.value!==t.oldValue&&u(e,t)},unmounted(e){a.ctx.removeTooltip(e.getAttribute("data-dt-tooltip-id"))}});function u(e,t){const i=e.getAttribute("data-dt-tooltip-id")||v.getUniqueString();let o;if(typeof t.value=="string")o={message:t.value,placement:t.arg||n};else if(typeof t.value=="object"&&t.value!==null)o={placement:t.arg||t.value.placement||n,...t.value};else{console.error("DtTooltipDirective: binding value must be a string or object");return}Object.keys(t.modifiers).forEach(r=>{switch(r){case"inverted":o.inverted=!0;break;case"no-delay":o.delay=!1;break;case"no-transition":o.transition=!1;break;default:m.TOOLTIP_DIRECTIONS.includes(r)&&(o.placement=r);break}}),e.setAttribute("data-dt-tooltip-id",i),a.ctx.addOrUpdateTooltip(i,o)}}};exports.DtTooltipDirective=d;exports.default=d;
//# sourceMappingURL=tooltip.cjs.map
