Liferay.Loader.define("adaptive-media-web@5.0.49/adaptive_media/js/AdaptiveMediaProgress",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/progress-bar","@liferay/frontend-js-react-web","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","./utils/entryIcons"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/progress-bar")),i=a("@liferay/frontend-js-react-web"),o=a("frontend-js-web"),c=(_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),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 a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=r?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(a,n,l):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"))),d=a("./utils/entryIcons");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}}var _default=({adaptedImages:e,adaptiveMediaProgressComponentId:t,autoStartProgress:a=!1,disabled:u=!1,intervalSpeed:s=1e3,namespace:f,percentageUrl:g,tooltip:p,totalImages:y,uuid:m})=>{const b=(0,i.useTimeout)(),v=(0,i.useIsMounted)(),[j,E]=(0,c.useState)(a),[_,w]=(0,c.useState)(Math.ceil(e/y*100)||0),[I,h]=(0,c.useState)(e+"/"+y),[L,q]=(0,c.useState)(0),M=(0,c.useCallback)((()=>{(0,o.fetch)(g).then((e=>e.json())).then((({adaptedImages:e,errors:t,totalImages:a})=>{v()&&(q(t),w(Math.ceil(e/a*100)||0),h(p||e+"/"+a)),e+t===a?(v()&&E(!1),(0,d.enableEntryIcon)(document.getElementById("".concat(f,"icon-disable-").concat(m)))):b(M,s)}))}),[b,s,v,f,g,p,m]),O=(0,c.useCallback)((e=>((0,o.fetch)(e),v()&&E(!0),(0,d.disableEntryIcon)(document.getElementById("".concat(f,"icon-adapt-remaining").concat(m))),(0,d.disableEntryIcon)(document.getElementById("".concat(f,"icon-disable-").concat(m))),b(M,s))),[b,s,v,f,M,m]);return(0,c.useEffect)((()=>{a&&M()}),[a,M]),Liferay.component(t)||Liferay.component(t,{startProgress:O},{destroyOnNavigate:!0}),L>0?c.default.createElement("div",{className:"progress-error-container"},c.default.createElement("span",{className:"text-danger"},c.default.createElement(n.default,{symbol:"exclamation-full"}),c.default.createElement("span",null,c.default.createElement("strong",null,Liferay.Language.get("error"),": "),1===L?Liferay.Language.get("1-image-failed-process"):(0,o.sub)(Liferay.Language.get("x-images-failed-process"),L))),c.default.createElement(r.default,{borderless:!0,className:"text-danger",onClick:()=>{q(0),O()},small:!0},Liferay.Language.get("retry"))):c.default.createElement(c.default.Fragment,null,c.default.createElement("div",{className:"progress-container ".concat(u?"disabled":""),"data-percentage":_,"data-title":I},c.default.createElement(l.default,{value:_})),c.default.createElement("span",{className:"".concat(j?"":"hide ","loading-animation loading-animation-sm")}))};t.default=_default}}));
//# sourceMappingURL=AdaptiveMediaProgress.js.map