import{r as R,R as Be}from"./react-693b90b0.js";import{r as He}from"./react-dom-52fffd61.js";function Y(e){return e.split("-")[1]}function ue(e){return e==="y"?"height":"width"}function S(e){return e.split("-")[0]}function z(e){return["top","bottom"].includes(S(e))?"x":"y"}function ye(e,t,o){let{reference:n,floating:r}=e;const i=n.x+n.width/2-r.width/2,s=n.y+n.height/2-r.height/2,c=z(t),f=ue(c),u=n[f]/2-r[f]/2,g=c==="x";let l;switch(S(t)){case"top":l={x:i,y:n.y-r.height};break;case"bottom":l={x:i,y:n.y+n.height};break;case"right":l={x:n.x+n.width,y:s};break;case"left":l={x:n.x-r.width,y:s};break;default:l={x:n.x,y:n.y}}switch(Y(t)){case"start":l[c]-=u*(o&&g?-1:1);break;case"end":l[c]+=u*(o&&g?-1:1)}return l}const Ve=async(e,t,o)=>{const{placement:n="bottom",strategy:r="absolute",middleware:i=[],platform:s}=o,c=i.filter(Boolean),f=await(s.isRTL==null?void 0:s.isRTL(t));let u=await s.getElementRects({reference:e,floating:t,strategy:r}),{x:g,y:l}=ye(u,n,f),d=n,a={},m=0;for(let p=0;p<c.length;p++){const{name:y,fn:h}=c[p],{x,y:w,data:v,reset:b}=await h({x:g,y:l,initialPlacement:n,placement:d,strategy:r,middlewareData:a,rects:u,platform:s,elements:{reference:e,floating:t}});g=x??g,l=w??l,a={...a,[y]:{...a[y],...v}},b&&m<=50&&(m++,typeof b=="object"&&(b.placement&&(d=b.placement),b.rects&&(u=b.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:r}):b.rects),{x:g,y:l}=ye(u,d,f)),p=-1)}return{x:g,y:l,placement:d,strategy:r,middlewareData:a}};function de(e){return typeof e!="number"?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(e):{top:e,right:e,bottom:e,left:e}}function q(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}async function me(e,t){var o;t===void 0&&(t={});const{x:n,y:r,platform:i,rects:s,elements:c,strategy:f}=e,{boundary:u="clippingAncestors",rootBoundary:g="viewport",elementContext:l="floating",altBoundary:d=!1,padding:a=0}=t,m=de(a),p=c[d?l==="floating"?"reference":"floating":l],y=q(await i.getClippingRect({element:(o=await(i.isElement==null?void 0:i.isElement(p)))==null||o?p:p.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:u,rootBoundary:g,strategy:f})),h=l==="floating"?{...s.floating,x:n,y:r}:s.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),w=await(i.isElement==null?void 0:i.isElement(x))&&await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1},v=q(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({rect:h,offsetParent:x,strategy:f}):h);return{top:(y.top-v.top+m.top)/w.y,bottom:(v.bottom-y.bottom+m.bottom)/w.y,left:(y.left-v.left+m.left)/w.x,right:(v.right-y.right+m.right)/w.x}}const X=Math.min,M=Math.max;function ce(e,t,o){return M(e,X(t,o))}const xe=e=>({name:"arrow",options:e,async fn(t){const{element:o,padding:n=0}=e||{},{x:r,y:i,placement:s,rects:c,platform:f,elements:u}=t;if(o==null)return{};const g=de(n),l={x:r,y:i},d=z(s),a=ue(d),m=await f.getDimensions(o),p=d==="y",y=p?"top":"left",h=p?"bottom":"right",x=p?"clientHeight":"clientWidth",w=c.reference[a]+c.reference[d]-l[d]-c.floating[a],v=l[d]-c.reference[d],b=await(f.getOffsetParent==null?void 0:f.getOffsetParent(o));let E=b?b[x]:0;E&&await(f.isElement==null?void 0:f.isElement(b))||(E=u.floating[x]||c.floating[a]);const T=w/2-v/2,D=g[y],P=E-m[a]-g[h],A=E/2-m[a]/2+T,L=ce(D,A,P),C=Y(s)!=null&&A!=L&&c.reference[a]/2-(A<D?g[y]:g[h])-m[a]/2<0;return{[d]:l[d]-(C?A<D?D-A:P-A:0),data:{[d]:L,centerOffset:A-L}}}}),je=["top","right","bottom","left"];je.reduce((e,t)=>e.concat(t,t+"-start",t+"-end"),[]);const ze={left:"right",right:"left",bottom:"top",top:"bottom"};function te(e){return e.replace(/left|right|bottom|top/g,t=>ze[t])}function Ne(e,t,o){o===void 0&&(o=!1);const n=Y(e),r=z(e),i=ue(r);let s=r==="x"?n===(o?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=te(s)),{main:s,cross:te(s)}}const Ie={start:"end",end:"start"};function se(e){return e.replace(/start|end/g,t=>Ie[t])}const lt=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var o;const{placement:n,middlewareData:r,rects:i,initialPlacement:s,platform:c,elements:f}=t,{mainAxis:u=!0,crossAxis:g=!0,fallbackPlacements:l,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:a="none",flipAlignment:m=!0,...p}=e,y=S(n),h=S(s)===s,x=await(c.isRTL==null?void 0:c.isRTL(f.floating)),w=l||(h||!m?[te(s)]:function(L){const C=te(L);return[se(L),C,se(C)]}(s));l||a==="none"||w.push(...function(L,C,N,H){const B=Y(L);let O=function(G,le,Fe){const he=["left","right"],pe=["right","left"],Me=["top","bottom"],We=["bottom","top"];switch(G){case"top":case"bottom":return Fe?le?pe:he:le?he:pe;case"left":case"right":return le?Me:We;default:return[]}}(S(L),N==="start",H);return B&&(O=O.map(G=>G+"-"+B),C&&(O=O.concat(O.map(se)))),O}(s,m,a,x));const v=[s,...w],b=await me(t,p),E=[];let T=((o=r.flip)==null?void 0:o.overflows)||[];if(u&&E.push(b[y]),g){const{main:L,cross:C}=Ne(n,i,x);E.push(b[L],b[C])}if(T=[...T,{placement:n,overflows:E}],!E.every(L=>L<=0)){var D,P;const L=(((D=r.flip)==null?void 0:D.index)||0)+1,C=v[L];if(C)return{data:{index:L,overflows:T},reset:{placement:C}};let N=(P=T.filter(H=>H.overflows[0]<=0).sort((H,B)=>H.overflows[1]-B.overflows[1])[0])==null?void 0:P.placement;if(!N)switch(d){case"bestFit":{var A;const H=(A=T.map(B=>[B.placement,B.overflows.filter(O=>O>0).reduce((O,G)=>O+G,0)]).sort((B,O)=>B[1]-O[1])[0])==null?void 0:A[0];H&&(N=H);break}case"initialPlacement":N=s}if(n!==N)return{reset:{placement:N}}}return{}}}};function we(e){const t=X(...e.map(n=>n.left)),o=X(...e.map(n=>n.top));return{x:t,y:o,width:M(...e.map(n=>n.right))-t,height:M(...e.map(n=>n.bottom))-o}}const st=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){const{placement:o,elements:n,rects:r,platform:i,strategy:s}=t,{padding:c=2,x:f,y:u}=e,g=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(n.reference))||[]),l=function(p){const y=p.slice().sort((w,v)=>w.y-v.y),h=[];let x=null;for(let w=0;w<y.length;w++){const v=y[w];!x||v.y-x.y>x.height/2?h.push([v]):h[h.length-1].push(v),x=v}return h.map(w=>q(we(w)))}(g),d=q(we(g)),a=de(c),m=await i.getElementRects({reference:{getBoundingClientRect:function(){if(l.length===2&&l[0].left>l[1].right&&f!=null&&u!=null)return l.find(p=>f>p.left-a.left&&f<p.right+a.right&&u>p.top-a.top&&u<p.bottom+a.bottom)||d;if(l.length>=2){if(z(o)==="x"){const b=l[0],E=l[l.length-1],T=S(o)==="top",D=b.top,P=E.bottom,A=T?b.left:E.left,L=T?b.right:E.right;return{top:D,bottom:P,left:A,right:L,width:L-A,height:P-D,x:A,y:D}}const p=S(o)==="left",y=M(...l.map(b=>b.right)),h=X(...l.map(b=>b.left)),x=l.filter(b=>p?b.left===h:b.right===y),w=x[0].top,v=x[x.length-1].bottom;return{top:w,bottom:v,left:h,right:y,width:y-h,height:v-w,x:h,y:w}}return d}},floating:n.floating,strategy:s});return r.reference.x!==m.reference.x||r.reference.y!==m.reference.y||r.reference.width!==m.reference.width||r.reference.height!==m.reference.height?{reset:{rects:m}}:{}}}},ct=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){const{x:o,y:n}=t,r=await async function(i,s){const{placement:c,platform:f,elements:u}=i,g=await(f.isRTL==null?void 0:f.isRTL(u.floating)),l=S(c),d=Y(c),a=z(c)==="x",m=["left","top"].includes(l)?-1:1,p=g&&a?-1:1,y=typeof s=="function"?s(i):s;let{mainAxis:h,crossAxis:x,alignmentAxis:w}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...y};return d&&typeof w=="number"&&(x=d==="end"?-1*w:w),a?{x:x*p,y:h*m}:{x:h*m,y:x*p}}(t,e);return{x:o+r.x,y:n+r.y,data:r}}}};function Te(e){return e==="x"?"y":"x"}const ft=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:o,y:n,placement:r}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:c={fn:y=>{let{x:h,y:x}=y;return{x:h,y:x}}},...f}=e,u={x:o,y:n},g=await me(t,f),l=z(S(r)),d=Te(l);let a=u[l],m=u[d];if(i){const y=l==="y"?"bottom":"right";a=ce(a+g[l==="y"?"top":"left"],a,a-g[y])}if(s){const y=d==="y"?"bottom":"right";m=ce(m+g[d==="y"?"top":"left"],m,m-g[y])}const p=c.fn({...t,[l]:a,[d]:m});return{...p,data:{x:p.x-o,y:p.y-n}}}}},at=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:o,y:n,placement:r,rects:i,middlewareData:s}=t,{offset:c=0,mainAxis:f=!0,crossAxis:u=!0}=e,g={x:o,y:n},l=z(r),d=Te(l);let a=g[l],m=g[d];const p=typeof c=="function"?c(t):c,y=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(f){const w=l==="y"?"height":"width",v=i.reference[l]-i.floating[w]+y.mainAxis,b=i.reference[l]+i.reference[w]-y.mainAxis;a<v?a=v:a>b&&(a=b)}if(u){var h,x;const w=l==="y"?"width":"height",v=["top","left"].includes(S(r)),b=i.reference[d]-i.floating[w]+(v&&((h=s.offset)==null?void 0:h[d])||0)+(v?0:y.crossAxis),E=i.reference[d]+i.reference[w]+(v?0:((x=s.offset)==null?void 0:x[d])||0)-(v?y.crossAxis:0);m<b?m=b:m>E&&(m=E)}return{[l]:a,[d]:m}}}},ut=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:o,rects:n,platform:r,elements:i}=t,{apply:s=()=>{},...c}=e,f=await me(t,c),u=S(o),g=Y(o),l=z(o)==="x",{width:d,height:a}=n.floating;let m,p;u==="top"||u==="bottom"?(m=u,p=g===(await(r.isRTL==null?void 0:r.isRTL(i.floating))?"start":"end")?"left":"right"):(p=u,m=g==="end"?"top":"bottom");const y=a-f[m],h=d-f[p],x=!t.middlewareData.shift;let w=y,v=h;if(l){const E=d-f.left-f.right;v=g||x?X(h,E):E}else{const E=a-f.top-f.bottom;w=g||x?X(y,E):E}if(x&&!g){const E=M(f.left,0),T=M(f.right,0),D=M(f.top,0),P=M(f.bottom,0);l?v=d-2*(E!==0||T!==0?E+T:M(f.left,f.right)):w=a-2*(D!==0||P!==0?D+P:M(f.top,f.bottom))}await s({...t,availableWidth:v,availableHeight:w});const b=await r.getDimensions(i.floating);return d!==b.width||a!==b.height?{reset:{rects:!0}}:{}}}};function $(e){var t;return((t=e.ownerDocument)==null?void 0:t.defaultView)||window}function W(e){return $(e).getComputedStyle(e)}function De(e){return e instanceof $(e).Node}function j(e){return De(e)?(e.nodeName||"").toLowerCase():""}let U;function Ce(){if(U)return U;const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?(U=e.brands.map(t=>t.brand+"/"+t.version).join(" "),U):navigator.userAgent}function F(e){return e instanceof $(e).HTMLElement}function k(e){return e instanceof $(e).Element}function ve(e){return typeof ShadowRoot>"u"?!1:e instanceof $(e).ShadowRoot||e instanceof ShadowRoot}function re(e){const{overflow:t,overflowX:o,overflowY:n,display:r}=W(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+o)&&!["inline","contents"].includes(r)}function _e(e){return["table","td","th"].includes(j(e))}function fe(e){const t=/firefox/i.test(Ce()),o=W(e),n=o.backdropFilter||o.WebkitBackdropFilter;return o.transform!=="none"||o.perspective!=="none"||!!n&&n!=="none"||t&&o.willChange==="filter"||t&&!!o.filter&&o.filter!=="none"||["transform","perspective"].some(r=>o.willChange.includes(r))||["paint","layout","strict","content"].some(r=>{const i=o.contain;return i!=null&&i.includes(r)})}function ae(){return/^((?!chrome|android).)*safari/i.test(Ce())}function ge(e){return["html","body","#document"].includes(j(e))}const be=Math.min,J=Math.max,ne=Math.round;function Pe(e){const t=W(e);let o=parseFloat(t.width),n=parseFloat(t.height);const r=F(e),i=r?e.offsetWidth:o,s=r?e.offsetHeight:n,c=ne(o)!==i||ne(n)!==s;return c&&(o=i,n=s),{width:o,height:n,fallback:c}}function $e(e){return k(e)?e:e.contextElement}const Oe={x:1,y:1};function _(e){const t=$e(e);if(!F(t))return Oe;const o=t.getBoundingClientRect(),{width:n,height:r,fallback:i}=Pe(t);let s=(i?ne(o.width):o.width)/n,c=(i?ne(o.height):o.height)/r;return s&&Number.isFinite(s)||(s=1),c&&Number.isFinite(c)||(c=1),{x:s,y:c}}function I(e,t,o,n){var r,i;t===void 0&&(t=!1),o===void 0&&(o=!1);const s=e.getBoundingClientRect(),c=$e(e);let f=Oe;t&&(n?k(n)&&(f=_(n)):f=_(e));const u=c?$(c):window,g=ae()&&o;let l=(s.left+(g&&((r=u.visualViewport)==null?void 0:r.offsetLeft)||0))/f.x,d=(s.top+(g&&((i=u.visualViewport)==null?void 0:i.offsetTop)||0))/f.y,a=s.width/f.x,m=s.height/f.y;if(c){const p=$(c),y=n&&k(n)?$(n):n;let h=p.frameElement;for(;h&&n&&y!==p;){const x=_(h),w=h.getBoundingClientRect(),v=getComputedStyle(h);w.x+=(h.clientLeft+parseFloat(v.paddingLeft))*x.x,w.y+=(h.clientTop+parseFloat(v.paddingTop))*x.y,l*=x.x,d*=x.y,a*=x.x,m*=x.y,l+=w.x,d+=w.y,h=$(h).frameElement}}return q({width:a,height:m,x:l,y:d})}function V(e){return((De(e)?e.ownerDocument:e.document)||window.document).documentElement}function ie(e){return k(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Se(e){return I(V(e)).left+ie(e).scrollLeft}function Q(e){if(j(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ve(e)&&e.host||V(e);return ve(t)?t.host:t}function ke(e){const t=Q(e);return ge(t)?t.ownerDocument.body:F(t)&&re(t)?t:ke(t)}function K(e,t){var o;t===void 0&&(t=[]);const n=ke(e),r=n===((o=e.ownerDocument)==null?void 0:o.body),i=$(n);return r?t.concat(i,i.visualViewport||[],re(n)?n:[]):t.concat(n,K(n))}function Re(e,t,o){let n;if(t==="viewport")n=function(s,c){const f=$(s),u=V(s),g=f.visualViewport;let l=u.clientWidth,d=u.clientHeight,a=0,m=0;if(g){l=g.width,d=g.height;const p=ae();(!p||p&&c==="fixed")&&(a=g.offsetLeft,m=g.offsetTop)}return{width:l,height:d,x:a,y:m}}(e,o);else if(t==="document")n=function(s){const c=V(s),f=ie(s),u=s.ownerDocument.body,g=J(c.scrollWidth,c.clientWidth,u.scrollWidth,u.clientWidth),l=J(c.scrollHeight,c.clientHeight,u.scrollHeight,u.clientHeight);let d=-f.scrollLeft+Se(s);const a=-f.scrollTop;return W(u).direction==="rtl"&&(d+=J(c.clientWidth,u.clientWidth)-g),{width:g,height:l,x:d,y:a}}(V(e));else if(k(t))n=function(s,c){const f=I(s,!0,c==="fixed"),u=f.top+s.clientTop,g=f.left+s.clientLeft,l=F(s)?_(s):{x:1,y:1};return{width:s.clientWidth*l.x,height:s.clientHeight*l.y,x:g*l.x,y:u*l.y}}(t,o);else{const s={...t};if(ae()){var r,i;const c=$(e);s.x-=((r=c.visualViewport)==null?void 0:r.offsetLeft)||0,s.y-=((i=c.visualViewport)==null?void 0:i.offsetTop)||0}n=s}return q(n)}function Ee(e,t){return F(e)&&W(e).position!=="fixed"?t?t(e):e.offsetParent:null}function Ae(e,t){const o=$(e);if(!F(e))return o;let n=Ee(e,t);for(;n&&_e(n)&&W(n).position==="static";)n=Ee(n,t);return n&&(j(n)==="html"||j(n)==="body"&&W(n).position==="static"&&!fe(n))?o:n||function(r){let i=Q(r);for(;F(i)&&!ge(i);){if(fe(i))return i;i=Q(i)}return null}(e)||o}function qe(e,t,o){const n=F(t),r=V(t),i=I(e,!0,o==="fixed",t);let s={scrollLeft:0,scrollTop:0};const c={x:0,y:0};if(n||!n&&o!=="fixed")if((j(t)!=="body"||re(r))&&(s=ie(t)),F(t)){const f=I(t,!0);c.x=f.x+t.clientLeft,c.y=f.y+t.clientTop}else r&&(c.x=Se(r));return{x:i.left+s.scrollLeft-c.x,y:i.top+s.scrollTop-c.y,width:i.width,height:i.height}}const Xe={getClippingRect:function(e){let{element:t,boundary:o,rootBoundary:n,strategy:r}=e;const i=o==="clippingAncestors"?function(u,g){const l=g.get(u);if(l)return l;let d=K(u).filter(y=>k(y)&&j(y)!=="body"),a=null;const m=W(u).position==="fixed";let p=m?Q(u):u;for(;k(p)&&!ge(p);){const y=W(p),h=fe(p);y.position==="fixed"&&(a=null),(m?h||a:h||y.position!=="static"||!a||!["absolute","fixed"].includes(a.position))?a=y:d=d.filter(x=>x!==p),p=Q(p)}return g.set(u,d),d}(t,this._c):[].concat(o),s=[...i,n],c=s[0],f=s.reduce((u,g)=>{const l=Re(t,g,r);return u.top=J(l.top,u.top),u.right=be(l.right,u.right),u.bottom=be(l.bottom,u.bottom),u.left=J(l.left,u.left),u},Re(t,c,r));return{width:f.right-f.left,height:f.bottom-f.top,x:f.left,y:f.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{rect:t,offsetParent:o,strategy:n}=e;const r=F(o),i=V(o);if(o===i)return t;let s={scrollLeft:0,scrollTop:0},c={x:1,y:1};const f={x:0,y:0};if((r||!r&&n!=="fixed")&&((j(o)!=="body"||re(i))&&(s=ie(o)),F(o))){const u=I(o);c=_(o),f.x=u.x+o.clientLeft,f.y=u.y+o.clientTop}return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-s.scrollLeft*c.x+f.x,y:t.y*c.y-s.scrollTop*c.y+f.y}},isElement:k,getDimensions:function(e){return Pe(e)},getOffsetParent:Ae,getDocumentElement:V,getScale:_,async getElementRects(e){let{reference:t,floating:o,strategy:n}=e;const r=this.getOffsetParent||Ae,i=this.getDimensions;return{reference:qe(t,await r(o),n),floating:{x:0,y:0,...await i(o)}}},getClientRects:e=>Array.from(e.getClientRects()),isRTL:e=>W(e).direction==="rtl"};function dt(e,t,o,n){n===void 0&&(n={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:s=!0,animationFrame:c=!1}=n,f=r&&!c,u=f||i?[...k(e)?K(e):e.contextElement?K(e.contextElement):[],...K(t)]:[];u.forEach(a=>{f&&a.addEventListener("scroll",o,{passive:!0}),i&&a.addEventListener("resize",o)});let g,l=null;s&&(l=new ResizeObserver(()=>{o()}),k(e)&&!c&&l.observe(e),k(e)||!e.contextElement||c||l.observe(e.contextElement),l.observe(t));let d=c?I(e):null;return c&&function a(){const m=I(e);!d||m.x===d.x&&m.y===d.y&&m.width===d.width&&m.height===d.height||o(),d=m,g=requestAnimationFrame(a)}(),o(),()=>{var a;u.forEach(m=>{f&&m.removeEventListener("scroll",o),i&&m.removeEventListener("resize",o)}),(a=l)==null||a.disconnect(),l=null,c&&cancelAnimationFrame(g)}}const Ye=(e,t,o)=>{const n=new Map,r={platform:Xe,...o},i={...r.platform,_c:n};return Ve(e,t,{...r,platform:i})},mt=e=>{const{element:t,padding:o}=e;function n(r){return Object.prototype.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){return n(t)?t.current!=null?xe({element:t.current,padding:o}).fn(r):{}:t?xe({element:t,padding:o}).fn(r):{}}}};var ee=typeof document<"u"?R.useLayoutEffect:R.useEffect;function oe(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let o,n,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(o=e.length,o!=t.length)return!1;for(n=o;n--!==0;)if(!oe(e[n],t[n]))return!1;return!0}if(r=Object.keys(e),o=r.length,o!==Object.keys(t).length)return!1;for(n=o;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[n]))return!1;for(n=o;n--!==0;){const i=r[n];if(!(i==="_owner"&&e.$$typeof)&&!oe(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function Le(e){const t=R.useRef(e);return ee(()=>{t.current=e}),t}function Ge(e){e===void 0&&(e={});const{placement:t="bottom",strategy:o="absolute",middleware:n=[],platform:r,whileElementsMounted:i,open:s}=e,[c,f]=R.useState({x:null,y:null,strategy:o,placement:t,middlewareData:{},isPositioned:!1}),[u,g]=R.useState(n);oe(u,n)||g(n);const l=R.useRef(null),d=R.useRef(null),a=R.useRef(c),m=Le(i),p=Le(r),[y,h]=R.useState(null),[x,w]=R.useState(null),v=R.useCallback(A=>{l.current!==A&&(l.current=A,h(A))},[]),b=R.useCallback(A=>{d.current!==A&&(d.current=A,w(A))},[]),E=R.useCallback(()=>{if(!l.current||!d.current)return;const A={placement:t,strategy:o,middleware:u};p.current&&(A.platform=p.current),Ye(l.current,d.current,A).then(L=>{const C={...L,isPositioned:!0};T.current&&!oe(a.current,C)&&(a.current=C,He.flushSync(()=>{f(C)}))})},[u,t,o,p]);ee(()=>{s===!1&&a.current.isPositioned&&(a.current.isPositioned=!1,f(A=>({...A,isPositioned:!1})))},[s]);const T=R.useRef(!1);ee(()=>(T.current=!0,()=>{T.current=!1}),[]),ee(()=>{if(y&&x){if(m.current)return m.current(y,x,E);E()}},[y,x,E,m]);const D=R.useMemo(()=>({reference:l,floating:d,setReference:v,setFloating:b}),[v,b]),P=R.useMemo(()=>({reference:y,floating:x}),[y,x]);return R.useMemo(()=>({...c,update:E,refs:D,elements:P,reference:v,floating:b}),[c,E,D,P,v,b])}var Je=typeof document<"u"?R.useLayoutEffect:R.useEffect;function Ke(){const e=new Map;return{emit(t,o){var n;(n=e.get(t))==null||n.forEach(r=>r(o))},on(t,o){e.set(t,[...e.get(t)||[],o])},off(t,o){e.set(t,(e.get(t)||[]).filter(n=>n!==o))}}}const Qe=R.createContext(null),Ue=()=>R.useContext(Qe);function Ze(e){return(e==null?void 0:e.ownerDocument)||document}function et(e){return Ze(e).defaultView||window}function Z(e){return e?e instanceof et(e).Element:!1}const tt=Be["useInsertionEffect".toString()],nt=tt||(e=>e());function ot(e){const t=R.useRef(()=>{});return nt(()=>{t.current=e}),R.useCallback(function(){for(var o=arguments.length,n=new Array(o),r=0;r<o;r++)n[r]=arguments[r];return t.current==null?void 0:t.current(...n)},[])}function gt(e){e===void 0&&(e={});const{open:t=!1,onOpenChange:o,nodeId:n}=e,r=Ge(e),i=Ue(),s=R.useRef(null),c=R.useRef({}),f=R.useState(()=>Ke())[0],[u,g]=R.useState(null),l=R.useCallback(h=>{const x=Z(h)?{getBoundingClientRect:()=>h.getBoundingClientRect(),contextElement:h}:h;r.refs.setReference(x)},[r.refs]),d=R.useCallback(h=>{(Z(h)||h===null)&&(s.current=h,g(h)),(Z(r.refs.reference.current)||r.refs.reference.current===null||h!==null&&!Z(h))&&r.refs.setReference(h)},[r.refs]),a=R.useMemo(()=>({...r.refs,setReference:d,setPositionReference:l,domReference:s}),[r.refs,d,l]),m=R.useMemo(()=>({...r.elements,domReference:u}),[r.elements,u]),p=ot(o),y=R.useMemo(()=>({...r,refs:a,elements:m,dataRef:c,nodeId:n,events:f,open:t,onOpenChange:p}),[r,n,f,t,p,a,m]);return Je(()=>{const h=i==null?void 0:i.nodesRef.current.find(x=>x.id===n);h&&(h.context=y)}),R.useMemo(()=>({...r,context:y,refs:a,reference:d,positionReference:l}),[r,a,y,d,l])}export{ut as B,ct as D,at as O,dt as P,st as T,mt as a,lt as b,ft as k,gt as u};
