import { jsx as t, jsxs as W } from "react/jsx-runtime";
import { PostProvider as $, PostConsumer as p } from "@devgateway/wp-react-lib";
import j from "../connected-templates/PostIntro.js";
import { useState as J } from "react";
import { Container as c } from "semantic-ui-react";
import { CarouselProvider as L, Slider as O, Slide as T } from "pure-react-carousel";
import U from "./timeline.js";
const _ = (r) => {
  let a = 0;
  const { posts: i, height: n, interval: d, autoSwitch: o, currentSlide: l } = r;
  return /* @__PURE__ */ t(
    L,
    {
      currentSlide: l,
      interval: d,
      isPlaying: o,
      totalSlides: i.length,
      children: /* @__PURE__ */ t(O, { style: { height: `${n}px` }, tag: "ul", children: i.map((s) => /* @__PURE__ */ t(T, { index: a++, tag: "li", children: /* @__PURE__ */ t(j, { post: s, fluid: !0 }) })) })
    }
  );
}, G = (r) => {
  const {
    "data-type": a,
    "data-taxonomy": i,
    "data-categories": n,
    "data-count": d,
    "data-height": o,
    "data-line-color": l = "#000",
    "data-config": s = "{}",
    "data-position": u = "middle",
    "data-line-width": f = "1",
    "data-margin-left": S = 50,
    "data-margin-top": C = 25,
    "data-margin-right": x = 50,
    "data-margin-bottom": P = 25,
    "data-font-size": y = 14,
    "data-title-width": w = 100,
    "data-subtitle-width": N = 50,
    editing: m,
    parent: v,
    unique: b
  } = r, [h, z] = J([0]), g = (e) => m ? e : decodeURIComponent(e), I = (e) => JSON.parse(g(e)), R = {
    marginLeft: S,
    marginTop: C,
    marginRight: x,
    marginBottom: P,
    lineWidth: f,
    height: 150,
    position: u,
    lineColor: g(l),
    config: JSON.parse(decodeURIComponent(s)),
    fontSize: y,
    titleWidth: w,
    subtitleWidth: N
  };
  return /* @__PURE__ */ t(
    c,
    {
      style: { height: `${o}px` },
      className: "viz new-time-line ",
      fluid: !0,
      children: /* @__PURE__ */ W(
        $,
        {
          type: a,
          taxonomy: i,
          categories: I(n),
          store: "carousel_" + v + "_" + b,
          page: 1,
          perPage: d,
          children: [
            /* @__PURE__ */ t(c, { className: "carousel-section", children: /* @__PURE__ */ t(p, { children: /* @__PURE__ */ t(_, { currentSlide: h, height: o - 250, interval: 5, autoSwitch: !1 }) }) }),
            /* @__PURE__ */ t(c, { className: "time-line-section", children: /* @__PURE__ */ t(p, { children: /* @__PURE__ */ t(U, { currentSlide: h, onSelectSlide: (e) => {
              z(e);
            }, ...R }) }) })
          ]
        }
      )
    }
  );
};
export {
  G as default
};
