const Z=["top","right","bottom","left"],L=Math.min,v=Math.max,I=Math.round,tt=Math.floor,et=t=>({x:t,y:t}),C={left:"right",right:"left",bottom:"top",top:"bottom"},D={start:"end",end:"start"};function nt(t,e,n){return v(t,L(e,n))}function ot(t,e){return typeof t=="function"?t(e):t}function b(t){return t.split("-")[0]}function y(t){return t.split("-")[1]}function O(t){return t==="x"?"y":"x"}function M(t){return t==="y"?"height":"width"}const k=new Set(["top","bottom"]);function R(t){return k.has(b(t))?"y":"x"}function V(t){return O(R(t))}function rt(t,e,n){n===void 0&&(n=!1);const o=y(t),r=V(t),s=M(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=u(i)),[i,u(i)]}function st(t){const e=u(t);return[l(t),e,l(e)]}function l(t){return t.replace(/start|end/g,e=>D[e])}const d=["left","right"],g=["right","left"],j=["top","bottom"],B=["bottom","top"];function F(t,e,n){switch(t){case"top":case"bottom":return n?e?g:d:e?d:g;case"left":case"right":return e?j:B;default:return[]}}function it(t,e,n,o){const r=y(t);let s=F(b(t),n==="start",o);return r&&(s=s.map(i=>i+"-"+r),e&&(s=s.concat(s.map(l)))),s}function u(t){return t.replace(/left|right|bottom|top/g,e=>C[e])}function H(t){return{top:0,right:0,bottom:0,left:0,...t}}function ct(t){return typeof t!="number"?H(t):{top:t,right:t,bottom:t,left:t}}function at(t){const{x:e,y:n,width:o,height:r}=t;return{width:o,height:r,top:n,left:e,right:e+o,bottom:n+r,x:e,y:n}}function a(){return typeof window<"u"}function m(t){return S(t)?(t.nodeName||"").toLowerCase():"#document"}function c(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function _(t){var e;return(e=(S(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function S(t){return a()?t instanceof Node||t instanceof c(t).Node:!1}function x(t){return a()?t instanceof Element||t instanceof c(t).Element:!1}function A(t){return a()?t instanceof HTMLElement||t instanceof c(t).HTMLElement:!1}function h(t){return!a()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof c(t).ShadowRoot}const W=new Set(["inline","contents"]);function E(t){const{overflow:e,overflowX:n,overflowY:o,display:r}=P(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!W.has(r)}const K=new Set(["table","td","th"]);function lt(t){return K.has(m(t))}const X=[":popover-open",":modal"];function Y(t){return X.some(e=>{try{return t.matches(e)}catch{return!1}})}const $=["transform","translate","scale","rotate","perspective"],q=["transform","translate","scale","rotate","perspective","filter"],z=["paint","layout","strict","content"];function G(t){const e=J(),n=x(t)?P(t):t;return $.some(o=>n[o]?n[o]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||q.some(o=>(n.willChange||"").includes(o))||z.some(o=>(n.contain||"").includes(o))}function ut(t){let e=f(t);for(;A(e)&&!N(e);){if(G(e))return e;if(Y(e))return null;e=f(e)}return null}function J(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Q=new Set(["html","body","#document"]);function N(t){return Q.has(m(t))}function P(t){return c(t).getComputedStyle(t)}function ft(t){return x(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function f(t){if(m(t)==="html")return t;const e=t.assignedSlot||t.parentNode||h(t)&&t.host||_(t);return h(e)?e.host:e}function T(t){const e=f(t);return N(e)?t.ownerDocument?t.ownerDocument.body:t.body:A(e)&&E(e)?e:T(e)}function w(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=T(t),s=r===((o=t.ownerDocument)==null?void 0:o.body),i=c(r);if(s){const p=U(i);return e.concat(i,i.visualViewport||[],E(r)?r:[],p&&n?w(p):[])}return e.concat(r,w(r,[],n))}function U(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}export{f as A,N as B,lt as C,G as D,ut as E,m as F,E as G,ft as H,U as I,tt as J,J as K,b as a,u as b,nt as c,st as d,ot as e,it as f,R as g,rt as h,y as i,v as j,ct as k,O as l,L as m,V as n,M as o,x as p,_ as q,at as r,Z as s,w as t,P as u,A as v,et as w,I as x,c as y,Y as z};