import{t as L,z as C,y as E,u as R,d as w,R as h,ao as B,Z as m,az as N,$ as _,W as y,a0 as z,c as r,_ as A,at as b,aA as F,L as H,x as I}from"./index.27735e87.js";import{u as M}from"./use-tab-status.d6e8df54.js";const[U,o,V]=L("list"),W={error:Boolean,offset:C(300),loading:Boolean,disabled:Boolean,finished:Boolean,errorText:String,direction:E("down"),loadingText:String,finishedText:String,immediateCheck:R};var Z=w({name:U,props:W,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(e.loading),u=h(),g=h(),l=M(),x=B(u),i=()=>{A(()=>{if(d.value||e.finished||e.disabled||e.error||(l==null?void 0:l.value)===!1)return;const{offset:t,direction:s}=e,n=b(x);if(!n.height||F(u))return;let f=!1;const v=b(g);s==="up"?f=n.top-v.top<=t:f=v.bottom-n.bottom<=t,f&&(d.value=!0,c("update:loading",!0),c("load"))})},T=()=>{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),i()},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&&!e.disabled)return r("div",{class:o("loading")},[a.loading?a.loading():r(H,{class:o("loading-icon")},{default:()=>[e.loadingText||V("loading")]})])};return m(()=>[e.loading,e.finished,e.error],i),l&&m(l,t=>{t&&i()}),N(()=>{d.value=e.loading}),_(()=>{e.immediateCheck&&i()}),y({check:i}),z("scroll",i,{target:x,passive:!0}),()=>{var t;const s=(t=a.default)==null?void 0:t.call(a),n=r("div",{ref:g,class:o("placeholder")},null);return r("div",{ref:u,role:"feed",class:o(),"aria-busy":d.value},[e.direction==="down"?s:n,S(),T(),P(),e.direction==="up"?s:n])}}});const q=I(Z);export{q as L};
