import { j as w, a as v, C as b } from "./index-b203ecbb.js";
import { useRef as N, useEffect as p, useCallback as y, useMemo as K } from "react";
import { R as H } from "./index-a124d83e.js";
import "react-dom";
const S = (C) => {
  const {
    currentIndex: i,
    updateComponentRuntimeProps: a,
    // deleteComponentRuntimeProps,
    viewList: t,
    // tooltipText,
    childrenNode: l,
    columnNumber: I,
    dynamicHeight: x = "auto",
    triggerEventHandler: c,
    updateComponentHeight: o,
    linkWidgetDisplayName: s,
    padding: f,
    displayName: m,
    handleUpdateMultiExecutionResult: h
  } = C, d = N(i);
  p(() => {
    typeof d.current != "number" && (d.current = i), d.current !== i && (c("change"), d.current = i);
  }, [i, c]);
  const V = y(() => {
    c("click");
  }, [c]), g = K(() => {
    switch (x) {
      case "auto":
        return !0;
      case "limited":
        return !0;
      case "fixed":
      default:
        return !1;
    }
  }, [x]), k = y(
    (n) => {
      !o || !g || o(n + 2);
    },
    [g, o]
  ), u = y(
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    (n) => {
      if (h([
        {
          displayName: m,
          value: n
        }
      ]), s && s.length > 0) {
        const e = s.map((r) => ({
          displayName: r,
          value: n
        }));
        h(e);
      }
    },
    [m, h, s]
  );
  return p(() => {
    a == null || a({
      setCurrentViewKey: (n) => {
        const e = t.findIndex((r) => r.key === n);
        e !== -1 && u({
          currentIndex: e,
          currentKey: n
        });
      },
      setCurrentViewIndex: (n) => {
        const e = parseInt(n), r = t[e];
        r && u({
          currentIndex: e,
          currentKey: r.key
        });
      },
      showNextView: (n) => {
        let e = i + 1;
        if (e >= t.length) {
          if (!n)
            return;
          e = 0;
        }
        const r = t[e];
        u({
          currentIndex: e,
          currentKey: r.key
        });
      },
      showNextVisibleView: (n) => {
        let e = i + 1;
        if (e >= t.length) {
          if (!n)
            return;
          e = 0;
        }
        let r = t[e];
        for (; r.hidden || r.disabled; )
          if (e++, r = t[e], e >= t.length) {
            if (!n)
              return;
            e = 0;
          }
        u({
          currentIndex: e,
          currentKey: r.key
        });
      },
      showPreviousView: (n) => {
        let e = i - 1;
        if (e < 0) {
          if (!n)
            return;
          e = t.length - 1;
        }
        const r = t[e];
        u({
          currentIndex: e,
          currentKey: r.key
        });
      },
      showPreviousVisibleView: (n) => {
        let e = i - 1;
        if (e < 0) {
          if (!n)
            return;
          e = t.length - 1;
        }
        let r = t[e];
        for (; r.hidden || r.disabled; )
          if (e--, r = t[e], e < 0) {
            if (!n)
              return;
            e = t.length - 1;
          }
        u({
          currentIndex: e,
          currentKey: r.key
        });
      }
    });
  }, [
    // deleteComponentRuntimeProps,
    a,
    u,
    t,
    i
  ]), /* @__PURE__ */ w("div", { css: v, onClick: V, children: Array.isArray(l) && i < l.length ? /* @__PURE__ */ w(
    H,
    {
      displayName: l[i],
      columnNumber: I,
      handleUpdateHeight: k,
      canResizeCanvas: !0,
      containerPadding: f == null ? void 0 : f.size
    }
  ) : /* @__PURE__ */ w(b, {}) });
};
export {
  S as ContainerWidget,
  S as default
};
//# sourceMappingURL=container-486ab76d.js.map
