import{d as w,r as h,P as L,w as v,a1 as C,o as E,K as R,c as r,J as B,g as T}from"./index.ce3b9611.js";import{c as N,b as _,m as y,t as F,f as H,i as I,L as J,w as K}from"./_commonjsHelpers.5bb79380.js";import{u as M}from"./use-tab-status.742d6f01.js";const[U,o,V]=N("list"),j={error:Boolean,offset:_(300),loading:Boolean,finished:Boolean,errorText:String,direction:y("down"),loadingText:String,finishedText:String,immediateCheck:F};var q=w({name:U,props:j,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(!1),f=h(),g=h(),s=M(),m=L(f),n=()=>{B(()=>{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||I(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])}},P=()=>{c("update:error",!1),n()},k=()=>{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:P},[t])}},S=()=>{if(d.value&&!e.finished)return r("div",{class:o("loading")},[a.loading?a.loading():r(J,{class:o("loading-icon")},{default:()=>[e.loadingText||V("loading")]})])};return v(()=>[e.loading,e.finished,e.error],n),s&&v(s,t=>{t&&n()}),C(()=>{d.value=e.loading}),E(()=>{e.immediateCheck&&n()}),H({check:n}),R("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(),k(),e.direction==="up"?l:i])}}});const G=K(q);export{G as L};
