"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("../../common/utils/index.cjs"),l=require("vue"),r=require("../tooltip/tooltip.cjs"),u={name:"dt-tooltip-directive",install(a){let p;const s=document.createElement("div");document.body.appendChild(s);const c="top";l.createApp({name:"DtTooltipDirectiveApp",components:{DtTooltip:r.default},data(){return{tooltips:[]}},mounted(){p=l.getCurrentInstance()},methods:{addOrUpdateTooltip(t,e,o){const i=this.tooltips.findIndex(d=>d.id===t);i!==-1?(this.tooltips[i].message=e,this.tooltips[i].placement=o):this.tooltips.push({id:t,message:e,placement:o})},removeTooltip(t){this.tooltips=this.tooltips.filter(e=>e.id!==t)}},render(){return l.h("div",this.tooltips.map(({id:t,message:e,placement:o})=>l.h(r.default,{key:t,message:e,placement:o,sticky:!0,delay:process.env.NODE_ENV!=="test",externalAnchor:`[data-dt-tooltip-id="${t}"]`})))}}).mount(s),a.directive("dt-tooltip",{beforeMount(t,e){n(t,e)},updated(t,e){e.value!==e.oldValue&&n(t,e)},unmounted(t){p.ctx.removeTooltip(t.getAttribute("data-dt-tooltip-id"))}});function n(t,e){const o=t.getAttribute("data-dt-tooltip-id")||m.getUniqueString(),i=e.value,d=e.arg||c;t.setAttribute("data-dt-tooltip-id",o),p.ctx.addOrUpdateTooltip(o,i,d)}}};exports.DtTooltipDirective=u;exports.default=u;
//# sourceMappingURL=tooltip.cjs.map
