Liferay.Loader.define("analytics-reports-web@2.0.38/js/components/AnalyticsReports",["module","exports","require","@frontend-taglib-clay$clayui/alert","@frontend-taglib-clay$clayui/loading-indicator","@liferay/frontend-js-react-web","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../context/ChartStateContext","../context/ConnectionContext","../context/StoreContext","../context/dataReducer","./Navigation","../../css/analytics-reports-app.scss"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({analyticsReportsDataURL:e,hoverOrFocusEventTriggered:t,isPanelStateOpen:n}){const f=(0,o.useIsMounted)(),[y,b]=(0,i.useReducer)(s.dataReducer,s.initialState),v=(0,i.useCallback)((e=>{f()&&b(e)}),[f]),O=(0,i.useCallback)(((e,t,n)=>{v({type:"LOAD_DATA"});const a=!n&&t?{timeSpanKey:t,timeSpanOffset:n}:{};(0,l.fetch)(e,{body:a,method:"POST"}).then((e=>e.json().then((e=>v({data:e.context,type:"SET_DATA"}))))).catch((()=>{v({error:Liferay.Language.get("an-unexpected-error-occurred"),type:"SET_ERROR"})}))}),[v]);(0,i.useEffect)((()=>{t&&!y.data&&O(e)}),[t]),(0,i.useEffect)((()=>{!n||y.data||y.loading||O(e)}),[n]);const j=(0,i.useCallback)(((e,t,n)=>{O(e,t,n)}),[]),{data:m,error:w,loading:h}=y;return h?i.default.createElement(r.default,{small:!0}):w?i.default.createElement(a.default,{displayType:"danger",variant:"stripe"},w):m&&i.default.createElement(u.default.Provider,{value:{validAnalyticsConnection:null==m?void 0:m.validAnalyticsConnection}},i.default.createElement(d.StoreContextProvider,{value:{endpoints:g({},null==m?void 0:m.endpoints),languageTag:null==m?void 0:m.languageTag,namespace:null==m?void 0:m.namespace,page:null==m?void 0:m.page,publishedToday:null==m?void 0:m.publishedToday}},i.default.createElement(c.ChartStateContextProvider,{publishDate:null==m?void 0:m.publishDate,timeRange:null==m?void 0:m.timeRange,timeSpanKey:null==m?void 0:m.timeSpanKey},i.default.createElement("div",{className:"analytics-reports-app"},i.default.createElement(p.default,{author:null==m?void 0:m.author,canonicalURL:null==m?void 0:m.canonicalURL,onSelectedLanguageClick:j,pagePublishDate:null==m?void 0:m.publishDate,pageTitle:null==m?void 0:m.title,timeSpanOptions:null==m?void 0:m.timeSpans,viewURLs:null==m?void 0:m.viewURLs})))))};var a=y(n("@frontend-taglib-clay$clayui/alert")),r=y(n("@frontend-taglib-clay$clayui/loading-indicator")),o=n("@liferay/frontend-js-react-web"),l=n("frontend-js-web"),i=(y(n("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var o=a?Object.getOwnPropertyDescriptor(e,r):null;o&&(o.get||o.set)?Object.defineProperty(n,r,o):n[r]=e[r]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react"))),c=n("../context/ChartStateContext"),u=y(n("../context/ConnectionContext")),d=n("../context/StoreContext"),s=n("../context/dataReducer"),p=y(n("./Navigation"));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function y(e){return e&&e.__esModule?e:{default:e}}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function g(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?b(Object(n),!0).forEach((function(t){v(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n("../../css/analytics-reports-app.scss")}}));
//# sourceMappingURL=AnalyticsReports.js.map