preline
Version:
Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.
16 lines • 24.4 kB
JavaScript
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"}},7615(t,e,n){n.d(e,{A:()=>o});
/*
* HSBasePlugin
* @version: 4.2.0
* @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.
*/
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,o;let i=t;if(!Array.isArray(i)&&"undefined"!=typeof window){const t=null===(n=this.constructor)||void 0===n?void 0:n.name,e="string"==typeof t&&t.startsWith("HS")?`$hs${t.slice(2)}Collection`:null;e&&(Array.isArray(window[e])||(window[e]=[]),i=window[e])}Array.isArray(i)&&i.push({id:(null===(o=null==e?void 0:e.el)||void 0===o?void 0:o.id)||i.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}}},1926(t,e,n){n.d(e,{JD:()=>i,gj:()=>o,yd:()=>s});
/*
* @version: 4.2.0
* @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)},s=(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()}},7663(t,e,n){n.d(e,{ll:()=>ft,rD:()=>pt,UU:()=>gt,cY:()=>dt});const o=Math.min,i=Math.max,s=Math.round,l=Math.floor,r=t=>({x:t,y:t}),c={left:"right",right:"left",bottom:"top",top:"bottom"};function a(t,e){return"function"==typeof t?t(e):t}function h(t){return t.split("-")[0]}function u(t){return t.split("-")[1]}function f(t){return"y"===t?"height":"width"}function d(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function g(t){return"x"===d(t)?"y":"x"}function p(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const m=["left","right"],w=["right","left"],v=["top","bottom"],y=["bottom","top"];function x(t,e,n,o){const i=u(t);let s=function(t,e,n){switch(t){case"top":case"bottom":return n?e?w:m:e?m:w;case"left":case"right":return e?v:y;default:return[]}}(h(t),"start"===n,o);return i&&(s=s.map(t=>t+"-"+i),e&&(s=s.concat(s.map(p)))),s}function b(t){const e=h(t);return c[e]+t.slice(e.length)}function L(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 T(t,e,n){let{reference:o,floating:i}=t;const s=d(e),l=g(e),r=f(l),c=h(e),a="y"===s,p=o.x+o.width/2-i.width/2,m=o.y+o.height/2-i.height/2,w=o[r]/2-i[r]/2;let v;switch(c){case"top":v={x:p,y:o.y-i.height};break;case"bottom":v={x:p,y:o.y+o.height};break;case"right":v={x:o.x+o.width,y:m};break;case"left":v={x:o.x-i.width,y:m};break;default:v={x:o.x,y:o.y}}switch(u(e)){case"start":v[l]-=w*(n&&a?-1:1);break;case"end":v[l]+=w*(n&&a?-1:1)}return v}async function E(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:s,rects:l,elements:r,strategy:c}=t,{boundary:h="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:g=0}=a(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],w=L(await s.getClippingRect({element:null==(n=await(null==s.isElement?void 0:s.isElement(m)))||n?m:m.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(r.floating)),boundary:h,rootBoundary:u,strategy:c})),v="floating"===f?{x:o,y:i,width:l.floating.width,height:l.floating.height}:l.reference,y=await(null==s.getOffsetParent?void 0:s.getOffsetParent(r.floating)),x=await(null==s.isElement?void 0:s.isElement(y))&&await(null==s.getScale?void 0:s.getScale(y))||{x:1,y:1},b=L(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:r,rect:v,offsetParent:y,strategy:c}):v);return{top:(w.top-b.top+p.top)/x.y,bottom:(b.bottom-w.bottom+p.bottom)/x.y,left:(w.left-b.left+p.left)/x.x,right:(b.right-w.right+p.right)/x.x}}const C=new Set(["left","top"]);function A(){return"undefined"!=typeof window}function R(t){return P(t)?(t.nodeName||"").toLowerCase():"#document"}function k(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function S(t){var e;return null==(e=(P(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function P(t){return!!A()&&(t instanceof Node||t instanceof k(t).Node)}function F(t){return!!A()&&(t instanceof Element||t instanceof k(t).Element)}function O(t){return!!A()&&(t instanceof HTMLElement||t instanceof k(t).HTMLElement)}function M(t){return!(!A()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof k(t).ShadowRoot)}function $(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=z(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&"inline"!==i&&"contents"!==i}function D(t){return/^(table|td|th)$/.test(R(t))}function H(t){try{if(t.matches(":popover-open"))return!0}catch(t){}try{return t.matches(":modal")}catch(t){return!1}}const U=/transform|translate|scale|rotate|perspective|filter/,I=/paint|layout|strict|content/,W=t=>!!t&&"none"!==t;let j;function B(t){const e=F(t)?z(t):t;return W(e.transform)||W(e.translate)||W(e.scale)||W(e.rotate)||W(e.perspective)||!V()&&(W(e.backdropFilter)||W(e.filter))||U.test(e.willChange||"")||I.test(e.contain||"")}function V(){return null==j&&(j="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),j}function q(t){return/^(html|body|#document)$/.test(R(t))}function z(t){return k(t).getComputedStyle(t)}function N(t){return F(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function _(t){if("html"===R(t))return t;const e=t.assignedSlot||t.parentNode||M(t)&&t.host||S(t);return M(e)?e.host:e}function Y(t){const e=_(t);return q(e)?t.ownerDocument?t.ownerDocument.body:t.body:O(e)&&$(e)?e:Y(e)}function J(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=Y(t),s=i===(null==(o=t.ownerDocument)?void 0:o.body),l=k(i);if(s){const t=X(l);return e.concat(l,l.visualViewport||[],$(i)?i:[],t&&n?J(t):[])}return e.concat(i,J(i,[],n))}function X(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function G(t){const e=z(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=O(t),l=i?t.offsetWidth:n,r=i?t.offsetHeight:o,c=s(n)!==l||s(o)!==r;return c&&(n=l,o=r),{width:n,height:o,$:c}}function K(t){return F(t)?t:t.contextElement}function Q(t){const e=K(t);if(!O(e))return r(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:l}=G(e);let c=(l?s(n.width):n.width)/o,a=(l?s(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 tt(t){const e=k(t);return V()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:Z}function et(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const i=t.getBoundingClientRect(),s=K(t);let l=r(1);e&&(o?F(o)&&(l=Q(o)):l=Q(t));const c=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==k(t))&&e}(s,n,o)?tt(s):r(0);let a=(i.left+c.x)/l.x,h=(i.top+c.y)/l.y,u=i.width/l.x,f=i.height/l.y;if(s){const t=k(s),e=o&&F(o)?k(o):o;let n=t,i=X(n);for(;i&&o&&e!==n;){const t=Q(i),e=i.getBoundingClientRect(),o=z(i),s=e.left+(i.clientLeft+parseFloat(o.paddingLeft))*t.x,l=e.top+(i.clientTop+parseFloat(o.paddingTop))*t.y;a*=t.x,h*=t.y,u*=t.x,f*=t.y,a+=s,h+=l,n=k(i),i=X(n)}}return L({width:u,height:f,x:a,y:h})}function nt(t,e){const n=N(t).scrollLeft;return e?e.left+n:et(S(t)).left+n}function ot(t,e){const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-nt(t,n),y:n.top+e.scrollTop}}function it(t,e,n){let o;if("viewport"===e)o=function(t,e){const n=k(t),o=S(t),i=n.visualViewport;let s=o.clientWidth,l=o.clientHeight,r=0,c=0;if(i){s=i.width,l=i.height;const t=V();(!t||t&&"fixed"===e)&&(r=i.offsetLeft,c=i.offsetTop)}const a=nt(o);if(a<=0){const t=o.ownerDocument,e=t.body,n=getComputedStyle(e),i="CSS1Compat"===t.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,l=Math.abs(o.clientWidth-e.clientWidth-i);l<=25&&(s-=l)}else a<=25&&(s+=a);return{width:s,height:l,x:r,y:c}}(t,n);else if("document"===e)o=function(t){const e=S(t),n=N(t),o=t.ownerDocument.body,s=i(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),l=i(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let r=-n.scrollLeft+nt(t);const c=-n.scrollTop;return"rtl"===z(o).direction&&(r+=i(e.clientWidth,o.clientWidth)-s),{width:s,height:l,x:r,y:c}}(S(t));else if(F(e))o=function(t,e){const n=et(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,s=O(t)?Q(t):r(1);return{width:t.clientWidth*s.x,height:t.clientHeight*s.y,x:i*s.x,y:o*s.y}}(e,n);else{const n=tt(t);o={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return L(o)}function st(t,e){const n=_(t);return!(n===e||!F(n)||q(n))&&("fixed"===z(n).position||st(n,e))}function lt(t,e,n){const o=O(e),i=S(e),s="fixed"===n,l=et(t,!0,s,e);let c={scrollLeft:0,scrollTop:0};const a=r(0);function h(){a.x=nt(i)}if(o||!o&&!s)if(("body"!==R(e)||$(i))&&(c=N(e)),o){const t=et(e,!0,s,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else i&&h();s&&!o&&i&&h();const u=!i||o||s?r(0):ot(i,c);return{x:l.left+c.scrollLeft-a.x-u.x,y:l.top+c.scrollTop-a.y-u.y,width:l.width,height:l.height}}function rt(t){return"static"===z(t).position}function ct(t,e){if(!O(t)||"fixed"===z(t).position)return null;if(e)return e(t);let n=t.offsetParent;return S(t)===n&&(n=n.ownerDocument.body),n}function at(t,e){const n=k(t);if(H(t))return n;if(!O(t)){let e=_(t);for(;e&&!q(e);){if(F(e)&&!rt(e))return e;e=_(e)}return n}let o=ct(t,e);for(;o&&D(o)&&rt(o);)o=ct(o,e);return o&&q(o)&&rt(o)&&!B(o)?n:o||function(t){let e=_(t);for(;O(e)&&!q(e);){if(B(e))return e;if(H(e))return null;e=_(e)}return null}(t)||n}const ht={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const s="fixed"===i,l=S(o),c=!!e&&H(e.floating);if(o===l||c&&s)return n;let a={scrollLeft:0,scrollTop:0},h=r(1);const u=r(0),f=O(o);if((f||!f&&!s)&&(("body"!==R(o)||$(l))&&(a=N(o)),f)){const t=et(o);h=Q(o),u.x=t.x+o.clientLeft,u.y=t.y+o.clientTop}const d=!l||f||s?r(0):ot(l,a);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-a.scrollLeft*h.x+u.x+d.x,y:n.y*h.y-a.scrollTop*h.y+u.y+d.y}},getDocumentElement:S,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:s,strategy:l}=t;const r=[..."clippingAncestors"===n?H(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=J(t,[],!1).filter(t=>F(t)&&"body"!==R(t)),i=null;const s="fixed"===z(t).position;let l=s?_(t):t;for(;F(l)&&!q(l);){const e=z(l),n=B(l);n||"fixed"!==e.position||(i=null),(s?!n&&!i:!n&&"static"===e.position&&i&&("absolute"===i.position||"fixed"===i.position)||$(l)&&!n&&st(t,l))?o=o.filter(t=>t!==l):i=e,l=_(l)}return e.set(t,o),o}(e,this._c):[].concat(n),s],c=it(e,r[0],l);let a=c.top,h=c.right,u=c.bottom,f=c.left;for(let t=1;t<r.length;t++){const n=it(e,r[t],l);a=i(n.top,a),h=o(n.right,h),u=o(n.bottom,u),f=i(n.left,f)}return{width:h-f,height:u-a,x:f,y:a}},getOffsetParent:at,getElementRects:async function(t){const e=this.getOffsetParent||at,n=this.getDimensions,o=await n(t.floating);return{reference:lt(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}=G(t);return{width:e,height:n}},getScale:Q,isElement:F,isRTL:function(t){return"rtl"===z(t).direction}};function ut(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function ft(t,e,n,s){void 0===s&&(s={});const{ancestorScroll:r=!0,ancestorResize:c=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:h="function"==typeof IntersectionObserver,animationFrame:u=!1}=s,f=K(t),d=r||c?[...f?J(f):[],...e?J(e):[]]:[];d.forEach(t=>{r&&t.addEventListener("scroll",n,{passive:!0}),c&&t.addEventListener("resize",n)});const g=f&&h?function(t,e){let n,s=null;const r=S(t);function c(){var t;clearTimeout(n),null==(t=s)||t.disconnect(),s=null}return function a(h,u){void 0===h&&(h=!1),void 0===u&&(u=1),c();const f=t.getBoundingClientRect(),{left:d,top:g,width:p,height:m}=f;if(h||e(),!p||!m)return;const w={rootMargin:-l(g)+"px "+-l(r.clientWidth-(d+p))+"px "+-l(r.clientHeight-(g+m))+"px "+-l(d)+"px",threshold:i(0,o(1,u))||1};let v=!0;function y(e){const o=e[0].intersectionRatio;if(o!==u){if(!v)return a();o?a(!1,o):n=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==o||ut(f,t.getBoundingClientRect())||a(),v=!1}try{s=new IntersectionObserver(y,{...w,root:r.ownerDocument})}catch(t){s=new IntersectionObserver(y,w)}s.observe(t)}(!0),c}(f,n):null;let p,m=-1,w=null;a&&(w=new ResizeObserver(t=>{let[o]=t;o&&o.target===f&&w&&e&&(w.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var t;null==(t=w)||t.observe(e)})),n()}),f&&!u&&w.observe(f),e&&w.observe(e));let v=u?et(t):null;return u&&function e(){const o=et(t);v&&!ut(v,o)&&n();v=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=w)||t.disconnect(),w=null,u&&cancelAnimationFrame(p)}}const dt=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:i,y:s,placement:l,middlewareData:r}=e,c=await async function(t,e){const{placement:n,platform:o,elements:i}=t,s=await(null==o.isRTL?void 0:o.isRTL(i.floating)),l=h(n),r=u(n),c="y"===d(n),f=C.has(l)?-1:1,g=s&&c?-1:1,p=a(e,t);let{mainAxis:m,crossAxis:w,alignmentAxis:v}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return r&&"number"==typeof v&&(w="end"===r?-1*v:v),c?{x:w*g,y:m*f}:{x:m*f,y:w*g}}(e,t);return l===(null==(n=r.offset)?void 0:n.placement)&&null!=(o=r.arrow)&&o.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:l}}}}},gt=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:s,rects:l,initialPlacement:r,platform:c,elements:m}=e,{mainAxis:w=!0,crossAxis:v=!0,fallbackPlacements:y,fallbackStrategy:L="bestFit",fallbackAxisSideDirection:T="none",flipAlignment:E=!0,...C}=a(t,e);if(null!=(n=s.arrow)&&n.alignmentOffset)return{};const A=h(i),R=d(r),k=h(r)===r,S=await(null==c.isRTL?void 0:c.isRTL(m.floating)),P=y||(k||!E?[b(r)]:function(t){const e=b(t);return[p(t),e,p(e)]}(r)),F="none"!==T;!y&&F&&P.push(...x(r,E,T,S));const O=[r,...P],M=await c.detectOverflow(e,C),$=[];let D=(null==(o=s.flip)?void 0:o.overflows)||[];if(w&&$.push(M[A]),v){const t=function(t,e,n){void 0===n&&(n=!1);const o=u(t),i=g(t),s=f(i);let l="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[s]>e.floating[s]&&(l=b(l)),[l,b(l)]}(i,l,S);$.push(M[t[0]],M[t[1]])}if(D=[...D,{placement:i,overflows:$}],!$.every(t=>t<=0)){var H,U;const t=((null==(H=s.flip)?void 0:H.index)||0)+1,e=O[t];if(e){if(!("alignment"===v&&R!==d(e))||D.every(t=>d(t.placement)!==R||t.overflows[0]>0))return{data:{index:t,overflows:D},reset:{placement:e}}}let n=null==(U=D.filter(t=>t.overflows[0]<=0).sort((t,e)=>t.overflows[1]-e.overflows[1])[0])?void 0:U.placement;if(!n)switch(L){case"bestFit":{var I;const t=null==(I=D.filter(t=>{if(F){const e=d(t.placement);return e===R||"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:I[0];t&&(n=t);break}case"initialPlacement":n=r}if(i!==n)return{reset:{placement:n}}}return{}}}},pt=(t,e,n)=>{const o=new Map,i={platform:ht,...n},s={...i.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:s=[],platform:l}=n,r=l.detectOverflow?l:{...l,detectOverflow:E},c=await(null==l.isRTL?void 0:l.isRTL(e));let a=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:h,y:u}=T(a,o,c),f=o,d=0;const g={};for(let n=0;n<s.length;n++){const p=s[n];if(!p)continue;const{name:m,fn:w}=p,{x:v,y,data:x,reset:b}=await w({x:h,y:u,initialPlacement:o,placement:f,strategy:i,middlewareData:g,rects:a,platform:r,elements:{reference:t,floating:e}});h=null!=v?v:h,u=null!=y?y:u,g[m]={...g[m],...x},b&&d<50&&(d++,"object"==typeof b&&(b.placement&&(f=b.placement),b.rects&&(a=!0===b.rects?await l.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:h,y:u}=T(a,f,c))),n=-1)}return{x:h,y:u,placement:f,strategy:i,middlewareData:g}})(t,e,{...i,platform:s})}}},e={};function n(o){var i=e[o];if(void 0!==i)return i.exports;var s=e[o]={exports:{}};return t[o](s,s.exports,n),s.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:()=>h});var i=n(7663),s=n(1926),l=n(7615),r=n(189),c=function(t,e,n,o){return new(n||(n=Promise))(function(i,s){function l(t){try{c(o.next(t))}catch(t){s(t)}}function r(t){try{c(o.throw(t))}catch(t){s(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(l,r)}c((o=o.apply(t,e||[])).next())})};class a extends l.A{constructor(t,e,n){super(t,e,n),this.cleanupAutoUpdate=null,window.$hsTooltipCollection||(window.$hsTooltipCollection=[]),this.el&&(this.toggle=this.el.querySelector(".hs-tooltip-toggle")||this.el,this.content=this.el.querySelector(".hs-tooltip-content"),this.eventMode=(0,s.gj)(this.el,"--trigger")||"hover",this.preventFloatingUI=(0,s.gj)(this.el,"--prevent-popper","false"),this.placement=(0,s.gj)(this.el,"--placement")||"top",this.strategy=(0,s.gj)(this.el,"--strategy"),this.scope=(0,s.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)}hideOtherTooltips(){window.$hsTooltipCollection&&window.$hsTooltipCollection.forEach(({element:t})=>t.el!==this.el&&(!!t.el.classList.contains("show")&&void t.hide()))}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))}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,s.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(){if(this.el.classList.contains("show"))return!1;this.hideOtherTooltips(),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,s.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,s.JD)("hide.hs.tooltip",this.el,this.el),(0,s.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)}}const h=a,u=o.A;export{u as default};