import{rectToClientRect as t}from"../../core/dist/floating-ui.core.js";function e(t){var e;return(null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function n(t){return e(t).getComputedStyle(t)}function o(t){return t instanceof e(t).Node}function i(t){return o(t)?(t.nodeName||"").toLowerCase():""}let r;function c(t){return t instanceof e(t).HTMLElement}function u(t){return t instanceof e(t).Element}function s(t){if("undefined"==typeof ShadowRoot)return!1;return t instanceof e(t).ShadowRoot||t instanceof ShadowRoot}function l(t){const{overflow:e,overflowX:o,overflowY:i,display:r}=n(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+o)&&!["inline","contents"].includes(r)}function a(){return/^((?!chrome|android).)*safari/i.test(function(){if(r)return r;const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?(r=t.brands.map((t=>t.brand+"/"+t.version)).join(" "),r):navigator.userAgent}())}const d=Math.round;function f(t){return u(t)?t:t.contextElement}const h={x:1,y:1};function m(t){const e=f(t);if(!c(e))return h;const o=e.getBoundingClientRect(),{width:i,height:r,fallback:u}=function(t){const e=n(t);let o=parseFloat(e.width),i=parseFloat(e.height);const r=c(t),u=r?t.offsetWidth:o,s=r?t.offsetHeight:i,l=d(o)!==u||d(i)!==s;return l&&(o=u,i=s),{width:o,height:i,fallback:l}}(e);let s=(u?d(o.width):o.width)/i,l=(u?d(o.height):o.height)/r;return s&&Number.isFinite(s)||(s=1),l&&Number.isFinite(l)||(l=1),{x:s,y:l}}function v(n,o,i,r){var c,s;void 0===o&&(o=!1),void 0===i&&(i=!1);const l=n.getBoundingClientRect(),d=f(n);let v=h;o&&(r?u(r)&&(v=m(r)):v=m(n));const w=d?e(d):window,g=a()&&i;let p=(l.left+(g&&(null==(c=w.visualViewport)?void 0:c.offsetLeft)||0))/v.x,y=(l.top+(g&&(null==(s=w.visualViewport)?void 0:s.offsetTop)||0))/v.y,x=l.width/v.x,E=l.height/v.y;if(d){const t=e(d),n=r&&u(r)?e(r):r;let o=t.frameElement;for(;o&&r&&n!==t;){const t=m(o),n=o.getBoundingClientRect(),i=getComputedStyle(o);n.x+=(o.clientLeft+parseFloat(i.paddingLeft))*t.x,n.y+=(o.clientTop+parseFloat(i.paddingTop))*t.y,p*=t.x,y*=t.y,x*=t.x,E*=t.y,p+=n.x,y+=n.y,o=e(o).frameElement}}return t({width:x,height:E,x:p,y:y})}function w(t){if("html"===i(t))return t;const e=t.assignedSlot||t.parentNode||s(t)&&t.host||function(t){return((o(t)?t.ownerDocument:t.document)||window.document).documentElement}(t);return s(e)?e.host:e}function g(t){const e=w(t);return function(t){return["html","body","#document"].includes(i(t))}(e)?e.ownerDocument.body:c(e)&&l(e)?e:g(e)}function p(t,n){var o;void 0===n&&(n=[]);const i=g(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=e(i);return r?n.concat(c,c.visualViewport||[],l(i)?i:[]):n.concat(i,p(i))}function y(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:c=!0,animationFrame:s=!1}=o,l=i||r?[...u(t)?p(t):t.contextElement?p(t.contextElement):[],...p(e)]:[];l.forEach((t=>{const e=!u(t)&&t.toString().includes("V");!i||s&&!e||t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));let a,d=null;c&&(d=new ResizeObserver((()=>{n()})),u(t)&&!s&&d.observe(t),u(t)||!t.contextElement||s||d.observe(t.contextElement),d.observe(e));let f=s?v(t):null;return s&&function e(){const o=v(t);!f||o.x===f.x&&o.y===f.y&&o.width===f.width&&o.height===f.height||n();f=o,a=requestAnimationFrame(e)}(),n(),()=>{var t;l.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),null==(t=d)||t.disconnect(),d=null,s&&cancelAnimationFrame(a)}}export{y as autoUpdate,p as getOverflowAncestors};
//# sourceMappingURL=floating-ui.dom.js.map
