Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.169/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"),l=a("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 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?o.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?o.default.createElement(n.default,{"aria-label":Liferay.Language.get("saving"),className:"my-0",size:"sm",title:Liferay.Language.get("saving")}):null:o.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,o.useState)(!0),n=(0,o.useRef)(null);(0,o.useEffect)((()=>{t===c.SERVICE_NETWORK_STATUS_TYPES.error&&(0,l.openToast)({message:e,type:"danger"})}),[e,t]),(0,o.useEffect)((()=>{t!==c.SERVICE_NETWORK_STATUS_TYPES.draftSaved||n.current||(n.current=Liferay.Language.get("changes-have-been-saved.-page-editor-will-autosave-new-changes"))}),[t]),(0,i.useEventListener)("online",(()=>r(!0)),!0,window),(0,i.useEventListener)("offline",(()=>r(!1)),!0,window);const u=getContent(a,t);return o.default.createElement("div",{className:"page-editor__status-bar"},o.default.createElement("span",{"aria-live":"polite",className:"sr-only"},n.current),u)};t.default=_default}}));
//# sourceMappingURL=NetworkStatusBar.js.map