"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),x=require("react"),o=require("semantic-ui-react"),a=require("@devgateway/wp-react-lib"),L=require("../connected-templates/PostIntro.js"),k=require("react-router"),y=require("../connected-templates/PostContent.js"),I=f=>{const{posts:d,showIcons:j,showContentToggle:l,contentToggleHPosition:C,locale:T,readMoreLabel:u,readLessLabel:w}=f,[s,b]=x.useState({}),i=x.createRef(),c=(e,n="Read More")=>e&&e.trim()!==""?e:n;x.useEffect(()=>{window.setTimeout(()=>{if(window.location.hash){const e=document.getElementById(window.location.hash.substr(1));e&&e.scrollIntoView({behavior:"auto",block:"start"})}},0)},[d]);const h=e=>{const n=e.content?e.content.rendered.split("<!--more-->"):[];return n.length>1?n[1]:n[0]},g=e=>{const n=s[e]||!1,r=n?c(w,"Read less"):c(u,"Read more");return t.jsx("div",{children:t.jsx("div",{style:{position:"relative",left:C+"%"},children:t.jsx("a",{className:"link",onClick:()=>{i.current&&n&&(i.current.scrollIntoView({behavior:"smooth",block:"start"}),i.current.scrollTop=0),b({...s,[e]:!n})},children:r})})})},m=e=>{const n=e.content?e.content.rendered.split("<!--more-->"):[],r=n.length>1?n[0]:null;return r?r.trim():null},P=e=>{const n=e.content?e.content.rendered.split("<!--more-->"):[];return n.length>1&&n[1].trim().length>0};return t.jsx(o.Container,{fluid:!0,className:"inline list",children:d&&d.map(e=>t.jsxs(o.Grid,{children:[j&&t.jsxs(o.Grid.Column,{textAlign:"center",width:1,children:[t.jsx("a",{id:e.slug}),t.jsx(a.MediaProvider,{id:e.meta_fields&&e.meta_fields.icon?e.meta_fields.icon[0]:null,children:t.jsx(a.MediaConsumer,{children:t.jsx(a.PostIcon,{as:o.Label})})})]}),t.jsxs(o.Grid.Column,{width:j?15:16,children:[m(e)&&t.jsx(L.default,{as:o.Container,fluid:!0,post:e,ref:i}),!m(e)&&t.jsx(y.default,{post:{content:{rendered:h(e)}},style:{clear:"both",display:"block"}}),P(e)&&t.jsxs(o.Container,{children:[l&&t.jsxs(t.Fragment,{children:[!s[e.slug]&&g(e.slug),t.jsx(y.default,{post:{content:{rendered:h(e)}},style:{clear:"both",display:s[e.slug]?"block":"none"}}),s[e.slug]&&g(e.slug)]}),!l&&t.jsx("a",{href:a.utils.replaceLink(e.link,T),className:"link",children:c(u)})]})]})]}))})},v=f=>{const[d,j]=x.useState(Math.random()*99998+1),{locale:l}=k.useParams(),{"data-width":C,"data-height":T,"data-type":u,"data-taxonomy":w,"data-categories":s,"data-items":b,"data-color":i,"data-show-post-icons":c,"data-show-content-toggle":h,"data-content-toggle-h-position":g,"data-read-more-label":m,"data-read-less-label":P,parent:e,editing:n,component:r,unique:R}=f;return t.jsx(o.Container,{fluid:!0,children:t.jsx(a.PostProvider,{type:u,locale:l,taxonomy:w,categories:s,store:"inline_list_"+e+"_"+R,page:1,perPage:b,children:t.jsx(a.PostConsumer,{children:t.jsx(I,{locale:l??"en",showIcons:c==="true",showContentToggle:h==="true",contentToggleHPosition:parseInt(g||"50",10),readMoreLabel:m,readLessLabel:P})})})})};exports.default=v;
