import{start as t,top as e,left as i,bottom as r,right as o}from"../enums.js";import a from"../utils/getBasePlacement.js";import s from"../utils/getMainAxisFromPlacement.js";import m from"../utils/getAltAxis.js";import n from"../utils/within.js";import f from"../dom-utils/getLayoutRect.js";import p from"../dom-utils/getOffsetParent.js";import d from"../utils/detectOverflow.js";import l from"../utils/getVariation.js";import u from"../utils/getFreshSideObject.js";var c={name:"preventOverflow",enabled:!0,phase:"main",fn:function(c){var g=c.state,h=c.options,j=c.name,y=h.mainAxis,v=void 0===y||y,w=h.altAxis,x=void 0!==w&&w,O=h.boundary,b=h.rootBoundary,D=h.altBoundary,A=h.padding,B=h.tether,M=void 0===B||B,P=h.tetherOffset,F=void 0===P?0:P,L=d(g,{boundary:O,rootBoundary:b,padding:A,altBoundary:D}),q=a(g.placement),E=l(g.placement),I=!E,R=s(q),S=m(R),T=g.modifiersData.popperOffsets,V=g.rects.reference,k=g.rects.popper,z="function"==typeof F?F(Object.assign(Object.assign({},g.rects),{},{placement:g.placement})):F,C={x:0,y:0};if(T){if(v){var G="y"===R?e:i,H="y"===R?r:o,J="y"===R?"height":"width",K=T[R],N=T[R]+L[G],Q=T[R]-L[H],U=M?-k[J]/2:0,W=E===t?V[J]:k[J],X=E===t?-k[J]:-V[J],Y=g.elements.arrow,Z=M&&Y?f(Y):{width:0,height:0},$=g.modifiersData["arrow#persistent"]?g.modifiersData["arrow#persistent"].padding:u(),_=$[G],tt=$[H],et=n(0,V[J],Z[J]),it=I?V[J]/2-U-et-_-z:W-et-_-z,rt=I?-V[J]/2+U+et+tt+z:X+et+tt+z,ot=g.elements.arrow&&p(g.elements.arrow),at=ot?"y"===R?ot.clientTop||0:ot.clientLeft||0:0,st=g.modifiersData.offset?g.modifiersData.offset[g.placement][R]:0,mt=T[R]+it-st-at,nt=T[R]+rt-st,ft=n(M?Math.min(N,mt):N,K,M?Math.max(Q,nt):Q);T[R]=ft,C[R]=ft-K}if(x){var pt="x"===R?e:i,dt="x"===R?r:o,lt=T[S],ut=lt+L[pt],ct=lt-L[dt],gt=n(ut,lt,ct);T[S]=gt,C[S]=gt-lt}g.modifiersData[j]=C}},requiresIfExists:["offset"]};export default c;
//# sourceMappingURL=preventOverflow.js.map
