Liferay.Loader.define("commerce-frontend-js@4.0.52/components/quantity_selector/RulesPopover",["module","exports","require","@frontend-taglib-clay$clayui/popover","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({alignment:e,errors:t,inputRef:r,max:i,min:u,multiple:c}){const s=(0,o.useRef)(),[p,d]=(0,o.useState)({});(0,o.useLayoutEffect)((()=>{const t={transform:"translateX(-50%)"};if(e||!(null==r?void 0:r.current))return d(f(f({},t),{},{alignment:e,["bottom"===e?"top":"bottom"]:"calc(100% + 10px)",left:"50px"}));const{bottom:n,left:a,top:l,width:o}=r.current.getBoundingClientRect(),{height:i}=s.current.getBoundingClientRect();t.left=a+o/2;i>window.pageYOffset+l?(t.alignment="bottom",t.top=window.pageYOffset+n+4):(t.alignment="top",t.top=window.pageYOffset+l-i-8),d(t)}),[e,r]);const m=o.default.createElement(n.default,{alignPosition:p.alignment,className:"quantity-selector-popover",ref:s,style:p},o.default.createElement("ul",{className:"list-group list-group-flush mb-0"},u>1&&o.default.createElement("li",{className:"list-group-item px-0 py-1 text-truncate"},o.default.createElement("small",{className:(0,l.default)({"text-danger":t.includes("min")}),dangerouslySetInnerHTML:{__html:Liferay.Util.sub(Liferay.Language.get("min-quantity-per-order-is-x"),"<b>".concat(u,"</b>"))}})),i&&o.default.createElement("li",{className:"list-group-item px-0 py-1 text-truncate"},o.default.createElement("small",{className:(0,l.default)({"text-danger":t.includes("max")}),dangerouslySetInnerHTML:{__html:Liferay.Util.sub(Liferay.Language.get("max-quantity-per-order-is-x"),"<b>".concat(i,"</b>"))}})),c>1&&o.default.createElement("li",{className:"list-group-item px-0 py-1 text-truncate"},o.default.createElement("small",{className:(0,l.default)({"text-danger":t.includes("multiple")}),dangerouslySetInnerHTML:{__html:Liferay.Util.sub(Liferay.Util.sub(Liferay.Language.get("quantity-must-be-a-multiple-of-x"),"<b>".concat(c,"</b>")))}}))));if(e)return m;return o.default.createElement(a.ReactPortal,{container:document.body},m)};var n=u(r("@frontend-taglib-clay$clayui/popover")),a=r("@liferay/frontend-js-react-web"),l=u(r("liferay!frontend-js-react-web$classnames")),o=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=i();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var l=n?Object.getOwnPropertyDescriptor(e,a):null;l&&(l.get||l.set)?Object.defineProperty(r,a,l):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react"));function i(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return i=function(){return e},e}function u(e){return e&&e.__esModule?e:{default:e}}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function f(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}}}));
//# sourceMappingURL=RulesPopover.js.map