import{__assign as e,__awaiter as t,__generator as r}from"../../../node_modules/tslib/tslib.es6.js";import n,{useState as o,useEffect as l}from"react";import"../../../node_modules/prop-types/index.js";import"../../../node_modules/react-redux/es/index.js";import a from"../../common/Card/MediumCard.js";import{DEFAULT_BLOC_PROPERTIES as i}from"../../Bloc/BlocProperties.js";import s from"../../../node_modules/react-infinite-scroll-component/lib/index.js";import{convertToSlug as m}from"../../../utils/string.js";import{useSelector as c}from"../../../node_modules/react-redux/es/hooks/useSelector.js";import{useDispatch as d}from"../../../node_modules/react-redux/es/hooks/useDispatch.js";import{p}from"../../../_virtual/index.js_commonjs-module";var u=e(e({},i),{apiUrl:"",type:"grid"});function g(e){var i=e.apiUrl,p=e.maxItem;e.path;var u=e.migrated,g=e.loadNews,f=e.selectNews,h=e.selectTotalSize,v=e.loadPagesByStack,b=e.selectPages,x=o(!0),E=x[0],j=x[1],y=o(1),_=y[0],w=y[1],k=o("");k[0];var U=k[1],I=c(b),N=d(),B=o([]),S=B[0],T=B[1],A=c(h),C=c(f);l((function(){!u&&C&&T(C)}),[C]),l((function(){e&&e.page&&U(e.page.account)}),[e]),l((function(){var t=[];if(I&&I.length>0)for(var r=0,n=I;r<n.length;r++)for(var o=n[r],l=0,a=o.sections;l<a.length;l++)for(var i=0,s=a[l].rows;i<s.length;i++)for(var m=0,c=s[i].blocs;m<c.length;m++){var d=c[m];if(d.properties){var p=d.properties;t.push({alignment:p.alignment,author:p.author,name:o.route,content:p.content,filledIn:p.filledIn,images:o.mediaUrl?[e.assetsEndpoint+o.mediaUrl]:p.images,publishedOn:p.publishedOn,title:p.title})}}T(t)}),[I]);return l((function(){N(u?v({domain:e.domain,stack:"news-and-events",language:"en"}):g(i,_))}),[i,_,u]),n.createElement(n.Fragment,null,n.createElement(s,{dataLength:S&&S.length?S.length:0,next:function(){!function(){t(this,void 0,void 0,(function(){return r(this,(function(e){try{w(_+1),j(null==A||S.length<A)}catch(e){console.log("error",e)}return[2]}))}))}()},hasMore:E,loader:n.createElement("h4",{style:{marginLeft:"20px"}},"Loading..."),scrollableTarget:"scrollableDiv",className:"InfiniteScrollBar"},n.createElement("div",{className:"container mt-5"},n.createElement("div",{className:"row"},S.slice(0,p).map((function(e){return n.createElement("div",{className:"col-12 col-sm-4 mt-2 mb-2",key:Math.random()},n.createElement(a,{title:e.title,text:e.content.replaceAll("<br>","").replaceAll("<br/>","").replaceAll("<br />",""),date:e.publish_date,linkUrl:(t=u?e.name:e.title,r=e.id,u?"/news-and-events/"+t:"/news-and-events/articles/"+m(t+" "+r)),imageUrl:e.images&&e.images.length>0?e.images[0]:"",imageHeight:189,youtube:null!=e.embed&&e.embed.length>0?e.embed[0]:"",linkText:"CLICK HERE TO READ MORE"}));var t,r}))))),n.createElement("style",{jsx:!0},"\n            .InfiniteScrollBar{\n              overflow: hidden !important\n            }"))}g.propTypes={apiUrl:p.exports.string,type:p.exports.string};export default g;export{u as DEFAULT_NEWS_EVENT};
//# sourceMappingURL=NewsEventGridApi.js.map
