import{d as w,r as h,N as E,w as v,a3 as L,G as C,F as N,c as r,E as R,b as T}from"./index.35d77172.js";import{c as B,b as F,m as _,t as y,f as G,i as H,L as I,w as M}from"./index.51488539.js";import{u as U}from"./use-tab-status.cedbedcc.js";const[V,o,j]=B("list"),q={error:Boolean,offset:F(300),loading:Boolean,finished:Boolean,errorText:String,direction:_("down"),loadingText:String,finishedText:String,immediateCheck:y};var z=w({name:V,props:q,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(!1),f=h(),g=h(),s=U(),m=E(f),n=()=>{R(()=>{if(d.value||e.finished||e.error||(s==null?void 0:s.value)===!1)return;const{offset:t,direction:l}=e,i=T(m);if(!i.height||H(f))return;let u=!1;const x=T(g);l==="up"?u=i.top-x.top<=t:u=x.bottom-i.bottom<=t,u&&(d.value=!0,c("update:loading",!0),c("load"))})},b=()=>{if(e.finished){const t=a.finished?a.finished():e.finishedText;if(t)return r("div",{class:o("finished-text")},[t])}},k=()=>{c("update:error",!1),n()},P=()=>{if(e.error){const t=a.error?a.error():e.errorText;if(t)return r("div",{role:"button",class:o("error-text"),tabindex:0,onClick:k},[t])}},S=()=>{if(d.value&&!e.finished)return r("div",{class:o("loading")},[a.loading?a.loading():r(I,{class:o("loading-icon")},{default:()=>[e.loadingText||j("loading")]})])};return v(()=>[e.loading,e.finished,e.error],n),s&&v(s,t=>{t&&n()}),L(()=>{d.value=e.loading}),C(()=>{e.immediateCheck&&n()}),G({check:n}),N("scroll",n,{target:m}),()=>{var t;const l=(t=a.default)==null?void 0:t.call(a),i=r("div",{ref:g,class:o("placeholder")},null);return r("div",{ref:f,role:"feed",class:o(),"aria-busy":d.value},[e.direction==="down"?l:i,S(),b(),P(),e.direction==="up"?l:i])}}});const K=M(z);export{K as L};
