import{d as w,r as h,B as C,w as v,a1 as L,D as E,C as B,c as r,F as R,b as T}from"./index.fdb8061e.js";import{c as N,b as F,m as _,t as y,f as D,i as H,w as I}from"./index.555136dd.js";import{u as M}from"./use-tab-status.c91ae8ab.js";import{L as U}from"./index.d6266256.js";const[V,o,j]=N("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=M(),m=C(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(U,{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}),E(()=>{e.immediateCheck&&n()}),D({check:n}),B("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 O=I(z);export{O as L};
