@undp/design-system-react
Version:
React based design system for UNDP
2 lines • 19.4 kB
JavaScript
var e=[`top`,`right`,`bottom`,`left`],t=Math.min,n=Math.max,r=Math.round,i=Math.floor,a=e=>({x:e,y:e}),o={left:`right`,right:`left`,bottom:`top`,top:`bottom`},s={start:`end`,end:`start`};function c(e,r,i){return n(e,t(r,i))}function l(e,t){return typeof e==`function`?e(t):e}function u(e){return e.split(`-`)[0]}function d(e){return e.split(`-`)[1]}function f(e){return e===`x`?`y`:`x`}function p(e){return e===`y`?`height`:`width`}var m=new Set([`top`,`bottom`]);function h(e){return m.has(u(e))?`y`:`x`}function g(e){return f(h(e))}function _(e,t,n){n===void 0&&(n=!1);let r=d(e),i=g(e),a=p(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=E(o)),[o,E(o)]}function v(e){let t=E(e);return[y(e),t,y(t)]}function y(e){return e.replace(/start|end/g,e=>s[e])}var b=[`left`,`right`],x=[`right`,`left`],S=[`top`,`bottom`],C=[`bottom`,`top`];function w(e,t,n){switch(e){case`top`:case`bottom`:return n?t?x:b:t?b:x;case`left`:case`right`:return t?S:C;default:return[]}}function T(e,t,n,r){let i=d(e),a=w(u(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(y)))),a}function E(e){return e.replace(/left|right|bottom|top/g,e=>o[e])}function D(e){return{top:0,right:0,bottom:0,left:0,...e}}function O(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:D(e)}function k(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function A(e,t,n){let{reference:r,floating:i}=e,a=h(t),o=g(t),s=p(o),c=u(t),l=a===`y`,f=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,_=r[s]/2-i[s]/2,v;switch(c){case`top`:v={x:f,y:r.y-i.height};break;case`bottom`:v={x:f,y:r.y+r.height};break;case`right`:v={x:r.x+r.width,y:m};break;case`left`:v={x:r.x-i.width,y:m};break;default:v={x:r.x,y:r.y}}switch(d(t)){case`start`:v[o]-=_*(n&&l?-1:1);break;case`end`:v[o]+=_*(n&&l?-1:1);break}return v}var j=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=a.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=A(l,r,c),f=r,p={},m=0;for(let n=0;n<s.length;n++){let{name:a,fn:h}=s[n],{x:g,y:_,data:v,reset:y}=await h({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:l,platform:o,elements:{reference:e,floating:t}});u=g??u,d=_??d,p={...p,[a]:{...p[a],...v}},y&&m<=50&&(m++,typeof y==`object`&&(y.placement&&(f=y.placement),y.rects&&(l=y.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):y.rects),{x:u,y:d}=A(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}};async function M(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:u=`viewport`,elementContext:d=`floating`,altBoundary:f=!1,padding:p=0}=l(t,e),m=O(p),h=o[f?d===`floating`?`reference`:`floating`:d],g=k(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(h))??!0?h:h.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:u,strategy:s})),_=d===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),y=await(i.isElement==null?void 0:i.isElement(v))&&await(i.getScale==null?void 0:i.getScale(v))||{x:1,y:1},b=k(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:_,offsetParent:v,strategy:s}):_);return{top:(g.top-b.top+m.top)/y.y,bottom:(b.bottom-g.bottom+m.bottom)/y.y,left:(g.left-b.left+m.left)/y.x,right:(b.right-g.right+m.right)/y.x}}var N=e=>({name:`arrow`,options:e,async fn(n){let{x:r,y:i,placement:a,rects:o,platform:s,elements:u,middlewareData:f}=n,{element:m,padding:h=0}=l(e,n)||{};if(m==null)return{};let _=O(h),v={x:r,y:i},y=g(a),b=p(y),x=await s.getDimensions(m),S=y===`y`,C=S?`top`:`left`,w=S?`bottom`:`right`,T=S?`clientHeight`:`clientWidth`,E=o.reference[b]+o.reference[y]-v[y]-o.floating[b],D=v[y]-o.reference[y],k=await(s.getOffsetParent==null?void 0:s.getOffsetParent(m)),A=k?k[T]:0;(!A||!await(s.isElement==null?void 0:s.isElement(k)))&&(A=u.floating[T]||o.floating[b]);let j=E/2-D/2,M=A/2-x[b]/2-1,N=t(_[C],M),ee=t(_[w],M),P=N,te=A-x[b]-ee,F=A/2-x[b]/2+j,I=c(P,F,te),L=!f.arrow&&d(a)!=null&&F!==I&&o.reference[b]/2-(F<P?N:ee)-x[b]/2<0,R=L?F<P?F-P:F-te:0;return{[y]:v[y]+R,data:{[y]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),ee=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m=`bestFit`,fallbackAxisSideDirection:g=`none`,flipAlignment:y=!0,...b}=l(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let x=u(r),S=h(o),C=u(o)===o,w=await(s.isRTL==null?void 0:s.isRTL(c.floating)),D=p||(C||!y?[E(o)]:v(o)),O=g!==`none`;!p&&O&&D.push(...T(o,y,g,w));let k=[o,...D],A=await M(t,b),j=[],N=i.flip?.overflows||[];if(d&&j.push(A[x]),f){let e=_(r,a,w);j.push(A[e[0]],A[e[1]])}if(N=[...N,{placement:r,overflows:j}],!j.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=k[e];if(t&&(!(f===`alignment`&&S!==h(t))||N.every(e=>h(e.placement)!==S||e.overflows[0]>0)))return{data:{index:e,overflows:N},reset:{placement:t}};let n=N.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(m){case`bestFit`:{let e=N.filter(e=>{if(O){let t=h(e.placement);return t===S||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function P(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function te(t){return e.some(e=>t[e]>=0)}var F=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n}=t,{strategy:r=`referenceHidden`,...i}=l(e,t);switch(r){case`referenceHidden`:{let e=P(await M(t,{...i,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:te(e)}}}case`escaped`:{let e=P(await M(t,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:te(e)}}}default:return{}}}}},I=new Set([`left`,`top`]);async function L(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=u(n),s=d(n),c=h(n)===`y`,f=I.has(o)?-1:1,p=a&&c?-1:1,m=l(t,e),{mainAxis:g,crossAxis:_,alignmentAxis:v}=typeof m==`number`?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return s&&typeof v==`number`&&(_=s===`end`?v*-1:v),c?{x:_*p,y:g*f}:{x:g*f,y:_*p}}var R=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await L(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},ne=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i}=t,{mainAxis:a=!0,crossAxis:o=!1,limiter:s={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...d}=l(e,t),p={x:n,y:r},m=await M(t,d),g=h(u(i)),_=f(g),v=p[_],y=p[g];if(a){let e=_===`y`?`top`:`left`,t=_===`y`?`bottom`:`right`,n=v+m[e],r=v-m[t];v=c(n,v,r)}if(o){let e=g===`y`?`top`:`left`,t=g===`y`?`bottom`:`right`,n=y+m[e],r=y-m[t];y=c(n,y,r)}let b=s.fn({...t,[_]:v,[g]:y});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[_]:a,[g]:o}}}}}},re=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:d=!0}=l(e,t),p={x:n,y:r},m=h(i),g=f(m),_=p[g],v=p[m],y=l(s,t),b=typeof y==`number`?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(c){let e=g===`y`?`height`:`width`,t=a.reference[g]-a.floating[e]+b.mainAxis,n=a.reference[g]+a.reference[e]-b.mainAxis;_<t?_=t:_>n&&(_=n)}if(d){let e=g===`y`?`width`:`height`,t=I.has(u(i)),n=a.reference[m]-a.floating[e]+(t&&o.offset?.[m]||0)+(t?0:b.crossAxis),r=a.reference[m]+a.reference[e]+(t?0:o.offset?.[m]||0)-(t?b.crossAxis:0);v<n?v=n:v>r&&(v=r)}return{[g]:_,[m]:v}}}},ie=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(r){var i,a;let{placement:o,rects:s,platform:c,elements:f}=r,{apply:p=()=>{},...m}=l(e,r),g=await M(r,m),_=u(o),v=d(o),y=h(o)===`y`,{width:b,height:x}=s.floating,S,C;_===`top`||_===`bottom`?(S=_,C=v===(await(c.isRTL==null?void 0:c.isRTL(f.floating))?`start`:`end`)?`left`:`right`):(C=_,S=v===`end`?`top`:`bottom`);let w=x-g.top-g.bottom,T=b-g.left-g.right,E=t(x-g[S],w),D=t(b-g[C],T),O=!r.middlewareData.shift,k=E,A=D;if((i=r.middlewareData.shift)!=null&&i.enabled.x&&(A=T),(a=r.middlewareData.shift)!=null&&a.enabled.y&&(k=w),O&&!v){let e=n(g.left,0),t=n(g.right,0),r=n(g.top,0),i=n(g.bottom,0);y?A=b-2*(e!==0||t!==0?e+t:n(g.left,g.right)):k=x-2*(r!==0||i!==0?r+i:n(g.top,g.bottom))}await p({...r,availableWidth:A,availableHeight:k});let j=await c.getDimensions(f.floating);return b!==j.width||x!==j.height?{reset:{rects:!0}}:{}}}};function z(){return typeof window<`u`}function B(e){return ae(e)?(e.nodeName||``).toLowerCase():`#document`}function V(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function H(e){return((ae(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ae(e){return z()?e instanceof Node||e instanceof V(e).Node:!1}function U(e){return z()?e instanceof Element||e instanceof V(e).Element:!1}function W(e){return z()?e instanceof HTMLElement||e instanceof V(e).HTMLElement:!1}function oe(e){return!z()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof V(e).ShadowRoot}var se=new Set([`inline`,`contents`]);function G(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!se.has(i)}var ce=new Set([`table`,`td`,`th`]);function le(e){return ce.has(B(e))}var ue=[`:popover-open`,`:modal`];function K(e){return ue.some(t=>{try{return e.matches(t)}catch{return!1}})}var de=[`transform`,`translate`,`scale`,`rotate`,`perspective`],fe=[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`],pe=[`paint`,`layout`,`strict`,`content`];function me(e){let t=ge(),n=U(e)?J(e):e;return de.some(e=>n[e]?n[e]!==`none`:!1)||(n.containerType?n.containerType!==`normal`:!1)||!t&&(n.backdropFilter?n.backdropFilter!==`none`:!1)||!t&&(n.filter?n.filter!==`none`:!1)||fe.some(e=>(n.willChange||``).includes(e))||pe.some(e=>(n.contain||``).includes(e))}function he(e){let t=X(e);for(;W(t)&&!q(t);){if(me(t))return t;if(K(t))return null;t=X(t)}return null}function ge(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}var _e=new Set([`html`,`body`,`#document`]);function q(e){return _e.has(B(e))}function J(e){return V(e).getComputedStyle(e)}function Y(e){return U(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function X(e){if(B(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||oe(e)&&e.host||H(e);return oe(t)?t.host:t}function ve(e){let t=X(e);return q(t)?e.ownerDocument?e.ownerDocument.body:e.body:W(t)&&G(t)?t:ve(t)}function Z(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=ve(e),i=r===e.ownerDocument?.body,a=V(r);if(i){let e=ye(a);return t.concat(a,a.visualViewport||[],G(r)?r:[],e&&n?Z(e):[])}return t.concat(r,Z(r,[],n))}function ye(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function be(e){let t=J(e),n=parseFloat(t.width)||0,i=parseFloat(t.height)||0,a=W(e),o=a?e.offsetWidth:n,s=a?e.offsetHeight:i,c=r(n)!==o||r(i)!==s;return c&&(n=o,i=s),{width:n,height:i,$:c}}function xe(e){return U(e)?e:e.contextElement}function Q(e){let t=xe(e);if(!W(t))return a(1);let n=t.getBoundingClientRect(),{width:i,height:o,$:s}=be(t),c=(s?r(n.width):n.width)/i,l=(s?r(n.height):n.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!l||!Number.isFinite(l))&&(l=1),{x:c,y:l}}var Se=a(0);function Ce(e){let t=V(e);return!ge()||!t.visualViewport?Se:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function we(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==V(e)?!1:t}function $(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),o=xe(e),s=a(1);t&&(r?U(r)&&(s=Q(r)):s=Q(e));let c=we(o,n,r)?Ce(o):a(0),l=(i.left+c.x)/s.x,u=(i.top+c.y)/s.y,d=i.width/s.x,f=i.height/s.y;if(o){let e=V(o),t=r&&U(r)?V(r):r,n=e,i=ye(n);for(;i&&r&&t!==n;){let e=Q(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,u*=e.y,d*=e.x,f*=e.y,l+=a,u+=o,n=V(i),i=ye(n)}}return k({width:d,height:f,x:l,y:u})}function Te(e,t){let n=Y(e).scrollLeft;return t?t.left+n:$(H(e)).left+n}function Ee(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Te(e,n),y:n.top+t.scrollTop}}function De(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,o=i===`fixed`,s=H(r),c=t?K(t.floating):!1;if(r===s||c&&o)return n;let l={scrollLeft:0,scrollTop:0},u=a(1),d=a(0),f=W(r);if((f||!f&&!o)&&((B(r)!==`body`||G(s))&&(l=Y(r)),W(r))){let e=$(r);u=Q(r),d.x=e.x+r.clientLeft,d.y=e.y+r.clientTop}let p=s&&!f&&!o?Ee(s,l):a(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-l.scrollTop*u.y+d.y+p.y}}function Oe(e){return Array.from(e.getClientRects())}function ke(e){let t=H(e),r=Y(e),i=e.ownerDocument.body,a=n(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=n(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight),s=-r.scrollLeft+Te(e),c=-r.scrollTop;return J(i).direction===`rtl`&&(s+=n(t.clientWidth,i.clientWidth)-a),{width:a,height:o,x:s,y:c}}var Ae=25;function je(e,t){let n=V(e),r=H(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=ge();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Te(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Ae&&(a-=o)}else l<=Ae&&(a+=l);return{width:a,height:o,x:s,y:c}}var Me=new Set([`absolute`,`fixed`]);function Ne(e,t){let n=$(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=W(e)?Q(e):a(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:i*o.x,y:r*o.y}}function Pe(e,t,n){let r;if(t===`viewport`)r=je(e,n);else if(t===`document`)r=ke(H(e));else if(U(t))r=Ne(t,n);else{let n=Ce(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return k(r)}function Fe(e,t){let n=X(e);return n===t||!U(n)||q(n)?!1:J(n).position===`fixed`||Fe(n,t)}function Ie(e,t){let n=t.get(e);if(n)return n;let r=Z(e,[],!1).filter(e=>U(e)&&B(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?X(e):e;for(;U(o)&&!q(o);){let t=J(o),n=me(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&Me.has(i.position)||G(o)&&!n&&Fe(e,o))?r=r.filter(e=>e!==o):i=t,o=X(o)}return t.set(e,r),r}function Le(e){let{element:r,boundary:i,rootBoundary:a,strategy:o}=e,s=[...i===`clippingAncestors`?K(r)?[]:Ie(r,this._c):[].concat(i),a],c=s[0],l=s.reduce((e,i)=>{let a=Pe(r,i,o);return e.top=n(a.top,e.top),e.right=t(a.right,e.right),e.bottom=t(a.bottom,e.bottom),e.left=n(a.left,e.left),e},Pe(r,c,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Re(e){let{width:t,height:n}=be(e);return{width:t,height:n}}function ze(e,t,n){let r=W(t),i=H(t),o=n===`fixed`,s=$(e,!0,o,t),c={scrollLeft:0,scrollTop:0},l=a(0);function u(){l.x=Te(i)}if(r||!r&&!o)if((B(t)!==`body`||G(i))&&(c=Y(t)),r){let e=$(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&u();o&&!r&&i&&u();let d=i&&!r&&!o?Ee(i,c):a(0);return{x:s.left+c.scrollLeft-l.x-d.x,y:s.top+c.scrollTop-l.y-d.y,width:s.width,height:s.height}}function Be(e){return J(e).position===`static`}function Ve(e,t){if(!W(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return H(e)===n&&(n=n.ownerDocument.body),n}function He(e,t){let n=V(e);if(K(e))return n;if(!W(e)){let t=X(e);for(;t&&!q(t);){if(U(t)&&!Be(t))return t;t=X(t)}return n}let r=Ve(e,t);for(;r&&le(r)&&Be(r);)r=Ve(r,t);return r&&q(r)&&Be(r)&&!me(r)?n:r||he(e)||n}var Ue=async function(e){let t=this.getOffsetParent||He,n=this.getDimensions,r=await n(e.floating);return{reference:ze(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function We(e){return J(e).direction===`rtl`}var Ge={convertOffsetParentRelativeRectToViewportRelativeRect:De,getDocumentElement:H,getClippingRect:Le,getOffsetParent:He,getElementRects:Ue,getClientRects:Oe,getDimensions:Re,getScale:Q,isElement:U,isRTL:We};function Ke(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qe(e,r){let a=null,o,s=H(e);function c(){var e;clearTimeout(o),(e=a)==null||e.disconnect(),a=null}function l(u,d){u===void 0&&(u=!1),d===void 0&&(d=1),c();let f=e.getBoundingClientRect(),{left:p,top:m,width:h,height:g}=f;if(u||r(),!h||!g)return;let _=i(m),v=i(s.clientWidth-(p+h)),y=i(s.clientHeight-(m+g)),b=i(p),x={rootMargin:-_+`px `+-v+`px `+-y+`px `+-b+`px`,threshold:n(0,t(1,d))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(n!==d){if(!S)return l();n?l(!1,n):o=setTimeout(()=>{l(!1,1e-7)},1e3)}n===1&&!Ke(f,e.getBoundingClientRect())&&l(),S=!1}try{a=new IntersectionObserver(C,{...x,root:s.ownerDocument})}catch{a=new IntersectionObserver(C,x)}a.observe(e)}return l(!0),c}function Je(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=xe(e),u=i||a?[...l?Z(l):[],...Z(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?qe(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let m,h=c?$(e):null;c&&g();function g(){let t=$(e);h&&!Ke(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Ye=R,Xe=ne,Ze=ee,Qe=ie,$e=F,et=N,tt=re,nt=(e,t,n)=>{let r=new Map,i={platform:Ge,...n},a={...i.platform,_c:r};return j(e,t,{...i,platform:a})};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return et}});
//# sourceMappingURL=floating-ui.dom-Ca2FrYDD.cjs.map