Liferay.Loader.define("style-book-web@2.0.76/js/fragment-collection-preview/VariationPreview",["module","exports","require","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.VariationPreview=function VariationPreview({fragmentEntryKey:e,label:t,namespace:r,previewURL:i,showLabel:c,variation:l}){const[f,s]=(0,o.useState)(null),[u,d]=(0,o.useState)(!1);return(0,o.useEffect)((()=>{if(d(!1),!f)return;if(!("IntersectionObserver"in window))return void d(!0);const e=new IntersectionObserver((t=>{t.some((e=>e.isIntersecting&&e.target===f))&&(d(!0),e.disconnect())}));return e.observe(f),()=>{e.disconnect()}}),[f]),(0,o.useEffect)((()=>{if(!f||!u)return;const e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.className="flex-grow-0 loading-animation m-0",f.appendChild(e),(0,a.fetch)(i,{body:(0,a.objectToFormData)({["_".concat(r,"_configurationValues")]:JSON.stringify(l.reduce(((e,{name:t,value:r})=>_objectSpread(_objectSpread({},e),{},{[t]:r})),{}))}),method:"POST"}).then((e=>e.text())).then((e=>{f.innerHTML=e,(0,a.runScriptsInElement)(f)})).catch((e=>{console.error(e),f.innerHTML=""}))}),[f,e,r,i,l,u]),o.default.createElement("article",{className:"d-flex flex-column-reverse"},o.default.createElement("div",{className:"cadmin"},o.default.createElement("h4",{className:(0,n.default)("mb-0 mt-2 text-secondary",{"sr-only":!c})},t)),o.default.createElement("div",{className:"align-items-center d-flex flex-grow-1 justify-content-center overflow-hidden p-4 variation-preview__content",ref:s}))};var n=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(r("liferay!frontend-js-react-web$classnames")),a=r("frontend-js-web"),o=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 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=VariationPreview.js.map