Liferay.Loader.define("analytics-reports-web@2.0.38/js/components/Navigation",["module","exports","require","@frontend-taglib-clay$clayui/alert","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../context/ChartStateContext","../context/ConnectionContext","../context/StoreContext","../utils/APIService","./Main","./detail/Detail","./detail/Drawer"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.default=m;var n=y(t("@frontend-taglib-clay$clayui/alert")),r=y(t("liferay!frontend-js-react-web$classnames")),i=(y(t("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 a=p();if(a&&a.has(e))return a.get(e);var t={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=n?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(t,r,i):t[r]=e[r]}t.default=e,a&&a.set(e,t);return t}(t("liferay!frontend-js-react-web$react"))),l=t("../context/ChartStateContext"),s=y(t("../context/ConnectionContext")),o=t("../context/StoreContext"),c=y(t("../utils/APIService")),u=y(t("./Main")),d=y(t("./detail/Detail")),f=y(t("./detail/Drawer"));function p(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return p=function(){return e},e}function y(e){return e&&e.__esModule?e:{default:e}}const e=()=>{};function m({author:a,canonicalURL:t,onSelectedLanguageClick:p=e,pagePublishDate:y,pageTitle:m,timeSpanOptions:R,viewURLs:g}){const{endpoints:v,namespace:b,page:S,publishedToday:C,warning:w}=(0,i.useContext)(o.StoreStateContext),{validAnalyticsConnection:L}=(0,i.useContext)(s.default),[h,P]=(0,i.useState)({view:"main"}),[T,x]=(0,i.useState)([]),[D,O]=(0,i.useState)(""),{timeSpanKey:U,timeSpanOffset:j}=(0,i.useContext)(l.ChartStateContext),k=(0,i.useRef)(null),E=(0,i.useCallback)((e=>{P({view:e.view})}),[]),V=(0,i.useCallback)((()=>c.default.getHistoricalReads(v.analyticsReportsHistoricalReadsURL,{namespace:b,plid:S.plid,timeSpanKey:U,timeSpanOffset:j}).then((e=>e))),[v.analyticsReportsHistoricalReadsURL,b,S.plid,U,j]),$=(0,i.useCallback)((()=>c.default.getHistoricalReads(v.analyticsReportsHistoricalViewsURL,{namespace:b,plid:S.plid,timeSpanKey:U,timeSpanOffset:j}).then((e=>e))),[v.analyticsReportsHistoricalViewsURL,b,S.plid,U,j]),H=(0,i.useCallback)((()=>c.default.getTotalReads(v.analyticsReportsTotalReadsURL,{namespace:b,plid:S.plid}).then((({analyticsReportsTotalReads:e})=>e))),[v.analyticsReportsTotalReadsURL,b,S.plid]),M=(0,i.useCallback)((()=>c.default.getTotalReads(v.analyticsReportsTotalViewsURL,{namespace:b,plid:S.plid}).then((({analyticsReportsTotalViews:e})=>e))),[v.analyticsReportsTotalViewsURL,b,S.plid]),N=(0,i.useCallback)((()=>c.default.getTrafficSources(v.analyticsReportsTrafficSourcesURL,{namespace:b,plid:S.plid,timeSpanKey:U,timeSpanOffset:j}).then((({trafficSources:e})=>e))),[v.analyticsReportsTrafficSourcesURL,b,S.plid,U,j]),_=(0,i.useCallback)(((e,a)=>{x(e),O(a);const t=e.find((e=>e.name===a));P({data:t,view:t.name})}),[]),K=(0,i.useCallback)((()=>{var e;const a=T.find((e=>e.name===D));return Promise.resolve(null!==(e=null==a?void 0:a.share)&&void 0!==e?e:"-")}),[D,T]),A=(0,i.useCallback)((()=>{var e;const a=T.find((e=>e.name===D));return Promise.resolve(null!==(e=null==a?void 0:a.value)&&void 0!==e?e:"-")}),[D,T]),I="main"!==h.view;return(0,i.useEffect)((()=>{I&&k.current.scrollIntoView()}),[I]),i.default.createElement(i.default.Fragment,null,!L&&i.default.createElement(n.default,{className:"mb-3",displayType:"danger",variant:"stripe"},Liferay.Language.get("an-unexpected-error-occurred")),L&&w&&i.default.createElement(n.default,{className:"mb-3",displayType:"warning",variant:"stripe"},Liferay.Language.get("some-data-is-temporarily-unavailable")),L&&C&&!w&&i.default.createElement(n.default,{className:"mb-3",displayType:"info",title:Liferay.Language.get("no-data-is-available-yet"),variant:"stripe"},Liferay.Language.get("content-has-just-been-published")),i.default.createElement(u.default,{author:a,canonicalURL:t,chartDataProviders:v.analyticsReportsHistoricalReadsURL?[$,V]:[$],className:(0,r.default)({"analytics-reports-app-main--hide":I}),onSelectedLanguageClick:p,onTrafficSourceClick:_,pagePublishDate:y,pageTitle:m,timeSpanOptions:R,totalReadsDataProvider:v.analyticsReportsTotalReadsURL&&H,totalViewsDataProvider:M,trafficSourcesDataProvider:N,viewURLs:g}),I&&i.default.createElement(f.default,null,i.default.createElement(d.default,{currentPage:h,handleDetailPeriodChange:_,onCurrentPageChange:E,onTrafficSourceNameChange:e=>O(e),refProp:k,timeSpanOptions:R,trafficShareDataProvider:K,trafficSourcesDataProvider:N,trafficVolumeDataProvider:A})))}m.defaultProps={author:null}}}));
//# sourceMappingURL=Navigation.js.map