/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),t=require("@gsc-basic/hooks"),r=require("@gsc-basic/utils"),i=require("../../node_modules/lodash-es/isNaN.js"),n={height:[Number,String],maxHeight:[Number,String],maxWidth:[Number,String],minHeight:[Number,String],minWidth:[Number,String],width:[Number,String],bench:{type:[Number,String],default:0},itemHeight:{type:[Number,String],required:!0},items:{type:Array,default:()=>[]}},u="gsc-virtual-scroll";function s(e,t="px"){return null==e||""===e?void 0:i.default(+e)?String(e):`${Number(e)}${t}`}const o=e.defineComponent({name:"GscVirtualScroll",props:n,setup(i,{slots:n}){const o=e.ref(null),l=e.reactive({first:0,last:0,scrollTop:0}),c=e.computed(()=>Number.parseInt(i.bench,10)),m=e.computed(()=>Number.parseInt(i.itemHeight,10)),a=e.computed(()=>Math.max(0,l.first-e.unref(c))),h=e.computed(()=>Math.min((i.items||[]).length,l.last+e.unref(c))),d=e.computed(()=>({height:s((i.items||[]).length*e.unref(m))})),f=e.computed(()=>{const e={},t=s(i.height),r=s(i.minHeight),n=s(i.minWidth),u=s(i.maxHeight),o=s(i.maxWidth),l=s(i.width);return t&&(e.height=t),r&&(e.minHeight=r),n&&(e.minWidth=n),u&&(e.maxHeight=u),o&&(e.maxWidth=o),l&&(e.width=l),e});function g(t){const r=e.unref(o);if(!r)return 0;const n=Number.parseInt(i.height||0,10)||r.clientHeight;return t+Math.ceil(n/e.unref(m))}function p(){const t=e.unref(o);t&&(l.scrollTop=t.scrollTop,l.first=Math.floor(l.scrollTop/e.unref(m)),l.last=g(l.first))}function b(){const{items:t=[]}=i;return t.slice(e.unref(a),e.unref(h)).map(N)}function N(t,i){const o=s((i+=e.unref(a))*e.unref(m));return e.createVNode("div",{class:`${u}__item`,style:{top:o},key:i},[r.getSlot(n,"default",{index:i,item:t})])}return e.watch([()=>i.itemHeight,()=>i.height],()=>{p()}),e.onMounted(()=>{l.last=g(0),e.nextTick(()=>{const r=e.unref(o);r&&t.useEventListener({el:r,name:"scroll",listener:p,wait:0})})}),()=>e.createVNode("div",{class:u,style:e.unref(f),ref:o},[e.createVNode("div",{class:`${u}__container`,style:e.unref(d)},[b()])])}});exports.default=o;