import{t as L,z as C,y as E,u as R,d as w,R as h,ap as B,Z as m,az as N,$ as _,W as y,a0 as z,c as r,_ as A,an as b,aA as F,L as H,x as I}from"./index.8f93de0e.js";import{u as M}from"./use-tab-status.69e46758.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),n=()=>{A(()=>{if(d.value||e.finished||e.disabled||e.error||(l==null?void 0:l.value)===!1)return;const{offset:t,direction:s}=e,i=b(x);if(!i.height||F(u))return;let f=!1;const v=b(g);s==="up"?f=i.top-v.top<=t:f=v.bottom-i.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),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&&!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],n),l&&m(l,t=>{t&&n()}),N(()=>{d.value=e.loading}),_(()=>{e.immediateCheck&&n()}),y({check:n}),z("scroll",n,{target:x,passive:!0}),()=>{var t;const s=(t=a.default)==null?void 0:t.call(a),i=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:i,S(),T(),P(),e.direction==="up"?s:i])}}});const q=I(Z);export{q as L};
