import e from"../utils/getOppositePlacement.js";import t from"../utils/getBasePlacement.js";import r from"../utils/getOppositeVariationPlacement.js";import a from"../utils/detectOverflow.js";import i from"../utils/computeAutoPlacement.js";import{auto as n,start as o,right as s,left as f,bottom as u,top as p}from"../enums.js";import l from"../utils/getVariation.js";var m={name:"flip",enabled:!0,phase:"main",fn:function(m){var c=m.state,d=m.options,v=m.name;if(!c.modifiersData[v]._skip){for(var g=d.mainAxis,y=void 0===g||g,b=d.altAxis,k=void 0===b||b,h=d.fallbackPlacements,j=d.padding,P=d.boundary,B=d.rootBoundary,w=d.altBoundary,x=d.flipVariations,A=void 0===x||x,O=d.allowedAutoPlacements,V=c.options.placement,_=t(V),D=h||(_===V||!A?[e(V)]:function(a){if(t(a)===n)return[];var i=e(a);return[r(a),i,r(i)]}(V)),q=[V].concat(D).reduce((function(e,r){return e.concat(t(r)===n?i(c,{placement:r,boundary:P,rootBoundary:B,padding:j,flipVariations:A,allowedAutoPlacements:O}):r)}),[]),E=c.rects.reference,I=c.rects.popper,M=new Map,z=!0,C=q[0],F=0;F<q.length;F++){var G=q[F],H=t(G),J=l(G)===o,K=[p,u].indexOf(H)>=0,L=K?"width":"height",N=a(c,{placement:G,boundary:P,rootBoundary:B,altBoundary:w,padding:j}),Q=K?J?s:f:J?u:p;E[L]>I[L]&&(Q=e(Q));var R=e(Q),S=[];if(y&&S.push(N[H]<=0),k&&S.push(N[Q]<=0,N[R]<=0),S.every((function(e){return e}))){C=G,z=!1;break}M.set(G,S)}if(z)for(var T=function(e){var t=q.find((function(t){var r=M.get(t);if(r)return r.slice(0,e).every((function(e){return e}))}));if(t)return C=t,"break"},U=A?3:1;U>0;U--){if("break"===T(U))break}c.placement!==C&&(c.modifiersData[v]._skip=!0,c.placement=C,c.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};export default m;
//# sourceMappingURL=flip.js.map
