import { dO as k, w as i, aA as V, dc as A, O as l, Z as f, dP as z, az as E, U as F, F as g, G as N, dQ as P, dq as Y, dR as h, _ as p, y as U, dS as H, dT as y, dU as B, dV as x, dW as T, dX as X, dY as W, aa as Z, dZ as M, Y as O, cc as j, ab as v, cd as q, bX as G, d_ as Q, ad as S, S as _, d$ as J, e as K, d as $ } from "./603b75d9.js";
import { PaginationControl as ee } from "./048c5fdf.js";
import { ContextContainerComp as D } from "./bf5e4a58.js";
import { ListView as te } from "./89f08b0b.js";
import { listPropertyView as ne } from "./13a6a41a.js";
import "react";
import "react-dom";
const ie = {
  noOfRows: k(Q),
  // FIXME: migrate "noOfRows" to "data"
  noOfColumns: i(S, 1),
  itemIndexName: i(_, "i"),
  itemDataName: i(_, "currentItem"),
  dynamicHeight: V,
  heightUnitOfRow: i(S, 1),
  container: D,
  autoHeight: V,
  showVerticalScrollbar: i(l, !1),
  showHorizontalScrollbar: i(l, !1),
  horizontalGridCells: A,
  scrollbars: i(l, !1),
  showBorder: l,
  pagination: i(ee, {
    pageSize: "6"
  }),
  style: f(z, "style"),
  animationStyle: f(E, "animationStyle"),
  horizontal: i(l, !1),
  minHorizontalWidth: i(J, "100px")
}, oe = new F(ie, () => /* @__PURE__ */ g(N, {})).setPropertyViewFn(() => /* @__PURE__ */ g(N, {})).build();
class ae extends oe {
  getOriginalContainer() {
    return this.children.container.getSelectedComp().getComp();
  }
  realSimpleContainer(e) {
    return this.getOriginalContainer().realSimpleContainer(e);
  }
  getCompTree() {
    return this.getOriginalContainer().getCompTree();
  }
  findContainer(e) {
    return this.getOriginalContainer().findContainer(e);
  }
  getPasteValue(e) {
    return {
      ...this.toJsonValue(),
      container: this.getOriginalContainer().getPasteValue(e)
    };
  }
  autoHeight() {
    return this.children.autoHeight.getView();
  }
  reduce(e) {
    let n = P({
      inEventContext: !0
    }, () => super.reduce(e));
    if (e.type === Y.UPDATE_NODES_V2) {
      const {
        itemCount: c
      } = h(n.children.noOfRows.getView()), r = n.children.pagination.getView(), d = r.total || c, s = (r.current - 1) * r.pageSize;
      s >= d && r.current > 1 ? setTimeout(() => n.children.pagination.children.pageNo.dispatchChangeValueAction(1)) : String(s) !== this.children.container.getSelection() && setTimeout(() => n.children.container.dispatch(D.setSelectionAction(String(s))));
    }
    return n;
  }
  /** expose the data from inner comps */
  itemsNode() {
    const {
      itemCount: e
    } = h(this.children.noOfRows.getView()), n = this.children.itemIndexName.getView(), c = this.children.itemDataName.getView(), r = this.children.noOfRows.exposingNode(), d = this.children.container, s = p(p.range(0, e)).toPairs().fromPairs().mapValues((a) => {
      let m = d.getCachedComp(String(a)) ?? d.getOriginalComp();
      const b = U(m.getComp().getCompTree()), w = p(b).mapKeys((o) => o.children.name.getView()).mapValues((o) => o.children.comp.exposingNode()).value(), I = {
        [n]: H(a),
        [c]: y(r, (o) => typeof o == "number" ? {} : o[a])
      }, L = new B(x(w), I);
      return T(this, "exposing_row_" + a, [L, r, w, n, c], (o, C) => o[1] === C[1] && X(o.slice(2), C.slice(2), 3))[0];
    }).value(), R = y(x(s), (a) => p.range(0, e).map((m) => a[m]));
    return T(this, "exposing_data", [R, s], (a, m) => W(a[1], m[1]))[0];
  }
}
const re = $(ae, (t) => /* @__PURE__ */ g(te, {
  comp: t
})), se = ne("listView");
let u = K(re, (t) => /* @__PURE__ */ g(se, {
  comp: t
}));
u = Z(u, [
  new M("items", (t) => ({
    data: t.itemsNode()
  }), (t) => t.data, O("listView.itemsDesc")),
  j({
    name: "data",
    desc: O("listView.dataDesc"),
    depKeys: ["noOfRows"],
    func: (t) => {
      const {
        data: e
      } = h(t.noOfRows);
      return e;
    }
  }),
  new M("pageNo", (t) => ({
    index: t.children.pagination.children.pageNo.exposingNode()
  }), (t) => t.index, "Page Number"),
  v
]);
const we = q(u, [{
  method: {
    name: "setPage",
    description: "",
    params: [{
      name: "page",
      type: "number"
    }]
  },
  execute: (t, e) => {
    const n = e[0];
    n && n > 0 && t.children.pagination.children.pageNo.dispatchChangeValueAction(n);
  }
}]);
function Ce(t, e) {
  return {
    noOfRows: `[
  {
    "rate": "9.2",
    "title": "The Shawshank Redemption",
    "url": "https://www.imdb.com/title/tt0111161/",
    "cover": "https://m.media-amazon.com/images/M/MV5BMDFkYTc0MGEtZmNhMC00ZDIzLWFmNTEtODM1ZmRlYWMwMWFmXkEyXkFqcGdeQXVyMTMxODk2OTU@._V1_UY67_CR0,0,45,67_AL_.jpg"
  },
  {
    "rate": "9.2",
    "title": "The Godfather",
    "url": "https://www.imdb.com/title/tt0068646/",
    "cover": "https://m.media-amazon.com/images/M/MV5BM2MyNjYxNmUtYTAwNi00MTYxLWJmNWYtYzZlODY3ZTk3OTFlXkEyXkFqcGdeQXVyNzkwMjQ5NzM@._V1_UY67_CR1,0,45,67_AL_.jpg"
  },
  {
    "rate": "9.0",
    "title": "The Dark Knight",
    "url": "https://www.imdb.com/title/tt0468569/",
    "cover": "https://m.media-amazon.com/images/M/MV5BMTMxNTMwODM0NF5BMl5BanBnXkFtZTcwODAyMTk2Mw@@._V1_UY67_CR0,0,45,67_AL_.jpg"
  }
]`,
    container: G([{
      item: {
        compType: "image",
        name: e.genItemName("image"),
        comp: {
          src: "{{currentItem.cover}}",
          autoHeight: "fixed"
        }
      },
      layoutItem: {
        i: "",
        w: 6,
        h: 14,
        x: 0,
        y: 0
      }
    }, {
      item: {
        compType: "link",
        name: e.genItemName("link"),
        comp: {
          text: "{{i+1}}. {{currentItem.title}}",
          onEvent: [{
            name: "click",
            handler: {
              compType: "goToURL",
              comp: {
                url: "{{currentItem.url}}",
                inNewTab: !0
              },
              condition: "",
              slowdown: "debounce",
              delay: ""
            }
          }]
        }
      },
      layoutItem: {
        i: "",
        h: 5,
        w: 17,
        x: 7,
        y: 0
      }
    }, {
      item: {
        compType: "rating",
        name: e.genItemName("rating"),
        comp: {
          defaultValue: "{{currentItem.rate / 2}}",
          max: "5",
          label: {
            text: "",
            width: "33",
            widthUnit: "%",
            position: "row",
            align: "right"
          },
          allowHalf: !0,
          disabled: !0
        }
      },
      layoutItem: {
        i: "",
        h: 5,
        w: 17,
        x: 7,
        y: 9
      }
    }])
  };
}
export {
  we as ListViewComp,
  ae as ListViewImplComp,
  Ce as defaultListViewData
};
