import e from"./dom-utils/getCompositeRect.js";import t from"./dom-utils/getLayoutRect.js";import o from"./dom-utils/listScrollParents.js";import r from"./dom-utils/getOffsetParent.js";import n from"./dom-utils/getComputedStyle.js";import i from"./utils/orderModifiers.js";import s from"./utils/debounce.js";import a from"./utils/validateModifiers.js";import f from"./utils/uniqueBy.js";import p from"./utils/getBasePlacement.js";import c from"./utils/mergeByName.js";import{isElement as m}from"./dom-utils/instanceOf.js";import{auto as d}from"./enums.js";export{afterMain,afterRead,afterWrite,auto,basePlacements,beforeMain,beforeRead,beforeWrite,bottom,clippingParents,end,left,main,modifierPhases,placements,popper,read,reference,right,start,top,variationPlacements,viewport,write}from"./enums.js";var u="Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.",l={placement:"bottom",modifiers:[],strategy:"absolute"};function v(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return!t.some((function(e){return!(e&&"function"==typeof e.getBoundingClientRect)}))}function g(g){void 0===g&&(g={});var b=g,h=b.defaultModifiers,j=void 0===h?[]:h,y=b.defaultOptions,O=void 0===y?l:y;return function(g,b,h){void 0===h&&(h=O);var y={placement:"bottom",orderedModifiers:[],options:Object.assign(Object.assign({},l),O),modifiersData:{},elements:{reference:g,popper:b},attributes:{},styles:{}},E=[],M=!1,P={state:y,setOptions:function(e){w(),y.options=Object.assign(Object.assign(Object.assign({},O),y.options),e),y.scrollParents={reference:m(g)?o(g):g.contextElement?o(g.contextElement):[],popper:o(b)};var t=i(c([].concat(j,y.options.modifiers)));if(y.orderedModifiers=t.filter((function(e){return e.enabled})),"production"!==process.env.NODE_ENV){var r=f([].concat(t,y.options.modifiers),(function(e){return e.name}));if(a(r),p(y.options.placement)===d)y.orderedModifiers.find((function(e){return"flip"===e.name}))||console.error(['Popper: "auto" placements require the "flip" modifier be',"present and enabled to work."].join(" "));var s=n(b);[s.marginTop,s.marginRight,s.marginBottom,s.marginLeft].some((function(e){return parseFloat(e)}))&&console.warn(['Popper: CSS "margin" styles cannot be used to apply padding',"between the popper and its reference element or boundary.","To replicate margin, use the `offset` modifier, as well as","the `padding` option in the `preventOverflow` and `flip`","modifiers."].join(" "))}return y.orderedModifiers.forEach((function(e){var t=e.name,o=e.options,r=void 0===o?{}:o,n=e.effect;if("function"==typeof n){var i=n({state:y,name:t,instance:P,options:r}),s=function(){};E.push(i||s)}})),P.update()},forceUpdate:function(){if(!M){var o=y.elements,n=o.reference,i=o.popper;if(v(n,i)){y.rects={reference:e(n,r(i),"fixed"===y.options.strategy),popper:t(i)},y.reset=!1,y.placement=y.options.placement,y.orderedModifiers.forEach((function(e){return y.modifiersData[e.name]=Object.assign({},e.data)}));for(var s=0,a=0;a<y.orderedModifiers.length;a++){if("production"!==process.env.NODE_ENV&&(s+=1)>100){console.error("Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.");break}if(!0!==y.reset){var f=y.orderedModifiers[a],p=f.fn,c=f.options,m=void 0===c?{}:c,d=f.name;"function"==typeof p&&(y=p({state:y,options:m,name:d,instance:P})||y)}else y.reset=!1,a=-1}}else"production"!==process.env.NODE_ENV&&console.error(u)}},update:s((function(){return new Promise((function(e){P.forceUpdate(),e(y)}))})),destroy:function(){w(),M=!0}};if(!v(g,b))return"production"!==process.env.NODE_ENV&&console.error(u),P;function w(){E.forEach((function(e){return e()})),E=[]}return P.setOptions(h).then((function(e){!M&&h.onFirstUpdate&&h.onFirstUpdate(e)})),P}}export{g as popperGenerator};
//# sourceMappingURL=index.js.map
