Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.145/page_editor/app/components/NetworkStatusBar",["module","exports","require","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/loading-indicator","@liferay/frontend-js-react-web","frontend-js-web","liferay!frontend-js-react-web$react","../config/constants/serviceNetworkStatusTypes"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/loading-indicator")),i=a("@liferay/frontend-js-react-web"),o=a("frontend-js-web"),l=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 i=r?Object.getOwnPropertyDescriptor(e,n):null;i&&(i.get||i.set)?Object.defineProperty(a,n,i):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),c=a("../config/constants/serviceNetworkStatusTypes");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}}const getContent=(e,t)=>e?t===c.SERVICE_NETWORK_STATUS_TYPES.draftSaved?l.default.createElement(r.default,{"aria-label":Liferay.Language.get("saved"),className:"text-success","data-title":Liferay.Language.get("saved"),symbol:"check-circle"}):t===c.SERVICE_NETWORK_STATUS_TYPES.savingDraft?l.default.createElement(n.default,{"aria-label":Liferay.Language.get("saving"),className:"my-0",size:"sm",title:Liferay.Language.get("saving")}):null:l.default.createElement(n.default,{"aria-label":Liferay.Language.get("trying-to-reconnect"),className:"my-0",size:"sm",title:Liferay.Language.get("trying-to-reconnect")});var _default=({error:e,status:t})=>{const[a,r]=(0,l.useState)(!0),n=(0,l.useRef)(null);(0,l.useEffect)((()=>{t===c.SERVICE_NETWORK_STATUS_TYPES.error&&(0,o.openToast)({message:e,type:"danger"})}),[e,t]),(0,l.useEffect)((()=>{t!==c.SERVICE_NETWORK_STATUS_TYPES.draftSaved||n.current||(n.current=Liferay.Language.get("page-editor-autosaves-your-work"))}),[t]),(0,i.useEventListener)("online",(()=>r(!0)),!0,window),(0,i.useEventListener)("offline",(()=>r(!1)),!0,window);const u=getContent(a,t);return l.default.createElement("div",{className:"page-editor__status-bar"},l.default.createElement("span",{className:"sr-only",role:"alert"},n.current),u)};t.default=_default}}));
//# sourceMappingURL=NetworkStatusBar.js.map