UNPKG

preline

Version:

Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.

8 lines 23.6 kB
var t={189:(t,e,n)=>{n.d(e,{lP:()=>o});const o={auto:"auto","auto-start":"auto-start","auto-end":"auto-end",top:"top","top-left":"top-start","top-right":"top-end",bottom:"bottom","bottom-left":"bottom-start","bottom-right":"bottom-end",right:"right","right-start":"right-start","right-end":"right-end",left:"left","left-start":"left-start","left-end":"left-end"}},615:(t,e,n)=>{n.d(e,{A:()=>o});class o{constructor(t,e,n){this.el=t,this.options=e,this.events=n,this.el=t,this.options=e,this.events={}}createCollection(t,e){var n;t.push({id:(null===(n=null==e?void 0:e.el)||void 0===n?void 0:n.id)||t.length+1,element:e})}fireEvent(t,e=null){if(this.events.hasOwnProperty(t))return this.events[t](e)}on(t,e){this.events[t]=e}}},663:(t,e,n)=>{n.d(e,{ll:()=>ot,rD:()=>st,UU:()=>lt,cY:()=>it});const o=Math.min,i=Math.max,l=Math.round,s=Math.floor,r=t=>({x:t,y:t}),c={left:"right",right:"left",bottom:"top",top:"bottom"},a={start:"end",end:"start"};function u(t,e){return"function"==typeof t?t(e):t}function h(t){return t.split("-")[0]}function f(t){return t.split("-")[1]}function d(t){return"y"===t?"height":"width"}function g(t){return["top","bottom"].includes(h(t))?"y":"x"}function p(t){return"x"===g(t)?"y":"x"}function m(t){return t.replace(/start|end/g,(t=>a[t]))}function v(t){return t.replace(/left|right|bottom|top/g,(t=>c[t]))}function w(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function y(t,e,n){let{reference:o,floating:i}=t;const l=g(e),s=p(e),r=d(s),c=h(e),a="y"===l,u=o.x+o.width/2-i.width/2,m=o.y+o.height/2-i.height/2,v=o[r]/2-i[r]/2;let w;switch(c){case"top":w={x:u,y:o.y-i.height};break;case"bottom":w={x:u,y:o.y+o.height};break;case"right":w={x:o.x+o.width,y:m};break;case"left":w={x:o.x-i.width,y:m};break;default:w={x:o.x,y:o.y}}switch(f(e)){case"start":w[s]-=v*(n&&a?-1:1);break;case"end":w[s]+=v*(n&&a?-1:1)}return w}async function x(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:l,rects:s,elements:r,strategy:c}=t,{boundary:a="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:d=!1,padding:g=0}=u(e,t),p=function(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}(g),m=r[d?"floating"===f?"reference":"floating":f],v=w(await l.getClippingRect({element:null==(n=await(null==l.isElement?void 0:l.isElement(m)))||n?m:m.contextElement||await(null==l.getDocumentElement?void 0:l.getDocumentElement(r.floating)),boundary:a,rootBoundary:h,strategy:c})),y="floating"===f?{x:o,y:i,width:s.floating.width,height:s.floating.height}:s.reference,x=await(null==l.getOffsetParent?void 0:l.getOffsetParent(r.floating)),b=await(null==l.isElement?void 0:l.isElement(x))&&await(null==l.getScale?void 0:l.getScale(x))||{x:1,y:1},L=w(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:r,rect:y,offsetParent:x,strategy:c}):y);return{top:(v.top-L.top+p.top)/b.y,bottom:(L.bottom-v.bottom+p.bottom)/b.y,left:(v.left-L.left+p.left)/b.x,right:(L.right-v.right+p.right)/b.x}}function b(){return"undefined"!=typeof window}function L(t){return C(t)?(t.nodeName||"").toLowerCase():"#document"}function T(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function E(t){var e;return null==(e=(C(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function C(t){return!!b()&&(t instanceof Node||t instanceof T(t).Node)}function R(t){return!!b()&&(t instanceof Element||t instanceof T(t).Element)}function A(t){return!!b()&&(t instanceof HTMLElement||t instanceof T(t).HTMLElement)}function k(t){return!(!b()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof T(t).ShadowRoot)}function F(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=H(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function P(t){return["table","td","th"].includes(L(t))}function S(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function M(t){const e=D(),n=R(t)?H(t):t;return["transform","translate","scale","rotate","perspective"].some((t=>!!n[t]&&"none"!==n[t]))||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","translate","scale","rotate","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function D(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function O(t){return["html","body","#document"].includes(L(t))}function H(t){return T(t).getComputedStyle(t)}function U(t){return R(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function I(t){if("html"===L(t))return t;const e=t.assignedSlot||t.parentNode||k(t)&&t.host||E(t);return k(e)?e.host:e}function $(t){const e=I(t);return O(e)?t.ownerDocument?t.ownerDocument.body:t.body:A(e)&&F(e)?e:$(e)}function B(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=$(t),l=i===(null==(o=t.ownerDocument)?void 0:o.body),s=T(i);if(l){const t=j(s);return e.concat(s,s.visualViewport||[],F(i)?i:[],t&&n?B(t):[])}return e.concat(i,B(i,[],n))}function j(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function V(t){const e=H(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=A(t),s=i?t.offsetWidth:n,r=i?t.offsetHeight:o,c=l(n)!==s||l(o)!==r;return c&&(n=s,o=r),{width:n,height:o,$:c}}function W(t){return R(t)?t:t.contextElement}function q(t){const e=W(t);if(!A(e))return r(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:s}=V(e);let c=(s?l(n.width):n.width)/o,a=(s?l(n.height):n.height)/i;return c&&Number.isFinite(c)||(c=1),a&&Number.isFinite(a)||(a=1),{x:c,y:a}}const z=r(0);function N(t){const e=T(t);return D()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:z}function _(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const i=t.getBoundingClientRect(),l=W(t);let s=r(1);e&&(o?R(o)&&(s=q(o)):s=q(t));const c=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==T(t))&&e}(l,n,o)?N(l):r(0);let a=(i.left+c.x)/s.x,u=(i.top+c.y)/s.y,h=i.width/s.x,f=i.height/s.y;if(l){const t=T(l),e=o&&R(o)?T(o):o;let n=t,i=j(n);for(;i&&o&&e!==n;){const t=q(i),e=i.getBoundingClientRect(),o=H(i),l=e.left+(i.clientLeft+parseFloat(o.paddingLeft))*t.x,s=e.top+(i.clientTop+parseFloat(o.paddingTop))*t.y;a*=t.x,u*=t.y,h*=t.x,f*=t.y,a+=l,u+=s,n=T(i),i=j(n)}}return w({width:h,height:f,x:a,y:u})}function Y(t,e){const n=U(t).scrollLeft;return e?e.left+n:_(E(t)).left+n}function J(t,e,n){void 0===n&&(n=!1);const o=t.getBoundingClientRect();return{x:o.left+e.scrollLeft-(n?0:Y(t,o)),y:o.top+e.scrollTop}}function X(t,e,n){let o;if("viewport"===e)o=function(t,e){const n=T(t),o=E(t),i=n.visualViewport;let l=o.clientWidth,s=o.clientHeight,r=0,c=0;if(i){l=i.width,s=i.height;const t=D();(!t||t&&"fixed"===e)&&(r=i.offsetLeft,c=i.offsetTop)}return{width:l,height:s,x:r,y:c}}(t,n);else if("document"===e)o=function(t){const e=E(t),n=U(t),o=t.ownerDocument.body,l=i(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),s=i(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let r=-n.scrollLeft+Y(t);const c=-n.scrollTop;return"rtl"===H(o).direction&&(r+=i(e.clientWidth,o.clientWidth)-l),{width:l,height:s,x:r,y:c}}(E(t));else if(R(e))o=function(t,e){const n=_(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,l=A(t)?q(t):r(1);return{width:t.clientWidth*l.x,height:t.clientHeight*l.y,x:i*l.x,y:o*l.y}}(e,n);else{const n=N(t);o={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return w(o)}function G(t,e){const n=I(t);return!(n===e||!R(n)||O(n))&&("fixed"===H(n).position||G(n,e))}function K(t,e,n){const o=A(e),i=E(e),l="fixed"===n,s=_(t,!0,l,e);let c={scrollLeft:0,scrollTop:0};const a=r(0);if(o||!o&&!l)if(("body"!==L(e)||F(i))&&(c=U(e)),o){const t=_(e,!0,l,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else i&&(a.x=Y(i));const u=!i||o||l?r(0):J(i,c);return{x:s.left+c.scrollLeft-a.x-u.x,y:s.top+c.scrollTop-a.y-u.y,width:s.width,height:s.height}}function Q(t){return"static"===H(t).position}function Z(t,e){if(!A(t)||"fixed"===H(t).position)return null;if(e)return e(t);let n=t.offsetParent;return E(t)===n&&(n=n.ownerDocument.body),n}function tt(t,e){const n=T(t);if(S(t))return n;if(!A(t)){let e=I(t);for(;e&&!O(e);){if(R(e)&&!Q(e))return e;e=I(e)}return n}let o=Z(t,e);for(;o&&P(o)&&Q(o);)o=Z(o,e);return o&&O(o)&&Q(o)&&!M(o)?n:o||function(t){let e=I(t);for(;A(e)&&!O(e);){if(M(e))return e;if(S(e))return null;e=I(e)}return null}(t)||n}const et={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const l="fixed"===i,s=E(o),c=!!e&&S(e.floating);if(o===s||c&&l)return n;let a={scrollLeft:0,scrollTop:0},u=r(1);const h=r(0),f=A(o);if((f||!f&&!l)&&(("body"!==L(o)||F(s))&&(a=U(o)),A(o))){const t=_(o);u=q(o),h.x=t.x+o.clientLeft,h.y=t.y+o.clientTop}const d=!s||f||l?r(0):J(s,a,!0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-a.scrollLeft*u.x+h.x+d.x,y:n.y*u.y-a.scrollTop*u.y+h.y+d.y}},getDocumentElement:E,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:l,strategy:s}=t;const r=[..."clippingAncestors"===n?S(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=B(t,[],!1).filter((t=>R(t)&&"body"!==L(t))),i=null;const l="fixed"===H(t).position;let s=l?I(t):t;for(;R(s)&&!O(s);){const e=H(s),n=M(s);n||"fixed"!==e.position||(i=null),(l?!n&&!i:!n&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||F(s)&&!n&&G(t,s))?o=o.filter((t=>t!==s)):i=e,s=I(s)}return e.set(t,o),o}(e,this._c):[].concat(n),l],c=r[0],a=r.reduce(((t,n)=>{const l=X(e,n,s);return t.top=i(l.top,t.top),t.right=o(l.right,t.right),t.bottom=o(l.bottom,t.bottom),t.left=i(l.left,t.left),t}),X(e,c,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:tt,getElementRects:async function(t){const e=this.getOffsetParent||tt,n=this.getDimensions,o=await n(t.floating);return{reference:K(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=V(t);return{width:e,height:n}},getScale:q,isElement:R,isRTL:function(t){return"rtl"===H(t).direction}};function nt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function ot(t,e,n,l){void 0===l&&(l={});const{ancestorScroll:r=!0,ancestorResize:c=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:u="function"==typeof IntersectionObserver,animationFrame:h=!1}=l,f=W(t),d=r||c?[...f?B(f):[],...B(e)]:[];d.forEach((t=>{r&&t.addEventListener("scroll",n,{passive:!0}),c&&t.addEventListener("resize",n)}));const g=f&&u?function(t,e){let n,l=null;const r=E(t);function c(){var t;clearTimeout(n),null==(t=l)||t.disconnect(),l=null}return function a(u,h){void 0===u&&(u=!1),void 0===h&&(h=1),c();const f=t.getBoundingClientRect(),{left:d,top:g,width:p,height:m}=f;if(u||e(),!p||!m)return;const v={rootMargin:-s(g)+"px "+-s(r.clientWidth-(d+p))+"px "+-s(r.clientHeight-(g+m))+"px "+-s(d)+"px",threshold:i(0,o(1,h))||1};let w=!0;function y(e){const o=e[0].intersectionRatio;if(o!==h){if(!w)return a();o?a(!1,o):n=setTimeout((()=>{a(!1,1e-7)}),1e3)}1!==o||nt(f,t.getBoundingClientRect())||a(),w=!1}try{l=new IntersectionObserver(y,{...v,root:r.ownerDocument})}catch(t){l=new IntersectionObserver(y,v)}l.observe(t)}(!0),c}(f,n):null;let p,m=-1,v=null;a&&(v=new ResizeObserver((t=>{let[o]=t;o&&o.target===f&&v&&(v.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{var t;null==(t=v)||t.observe(e)}))),n()})),f&&!h&&v.observe(f),v.observe(e));let w=h?_(t):null;return h&&function e(){const o=_(t);w&&!nt(w,o)&&n();w=o,p=requestAnimationFrame(e)}(),n(),()=>{var t;d.forEach((t=>{r&&t.removeEventListener("scroll",n),c&&t.removeEventListener("resize",n)})),null==g||g(),null==(t=v)||t.disconnect(),v=null,h&&cancelAnimationFrame(p)}}const it=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:i,y:l,placement:s,middlewareData:r}=e,c=await async function(t,e){const{placement:n,platform:o,elements:i}=t,l=await(null==o.isRTL?void 0:o.isRTL(i.floating)),s=h(n),r=f(n),c="y"===g(n),a=["left","top"].includes(s)?-1:1,d=l&&c?-1:1,p=u(e,t);let{mainAxis:m,crossAxis:v,alignmentAxis:w}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return r&&"number"==typeof w&&(v="end"===r?-1*w:w),c?{x:v*d,y:m*a}:{x:m*a,y:v*d}}(e,t);return s===(null==(n=r.offset)?void 0:n.placement)&&null!=(o=r.arrow)&&o.alignmentOffset?{}:{x:i+c.x,y:l+c.y,data:{...c,placement:s}}}}},lt=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:l,rects:s,initialPlacement:r,platform:c,elements:a}=e,{mainAxis:w=!0,crossAxis:y=!0,fallbackPlacements:b,fallbackStrategy:L="bestFit",fallbackAxisSideDirection:T="none",flipAlignment:E=!0,...C}=u(t,e);if(null!=(n=l.arrow)&&n.alignmentOffset)return{};const R=h(i),A=g(r),k=h(r)===r,F=await(null==c.isRTL?void 0:c.isRTL(a.floating)),P=b||(k||!E?[v(r)]:function(t){const e=v(t);return[m(t),e,m(e)]}(r)),S="none"!==T;!b&&S&&P.push(...function(t,e,n,o){const i=f(t);let l=function(t,e,n){const o=["left","right"],i=["right","left"],l=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?l:s;default:return[]}}(h(t),"start"===n,o);return i&&(l=l.map((t=>t+"-"+i)),e&&(l=l.concat(l.map(m)))),l}(r,E,T,F));const M=[r,...P],D=await x(e,C),O=[];let H=(null==(o=l.flip)?void 0:o.overflows)||[];if(w&&O.push(D[R]),y){const t=function(t,e,n){void 0===n&&(n=!1);const o=f(t),i=p(t),l=d(i);let s="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[l]>e.floating[l]&&(s=v(s)),[s,v(s)]}(i,s,F);O.push(D[t[0]],D[t[1]])}if(H=[...H,{placement:i,overflows:O}],!O.every((t=>t<=0))){var U,I;const t=((null==(U=l.flip)?void 0:U.index)||0)+1,e=M[t];if(e)return{data:{index:t,overflows:H},reset:{placement:e}};let n=null==(I=H.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:I.placement;if(!n)switch(L){case"bestFit":{var $;const t=null==($=H.filter((t=>{if(S){const e=g(t.placement);return e===A||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:$[0];t&&(n=t);break}case"initialPlacement":n=r}if(i!==n)return{reset:{placement:n}}}return{}}}},st=(t,e,n)=>{const o=new Map,i={platform:et,...n},l={...i.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:l=[],platform:s}=n,r=l.filter(Boolean),c=await(null==s.isRTL?void 0:s.isRTL(e));let a=await s.getElementRects({reference:t,floating:e,strategy:i}),{x:u,y:h}=y(a,o,c),f=o,d={},g=0;for(let n=0;n<r.length;n++){const{name:l,fn:p}=r[n],{x:m,y:v,data:w,reset:x}=await p({x:u,y:h,initialPlacement:o,placement:f,strategy:i,middlewareData:d,rects:a,platform:s,elements:{reference:t,floating:e}});u=null!=m?m:u,h=null!=v?v:h,d={...d,[l]:{...d[l],...w}},x&&g<=50&&(g++,"object"==typeof x&&(x.placement&&(f=x.placement),x.rects&&(a=!0===x.rects?await s.getElementRects({reference:t,floating:e,strategy:i}):x.rects),({x:u,y:h}=y(a,f,c))),n=-1)}return{x:u,y:h,placement:f,strategy:i,middlewareData:d}})(t,e,{...i,platform:l})}},926:(t,e,n)=>{n.d(e,{JD:()=>i,gj:()=>o,yd:()=>l}); /* * @version: 3.2.3 * @author: Preline Labs Ltd. * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html) * Copyright 2024 Preline Labs Ltd. */ const o=(t,e,n="")=>(window.getComputedStyle(t).getPropertyValue(e)||n).replace(" ",""),i=(t,e,n=null)=>{const o=new CustomEvent(t,{detail:{payload:n},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(o)},l=(t,e)=>{const n=()=>{e(),t.removeEventListener("transitionend",n,!0)},o=window.getComputedStyle(t),i=o.getPropertyValue("transition-duration");"none"!==o.getPropertyValue("transition-property")&&parseFloat(i)>0?t.addEventListener("transitionend",n,!0):e()}}},e={};function n(o){var i=e[o];if(void 0!==i)return i.exports;var l=e[o]={exports:{}};return t[o](l,l.exports,n),l.exports}n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var o={};n.d(o,{A:()=>u});var i=n(663),l=n(926),s=n(615),r=n(189),c=function(t,e,n,o){return new(n||(n=Promise))((function(i,l){function s(t){try{c(o.next(t))}catch(t){l(t)}}function r(t){try{c(o.throw(t))}catch(t){l(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}c((o=o.apply(t,e||[])).next())}))};class a extends s.A{constructor(t,e,n){super(t,e,n),this.cleanupAutoUpdate=null,this.el&&(this.toggle=this.el.querySelector(".hs-tooltip-toggle")||this.el,this.content=this.el.querySelector(".hs-tooltip-content"),this.eventMode=(0,l.gj)(this.el,"--trigger")||"hover",this.preventFloatingUI=(0,l.gj)(this.el,"--prevent-popper","false"),this.placement=(0,l.gj)(this.el,"--placement")||"top",this.strategy=(0,l.gj)(this.el,"--strategy"),this.scope=(0,l.gj)(this.el,"--scope")||"parent"),this.el&&this.toggle&&this.content&&this.init()}toggleClick(){this.click()}toggleFocus(){this.focus()}toggleMouseEnter(){this.enter()}toggleMouseLeave(){this.leave()}toggleHandle(){this.hide(),this.toggle.removeEventListener("click",this.onToggleHandleListener,!0),this.toggle.removeEventListener("blur",this.onToggleHandleListener,!0)}init(){this.createCollection(window.$hsTooltipCollection,this),this.onToggleFocusListener=()=>this.enter(),this.onToggleBlurListener=()=>this.hide(),this.toggle.addEventListener("focus",this.onToggleFocusListener),this.toggle.addEventListener("blur",this.onToggleBlurListener),"click"===this.eventMode?(this.onToggleClickListener=()=>this.toggleClick(),this.toggle.addEventListener("click",this.onToggleClickListener)):"hover"===this.eventMode&&(this.onToggleMouseEnterListener=()=>this.toggleMouseEnter(),this.onToggleMouseLeaveListener=()=>this.toggleMouseLeave(),this.toggle.addEventListener("mouseenter",this.onToggleMouseEnterListener),this.toggle.addEventListener("mouseleave",this.onToggleMouseLeaveListener)),"false"===this.preventFloatingUI&&this.buildFloatingUI()}enter(){this._show()}leave(){this.hide()}click(){if(this.el.classList.contains("show"))return!1;this._show(),this.onToggleHandleListener=()=>{setTimeout((()=>this.toggleHandle()))},this.toggle.addEventListener("click",this.onToggleHandleListener,!0),this.toggle.addEventListener("blur",this.onToggleHandleListener,!0)}focus(){this._show()}positionTooltip(t){return c(this,void 0,void 0,(function*(){const e="auto"===t?"top":t,n="auto"===t?["bottom","left","right"]:this.getFallbackPlacements(e),o=[(0,i.cY)(5),(0,i.UU)({fallbackPlacements:n})];return yield(0,i.rD)(this.toggle,this.content,{placement:e,strategy:this.strategy||"fixed",middleware:o})}))}getFallbackPlacements(t){switch(t){case"top":return["bottom","left","right"];case"bottom":return["top","left","right"];case"left":return["right","top","bottom"];case"right":return["left","top","bottom"];case"top-start":return["bottom-start","top-end","bottom-end"];case"top-end":return["bottom-end","top-start","bottom-start"];case"bottom-start":return["top-start","bottom-end","top-end"];case"bottom-end":return["top-end","bottom-start","top-start"];case"left-start":return["right-start","left-end","right-end"];case"left-end":return["right-end","left-start","right-start"];case"right-start":return["left-start","right-end","left-end"];case"right-end":return["left-end","right-start","left-start"];default:return["top","bottom","left","right"]}}applyTooltipPosition(t,e,n){Object.assign(this.content.style,{position:this.strategy||"fixed",left:`${t}px`,top:`${e}px`}),this.content.setAttribute("data-placement",n)}buildFloatingUI(){"window"===this.scope&&document.body.appendChild(this.content);const t=this.placement.startsWith("auto"),e=(0,l.gj)(this.el,"--placement"),n=t||(!e||""===e)?"auto":r.lP[this.placement]||this.placement;this.positionTooltip(n).then((t=>{this.applyTooltipPosition(t.x,t.y,t.placement)})),this.cleanupAutoUpdate=(0,i.ll)(this.toggle,this.content,(()=>{this.positionTooltip(n).then((t=>{Object.assign(this.content.style,{position:this.strategy||"fixed",left:`${t.x}px`,top:`${t.y}px`}),this.content.setAttribute("data-placement",t.placement)}))}))}_show(){this.content.classList.remove("hidden"),"window"===this.scope&&this.content.classList.add("show"),"false"!==this.preventFloatingUI||this.cleanupAutoUpdate||this.buildFloatingUI(),setTimeout((()=>{this.el.classList.add("show"),this.fireEvent("show",this.el),(0,l.JD)("show.hs.tooltip",this.el,this.el)}))}show(){"click"===this.eventMode?this.click():this.enter(),this.toggle.focus(),this.toggle.style.outline="none"}hide(){this.el.classList.remove("show"),"window"===this.scope&&this.content.classList.remove("show"),"false"===this.preventFloatingUI&&this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null),this.fireEvent("hide",this.el),(0,l.JD)("hide.hs.tooltip",this.el,this.el),(0,l.yd)(this.content,(()=>{if(this.el.classList.contains("show"))return!1;this.content.classList.add("hidden"),this.toggle.style.outline=""}))}destroy(){this.el.classList.remove("show"),this.content.classList.add("hidden"),this.toggle.removeEventListener("focus",this.onToggleFocusListener),this.toggle.removeEventListener("blur",this.onToggleBlurListener),"click"===this.eventMode?this.toggle.removeEventListener("click",this.onToggleClickListener):"hover"===this.eventMode&&(this.toggle.removeEventListener("mouseenter",this.onToggleMouseEnterListener),this.toggle.removeEventListener("mouseleave",this.onToggleMouseLeaveListener)),this.toggle.removeEventListener("click",this.onToggleHandleListener,!0),this.toggle.removeEventListener("blur",this.onToggleHandleListener,!0),this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null),window.$hsTooltipCollection=window.$hsTooltipCollection.filter((({element:t})=>t.el!==this.el))}static findInCollection(t){return window.$hsTooltipCollection.find((e=>t instanceof a?e.element.el===t.el:"string"==typeof t?e.element.el===document.querySelector(t):e.element.el===t))||null}static getInstance(t,e=!1){const n=window.$hsTooltipCollection.find((e=>e.element.el===("string"==typeof t?document.querySelector(t):t)));return n?e?n:n.element.el:null}static autoInit(){window.$hsTooltipCollection||(window.$hsTooltipCollection=[]),window.$hsTooltipCollection&&(window.$hsTooltipCollection=window.$hsTooltipCollection.filter((({element:t})=>document.contains(t.el)))),document.querySelectorAll(".hs-tooltip:not(.--prevent-on-load-init)").forEach((t=>{window.$hsTooltipCollection.find((e=>{var n;return(null===(n=null==e?void 0:e.element)||void 0===n?void 0:n.el)===t}))||new a(t)}))}static show(t){const e=a.findInCollection(t);e&&e.element.show()}static hide(t){const e=a.findInCollection(t);e&&e.element.hide()}static on(t,e,n){const o=a.findInCollection(e);o&&(o.element.events[t]=n)}}window.addEventListener("load",(()=>{a.autoInit()})),"undefined"!=typeof window&&(window.HSTooltip=a);const u=a;var h=o.A;export{h as default};