import{__awaiter as e,__generator as t}from"../../../node_modules/tslib/tslib.es6.js";import o,{useState as r,useEffect as n}from"react";import"../../../node_modules/prop-types/index.js";import"../../../node_modules/react-redux/es/index.js";import s from"../../common/Card/MediumCard.js";import l from"../../../node_modules/react-infinite-scroll-component/lib/index.js";import{convertToSlug as i}from"../../../utils/string.js";import{useDispatch as m}from"../../../node_modules/react-redux/es/hooks/useDispatch.js";import{useSelector as a}from"../../../node_modules/react-redux/es/hooks/useSelector.js";import{p as c}from"../../../_virtual/index.js_commonjs-module";function d(c){var d=c.apiUrl,u=c.maxItem,p=c.loadNews,g=c.selectNews,f=c.selectTotalSize,h=r(!0),x=h[0],v=h[1],b=r(1),j=b[0],E=b[1],_=r("");_[0];var y=_[1],N=m(),k=a(g),w=a(f);n((function(){c&&c.page&&y(c.page.account)}),[c]);return n((function(){N(p(d,j))}),[d,j]),o.createElement(o.Fragment,null,o.createElement(l,{dataLength:k&&k.length?k.length:0,next:function(){!function(){e(this,void 0,void 0,(function(){return t(this,(function(e){try{E(j+1),v(null==w||k.length<w)}catch(e){console.log("error",e)}return[2]}))}))}()},hasMore:x,scrollableTarget:"scrollableDiv",className:""},o.createElement("div",{className:"container mt-5"},o.createElement("div",{className:"row"},k.slice(0,u).map((function(e,t){return o.createElement("div",{className:"col-12 col-sm-4 mt-2 mb-2",key:"news-event-slide-"+t},o.createElement(s,{title:e.title,text:e.content,date:e.publish_date,linkUrl:(r=e.title,n=e.id,"/news-and-events/articles/"+i(r+" "+n)),imageUrl: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 r,n}))))))}d.propTypes={apiUrl:c.exports.string,type:c.exports.string};export default d;
//# sourceMappingURL=NewsEventSliderApi.js.map
