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