var t = require; var e = module; var n = exports; var h, e = (this && this.__decorate) || function(t, e, i, s) { var o, a = arguments.length, n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s); else for (var r = t.length - 1; 0 <= r; r--) (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n); return 3 < a && n && Object.defineProperty(e, i, n), n; }, i = (this && this.__awaiter) || function(t, n, r, l) { return new(r = r || Promise)(function(i, e) { function s(t) { try { a(l.next(t)); } catch (t) { e(t); } } function o(t) { try { a(l.throw(t)); } catch (t) { e(t); } } function a(t) { var e; t.done ? i(t.value) : ((e = t.value) instanceof r ? e : new r(function(t) { t(e); }) ).then(s, o); } a((l = l.apply(t, n || [])).next()); }); }; Object.defineProperty(n, "__esModule", { value: !0 }), (n.ListViewBaseLayout = n.ListView = n.ListViewEvent = void 0); const s = t("App"), a = t("ItemRenderer"); Object.defineProperty(cc.Node.prototype, "LEFT_TOP", { configurable: !0, get: function() { return cc.v2(this.x + this.width * -this.anchorX, this.y + this.height * (1 - this.anchorY)); } }), ((t = h = h || {})[(t.NONE = 0)] = "NONE"), (t[(t.HORIZONTAL = 1)] = "HORIZONTAL"), (t[(t.VERTICAL = 2)] = "VERTICAL"), (t[(t.GRID = 3)] = "GRID"), (n.ListViewEvent = { ITEM_TAP: "ITEM_TAP", ITEM_CREATED: "ITEM_CREATED", ITEM_DATA_CHANGED: "ITEM_DATA_CHANGED", SELECTION_CHANGED: "SELECTION_CHANGED", SELECTION_REACH_MAX: "SELECTION_REACH_MAX" }); const { ccclass: o, property: r, menu: l } = cc._decorator; t = class extends cc.Component { constructor() { super(...arguments), (this.viewPort = { x: 0, y: 0, width: 0, height: 0 }), (this.itemRenderer = null), (this.itemRendererInline = null), (this.layoutType = h.NONE), (this.isMultipleSelect = !1), (this.maxMultipleSelectNum = 3), (this.scrollView = null), (this.isVirtualLayout = !1), (this.interactable = !0), (this.gapX = 0), (this.gapY = 0), (this.autoGap = !1), (this.autoPadding = !1), (this.paddingLeft = 0), (this.paddingRight = 0), (this.paddingTop = 0), (this.paddingBottom = 0), (this.nodeEmpty = null), (this.horizontalCenterInScrollView = !1), (this.lazyLoadItem = !1), (this.itemScale = 1), (this.tag = ""), (this.customViews = []), (this.itemPool = []), (this.items = []), (this.dataSource = []), (this.cols = 0), (this.itemWidth = 0), (this.itemHeight = 0), (this.initialized = !1), (this.selectedIndices = []), (this.selectedItem = null), (this.selectedItems = []), (this.disabledItems = []), (this.lastScrollPos = null), (this.container = null), (this._itemUpdateQueue = []), (this.layout = null); } get selectedIndex() { return this._selectedIndex; } set selectedIndex(t) { this.isMultipleSelect || ((this._selectedIndex = t), (this.selectedIndices = [t]), (this.selectedItem = this.dataSource[t]), (this.selectedItems = [this.selectedItem])); } onLoad() { this.init(); } start() {} onDestroy() { this.itemPool.forEach(function(t) { t.node && t.node.isValid && t.node.destroy(); }), (this.itemPool = []); } init() { var t = this; if (!this.initialized) { switch (this.layoutType) { case h.HORIZONTAL: this.layout = new d(); break; case h.VERTICAL: this.layout = new u(); break; case h.NONE: case h.GRID: this.layout = new p(); } if ( ((this.container = new cc.Node()), this.node.addChild(this.container), this.itemRendererInline && this.itemRendererInline.getParent() == this.node && this.itemRendererInline.removeFromParent(!1), (this.itemRendererClass = this.itemRendererClass || a.default), this.scrollView) ) { if (this.scrollView.content != this.node) this.node.on( cc.Node.EventType.POSITION_CHANGED, function() { t.updateViewPort(!0); }, this ); else { var e = this.scrollView.node.getComponent(cc.Widget); e && e.updateAlignment(), (this.node.anchorX = 0), (this.node.anchorY = 1), (this.node.width = Math.max(this.node.width, this.scrollView.node.width)); for (var i = this.node.getParent(), s = []; i && i != this.scrollView.node;) { var o = i.getComponent(cc.Widget); o || (((o = i.addComponent(cc.Widget)).left = o.right = o.top = o.bottom = 0), (o.isAlignLeft = o.isAlignRight = o.isAlignTop = o.isAlignBottom = !0), (o.alignMode = cc.Widget.AlignMode.ALWAYS)), s.push(o), (i = i.getParent()); } s.reverse().forEach(function(t) { return t.updateAlignment(); }), (i = this.node.getParent()), (this.node.x = -i.width * i.anchorX + this.node.width * this.node.anchorX), (this.node.y = i.height * (1 - i.anchorY) - this.node.height * (1 - this.node.anchorY)), this.isVirtualLayout && ((this.viewPort.width = this.scrollView.node.width), (this.viewPort.height = this.scrollView.node.height)); } this.scrollView.node.on("scrolling", this.onScrollChanged, this), this.scrollView.node.on("scroll-ended", this.onScrollChanged, this), this.scrollView.node.on( cc.Node.EventType.SIZE_CHANGED, function() { (t.node.width = t.scrollView.node.width), t.updateViewPort(!0); }, this ); } else this.isVirtualLayout = !1; this.initialized = !0; } } updateViewPort(t = !1) { var e, i; this.scrollView && ((e = this.scrollView.getScrollOffset()), (i = this.node .convertToWorldSpaceAR(this.node.LEFT_TOP.sub(this.node.position)) .sub( this.scrollView.content.convertToWorldSpaceAR( this.scrollView.content.LEFT_TOP.sub(this.scrollView.content.position) ) )), (this.viewPort.x = e.x - i.x), (this.viewPort.y = e.y + i.y), (this.viewPort.width = this.scrollView.node.width), (this.viewPort.height = this.scrollView.node.height)), t && ((this.cols = 0), this.autoPadding && (this.paddingLeft = this.paddingRight = 0), this.autoGap && (this.gapX = 0)), this.checkLayoutParam(0 < this.items.length ? this.items[0].node : null), this.updateLayout(t); } onScrollChanged() { var t = this.scrollView.getScrollOffset(); (!this.lastScrollPos || 30 < t.sub(this.lastScrollPos).mag()) && (this.updateViewPort(), (this.lastScrollPos = t)); } getItems() { return this.items; } getContentSize() { return cc.size( this.node.width, -this.getItemPositionAt(this.dataSource.length - 1).y + this.itemHeight + this.paddingBottom ); } refreshView(e = !1) { this.items.forEach(function(t) { return t.setData(t.data, e); }); } updateDataSource(t, e = !1) { var i, s = this; if ( ((this.dataSource = t), this.checkLayoutParam(), this.nodeEmpty && (this.nodeEmpty.active = t.length <= 0), this.clearSelection(), this.isVirtualLayout) ) this.updateLayout(e); else { for (var o = 0; o < this.items.length; o++) { var a = this.items[o]; a.index >= t.length ? (this.items.slice(o).forEach(function(t) { t.node.removeFromParent(!1), (t.recycled = !0), s.itemPool.push(t); }), this.items.splice(o)) : a.setData(t[a.index], e), a.onUnselected(); } var n = 0 < this.items.length ? this.items[this.items.length - 1].index : -1, r = t.length - 1 - n; if (0 < r) for (o = 0; o < r; o++) { var l = n + o + 1, l = this.createItemAt(l, t[l]); this.items.push(l), l.onUnselected(); } } this.layout instanceof d && (this.node.width = this.getItemPositionAt(t.length - 1).x + this.itemWidth + this.paddingLeft + this.paddingRight), (this.node.height = -this.getItemPositionAt(t.length - 1).y + this.itemHeight + this.paddingBottom), (this.container.y = this.node.height * (1 - this.node.anchorY)), (this.container.x = this.node.width * -this.node.anchorX), (!this.scrollView && (this.scrollView || (this.layoutType != h.GRID && this.layoutType != h.HORIZONTAL))) || !this.horizontalCenterInScrollView || (this.dataSource.length < this.cols && (this.scrollView ? (this.container.x = (this.scrollView.node.width - (this.dataSource.length * this.itemWidth + this.gapX * (this.dataSource.length - 1))) / 2) : (this.container.x += ((this.cols - this.dataSource.length) / 2) * (this.itemWidth - this.gapX / 2) - this.paddingLeft))), this.scrollView && this.layoutType == h.VERTICAL && this.horizontalCenterInScrollView && ((i = (this.scrollView.node.height - this.layout.paddingTop) / (this.itemHeight + this.paddingTop / 2 + this.paddingBottom / 2)), this.dataSource.length < i && (this.scrollView ? (this.container.y = -( this.scrollView.node.height - (this.dataSource.length * this.itemHeight + this.gapY * (this.dataSource.length - 1)) ) / 2 + this.paddingTop) : (this.container.y -= ((i - this.dataSource.length) / 2) * (this.itemHeight - this.gapY / 2) - this.paddingTop))); } clearSelection() { var i = this; this.selectedItems.forEach(function(e) { var t = i.items.find(function(t) { return t.data == e; }); t && t.onUnselected(); }), (this._selectedIndex = -1), (this.selectedIndices = []), (this.selectedItem = null), (this.selectedItems = []), this.node.emit(n.ListViewEvent.SELECTION_CHANGED); } select(e) { var t, i = this; (e.length == this.selectedItems.length && e.every(function(t, e) { return t == i.selectedItems[e]; })) || ((t = e.filter(function(t) { return i.selectedItems.indexOf(t) < 0; })), this.selectedItems .filter(function(t) { return e.indexOf(t) < 0; }) .forEach(function(e) { var t = i.items.find(function(t) { return t.data == e; }); t && t.onUnselected(); }), (this.selectedItems = e), (this.selectedIndices = this.selectedItems.map(function(t) { return i.dataSource.indexOf(t); })), e.length <= 1 ? ((this.selectedItem = e[0]), (this._selectedIndex = this.dataSource.indexOf(e[0]))) : ((this.selectedItem = null), (this._selectedIndex = -1)), this.refreshView(), t.forEach(function(e) { var t = i.items.find(function(t) { return t.data == e; }); t && t.onSelected(); }), this.node.emit(n.ListViewEvent.SELECTION_CHANGED)); } selectByIndices(e) { var t, i = this; 0 == e.length && this.clearSelection(), (e.length == this.selectedIndices.length && e.every(function(t, e) { return t == i.selectedIndices[e]; })) || ((t = e.filter(function(t) { return i.selectedIndices.indexOf(t) < 0; })), this.selectedIndices .filter(function(t) { return e.indexOf(t) < 0; }) .forEach(function(e) { var t = i.items.find(function(t) { return t.index == e; }); t && t.onUnselected(); }), (this.selectedIndices = e), (this.selectedItems = this.selectedIndices.map(function(t) { return i.dataSource[t]; })), e.length <= 1 ? ((this.selectedItem = this.selectedItems[0]), (this._selectedIndex = e[0])) : ((this.selectedItem = null), (this._selectedIndex = -1)), this.refreshView(), t.forEach(function(e) { var t = i.items.find(function(t) { return t.index == e; }); t && t.onSelected(); }), this.node.emit(n.ListViewEvent.SELECTION_CHANGED)); } disableSelectByIndices(i) { (this.disabledItems = this.dataSource.filter(function(t, e) { return i.include(e); })), this.items.forEach(function(t) { i.include(t.index) ? t.onDisableSelect() : t.onEnableSelect(); }); } disableSelect(t) { (this.disabledItems = t.slice()), this.items.forEach(function(e) { t.some(function(t) { return t == e.data; }) ? e.onDisableSelect() : e.onEnableSelect(); }); } getCoordinateAt(t) { return this.layout.getItemCoordinateAtAt(t); } refreshLayout() { (this.cols = 0), this.autoPadding && (this.paddingLeft = this.paddingRight = 0), this.autoGap && (this.gapX = 0), this.checkLayoutParam(0 < this.items.length ? this.items[0].node : null), this.updateLayout(!0); } updateLayout(o = !1) { var a = this; this.checkLayoutParam(); var t = cc.rect(this.viewPort.x, this.viewPort.y, this.viewPort.width, this.viewPort.height), t = f(this.layout.getVisibleIndexStartEnd(t.x, t.y, t.width, t.height), 2), i = t[0], s = t[1], i = i.limit(0, this.dataSource.length - 1), s = s.limit(0, this.dataSource.length - 1); if (this.isVirtualLayout) { var e = 0 < this.items.length ? this.items[0].index : -1, n = 0 < this.items.length ? this.items[this.items.length - 1].index : -1, r = this.items.slice(); if (e != i || n != s) { for (var l, h, t = Math.min(i, e).limit(0), c = Math.max(s, n), d = [], u = [], p = t; p <= c; p++) (n < p && p < i) || (p < e && s < p) || (p < e && ((l = this.createItemAt(p, this.dataSource[p])), d.push(l)), n < p && ((l = this.createItemAt(p, this.dataSource[p])), u.push(l)), p < i && ((h = r[p - e]), this.recycleItem(h)), s < p && ((h = r[p - e]), this.recycleItem(h))); d.reverse().forEach(function(t) { return a.items.unshift(t); }), u.forEach(function(t) { return a.items.push(t); }), this.items.forEach(function(t, e) { var i = a .getItemPositionAt(t.index) .add(cc.v2(t.node.width * t.node.anchorX, -t.node.height * (1 - t.node.anchorY))); (t.node.position = i), (t.node.zIndex = e); var s = a.dataSource[t.index]; a.lazyLoadItem ? a.pushItemUpdate(t, s, o) : t.setData(s, o), a.selectedItems.some(function(t) { return t == s; }) ? t.onSelected() : t.onUnselected(), a.disabledItems.some(function(t) { return t == s; }) ? t.onDisableSelect() : t.onEnableSelect(); }); } else this.items.forEach(function(t) { var e = a .getItemPositionAt(t.index) .add(cc.v2(t.node.width * t.node.anchorX, -t.node.height * (1 - t.node.anchorY))); (t.node.position = e), t.setData(a.dataSource[t.index], o), (t.node.active = !0); }); } else (i = 0), (s = this.dataSource.length - 1), o && this.items.forEach(function(t) { var e = a .getItemPositionAt(t.index) .add(cc.v2(t.node.width * t.node.anchorX, -t.node.height * (1 - t.node.anchorY))); (t.node.position = e), (t.node.active = t.index >= i && t.index <= s), t.setData(a.dataSource[t.index], o); }); } ensureItemInView(t, e) { void 0 === e && (e = 0); var i = f( this.layout.getVisibleIndexStartEnd( this.viewPort.x, this.viewPort.y, this.viewPort.width, this.viewPort.height ), 2 ), s = i[0], i = i[1]; (s <= t && t <= i) || ((i = this.getItemPositionAt(t)), (t = this.node .convertToWorldSpaceAR(this.node.LEFT_TOP.sub(this.node.position)) .sub( this.scrollView.content.convertToWorldSpaceAR( this.scrollView.content.LEFT_TOP.sub(this.scrollView.content.position) ) )), i.addSelf(t), this.scrollView.scrollToOffset(cc.v2(i.x, -i.y), e), e || ((this.viewPort.x = i.x), (this.viewPort.y = -i.y), this.updateLayout())); } focusItem(t, e, i) { void 0 === e && (e = 0); t = this.getItemPositionAt(t); i && t.addSelf(i); i = this.node .convertToWorldSpaceAR(this.node.LEFT_TOP.sub(this.node.position)) .sub( this.scrollView.content.convertToWorldSpaceAR( this.scrollView.content.LEFT_TOP.sub(this.scrollView.content.position) ) ); t.addSelf(i), this.scrollView.scrollToOffset(cc.v2(t.x, -t.y), e), e || ((this.viewPort.x = t.x), (this.viewPort.y = -t.y), this.updateLayout()); } scrollToItemByPos(t, e) { void 0 === e && (e = 0), this.scrollView.scrollToOffset(cc.v2(t.x, -t.y), e), e || ((this.viewPort.x = t.x), (this.viewPort.y = -t.y), this.updateLayout()); } recycleItem(t) { this.items.splice(this.items.indexOf(t), 1), t.node.removeFromParent(!1), (t.recycled = !0), this.itemPool.push(t); } createItemAt(t, e) { var i, s = this; 0 < this.itemPool.length ? (i = this.itemPool.shift().node) : ((i = cc.instantiate(this.itemRenderer || this.itemRendererInline)).on( cc.Node.EventType.TOUCH_END, function(t) { (cc.sys.isNative && 0 < t.touch.getID()) || s.onItemTap(o); }, this ), (i.scaleX *= this.itemScale), (i.scaleY *= this.itemScale)); var o = i.getComponent(this.itemRendererClass); ((o = o || i.addComponent(this.itemRendererClass)).listView = this).container.addChild(i), this.checkLayoutParam(i); var a = this.getItemPositionAt(t).add( cc.v2(i.width * this.itemScale * i.anchorX, -i.height * this.itemScale * (1 - i.anchorY)) ); return ( (i.position = a), (o.index = t), this.lazyLoadItem ? this.pushItemUpdate(o, e) : o.setData(e), (o.recycled = !1), this.node.emit(n.ListViewEvent.ITEM_CREATED, o), o ); } getItemPositionAt(t) { return this.layout.getItemPositionAt(t); } addCustomView(t, e) { this.checkLayoutParam(); var i = { width: e.width, height: e.height }; this.cols && e instanceof cc.Node && (e.removeFromParent(!1), (e.position = this.getItemPositionAt(t).add(cc.v2(i.width * e.anchorX, -i.height * (1 - e.anchorY)))), this.container.addChild(e), this.customViews.push(e)), this.layout.addCustomSpace([t, i]), this.updateLayout(!1); } clearCustomView(e) { void 0 === e && (e = !0), this.customViews.forEach(function(t) { t.parent && t.removeFromParent(e), e && t.isValid && t.destroy(); }), (this.customViews = []), this.layout.clearCustomSpace(); } pushItemUpdate(e, t, i = !1) { var s = this._itemUpdateQueue.slice(1).find(function(t) { return t.item == e; }); s ? (s.data = t) : (this._itemUpdateQueue.push({ item: e, data: t, force: i }), 1 == this._itemUpdateQueue.length && this.handleItemUpdate()); } handleItemUpdate() { return i(this, void 0, void 0, function*() { var t = this._itemUpdateQueue[0]; t && (t.item.setData(t.data, t.force), yield s.default.TimerManager.sleep(0.01), this._itemUpdateQueue.shift(), this.handleItemUpdate()); }); } checkLayoutParam(t) { var e; this.initialized || this.init(), this.cols || ((e = (t = t || cc.instantiate(this.itemRenderer || this.itemRendererInline)).width * this.itemScale), (t = t.height * this.itemScale), this.autoGap ? ((this.cols = Math.floor((this.node.width - this.paddingLeft - this.paddingRight) / e) || 1), this.cols && (this.gapX = (this.node.width - this.paddingLeft - this.paddingRight - this.cols * e) / (this.cols - 1))) : (this.cols = Math.floor((this.node.width - this.paddingLeft - this.paddingRight) / (e + this.gapX)) || 1), this.autoPadding && (this.autoGap ? ((this.gapX = this.node.width / this.cols - e), (this.paddingLeft = this.paddingRight = this.gapX / 2)) : (this.paddingLeft = this.paddingRight = (this.node.width - this.cols * e - this.gapX * (this.cols - 1)) / 2)), (this.itemWidth = e), (this.itemHeight = t), this.layout.updateParams( e, t, this.cols, this.gapX, this.gapY, this.paddingLeft, this.paddingRight, this.paddingTop, this.paddingBottom )); } onItemTap(t) { if (!t.checkSelect(-1 == this.selectedIndices.indexOf(t.index))) return !1; var e, i, s = this; this.interactable ? ((e = t.index), this.disabledItems.include(t.data) || (0 <= this.selectedIndices.indexOf(e) ? this.isMultipleSelect && (this.selectedIndices.splice(this.selectedIndices.indexOf(e), 1), this.selectedItems.splice(this.selectedItems.indexOf(t.data), 1), t.onCancelSelected(), this.node.emit(n.ListViewEvent.SELECTION_CHANGED)) : (this.isMultipleSelect ? this.selectedIndices.length < this.maxMultipleSelectNum ? (this.selectedIndices.push(e), this.selectedItems.push(t.data), (this.selectedIndex = e), (this.selectedItem = t.data), t.onClickSelected()) : this.node.emit(n.ListViewEvent.SELECTION_REACH_MAX) : (0 <= this.selectedIndex && (i = this.items.find(function(t) { return t.index == s.selectedIndex; })) && i.onCancelSelected(), (this.selectedIndices = [e]), (this.selectedItems = [t.data]), (this.selectedIndex = e), (this.selectedItem = t.data), t.onClickSelected(), this.node.emit(n.ListViewEvent.SELECTION_REACH_MAX)), this.node.emit(n.ListViewEvent.SELECTION_CHANGED))), this.node.emit(n.ListViewEvent.ITEM_TAP, t, e)) : this.node.emit(n.ListViewEvent.ITEM_TAP, t, t.index); } }; e([r(cc.Prefab)], t.prototype, "itemRenderer", void 0), e([r(cc.Node)], t.prototype, "itemRendererInline", void 0), e([r({ type: cc.Enum(h) })], t.prototype, "layoutType", void 0), e([r({})], t.prototype, "isMultipleSelect", void 0), e( [ r({ type: cc.Integer, visible: function() { return this.isMultipleSelect; } }) ], t.prototype, "maxMultipleSelectNum", void 0 ), e([r(cc.ScrollView)], t.prototype, "scrollView", void 0), e([r({})], t.prototype, "isVirtualLayout", void 0), e([r({})], t.prototype, "interactable", void 0), e([r], t.prototype, "gapX", void 0), e([r], t.prototype, "gapY", void 0), e([r], t.prototype, "autoGap", void 0), e([r], t.prototype, "autoPadding", void 0), e([r], t.prototype, "paddingLeft", void 0), e([r], t.prototype, "paddingRight", void 0), e([r], t.prototype, "paddingTop", void 0), e([r], t.prototype, "paddingBottom", void 0), e([r(cc.Node)], t.prototype, "nodeEmpty", void 0), e([r], t.prototype, "horizontalCenterInScrollView", void 0), e([r], t.prototype, "itemScale", void 0), e([r], t.prototype, "tag", void 0), (t = e([o], t)), (n.ListView = t); class c { constructor() { (this.itemScale = 1), (this.spaces = []); } updateParams(t, e, i, s, o, a, n, r, l) { (this.itemWidth = t), (this.itemHeight = e), (this.cols = i), (this.gapX = s), (this.gapY = o), (this.paddingLeft = a), (this.paddingRight = n), (this.paddingTop = r), (this.paddingBottom = l); } addCustomSpace(t) { this.spaces.push(t); } clearCustomSpace() { this.spaces = []; } getItemCoordinateAtAt(t) { return cc.v2(t % this.cols, Math.floor(t / this.cols)); } getItemPositionAt(t) { return cc.v2(0, 0); } getVisibleIndexStartEnd(t, e, i, s) { return [0, 0]; } } function f(t, e) { var i = "function" == typeof Symbol && t[Symbol.iterator]; if (!i) return t; var s, o, a = i.call(t), n = []; try { for (; (void 0 === e || 0 < e--) && !(s = a.next()).done;) n.push(s.value); } catch (t) { o = { error: t }; } finally { try { s && !s.done && (i = a.return) && i.call(a); } finally { if (o) throw o.error; } } return n; } class d extends(n.ListViewBaseLayout = c) { getItemPositionAt(i) { var s = cc.v2(this.paddingLeft + i * (this.itemWidth + this.gapX), -this.paddingTop); return ( this.spaces.forEach(function(t) { var e = f(t, 2), t = e[0], e = e[1]; t <= i && (s.x += e.width); }), s ); } getVisibleIndexStartEnd(i, t, s, e) { var o = this, a = Math.floor((-i - this.paddingLeft) / (this.itemWidth + this.gapX)), n = Math.ceil((-i + s - this.paddingLeft) / (this.itemWidth + this.gapX)); return ( this.spaces.forEach(function(t) { var e = f(t, 2), t = e[0], e = e[1]; t <= a && ((i += e.width), (a = Math.floor((-i - o.paddingLeft) / (o.itemWidth + o.gapX))), (n = Math.ceil((-i + s - o.paddingLeft) / (o.itemWidth + o.gapX)))); }), [a, n] ); } } class u extends c { getItemPositionAt(i) { var s = cc.v2(this.paddingLeft, -(this.paddingTop + i * (this.itemHeight + this.gapY))); return ( this.spaces.forEach(function(t) { var e = f(t, 2), t = e[0], e = e[1]; t <= i && (s.y -= e.height); }), s ); } getVisibleIndexStartEnd(t, i, e, s) { var o = this, a = Math.floor((i - this.paddingTop) / (this.itemHeight + this.gapY)), n = Math.ceil((i + s - this.paddingTop) / (this.itemHeight + this.gapY)); return ( this.spaces.forEach(function(t) { var e = f(t, 2), t = e[0], e = e[1]; t <= a && ((i -= e.height), (a = Math.floor((i - o.paddingTop) / (o.itemHeight + o.gapY))), (n = Math.ceil((i + s - o.paddingTop) / (o.itemHeight + o.gapY)))); }), [a, n] ); } } class p extends c { getItemPositionAt(i) { var t = i % this.cols, e = Math.floor(i / this.cols), s = cc.v2( this.paddingLeft + t * (this.itemWidth + this.gapX), -(this.paddingTop + e * (this.itemHeight + this.gapY)) ); return ( this.spaces.forEach(function(t) { var e = f(t, 2), t = e[0], e = e[1]; t <= i && (s.y -= e.height); }), s ); } getVisibleIndexStartEnd(t, i, e, s) { var o = this, a = Math.floor((i - this.paddingTop) / (this.itemHeight + this.gapY)) * this.cols, n = Math.ceil((i + s - this.paddingTop) / (this.itemHeight + this.gapY)) * this.cols; return ( this.spaces.forEach(function(t) { var e = f(t, 2), t = e[0], e = e[1]; t <= a && ((i -= e.height), (a = Math.floor((i - o.paddingTop) / (o.itemHeight + o.gapY)) * o.cols), (n = Math.ceil((i + s - o.paddingTop) / (o.itemHeight + o.gapY)) * o.cols)); }), [a, n] ); } }